Skip to content

Commit

Permalink
Merge branch 'release/1.26'
Browse files Browse the repository at this point in the history
  • Loading branch information
rentzsch committed Apr 13, 2012
2 parents 83ca093 + 4fd6f8d commit b08eede
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 77 deletions.
14 changes: 14 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ Xmo'd works by noticing when your `*.xcdatamodel` is saved. If the model file's

## Version History

### v1.26: Thu Apr 12 2012 [download](http://github.com/downloads/rentzsch/mogenerator/mogenerator-1.26.dmg)

* [FIX] Missing space in transformable attribute codegen. [issue 89](https://github.com/rentzsch/mogenerator/issues/89) ([Daniel Tull](https://github.com/rentzsch/mogenerator/issues/89), [Kris Markel](https://github.com/rentzsch/mogenerator/pull/99), [Whitney Young](https://github.com/rentzsch/mogenerator/pull/101))

* [NEW] mogenerator's standard templates are now bundled into the mogenerator binary itself. This should solve the problem of templates growing out of sync with the intended version of mogenerator ([exacerbated](https://github.com/rentzsch/mogenerator/issues/93#issuecomment-4059248) by the now-popular homebrew installer). You can still use your own templates with the `--template-path` and `--template-group` parameters. [issue 79](https://github.com/rentzsch/mogenerator/pull/79) (Ingvar Nedrebo, rentzsch).

* [NEW] Support for per-entity custom base classes, set via `mogenerator.customBaseClass` key in the entity's user info. ([Trevor Squires](https://github.com/rentzsch/mogenerator/pull/94))

* [CHANGE] mogenerator installer no longer installs separate template files (but it won't touch those already installed).

* [CHANGE] mogenerator's .pkg installer no longer includes Xmo'd since 1) Xmo'd doesn't work with Xcode 4 yet and 2) Xcode.app now lives in /Applications, so the installer needs to get smarter to cope.



### v1.25: Thu Feb 16 2012 [download](http://github.com/downloads/rentzsch/mogenerator/mogenerator-1.25.dmg)

* [NEW] Support for Xcode 4.3 and it's relocation of `momc` into its bundle. Only supports /Applications/Xcode.app for now. ([Matt McGlincy](https://github.com/rentzsch/mogenerator/pull/90))
Expand Down
8 changes: 8 additions & 0 deletions build-mogenerator-Info-plist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rm -f /tmp/mogenerator-Info.plist
/usr/libexec/PlistBuddy \
-c "Clear" \
-c "Import :human.h.motemplate templates/human.h.motemplate" \
-c "Import :human.m.motemplate templates/human.m.motemplate" \
-c "Import :machine.h.motemplate templates/machine.h.motemplate" \
-c "Import :machine.m.motemplate templates/machine.m.motemplate" \
/tmp/mogenerator-Info.plist
2 changes: 1 addition & 1 deletion installer/Description.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<key>IFPkgDescriptionDescription</key>
<string>Implements generation gap codegen pattern for Core Data. Inspired by eogenerator.</string>
<key>IFPkgDescriptionTitle</key>
<string>mogenerator + Xmo'd VERSION</string>
<string>mogenerator VERSION</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion installer/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleGetInfoString</key>
<string>VERSION, Copyright © 2006-2007 Jonathan 'Wolf' Rentzsch</string>
<string>VERSION, Copyright © 2006-2012 Jonathan 'Wolf' Rentzsch</string>
<key>CFBundleIdentifier</key>
<string>com.rentzsch.mogenerator</string>
<key>CFBundleShortVersionString</key>
Expand Down
11 changes: 6 additions & 5 deletions installer/make_installer.command
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ cd "`dirname \"$0\"`"
sudo echo

sudo rm -rf 'build'
mkdir -p 'build/root/Library/Application Support/mogenerator'

