@@ -52,6 +52,7 @@ static void usage()
5252 " \t -s <suffix> : create standalone test library (framework/shared)\n "
5353 " \t -t <target> : target to export\n "
5454 " \t -u : add UIKIt\n "
55+ " \t -w <name> : add weight to name for sorting"
5556 " \n "
5657 " Commands:\n "
5758 " \t export : export CMakeLists.txt to stdout\n "
@@ -155,10 +156,33 @@ static void usage()
155156static BOOL suppressUIKit = YES ;
156157static enum CompilerLanguage language=ObjC_Language;
157158
158- static NSString *hackPrefix = @" " ;
159- static NSString *standaloneSuffix = nil ;
159+ static NSString *hackPrefix = @" " ;
160+ static NSString *standaloneSuffix = nil ;
161+ static NSMutableArray *heavyStrings;
160162
161163
164+ @implementation NSString ( XcodeWeightedCompare)
165+
166+ - (NSComparisonResult ) xcodeWeightedCompare : (id ) other
167+ {
168+ NSComparisonResult result;
169+
170+ result = [self compare: other];
171+ if ( [heavyStrings containsObject: other])
172+ {
173+ if ( [heavyStrings containsObject: self ])
174+ return ( result);
175+
176+ return ( NSOrderedAscending);
177+ }
178+
179+ if ( [heavyStrings containsObject: self ])
180+ return ( NSOrderedDescending);
181+ return ( result);
182+ }
183+
184+ @end
185+
162186#pragma mark - Global Storage
163187
164188static NSMutableDictionary *staticLibraries;
@@ -429,7 +453,7 @@ static void print_paths( NSArray *paths,
429453 printf ( " \n "
430454 " set( %s \n " , [name UTF8String ]);
431455
432- rover = [[paths sortedArrayUsingSelector: @selector ( compare : )] objectEnumerator ];
456+ rover = [[paths sortedArrayUsingSelector: @selector ( xcodeWeightedCompare : )] objectEnumerator ];
433457 while ( path = [rover nextObject ])
434458 printf ( " %s \n " , [quotedPathIfNeeded ( path) UTF8String ]);
435459
@@ -1328,6 +1352,7 @@ static int _main( int argc, const char * argv[])
13281352 NSString *file;
13291353 NSString *s;
13301354 NSString *target;
1355+ NSString *name;
13311356 id root;
13321357 id targetNames;
13331358 unsigned int i, n;
@@ -1484,7 +1509,6 @@ static int _main( int argc, const char * argv[])
14841509 [targetNames addObject: target];
14851510 continue ;
14861511 }
1487-
14881512
14891513 if ( [s isEqualToString: @" -u" ] ||
14901514 [s isEqualToString: @" --add-uikit" ])
@@ -1493,6 +1517,19 @@ static int _main( int argc, const char * argv[])
14931517 continue ;
14941518 }
14951519
1520+ if ( [s isEqualToString: @" -w" ] ||
1521+ [s isEqualToString: @" --weighted-name" ])
1522+ {
1523+ if ( ++i >= n)
1524+ usage ();
1525+
1526+ name = [arguments objectAtIndex: i];
1527+ if ( ! heavyStrings)
1528+ heavyStrings = [NSMutableArray array ];
1529+ [heavyStrings addObject: name];
1530+ continue ;
1531+ }
1532+
14961533 // commands
14971534 if ( ! targetNames)
14981535 targetNames = all_target_names ( root);
0 commit comments