Skip to content

Commit 2fdd0a5

Browse files
committed
Fix Makefile generation
1 parent 0552412 commit 2fdd0a5

File tree

6 files changed

+86
-66
lines changed

6 files changed

+86
-66
lines changed

Generators/Makefile/GSXCMakefileGenerator.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ - (BOOL) generate
4242
NSString *additionalOCflags = [[context objectForKey: @"ADDITIONAL_OBJC_LIBS"] arrayToLinkList];
4343
NSString *projectType = [context objectForKey: @"PROJECT_TYPE"];
4444

45+
// Debug output to see what we're getting from the context
46+
NSLog(@"=== DEBUG: Makefile Generator Context ===");
47+
NSLog(@"OBJC_FILES: %@", [context objectForKey: @"OBJC_FILES"]);
48+
NSLog(@"C_FILES: %@", [context objectForKey: @"C_FILES"]);
49+
NSLog(@"CPP_FILES: %@", [context objectForKey: @"CPP_FILES"]);
50+
NSLog(@"OBJCPP_FILES: %@", [context objectForKey: @"OBJCPP_FILES"]);
51+
NSLog(@"RESOURCES: %@", [context objectForKey: @"RESOURCES"]);
52+
NSLog(@"PROJECT_TYPE: %@", projectType);
53+
NSLog(@"========================================");
54+
4555
// Construct the makefile out of the data we have thusfar collected.
4656
xcputs("\t* Generating GNUmakefile");
4757

XCode/PBXBuildPhase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
/**
135135
* Returns files from groups that support the children method.
136136
* This includes PBXFileSystemSynchronizedRootGroup and other group types.
137+
* Base implementation returns empty array - subclasses should override
138+
* to return appropriate file types for their specific build phase.
137139
*/
138140
- (NSArray *) filesFromGroups;
139141

XCode/PBXBuildPhase.m

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -144,44 +144,10 @@ - (NSArray *) allFiles
144144

145145
- (NSArray *) filesFromGroups
146146
{
147-
NSMutableArray *result = [NSMutableArray array];
148-
149-
if (_target != nil)
150-
{
151-
// Get files from synchronized groups (like PBXFileSystemSynchronizedRootGroup)
152-
NSArray *synchronizedSources = [_target synchronizedSources];
153-
if (synchronizedSources != nil)
154-
{
155-
[result addObjectsFromArray: synchronizedSources];
156-
}
157-
158-
// Get files from synchronized headers
159-
NSArray *synchronizedHeaders = [_target synchronizedHeaders];
160-
if (synchronizedHeaders != nil)
161-
{
162-
[result addObjectsFromArray: synchronizedHeaders];
163-
}
164-
165-
// Future enhancement: We could extend this to handle other group types
166-
// that support the children method by iterating through all groups in the target.
167-
// This would allow build phases to automatically discover files from any
168-
// group type that implements the children method, not just synchronized groups.
169-
//
170-
// Example approach for future expansion:
171-
// NSArray *allGroups = [_target allGroups]; // hypothetical method
172-
// NSEnumerator *groupEnum = [allGroups objectEnumerator];
173-
// id group = nil;
174-
// while ((group = [groupEnum nextObject]) != nil)
175-
// {
176-
// if ([group respondsToSelector: @selector(children)])
177-
// {
178-
// NSArray *children = [group children];
179-
// [result addObjectsFromArray: children];
180-
// }
181-
// }
182-
}
183-
184-
return result;
147+
// Base implementation returns empty array.
148+
// Subclasses should override this method to return appropriate files
149+
// from groups based on the type of build phase.
150+
return [NSArray array];
185151
}
186152

187153
@end

XCode/PBXHeadersBuildPhase.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ - (BOOL) generate
154154
return result;
155155
}
156156