cd ..
xcodebuild -configuration Release CONFIGURATION_BUILD_DIR="$PWD/installer/build/root/usr/bin/"
cp templates/*.motemplate "$PWD/installer/build/root/Library/Application Support/mogenerator/"
# The standard templates are now integrated into mogenerator's binary itself.
# mkdir -p 'build/root/Library/Application Support/mogenerator'
# cp templates/*.motemplate "$PWD/installer/build/root/Library/Application Support/mogenerator/"
cd installer

VERSION=`build/root/usr/bin/mogenerator --version|head -n 1|sed -E 's/mogenerator ([0-9]+\.[0-9]+(\.[0-9]+)?).+/\1/g'`
Expand All @@ -18,9 +19,9 @@ MINOR_VERSION=`echo $VERSION|sed -E 's/[0-9]+\.([0-9]+).*/\1/g'`
sed -E "s/VERSION/$VERSION/g" < Description.plist > 'build/Description.plist'
sed -e "s/MAJOR_VERSION/$MAJOR_VERSION/g" -e "s/MINOR_VERSION/$MINOR_VERSION/g" -e "s/VERSION/$VERSION/g" < Info.plist > 'build/Info.plist'

cd ../Xmod
xcodebuild -configuration Release CONFIGURATION_BUILD_DIR="`dirname $PWD`/installer/build/root/Developer/Library/Xcode/Plug-ins/"
cd ../installer
# cd ../Xmod
# xcodebuild -configuration Release CONFIGURATION_BUILD_DIR="`dirname $PWD`/installer/build/root/Developer/Library/Xcode/Plug-ins/"
# cd ../installer

sudo chown -R root 'build/root'
sudo chgrp -R admin 'build/root'
Expand Down
4 changes: 1 addition & 3 deletions mogenerator.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
mogenerator.h - <http://github.com/rentzsch/mogenerator>
Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Copyright (c) 2006-2012 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
Expand Down Expand Up @@ -71,6 +71,4 @@
BOOL _orphaned;
NSMutableDictionary *templateVar;
}

