diff --git a/ChangeLog b/ChangeLog index 16bc5a6..babdf72 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-12-15 Riccardo Mottola + + * Framework/PCMakefileFactory.m + Create mm sections in makefiles for Objective-C++ + 2014-12-08 Riccardo Mottola * Framework/PCProject.m diff --git a/Framework/PCMakefileFactory.m b/Framework/PCMakefileFactory.m index 1b33f9a..c1ce512 100644 --- a/Framework/PCMakefileFactory.m +++ b/Framework/PCMakefileFactory.m @@ -1,10 +1,11 @@ /* GNUstep ProjectCenter - http://www.gnustep.org/experience/ProjectCenter.html - Copyright (C) 2002-2010 Free Software Foundation + Copyright (C) 2002-2014 Free Software Foundation Authors: Philippe C.D. Robert Serg Stoyan + Riccardo Mottola This file is part of GNUstep. @@ -33,7 +34,8 @@ #define COMMENT_HEADERS @"\n\n#\n# Header files\n#\n" #define COMMENT_RESOURCES @"\n\n#\n# Resource files\n#\n" -#define COMMENT_CLASSES @"\n\n#\n# Class files\n#\n" +#define COMMENT_CLASSES @"\n\n#\n# Objective-C Class files\n#\n" +#define COMMENT_OCPPCLASSES @"\n\n#\n# Objective-C++ Class files\n#\n" #define COMMENT_CFILES @"\n\n#\n# Other sources\n#\n" #define COMMENT_SUBPROJECTS @"\n\n#\n# Subprojects\n#\n" #define COMMENT_APP @"\n\n#\n# Main application\n#\n" @@ -337,16 +339,48 @@ static PCMakefileFactory *_factory = nil; - (void)appendClasses:(NSArray *)array forTarget:(NSString *)target { + NSEnumerator *oenum; + NSMutableArray *marray = nil; + NSMutableArray *mmarray = nil; + NSString *file; + if (array == nil || [array count] == 0) { return; } + oenum = [array objectEnumerator]; + while ((file = [oenum nextObject])) + { + if ([file hasSuffix: @".m"]) + { + if (marray == nil) + { + marray = [NSMutableArray array]; + } + [marray addObject: file]; + } + else if ([file hasSuffix: @".mm"]) + { + if (mmarray == nil) + { + mmarray = [NSMutableArray array]; + } + [mmarray addObject: file]; + } + } + [self appendString:COMMENT_CLASSES]; [self appendString: [NSString stringWithFormat: @"%@_OBJC_FILES = \\\n",target]]; - [self appendString: [array componentsJoinedByString: @" \\\n"]]; + [self appendString: [marray componentsJoinedByString: @" \\\n"]]; + + [self appendString:COMMENT_OCPPCLASSES]; + [self appendString: + [NSString stringWithFormat: @"%@_OBJCC_FILES = \\\n",target]]; + + [self appendString: [mmarray componentsJoinedByString: @" \\\n"]]; } - (void)appendOtherSources:(NSArray *)array @@ -362,6 +396,7 @@ static PCMakefileFactory *_factory = nil; - (void)appendOtherSources:(NSArray *)array forTarget: (NSString *)target { NSMutableArray *marray = nil; + NSMutableArray *mmarray = nil; NSMutableArray *oarray = nil; NSEnumerator *oenum; NSString *file; @@ -383,6 +418,14 @@ static PCMakefileFactory *_factory = nil; } [marray addObject: file]; } + else if ([file hasSuffix: @".mm"]) + { + if (mmarray == nil) + { + mmarray = [NSMutableArray array]; + } + [mmarray addObject: file]; + } else // non .m file { if (oarray == nil) @@ -416,6 +459,19 @@ static PCMakefileFactory *_factory = nil; [self appendString: [NSString stringWithFormat: @"%@_OBJC_FILES += ",pnme]]; + while ((file = [oenum nextObject])) + { + [self appendString: [NSString stringWithFormat: @"\\\n%@ ", file]]; + } + } + + // Add .mm files if any + if (mmarray && [marray count] != 0) + { + oenum = [mmarray objectEnumerator]; + + [self appendString: [NSString stringWithFormat: @"%@_OBJCC_FILES += ",pnme]]; + while ((file = [oenum nextObject])) { [self appendString: [NSString stringWithFormat: @"\\\n%@ ", file]];