157+
// Override filesFromGroups to only return header files for PBXHeadersBuildPhase
158+
- (NSArray *) filesFromGroups
159+
{
160+
NSMutableArray *result = [NSMutableArray array];
161+
162+
if (_target != nil)
163+
{
164+
// Only get header files for the headers build phase
165+
NSArray *synchronizedHeaders = [_target synchronizedHeaders];
166+
if (synchronizedHeaders != nil)
167+
{
168+
[result addObjectsFromArray: synchronizedHeaders];
169+
}
170+
}
171+
172+
return result;
173+
}
174+
157175
- (BOOL) link
158176
{
159177
return YES;

XCode/PBXResourcesBuildPhase.m

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,15 +389,18 @@ - (BOOL) build
389389
- (BOOL) generate
390390
{
391391
GSXCBuildContext *context = [GSXCBuildContext sharedBuildContext];
392-
NSMutableArray *resources = [NSMutableArray arrayWithCapacity: [_files count]];
392+
393+
// Use the new allFiles method to include files from groups
394+
NSArray *allFiles = [self allFiles];
395+
NSMutableArray *resources = [NSMutableArray arrayWithCapacity: [allFiles count]];
393396

394397
xcputs("=== Generating Resources Entries Build Phase");
395398
NSFileManager *mgr = [NSFileManager defaultManager];
396399
NSString *productName = [_target productName];
397400
NSString *appName = [productName stringByDeletingPathExtension];
398401

399402
// Copy all resources...
400-
NSEnumerator *en = [_files objectEnumerator];
403+
NSEnumerator *en = [allFiles objectEnumerator];
401404
BOOL result = YES;
402405
id file = nil;
403406
while((file = [en nextObject]) != nil && result)
@@ -462,6 +465,33 @@ - (BOOL) generate
462465
return result;
463466
}
464467

468+
// Override filesFromGroups for resources - could include any file type
469+
- (NSArray *) filesFromGroups
470+
{
471+
NSMutableArray *result = [NSMutableArray array];
472+
473+
if (_target != nil)
474+
{
475+
// Resources can include both source and header files, plus other resource types
476+
// For now, we get both synchronized sources and headers
477+
NSArray *synchronizedSources = [_target synchronizedSources];
478+
if (synchronizedSources != nil)
479+
{
480+
[result addObjectsFromArray: synchronizedSources];
481+
}
482+
483+
NSArray *synchronizedHeaders = [_target synchronizedHeaders];
484+
if (synchronizedHeaders != nil)
485+
{
486+
[result addObjectsFromArray: synchronizedHeaders];
487+
}
488+
489+
// TODO: Could extend this to handle other resource types from groups
490+
}
491+
492+
return result;
493+
}
494+
465495
- (BOOL) link
466496
{
467497
return [self build];

XCode/PBXSourcesBuildPhase.m

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -113,32 +113,8 @@ - (BOOL) build
113113
}
114114
else
115115
{
116-
// Filter to only include source files (since allFiles might include headers too)
117-
NSMutableArray *sourceFiles = [NSMutableArray array];
118-
NSEnumerator *allEn = [allFiles objectEnumerator];
119-
id file = nil;
120-
121-
while ((file = [allEn nextObject]) != nil)
122-
{
123-
if ([file isKindOfClass: [PBXBuildFile class]])
124-
{
125-
PBXFileReference *fr = [file fileRef];
126-
NSString *name = [fr path];
127-
128-
if ([[name pathExtension] isEqualToString: @"m"]
129-
|| [[name pathExtension] isEqualToString: @"mm"]
130-
|| [[name pathExtension] isEqualToString: @"M"]
131-
|| [[name pathExtension] isEqualToString: @"c"]
132-
|| [[name pathExtension] isEqualToString: @"cc"]
133-
|| [[name pathExtension] isEqualToString: @"C"]
134-
|| [[name pathExtension] isEqualToString: @"swift"])
135-
{
136-
[sourceFiles addObject: file];
137-
}
138-
}
139-
}
140-
141-
files = sourceFiles;
116+
// Use all files from groups and regular files
117+
files = allFiles;
142118
}
143119

144120
en = [files objectEnumerator];
@@ -199,6 +175,24 @@ - (BOOL) generate
199175
return result;
200176
}
201177

178+
// Override filesFromGroups to only return source files for PBXSourcesBuildPhase
179+
- (NSArray *) filesFromGroups
180+
{
181+
NSMutableArray *result = [NSMutableArray array];
182+
183+
if (_target != nil)
184+
{
185+
// Only get source files for the sources build phase
186+
NSArray *synchronizedSources = [_target synchronizedSources];
187+
if (synchronizedSources != nil)
188+
{
189+
[result addObjectsFromArray: synchronizedSources];
190+
}
191+
}
192+
193+
return result;
194+
}
195+
202196
- (BOOL) link
203197
{
204198
GSXCBuildDatabase *db = [_target database];

0 commit comments

Comments
 (0)