Skip to content

Commit

Permalink
Added support for the following momc options:
Browse files Browse the repository at this point in the history
MOMC_NO_WARNINGS, MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS, MOMC_SUPPRESS_INVERSE_TRANSIENT_ERROR

These options can be set as ENV variables and they will be passed to the momc compiler.
  • Loading branch information
nikita-zhuk committed Jun 4, 2011
1 parent 4716a9c commit 96786d4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mogenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,19 @@ - (void)setModel:(NSString*)path;
assert(momc && "momc not found");

tempMOMPath = [[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]] stringByAppendingPathExtension:@"mom"];
system([[NSString stringWithFormat:@"\"%@\" \"%@\" \"%@\"", momc, path, tempMOMPath] UTF8String]); // Ignored system's result -- momc doesn't return any relevent error codes.

NSArray *supportedMomcOptions = [NSArray arrayWithObjects:@"MOMC_NO_WARNINGS", @"MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS", @"MOMC_SUPPRESS_INVERSE_TRANSIENT_ERROR", nil];
NSMutableString *momcOptions = [NSMutableString string];

for (NSString *momcOption in supportedMomcOptions)
{
if([[[NSProcessInfo processInfo] environment] objectForKey:momcOption] != nil)
{
[momcOptions appendFormat:@" -%@ ", momcOption];
}
}

system([[NSString stringWithFormat:@"\"%@\" %@ \"%@\" \"%@\"", momc, momcOptions, 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 Down

0 comments on commit 96786d4

Please sign in to comment.