[49122] users/toby/objcports

toby at macports.org toby at macports.org
Fri Apr 3 23:12:04 PDT 2009


Revision: 49122
          http://trac.macports.org/changeset/49122
Author:   toby at macports.org
Date:     2009-04-03 23:12:04 -0700 (Fri, 03 Apr 2009)
Log Message:
-----------
handle array type variables more cleanly

Modified Paths:
--------------
    users/toby/objcports/MPParser.m
    users/toby/objcports/MPPort.h
    users/toby/objcports/MPPort.m
    users/toby/objcports/variables.plist

Modified: users/toby/objcports/MPParser.m
===================================================================
--- users/toby/objcports/MPParser.m	2009-04-04 06:05:05 UTC (rev 49121)
+++ users/toby/objcports/MPParser.m	2009-04-04 06:12:04 UTC (rev 49122)
@@ -48,7 +48,7 @@
 		for (NSString *opt in [_port settableVariables]) {
 			command_create(_interp, [opt UTF8String], self);
 		}
-		for (NSString *opt in [_port modifiableVariables]) {
+		for (NSString *opt in [_port settableArrayVariables]) {
 			command_create(_interp, [[opt stringByAppendingString:@"-append"] UTF8String], self);
 			command_create(_interp, [[opt stringByAppendingString:@"-delete"] UTF8String], self);
 		}

Modified: users/toby/objcports/MPPort.h
===================================================================
--- users/toby/objcports/MPPort.h	2009-04-04 06:05:05 UTC (rev 49121)
+++ users/toby/objcports/MPPort.h	2009-04-04 06:12:04 UTC (rev 49122)
@@ -25,7 +25,7 @@
 - (NSArray *)settableVariables;
 - (void)variable:(NSString *)var set:(NSArray *)value;
 
-- (NSArray *)modifiableVariables;
+- (NSArray *)settableArrayVariables;
 - (void)variable:(NSString *)var append:(NSArray *)value;
 - (void)variable:(NSString *)var delete:(NSArray *)value;
 

Modified: users/toby/objcports/MPPort.m
===================================================================
--- users/toby/objcports/MPPort.m	2009-04-04 06:05:05 UTC (rev 49121)
+++ users/toby/objcports/MPPort.m	2009-04-04 06:12:04 UTC (rev 49122)
@@ -5,8 +5,8 @@
 #include "MPPort.h"
 #include "MPParser.h"
 
-static NSString *kPortVariableAllowSet = @"AllowSet";
-static NSString *kPortVariableAllowAppendDelete = @"AllowAppendDelete";
+static NSString *kPortVariableType = @"Type";
+static NSString *kPortVariableConstant = @"Constant";
 
 @implementation MPPort
 
@@ -40,12 +40,12 @@
 	for (NSString *command in commands) {
 		[_variableInfo setObject:[NSDictionary dictionary] forKey:[NSString stringWithFormat:@"use_%@", command]];
 		[_variableInfo setObject:[NSDictionary dictionary] forKey:[NSString stringWithFormat:@"%@.dir", command]];
-		[_variableInfo setObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:kPortVariableAllowAppendDelete] forKey:[NSString stringWithFormat:@"%@.pre_args", command]];
-		[_variableInfo setObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:kPortVariableAllowAppendDelete] forKey:[NSString stringWithFormat:@"%@.args", command]];
-		[_variableInfo setObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:kPortVariableAllowAppendDelete] forKey:[NSString stringWithFormat:@"%@.post_args", command]];
-		[_variableInfo setObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:kPortVariableAllowAppendDelete] forKey:[NSString stringWithFormat:@"%@.env", command]];
+		[_variableInfo setObject:[NSDictionary dictionaryWithObject:@"Array" forKey:kPortVariableType] forKey:[NSString stringWithFormat:@"%@.pre_args", command]];
+		[_variableInfo setObject:[NSDictionary dictionaryWithObject:@"Array" forKey:kPortVariableType] forKey:[NSString stringWithFormat:@"%@.args", command]];
+		[_variableInfo setObject:[NSDictionary dictionaryWithObject:@"Array" forKey:kPortVariableType] forKey:[NSString stringWithFormat:@"%@.post_args", command]];
+		[_variableInfo setObject:[NSDictionary dictionaryWithObject:@"Array" forKey:kPortVariableType] forKey:[NSString stringWithFormat:@"%@.env", command]];
 		[_variableInfo setObject:[NSDictionary dictionary] forKey:[NSString stringWithFormat:@"%@.type", command]];
