Navigation Menu

Skip to content

Commit

Permalink
[NEW] mogenerator 1.2:
Browse files Browse the repository at this point in the history
[NEW] Binary installer! Double-click the installer/make_installer.command file to create the distributable .dmg (which contains a .pkg).

[NEW] Works on latest seed of The Operating System That Shall Not Be Named.

[NEW] Now looks for templates in /Library/Application Support/mogenerator/ as well was ~/Library/Application Support/mogenerator/. This is mostly to make the installer package easier to create.
  • Loading branch information
rentzsch committed Apr 20, 2007
1 parent 895f0a6 commit 45ada95
Show file tree
Hide file tree
Showing 14 changed files with 2,889 additions and 132 deletions.
10 changes: 10 additions & 0 deletions installer/Description.plist
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IFPkgDescriptionDescription</key>
<string>Implements generation gap codegen pattern for Core Data. Inspired by eogenerator.</string>
<key>IFPkgDescriptionTitle</key>
<string>mogenerator VERSION</string>
</dict>
</plist>
46 changes: 46 additions & 0 deletions installer/Info.plist
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleGetInfoString</key>
<string>VERSION, Copyright © 2006-2007 Jonathan 'Wolf' Rentzsch</string>
<key>CFBundleIdentifier</key>
<string>com.rentzsch.mogenerator</string>
<key>CFBundleShortVersionString</key>
<string>VERSION</string>
<key>IFMajorVersion</key>
<integer>MAJOR_VERSION</integer>
<key>IFMinorVersion</key>
<integer>MINOR_VERSION</integer>
<key>IFPkgFlagAllowBackRev</key>
<false/>
<key>IFPkgFlagAuthorizationAction</key>
<string>AdminAuthorization</string>
<key>IFPkgFlagBackgroundAlignment</key>
<string>topleft</string>
<key>IFPkgFlagBackgroundScaling</key>
<string>none</string>
<key>IFPkgFlagDefaultLocation</key>
<string>/</string>
<key>IFPkgFlagFollowLinks</key>
<true/>
<key>IFPkgFlagInstallFat</key>
<false/>
<key>IFPkgFlagInstalledSize</key>
<integer>292</integer>
<key>IFPkgFlagIsRequired</key>
<false/>
<key>IFPkgFlagOverwritePermissions</key>
<false/>
<key>IFPkgFlagRelocatable</key>
<false/>
<key>IFPkgFlagRestartAction</key>
<string>NoRestart</string>
<key>IFPkgFlagRootVolumeOnly</key>
<false/>
<key>IFPkgFlagUpdateInstalledLanguages</key>
<false/>
<key>IFPkgFormatVersion</key>
<real>0.10000000149011612</real>
</dict>
</plist>
24 changes: 24 additions & 0 deletions installer/make_installer.command
@@ -0,0 +1,24 @@
#!/bin/sh
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 *.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'`
MAJOR_VERSION=`echo $VERSION|sed -E 's/([0-9]+).+/\1/g'`
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'

sudo chown -R root 'build/root'
sudo chgrp -R admin 'build/root'
/Developer/Tools/packagemaker -build -p "build/mogenerator-$VERSION.pkg" -f 'build/root' -i 'build/Info.plist' -d 'build/Description.plist' -ds
hdiutil create -srcfolder "build/mogenerator-$VERSION.pkg" -volname "mogenerator $VERSION" "build/mogenerator-$VERSION.dmg"
47 changes: 35 additions & 12 deletions mogenerator.m
Expand Up @@ -136,6 +136,31 @@ - (NSString*)camelCaseString {
return [[[MiscMergeEngine alloc] initWithTemplate:template] autorelease];
}

NSString *ApplicationSupportSubdirectoryName = @"mogenerator";
static NSString* appSupportFileNamed(NSString *fileName_) {
NSArray *appSupportDirectories = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask+NSLocalDomainMask, YES);
assert(appSupportDirectories);

NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDirectory;

nsenumerate (appSupportDirectories, NSString*, appSupportDirectory) {
if ([fileManager fileExistsAtPath:appSupportDirectory isDirectory:&isDirectory]) {
NSString *appSupportSubdirectory = [appSupportDirectory stringByAppendingPathComponent:ApplicationSupportSubdirectoryName];
if ([fileManager fileExistsAtPath:appSupportSubdirectory isDirectory:&isDirectory] && isDirectory) {
NSString *appSupportFile = [appSupportSubdirectory stringByAppendingPathComponent:fileName_];
if ([fileManager fileExistsAtPath:appSupportFile isDirectory:&isDirectory] && !isDirectory) {
return appSupportFile;
}
}
}
}

