From 96786d4caf78ea6988ac430191e555350ca468c5 Mon Sep 17 00:00:00 2001 From: Nikita Zhuk Date: Sat, 4 Jun 2011 10:13:23 +0300 Subject: [PATCH] Added support for the following momc options: 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. --- mogenerator.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mogenerator.m b/mogenerator.m index 837d9e3a..8640b617 100644 --- a/mogenerator.m +++ b/mogenerator.m @@ -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];