-		[_variableInfo setObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:kPortVariableAllowAppendDelete] forKey:[NSString stringWithFormat:@"%@.cmd", command]];
+		[_variableInfo setObject:[NSDictionary dictionaryWithObject:@"Array" forKey:kPortVariableType] forKey:[NSString stringWithFormat:@"%@.cmd", command]];
 	}
 
 	_parser = [[MPParser alloc] initWithPort:self];
@@ -102,15 +102,30 @@
 	return [_variableInfo allKeys];
 }
 
+- (BOOL)variableIsArray:(NSString *)var
+{
+	NSString *type = [[_variableInfo objectForKey:var] objectForKey:kPortVariableType];
+	return [type isEqualToString:@"Array"];
+}
+
 - (NSString *)variable:(NSString *)name
 {
-	NSString *ret = nil;
+	NSString *ret = @"";
+	id val;
 	if ([_variableInfo objectForKey:name] != nil) {
-		ret = [_variables objectForKey:name];
-		if (ret == nil) {
-			ret = @"";
+		val = [_variables objectForKey:name];
+		if ([self variableIsArray:name]) {
+			if (val) {
+				NSLog(@"%@ %@", name, val);
+				assert([val isKindOfClass:[NSArray class]]);
+				ret = [val componentsJoinedByString:@" "];
+			}
+		} else {
+			if (val) {
+				assert([val isKindOfClass:[NSString class]]);
+				ret = val;
+			}
 		}
-		assert([ret isKindOfClass:[NSString class]]);
 	} else {
 		NSLog(@"WARNING: unknown variable %@", name);
 	}
@@ -121,9 +136,8 @@
 {
 	NSMutableArray *ret = [NSMutableArray arrayWithCapacity:0];
 	for (NSString *var in [self variables]) {
-		NSNumber *allowSet = [[_variableInfo objectForKey:var] objectForKey:kPortVariableAllowSet];
-		/* Default is YES, so nil is good. */
-		if (allowSet == nil || [allowSet boolValue] == YES) {
+		NSNumber *constant = [[_variableInfo objectForKey:var] objectForKey:kPortVariableConstant];
+		if (constant == nil || [constant boolValue] == NO) {
 			[ret addObject:var];
 		}
 	}
@@ -132,16 +146,18 @@
 
 - (void)variable:(NSString *)var set:(NSArray *)value
 {
-	[_variables setObject:[value componentsJoinedByString:@" "] forKey:var];
+	if ([self variableIsArray:var]) {
+		[_variables setObject:value forKey:var];
+	} else {
+		[_variables setObject:[value componentsJoinedByString:@" "] forKey:var];
+	}
 }
 
-- (NSArray *)modifiableVariables
+- (NSArray *)settableArrayVariables
 {
 	NSMutableArray *ret = [NSMutableArray arrayWithCapacity:0];
-	for (NSString *var in [self variables]) {
-		NSNumber *allowAppendDelete = [[_variableInfo objectForKey:var] objectForKey:kPortVariableAllowAppendDelete];
-		/* Default is NO, so it must be set. */
-		if ([allowAppendDelete boolValue]) {
+	for (NSString *var in [self settableVariables]) {
+		if ([self variableIsArray:var]) {
 			[ret addObject:var];
 		}
 	}
@@ -150,17 +166,30 @@
 
 - (void)variable:(NSString *)var append:(NSArray *)value
 {
-	// XXX: this doesn't work quite right when appending to an empty string
-	[_variables setObject:[NSString stringWithFormat:@"%@ %@", [self variable:var], [value componentsJoinedByString:@" "]] forKey:var];
+	id old = [_variables objectForKey:var];
+	if (old) {
+		assert([old isKindOfClass:[NSArray class]]);
+		[_variables setObject:[old arrayByAddingObjectsFromArray:value] forKey:var];
+	} else {
+		[_variables setObject:value forKey:var];
+	}
 }
 
 - (void)variable:(NSString *)var delete:(NSArray *)value
 {
-	NSMutableArray *tmp = [[[self variable:var] componentsSeparatedByString:@" "] mutableCopy];
+	id old;
+	NSMutableArray *tmp;
+
+	old = [_variables objectForKey:var];
+	if (old == nil) {
+		return;
+	}
+	assert([old isKindOfClass:[NSArray class]]);
+	tmp = [old mutableCopy];
 	for (NSString *v in value) {
 		[tmp removeObject:v];
 	}
-	[_variables setObject:[tmp componentsJoinedByString:@" "] forKey:var];
+	[_variables setObject:tmp forKey:var];
 	[tmp release];
 }
 

Modified: users/toby/objcports/variables.plist
===================================================================
--- users/toby/objcports/variables.plist	2009-04-04 06:05:05 UTC (rev 49121)
+++ users/toby/objcports/variables.plist	2009-04-04 06:12:04 UTC (rev 49122)
@@ -4,15 +4,15 @@
 <dict>
 	<key>applications_dir</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>build.jobs</key>
 	<dict/>
 	<key>build.target</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>buildmakejobs</key>
 	<dict/>
@@ -20,27 +20,27 @@
 	<dict/>
 	<key>categories</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>checksums</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>configure.awk</key>
 	<dict/>
 	<key>configure.cc</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>configure.ccache</key>
 	<dict/>
 	<key>configure.cflags</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>configure.compiler</key>
 	<dict/>
@@ -48,15 +48,15 @@
 	<dict/>
 	<key>configure.cppflags</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>configure.cxx</key>
 	<dict/>
 	<key>configure.cxxflags</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>configure.distcc</key>
 	<dict/>
@@ -68,8 +68,8 @@
 	<dict/>
 	<key>configure.fcflags</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>configure.install</key>
 	<dict/>
@@ -77,8 +77,8 @@
 	<dict/>
 	<key>configure.ldflags</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>configure.libs</key>
 	<dict/>
@@ -94,18 +94,18 @@
 	<dict/>
 	<key>configure.universal_archs</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>configure.universal_args</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>configure.universal_ldflags</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>cvs.date</key>
 	<dict/>
@@ -119,42 +119,42 @@
 	<dict/>
 	<key>default_variants</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>depends_build</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>depends_lib</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>depends_run</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>description</key>
 	<dict/>
 	<key>destroot</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>destroot.destdir</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>destroot.keepdirs</key>
 	<dict/>
 	<key>destroot.target</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>destroot.violate_mtree</key>
 	<dict/>
@@ -162,8 +162,8 @@
 	<dict/>
 	<key>distfiles</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>distname</key>
 	<dict/>
@@ -187,13 +187,13 @@
 	<dict/>
 	<key>filespath</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>frameworks_dir</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>git.url</key>
 	<dict/>
@@ -221,8 +221,8 @@
 	<dict/>
 	<key>master_sites</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>master_sites.mirror_subdir</key>
 	<dict/>
@@ -230,35 +230,35 @@
 	<dict/>
 	<key>os.arch</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>os.endian</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>os.major</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>os.platform</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>os.version</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>patch_sites</key>
 	<dict/>
 	<key>patchfiles</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>perl5.bin</key>
 	<dict/>
@@ -276,8 +276,8 @@
 	<dict/>
 	<key>prefix</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>python.bin</key>
 	<dict/>
@@ -335,8 +335,8 @@
 	<dict/>
 	<key>sysroot</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>test.run</key>
 	<dict/>
@@ -356,27 +356,27 @@
 	<dict/>
 	<key>workpath</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>worksrcdir</key>
 	<dict/>
 	<key>worksrcpath</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>x11font.setup</key>
 	<dict/>
 	<key>x11prefix</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>xcode.build.settings</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>xcode.configuration</key>
 	<dict/>
@@ -384,8 +384,8 @@
 	<dict/>
 	<key>xcode.destroot.settings</key>
 	<dict>
-		<key>AllowAppendDelete</key>
-		<true/>
+		<key>Type</key>
+		<string>Array</string>
 	</dict>
 	<key>xcode.destroot.type</key>
 	<dict/>
@@ -395,8 +395,8 @@
 	<dict/>
 	<key>xcodeversion</key>
 	<dict>
-		<key>AllowSet</key>
-		<false/>
+		<key>Constant</key>
+		<true/>
 	</dict>
 	<key>zope.need_subdir</key>
 	<dict/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090403/48a8e84e/attachment.html>


More information about the macports-changes mailing list