NSLog(@"appSupportFileNamed(@\"%@\"): file not found", fileName_);
exit(1);
return nil;
}

#define DEOPT_(OPTION_NAME) OPTION_NAME+(sizeof("opt_")-1)
#define LONG_OPT(OPTION_NAME, HAS_ARG) {DEOPT_(#OPTION_NAME), HAS_ARG, NULL, OPTION_NAME}
#define LONG_OPT_LAST { NULL,0,NULL,0 }
Expand Down Expand Up @@ -178,9 +203,12 @@ int main (int argc, const char * argv[]) {

if ([[path pathExtension] isEqualToString:@"xcdatamodel"]) {
// We've been handed a .xcdatamodel data model, transparently compile it into a .mom managed object model.
NSString *momc = [[NSFileManager defaultManager] fileExistsAtPath:@"/Library/Application Support/Apple/Developer Tools/Plug-ins/XDCoreDataModel.xdplugin/Contents/Resources/momc"]
? @"/Library/Application Support/Apple/Developer Tools/Plug-ins/XDCoreDataModel.xdplugin/Contents/Resources/momc"
: @"/Developer/Library/Xcode/Plug-ins/XDCoreDataModel.xdplugin/Contents/Resources/momc";

tempMOMPath = [[NSTemporaryDirectory() stringByAppendingPathComponent:[(id)CFUUIDCreateString(kCFAllocatorDefault, CFUUIDCreate(kCFAllocatorDefault)) autorelease]] stringByAppendingPathExtension:@"mom"];
NSString *momc = [NSString stringWithFormat:@"\"/Library/Application Support/Apple/Developer Tools/Plug-ins/XDCoreDataModel.xdplugin/Contents/Resources/momc\" %@ %@", path, tempMOMPath];
system([momc UTF8String]); // Ignored system's result -- momc doesn't return any relevent error codes.
system([[NSString stringWithFormat:@"\"%@\" %@ %@", momc, path, tempMOMPath] UTF8String]); // Ignored system's result -- momc doesn't return any relevent error codes.
path = tempMOMPath;
}
model = [[[NSManagedObjectModel alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path]] autorelease];
Expand All @@ -196,7 +224,7 @@ int main (int argc, const char * argv[]) {
assert([mfilePath length]);
break;
case opt_version:
printf("mogenerator 1.1.2. By Jonathan 'Wolf' Rentzsch + friends.\n");
printf("mogenerator 1.2. By Jonathan 'Wolf' Rentzsch + friends.\n");
break;
case opt_help:
default:
Expand All @@ -213,18 +241,13 @@ int main (int argc, const char * argv[]) {
int humanFilesGenerated = 0;

if (model) {
NSArray *appSupportFolders = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
assert(appSupportFolders);
assert([appSupportFolders count] == 1);
NSString *mogeneratorAppSupportFolder = [[appSupportFolders objectAtIndex:0] stringByAppendingPathComponent:@"mogenerator"];

MiscMergeEngine *machineH = engineWithTemplatePath([mogeneratorAppSupportFolder stringByAppendingPathComponent:@"machine.h.motemplate"]);
MiscMergeEngine *machineH = engineWithTemplatePath(appSupportFileNamed(@"machine.h.motemplate"));
assert(machineH);
MiscMergeEngine *machineM = engineWithTemplatePath([mogeneratorAppSupportFolder stringByAppendingPathComponent:@"machine.m.motemplate"]);
MiscMergeEngine *machineM = engineWithTemplatePath(appSupportFileNamed(@"machine.m.motemplate"));
assert(machineM);
MiscMergeEngine *humanH = engineWithTemplatePath([mogeneratorAppSupportFolder stringByAppendingPathComponent:@"human.h.motemplate"]);
MiscMergeEngine *humanH = engineWithTemplatePath(appSupportFileNamed(@"human.h.motemplate"));
assert(humanH);
MiscMergeEngine *humanM = engineWithTemplatePath([mogeneratorAppSupportFolder stringByAppendingPathComponent:@"human.m.motemplate"]);
MiscMergeEngine *humanM = engineWithTemplatePath(appSupportFileNamed(@"human.m.motemplate"));
assert(humanM);

int entityCount = [[model entities] count];
Expand Down
3 changes: 2 additions & 1 deletion mogenerator.xcodeproj/project.pbxproj
Expand Up @@ -139,7 +139,7 @@
79D2C00E0ACFB81200F3F141 /* nsenumerate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = nsenumerate.h; sourceTree = "<group>"; };
79D2C0570ACFBCB500F3F141 /* FoundationAdditions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FoundationAdditions.h; sourceTree = "<group>"; };
79D2C0580ACFBCB500F3F141 /* FoundationAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = FoundationAdditions.m; sourceTree = "<group>"; };
8DD76FA10486AA7600D96B5E /* mogenerator */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = mogenerator; sourceTree = BUILT_PRODUCTS_DIR; };
8DD76FA10486AA7600D96B5E /* mogenerator */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mogenerator; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -310,6 +310,7 @@
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* mogenerator */;
projectDirPath = "";
projectRoot = "";
targets = (
8DD76F960486AA7600D96B5E /* mogenerator */,
);
Expand Down
61 changes: 9 additions & 52 deletions mogenerator.xcodeproj/wolf.mode1
Expand Up @@ -185,48 +185,7 @@
<key>Notifications</key>
<array/>
<key>OpenEditors</key>
<array>
<dict>
<key>Content</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>790C56740B06A8FA00BF93B7</string>
<key>PBXProjectModuleLabel</key>
<string>mogenerator.m</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>790C56750B06A8FA00BF93B7</string>
<key>PBXProjectModuleLabel</key>
<string>mogenerator.m</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>793FDB640B8E117B00DAAB1A</string>
<key>history</key>
<array>
<string>793FDB5F0B8E10E500DAAB1A</string>
</array>
</dict>
<key>SplitCount</key>
<string>1</string>
</dict>
<key>StatusBarVisibility</key>
<true/>
</dict>
<key>Geometry</key>
<dict>
<key>Frame</key>
<string>{{0, 20}, {1096, 794}}</string>
<key>PBXModuleWindowStatusBarHidden2</key>
<false/>
<key>RubberWindowFrame</key>
<string>1444 743 1096 835 0 0 2560 1578 </string>
</dict>
</dict>
</array>
<array/>
<key>PerspectiveWidths</key>
<array>
<integer>-1</integer>
Expand Down Expand Up @@ -259,8 +218,6 @@
<key>Layout</key>
<array>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXBottomSmartGroupGIDs</key>
Expand Down Expand Up @@ -306,9 +263,8 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>2</integer>
<integer>1</integer>
<integer>0</integer>
<integer>12</integer>
<integer>11</integer>
</array>
</array>
<key>PBXSmartGroupTreeModuleOutlineStateVisibleRectKey</key>
Expand Down Expand Up @@ -412,9 +368,9 @@
</array>
<key>TableOfContents</key>
<array>
<string>793FDB5D0B8E10E500DAAB1A</string>
<string>791B1CD70BD8838600537AB8</string>
<string>1CE0B1FE06471DED0097A5F4</string>
<string>793FDB5E0B8E10E500DAAB1A</string>
<string>791B1CD80BD8838600537AB8</string>
<string>1CE0B20306471E060097A5F4</string>
<string>1CE0B20506471E060097A5F4</string>
</array>
Expand Down Expand Up @@ -549,7 +505,6 @@
<key>WindowOrderList</key>
<array>
<string>79D2BF1B0ACFAF4A00F3F141</string>
<string>790C56740B06A8FA00BF93B7</string>
<string>/Users/wolf/code/sf/redshed/cocoa/mogenerator/mogenerator.xcodeproj</string>
</array>
<key>WindowString</key>
Expand Down Expand Up @@ -591,10 +546,12 @@
<string>218pt</string>
</dict>
<dict>
<key>BecomeActive</key>
<true/>
<key>ContentConfiguration</key>
<dict>
<key>PBXBuildLogShowsTranscriptDefaultKey</key>
<string>{{0, 189}, {500, 47}}</string>
<string>{{0, 82}, {500, 154}}</string>
<key>PBXProjectModuleGUID</key>
<string>XCMainBuildResultsModuleGUID</string>
<key>PBXProjectModuleLabel</key>
Expand Down Expand Up @@ -632,7 +589,7 @@
<key>TableOfContents</key>
<array>
<string>79D2BF1B0ACFAF4A00F3F141</string>
<string>793FDB630B8E112200DAAB1A</string>
<string>791B1CD60BD8837E00537AB8</string>
<string>1CD0528F0623707200166675</string>
<string>XCMainBuildResultsModuleGUID</string>
</array>
Expand Down

0 comments on commit 45ada95

Please sign in to comment.