From cca0664e7fd42f6c046e1bee7fdf91eee74e5d77 Mon Sep 17 00:00:00 2001
From: barracuda156 <vital.had@gmail.com>
Date: Thu, 22 Jun 2023 09:30:32 +0800
Subject: [PATCH] Unbreak < 10.7

---
 ddcli/DDGetoptLongParser.h            | 10 ---------
 ddcli/DDGetoptLongParser.m            | 32 ---------------------------
 mogenerator.h                         |  1 -
 mogenerator.m                         | 11 +--------
 mogenerator.xcodeproj/project.pbxproj |  2 --
 test/Rakefile                         | 19 +---------------
 6 files changed, 2 insertions(+), 73 deletions(-)

diff --git ddcli/DDGetoptLongParser.h ddcli/DDGetoptLongParser.h
index f37a092..a0c09a6 100644
--- ddcli/DDGetoptLongParser.h
+++ ddcli/DDGetoptLongParser.h
@@ -85,7 +85,6 @@ typedef struct
     int mCurrentOption;
     NSMutableArray * mUtf8Data;
     DDGetoptFunction mGetoptFunction;
-    NSString *mArgumentsFilename;
 }
 
 /**
@@ -177,15 +176,6 @@ typedef struct
 - (NSArray *) parseOptionsWithArguments: (NSArray *) arguments
                                 command: (NSString *) command;
 
-/**
- * If set, provides the name of a file, located in the current working
- * directory, containing command-line arguments in a simple JSON array
- *
- * @param filename Name of the file to look for in the current working directory
- */
-
-- (void)setArgumentsFilename:(NSString*)filename;
-
 @end
 
 /**
diff --git ddcli/DDGetoptLongParser.m ddcli/DDGetoptLongParser.m
index 29d4f3d..09e70df 100644
--- ddcli/DDGetoptLongParser.m
+++ ddcli/DDGetoptLongParser.m
@@ -73,7 +73,6 @@
     [mOptionString release];
     [mOptionsData release];
     [mUtf8Data release];
-    [mArgumentsFilename release];
     
     [super dealloc];
 }
@@ -88,11 +87,6 @@
     mTarget = target;
 }
 
-- (void) setArgumentsFilename:(NSString *)filename
-{
-    mArgumentsFilename = [filename copy];
-}
-
 - (void) setGetoptLongOnly: (BOOL) getoptLongOnly
 {
     if (getoptLongOnly)
@@ -168,32 +162,6 @@
 {
     NSProcessInfo * processInfo = [NSProcessInfo processInfo];
     NSArray * arguments = [processInfo arguments];
-    
-    if (mArgumentsFilename != nil) {
-        if (NSClassFromString(@"NSJSONSerialization") == nil) {
-            fprintf(stderr, "Warning: ignoring %s, feature supported from OS X 10.7 onwards\n", [mArgumentsFilename UTF8String]);
-        } else {
-            NSFileManager *fm = [NSFileManager defaultManager];
-            NSString *argumentsFilePath = [[fm currentDirectoryPath] stringByAppendingPathComponent:mArgumentsFilename];
-            if ([fm fileExistsAtPath:argumentsFilePath]) {
-                NSError *error;
-                NSArray *argumentsFromFile = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:argumentsFilePath] options:0 error:&error];
-                if (argumentsFromFile != nil) {
-                    NSAssert([arguments count] > 0, @"Process has no arguments (not even the command). Weird.");
-                    NSString *command = [arguments objectAtIndex:0];
-                    arguments = [arguments subarrayWithRange:NSMakeRange(1, [arguments count] - 1)];
-                    
-                    NSMutableArray *mutableArguments = [NSMutableArray arrayWithObject:command];
-                    [mutableArguments addObjectsFromArray:argumentsFromFile];
-                    [mutableArguments addObjectsFromArray:arguments];
-                    arguments = [NSArray arrayWithArray:mutableArguments];
-                } else {
-                    fprintf(stderr, "Error reading %s: %s\n", [mArgumentsFilename UTF8String], [[error localizedDescription] UTF8String]);
-                    exit(1);
-                }
-            }
-        }
-    }
 
     NSString * command = [processInfo processName];
     return [self parseOptionsWithArguments: arguments command: command];
diff --git mogenerator.h mogenerator.h
index 5b9226e..781e4ab 100644
--- mogenerator.h
+++ mogenerator.h
@@ -77,7 +77,6 @@
     BOOL                  _listSourceFiles;
     BOOL                  _orphaned;
     BOOL                  _swift;
-    BOOL                  _v2;
     NSMutableDictionary   *templateVar;
 }
 @end
diff --git mogenerator.m mogenerator.m
index e86bc90..3ec30d3 100644
--- mogenerator.m
+++ mogenerator.m
@@ -664,9 +664,7 @@ NSString *ApplicationSupportSubdirectoryName = @"mogenerator";
     [optionsParser setGetoptLongOnly:YES];
     DDGetoptOption optionTable[] = 
     {
-        // Long                 Short  Argument options
-        {@"v2",                 '2',   DDGetoptNoArgument},
-        
+        // Long                 Short  Argument options        
         {@"model",              'm',   DDGetoptRequiredArgument},
         {@"configuration",      'C',   DDGetoptRequiredArgument},
         {@"base-class",         0,     DDGetoptRequiredArgument},
@@ -693,7 +691,6 @@ NSString *ApplicationSupportSubdirectoryName = @"mogenerator";
         {nil,                   0,     0},
     };
     [optionsParser addOptionsFromTable:optionTable];
-    [optionsParser setArgumentsFilename:@".mogenerator-args"];
 }
 
 - (void)printUsage {
@@ -925,12 +922,6 @@ NSString *ApplicationSupportSubdirectoryName = @"mogenerator";
         printf("mogenerator 1.28. By Jonathan 'Wolf' Rentzsch + friends.\n");
         return EXIT_SUCCESS;
     }
-    
-    if (_v2) {
-        [templateVar setObject:@YES forKey:@"arc"];
-        [templateVar setObject:@YES forKey:@"literals"];
-        [templateVar setObject:@YES forKey:@"modules"];
-    }
 
     gSwift = _swift;
 
diff --git mogenerator.xcodeproj/project.pbxproj mogenerator.xcodeproj/project.pbxproj
index bbc03c2..2b2825c 100644
--- mogenerator.xcodeproj/project.pbxproj
+++ mogenerator.xcodeproj/project.pbxproj
@@ -473,7 +473,6 @@
 				GCC_OPTIMIZATION_LEVEL = 0;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = mogenerator_Prefix.pch;
-				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				OTHER_LDFLAGS = (
 					"-sectcreate",
@@ -494,7 +493,6 @@
 				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = mogenerator_Prefix.pch;
-				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				OTHER_LDFLAGS = (
 					"-sectcreate",
diff --git test/Rakefile test/Rakefile
index 19095c8..c8acf4d 100644
--- test/Rakefile
+++ test/Rakefile
@@ -17,7 +17,7 @@ def gen_and_compile(desc, mogenPath, extra_mogen_args, extra_gcc_args)
   ENV['MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS'] = '1'
   run_or_die "#{mogenPath.gsub(/ /, '\\ ')} --model test.xcdatamodel --output MOs --baseClass MyBaseClass #{extra_mogen_args}"
   run_or_die 'cp HumanMO.h HumanMO.m MyProtocol.h TestProtocol.m MOs'
-  run_or_die "clang -o testbin test.m MyBaseClass.m Gender.m MOs/*.m -I#{Dir.pwd} -framework Foundation -framework Cocoa -framework CoreData -fmodules #{extra_gcc_args}"
+  run_or_die "clang -o testbin test.m MyBaseClass.m Gender.m MOs/*.m -I#{Dir.pwd} -framework Foundation -framework Cocoa -framework CoreData #{extra_gcc_args}"
   run_or_die "xcrun momc -MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS test.xcdatamodel #{Dir.pwd}/test.mom"
   puts run_or_die './testbin'
 end
@@ -32,23 +32,6 @@ task :mrc_noliterals do
   gen_and_compile('MRC (without objc literals)', mogenPath, '--template-var noliterals=true', '')
 end
 
-desc 'Generate, Compile and Run ARC Code (with objc literals)'
-task :arc do
-  gen_and_compile('ARC (with objc literals)', mogenPath, '--template-var arc=true', '-fobjc-arc')
-end
-
-desc 'Generate, Compile and Run ARC Code (without objc literals)'
-task :arc_noliterals do
-  gen_and_compile('ARC (without objc literals)', mogenPath, '--template-var arc=true --template-var noliterals=true', '-fobjc-arc')
-end
-
-desc 'Generate, Compile and Run ARC Code (without objc literals)'
-task :v2 do
-  Rake::Task[:clean].execute
-  gen_and_compile('v2 (ARC + objc literals)', mogenPath, '--v2', '-fobjc-arc')
-  Rake::Task[:clean].execute
-end
-
 desc 'Clean output'
 task :clean do
   run_or_die 'rm -rf MOs testbin test.mom'
-- 
2.41.0

