diff --git a/meson.build b/meson.build index eace2418..b1c0b940 100644 --- a/meson.build +++ b/meson.build @@ -65,8 +65,10 @@ global_args += run_command(objfw,'--cppflags').stdout().split() add_project_arguments(run_command(objfw,'--objcflags').stdout().split(), language:'objc') add_project_link_arguments(run_command(objfw,'--libs','--ldflags').stdout().split(), language:['objc','objcpp']) -if compilers['objc'].get_id() == 'clang' +if (compilers['objc'].get_id() == 'clang' and get_option('gc_type') == 'arc' and host_machine.cpu_family() == 'x86_64') add_project_arguments(run_command(objfw,'--arc').stdout().split(), language: ['objc','objcpp']) +else + add_project_arguments('-fobjc-gc', language: ['objc', 'objcpp']) endif subdir('src') diff --git a/meson_options.txt b/meson_options.txt index efbb0fb8..f0660f06 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -3,6 +3,7 @@ option('mk', type: 'boolean', value: false, description: 'Build to fit Marin\'s option('ruby_lib', type: 'string', value: 'ruby', description: 'Name of the Ruby library') option('console', type: 'boolean', value: true, description: 'Whether to debug information in the console') option('macos_min_version', type: 'string', value: '10.10', description: 'Minimum macOS system version to support') +option('gc_type', type: 'combo', choices: ['gc','arc'], value: 'arc', description: 'Which method of garbage collection to utilize') option('shared_fluid', type: 'boolean', value: false, description: 'Dynamically link fluidsynth at build time') option('cjk_fallback_font', type: 'boolean', value: false, description: 'Use WenQuanYi Micro Hei as the fallback font') diff --git a/src/filesystem.mm b/src/filesystem.mm index 9970b15c..1b1bceec 100644 --- a/src/filesystem.mm +++ b/src/filesystem.mm @@ -714,28 +714,25 @@ void FileSystem::openReadRaw(SDL_RWops &ops, // SDL_SaveBMP wants absolute paths char* FileSystem::normalize(const char *pathname, bool preferred, bool absolute) { - @autoreleasepool - { - char* ret = new char[512]; - id str = [OFMutableString stringWithUTF8String:pathname]; + char* ret = new char[512]; + id str = [OFMutableString stringWithUTF8String:pathname]; - if (absolute) - { - OFURL* base = [OFURL fileURLWithPath:[[OFFileManager defaultManager] currentDirectoryPath]]; - OFURL* purl = [OFURL fileURLWithPath:str]; - OFString* path = [[OFURL URLWithString:[purl string] relativeToURL:base] path]; - str = [OFMutableString stringWithString:path]; - } + if (absolute) + { + OFURL* base = [OFURL fileURLWithPath:[[OFFileManager defaultManager] currentDirectoryPath]]; + OFURL* purl = [OFURL fileURLWithPath:str]; + OFString* path = [[OFURL URLWithString:[purl string] relativeToURL:base] path]; + str = [OFMutableString stringWithString:path]; + } #ifdef __WIN32__ - if (preferred) - { - [str replaceOccurrencesOfString:@"/" withString:@"\\"]; - } -#endif - strncpy(ret, [[str stringByStandardizingPath] UTF8String], 512); - return ret; + if (preferred) + { + [str replaceOccurrencesOfString:@"/" withString:@"\\"]; } +#endif + strncpy(ret, [[str stringByStandardizingPath] UTF8String], 512); + return ret; } bool FileSystem::exists(const char *filename)