- (NSString*)appSupportFileNamed:(NSString*)fileName_;
@end
102 changes: 84 additions & 18 deletions mogenerator.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
mogenerator.m - <http://github.com/rentzsch/mogenerator>
Copyright (c) 2006-2011 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Copyright (c) 2006-2012 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
Some rights reserved: <http://opensource.org/licenses/mit-license.php>
***************************************************************************/
Expand Down Expand Up @@ -323,9 +323,14 @@ - (NSString*)objectAttributeClassName {
}
- (NSString*)objectAttributeType {
NSString *result = [self objectAttributeClassName];
result = [result stringByAppendingString:@" *"];
if ([result isEqualToString:@"NSObject *"]) {
if ([result isEqualToString:@"Class"]) {
// `Class` (don't append asterisk).
} else if ([result rangeOfString:@"<"].location != NSNotFound) {
// `id<Protocol1,Protocol2>` (don't append asterisk).
} else if ([result isEqualToString:@"NSObject"]) {
result = @"id";
} else {
result = [result stringByAppendingString:@"*"]; // Make it a pointer.
}
return result;
}
Expand Down Expand Up @@ -368,10 +373,29 @@ - (NSString*)camelCaseString {
}
@end

static MiscMergeEngine* engineWithTemplatePath(NSString *templatePath_) {
@interface MogeneratorTemplateDesc : NSObject {
NSString *templateName;
NSString *templatePath;
}
- (id)initWithName:(NSString*)name_ path:(NSString*)path_;
- (NSString*)templateName;
- (void)setTemplateName:(NSString*)name_;
- (NSString*)templatePath;
- (void)setTemplatePath:(NSString*)path_;
@end

static MiscMergeEngine* engineWithTemplateDesc(MogeneratorTemplateDesc *templateDesc_) {
MiscMergeTemplate *template = [[[MiscMergeTemplate alloc] init] autorelease];
[template setStartDelimiter:@"<$" endDelimiter:@"$>"];
[template parseContentsOfFile:templatePath_];
if ([templateDesc_ templatePath]) {
[template parseContentsOfFile:[templateDesc_ templatePath]];
} else {
NSData *templateData = [[NSBundle mainBundle] objectForInfoDictionaryKey:[templateDesc_ templateName]];
assert(templateData);
NSString *templateString = [[[NSString alloc] initWithData:templateData encoding:NSASCIIStringEncoding] autorelease];
[template setFilename:[@"x-__info_plist://" stringByAppendingString:[templateDesc_ templateName]]];
[template parseString:templateString];
}

return [[[MiscMergeEngine alloc] initWithTemplate:template] autorelease];
}
Expand All @@ -392,35 +416,36 @@ - (void)dealloc {
}

NSString *ApplicationSupportSubdirectoryName = @"mogenerator";
- (NSString*)appSupportFileNamed:(NSString*)fileName_ {
- (MogeneratorTemplateDesc*)templateDescNamed:(NSString*)fileName_ {
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDirectory;

if (templatePath) {
if ([fileManager fileExistsAtPath:templatePath isDirectory:&isDirectory] && isDirectory) {
return [templatePath stringByAppendingPathComponent:fileName_];
return [[[MogeneratorTemplateDesc alloc] initWithName:fileName_
path:[templatePath stringByAppendingPathComponent:fileName_]] autorelease];
}
} else {
} else if (templateGroup) {
NSArray *appSupportDirectories = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask+NSLocalDomainMask, YES);
assert(appSupportDirectories);

nsenumerate (appSupportDirectories, NSString*, appSupportDirectory) {
if ([fileManager fileExistsAtPath:appSupportDirectory isDirectory:&isDirectory]) {
NSString *appSupportSubdirectory = [appSupportDirectory stringByAppendingPathComponent:ApplicationSupportSubdirectoryName];
if (templateGroup) {
appSupportSubdirectory = [appSupportSubdirectory stringByAppendingPathComponent:templateGroup];
}
appSupportSubdirectory = [appSupportSubdirectory stringByAppendingPathComponent:templateGroup];
if ([fileManager fileExistsAtPath:appSupportSubdirectory isDirectory:&isDirectory] && isDirectory) {
NSString *appSupportFile = [appSupportSubdirectory stringByAppendingPathComponent:fileName_];
if ([fileManager fileExistsAtPath:appSupportFile isDirectory:&isDirectory] && !isDirectory) {
return appSupportFile;
return [[[MogeneratorTemplateDesc alloc] initWithName:fileName_ path:appSupportFile] autorelease];
}
}
}
}
} else {
return [[[MogeneratorTemplateDesc alloc] initWithName:fileName_ path:nil] autorelease];
}

ddprintf(@"appSupportFileNamed:@\"%@\": file not found", fileName_);
ddprintf(@"templateDescNamed:@\"%@\": file not found", fileName_);
exit(EXIT_FAILURE);
return nil;
}
Expand Down Expand Up @@ -606,7 +631,7 @@ - (int) application: (DDCliApplication *) app
}

if (_version) {
printf("mogenerator 1.25. By Jonathan 'Wolf' Rentzsch + friends.\n");
printf("mogenerator 1.26. By Jonathan 'Wolf' Rentzsch + friends.\n");
return EXIT_SUCCESS;
}

Expand Down Expand Up @@ -693,13 +718,13 @@ - (int) application: (DDCliApplication *) app
int humanFilesGenerated = 0;

if (model) {
MiscMergeEngine *machineH = engineWithTemplatePath([self appSupportFileNamed:@"machine.h.motemplate"]);
MiscMergeEngine *machineH = engineWithTemplateDesc([self templateDescNamed:@"machine.h.motemplate"]);
assert(machineH);
MiscMergeEngine *machineM = engineWithTemplatePath([self appSupportFileNamed:@"machine.m.motemplate"]);
MiscMergeEngine *machineM = engineWithTemplateDesc([self templateDescNamed:@"machine.m.motemplate"]);
assert(machineM);
MiscMergeEngine *humanH = engineWithTemplatePath([self appSupportFileNamed:@"human.h.motemplate"]);
MiscMergeEngine *humanH = engineWithTemplateDesc([self templateDescNamed:@"human.h.motemplate"]);
assert(humanH);
MiscMergeEngine *humanM = engineWithTemplatePath([self appSupportFileNamed:@"human.m.motemplate"]);
MiscMergeEngine *humanM = engineWithTemplateDesc([self templateDescNamed:@"human.m.motemplate"]);
assert(humanM);

// Add the template var dictionary to each of the merge engines
Expand Down Expand Up @@ -831,6 +856,47 @@ - (int) application: (DDCliApplication *) app

@end

@implementation MogeneratorTemplateDesc

- (id)initWithName:(NSString*)name_ path:(NSString*)path_ {
self = [super init];
if (self) {
templateName = [name_ retain];
templatePath = [path_ retain];
}
return self;
}

- (void)dealloc {
[templateName release];
[templatePath release];
[super dealloc];
}

- (NSString*)templateName {
return templateName;
}

- (void)setTemplateName:(NSString*)name_ {
if (templateName != name_) {
[templateName release];
templateName = [name_ retain];
}
}

- (NSString*)templatePath {
return templatePath;
}

- (void)setTemplatePath:(NSString*)path_ {
if (templatePath != path_) {
[templatePath release];
templatePath = [path_ retain];
}
}

@end

int main (int argc, char * const * argv)
{
return DDCliAppRunWithClass([MOGeneratorApp class]);
Expand Down
29 changes: 29 additions & 0 deletions mogenerator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "mogenerator" */;
buildPhases = (
7956A85B152E4A500081B5CA /* ShellScript */,
8DD76F990486AA7600D96B5E /* Sources */,
8DD76F9B0486AA7600D96B5E /* Frameworks */,
);
Expand Down Expand Up @@ -386,6 +387,22 @@
};
/* End PBXProject section */

/* Begin PBXShellScriptBuildPhase section */
7956A85B152E4A500081B5CA /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "sh build-mogenerator-Info-plist.sh\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
8DD76F990486AA7600D96B5E /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down Expand Up @@ -460,6 +477,12 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INSTALL_PATH = "$(HOME)/bin";
OTHER_LDFLAGS = (
"-sectcreate",
__TEXT,
__info_plist,
"/tmp/mogenerator-Info.plist",
);
PRODUCT_NAME = mogenerator;
WARNING_CFLAGS = "-Wall";
};
Expand All @@ -477,6 +500,12 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
INSTALL_PATH = "$(HOME)/bin";
OTHER_LDFLAGS = (
"-sectcreate",
__TEXT,
__info_plist,
"/tmp/mogenerator-Info.plist",
);
PRODUCT_NAME = mogenerator;
WARNING_CFLAGS = "-Wall";
};
Expand Down
7 changes: 4 additions & 3 deletions mogeneratorTestMule/MOs/_ChildMO.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern const struct ChildMOFetchedProperties {



@property (nonatomic, retain) NSString *childName;
@property (nonatomic, retain) NSString* childName;


//- (BOOL)validateChildName:(id*)value_ error:(NSError**)error_;
Expand All @@ -52,6 +52,7 @@ extern const struct ChildMOFetchedProperties {




@end

@interface _ChildMO (CoreDataGeneratedAccessors)
Expand All @@ -61,8 +62,8 @@ extern const struct ChildMOFetchedProperties {
@interface _ChildMO (CoreDataGeneratedPrimitiveAccessors)


- (NSString *)primitiveChildName;
- (void)setPrimitiveChildName:(NSString *)value;
- (NSString*)primitiveChildName;
- (void)setPrimitiveChildName:(NSString*)value;



Expand Down
1 change: 1 addition & 0 deletions mogeneratorTestMule/MOs/_ChildMO.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ + (NSArray*)fetchByParent:(NSManagedObjectContext*)moc_ parent:(ParentMO*)parent
}



@end
Loading

0 comments on commit b08eede

Please sign in to comment.