def configure(env): ## Build type if (env["target"].startswith("release")): env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1']) if (env["optimize"] == "speed"): #optimize for speed (default) env.Append(CPPFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer']) env.Append(LINKFLAGS=['-O2']) else: #optimize for size env.Append(CPPFLAGS=['-Os', '-ftree-vectorize']) env.Append(LINKFLAGS=['-Os']) if env["target"] == "release_debug": env.Append(CPPFLAGS=['-DDEBUG_ENABLED']) elif (env["target"] == "debug"): env.Append(CPPFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) if (env["use_lto"]): env.Append(CPPFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto']) ## Architecture if env["arch"] == "x86": # i386 env["bits"] = "32" elif env["arch"] == "x86_64": env["bits"] = "64" elif (env["arch"] == "arm" or env["arch"] == "arm32" or env["arch"] == "armv7" or env["bits"] == "32"): # arm env["arch"] = "arm" env["bits"] = "32" else: # armv64 env["arch"] = "arm64" env["bits"] = "64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_IOS" in os.environ: env["osxcross"] = True env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH'] compiler_path = '$IPHONEPATH/usr/bin/${ios_triple}' s_compiler_path = '$IPHONEPATH/Developer/usr/bin/' ccache_path = os.environ.get("CCACHE") if ccache_path is None: env['CC'] = compiler_path + 'clang' env['CXX'] = compiler_path + 'clang++' env['S_compiler'] = s_compiler_path + 'gcc' else: # there aren't any ccache wrappers available for iOS, # to enable caching we need to prepend the path to the ccache binary env['CC'] = ccache_path + ' ' + compiler_path + 'clang' env['CXX'] = ccache_path + ' ' + compiler_path + 'clang++' env['S_compiler'] = ccache_path + ' ' + s_compiler_path + 'gcc' env['AR'] = compiler_path + 'ar' env['RANLIB'] = compiler_path + 'ranlib' ## Compile flags if (env["arch"] == "x86" or env["arch"] == "x86_64"): detect_darwin_sdk_path('iphonesimulator', env) env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.9' arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(CCFLAGS=('-arch ' + arch_flag + ' -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=10.0 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"').split()) elif (env["arch"] == "arm"): detect_darwin_sdk_path('iphone', env) env.Append(CCFLAGS='-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=10.0 -MMD -MT dependencies'.split()) elif (env["arch"] == "arm64"): detect_darwin_sdk_path('iphone', env) env.Append(CCFLAGS='-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=10.0 -isysroot $IPHONESDK'.split()) env.Append(CPPFLAGS=['-DNEED_LONG_INT']) env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) if env['ios_exceptions']: env.Append(CPPFLAGS=['-fexceptions']) else: env.Append(CPPFLAGS=['-fno-exceptions']) ## Link flags if (env["arch"] == "x86" or env["arch"] == "x86_64"): arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(LINKFLAGS=['-arch', arch_flag, '-mios-simulator-version-min=10.0', '-isysroot', '$IPHONESDK', '-Xlinker', '-objc_abi_version', '-Xlinker', '2', '-F$IPHONESDK', ]) elif (env["arch"] == "arm"): env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=10.0']) if (env["arch"] == "arm64"): env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=10.0']) env.Append(LINKFLAGS=['-isysroot', '$IPHONESDK', '-framework', 'AudioToolbox', '-framework', 'AVFoundation', '-framework', 'CoreAudio', '-framework', 'CoreGraphics', '-framework', 'CoreMedia', '-framework', 'CoreMotion', '-framework', 'Foundation', '-framework', 'GameController', '-framework', 'MediaPlayer', '-framework', 'OpenGLES', '-framework', 'QuartzCore', '-framework', 'Security', '-framework', 'SystemConfiguration', '-framework', 'UIKit', ]) # Feature options if env['game_center']: env.Append(CPPFLAGS=['-DGAME_CENTER_ENABLED']) env.Append(LINKFLAGS=['-framework', 'GameKit']) if env['store_kit']: env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED']) env.Append(LINKFLAGS=['-framework', 'StoreKit']) if env['icloud']: env.Append(CPPFLAGS=['-DICLOUD_ENABLED']) env.Append(CPPPATH=['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers', ]) env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' env.Append(CPPPATH=['#platform/iphone']) env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES_ENABLED', '-DCOREAUDIO_ENABLED'])
def configure(env): ## Build type if (env["target"].startswith("release")): env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1']) if (env["optimize"] == "speed"): #optimize for speed (default) env.Append(CPPFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer', '-ffast-math', '-funsafe-math-optimizations']) env.Append(LINKFLAGS=['-O2']) else: #optimize for size env.Append(CPPFLAGS=['-Os', '-ftree-vectorize']) env.Append(LINKFLAGS=['-Os']) if env["target"] == "release_debug": env.Append(CPPFLAGS=['-DDEBUG_ENABLED']) elif (env["target"] == "debug"): env.Append(CPPFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) if (env["use_lto"]): env.Append(CPPFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto']) ## Architecture if env["ios_sim"] and not ("arch" in env): env["arch"] = "x86" if env["arch"] == "x86": # i386, simulator env["bits"] = "32" elif env["arch"] == "x86_64": env["bits"] = "64" elif (env["arch"] == "arm" or env["arch"] == "arm32" or env["arch"] == "armv7" or env["bits"] == "32"): # arm env["arch"] = "arm" env["bits"] = "32" else: # armv64 env["arch"] = "arm64" env["bits"] = "64" ## Compiler configuration env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH'] compiler_path = '$IPHONEPATH/usr/bin/${ios_triple}' s_compiler_path = '$IPHONEPATH/Developer/usr/bin/' ccache_path = os.environ.get("CCACHE") if ccache_path == None: env['CC'] = compiler_path + 'clang' env['CXX'] = compiler_path + 'clang++' env['S_compiler'] = s_compiler_path + 'gcc' else: # there aren't any ccache wrappers available for iOS, # to enable caching we need to prepend the path to the ccache binary env['CC'] = ccache_path + ' ' + compiler_path + 'clang' env['CXX'] = ccache_path + ' ' + compiler_path + 'clang++' env['S_compiler'] = ccache_path + ' ' + s_compiler_path + 'gcc' env['AR'] = compiler_path + 'ar' env['RANLIB'] = compiler_path + 'ranlib' ## Compile flags if (env["arch"] == "x86" or env["arch"] == "x86_64"): detect_darwin_sdk_path('iphonesimulator', env) env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.9' arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(CCFLAGS=('-arch ' + arch_flag + ' -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=9.0 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"').split()) elif (env["arch"] == "arm"): detect_darwin_sdk_path('iphone', env) env.Append(CCFLAGS='-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=9.0 -MMD -MT dependencies'.split()) elif (env["arch"] == "arm64"): detect_darwin_sdk_path('iphone', env) env.Append(CCFLAGS='-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=9.0 -isysroot $IPHONESDK'.split()) env.Append(CPPFLAGS=['-DNEED_LONG_INT']) env.Append(CPPFLAGS=['-DLIBYUV_DISABLE_NEON']) if env['ios_exceptions']: env.Append(CPPFLAGS=['-fexceptions']) else: env.Append(CPPFLAGS=['-fno-exceptions']) ## Link flags if (env["arch"] == "x86" or env["arch"] == "x86_64"): arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(LINKFLAGS=['-arch', arch_flag, '-mios-simulator-version-min=9.0', '-isysroot', '$IPHONESDK', '-Xlinker', '-objc_abi_version', '-Xlinker', '2', '-F$IPHONESDK', ]) elif (env["arch"] == "arm"): env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=9.0']) if (env["arch"] == "arm64"): env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=9.0']) env.Append(LINKFLAGS=['-isysroot', '$IPHONESDK', '-framework', 'AudioToolbox', '-framework', 'AVFoundation', '-framework', 'CoreAudio', '-framework', 'CoreGraphics', '-framework', 'CoreMedia', '-framework', 'CoreMotion', '-framework', 'Foundation', '-framework', 'GameController', '-framework', 'MediaPlayer', '-framework', 'OpenGLES', '-framework', 'QuartzCore', '-framework', 'Security', '-framework', 'SystemConfiguration', '-framework', 'UIKit', ]) # Feature options if env['game_center']: env.Append(CPPFLAGS=['-DGAME_CENTER_ENABLED']) env.Append(LINKFLAGS=['-framework', 'GameKit']) if env['store_kit']: env.Append(CPPFLAGS=['-DSTOREKIT_ENABLED']) env.Append(LINKFLAGS=['-framework', 'StoreKit']) if env['icloud']: env.Append(CPPFLAGS=['-DICLOUD_ENABLED']) env.Append(CPPPATH=['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers', ]) env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' env.Append(CPPPATH=['#platform/iphone']) env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES_ENABLED', '-DMPC_FIXED_POINT', '-DCOREAUDIO_ENABLED']) # TODO: Move that to opus module's config if 'module_opus_enabled' in env and env['module_opus_enabled']: env.opus_fixed_point = "yes" if (env["arch"] == "arm"): env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) elif (env["arch"] == "arm64"): env.Append(CFLAGS=["-DOPUS_ARM64_OPT"])
def configure(env): ## Build type if env["target"] == "release": if env["optimize"] == "speed": # optimize for speed (default) env.Prepend( CCFLAGS=["-O3", "-fomit-frame-pointer", "-ftree-vectorize"]) elif env["optimize"] == "size": # optimize for size env.Prepend(CCFLAGS=["-Os", "-ftree-vectorize"]) if env["arch"] != "arm64": env.Prepend(CCFLAGS=["-msse2"]) if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "release_debug": if env["optimize"] == "speed": # optimize for speed (default) env.Prepend(CCFLAGS=["-O2"]) elif env["optimize"] == "size": # optimize for size env.Prepend(CCFLAGS=["-Os"]) if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "debug": env.Prepend(CCFLAGS=["-g3"]) env.Prepend(LINKFLAGS=["-Xlinker", "-no_deduplicate"]) ## Architecture # Mac OS X no longer runs on 32-bit since 10.7 which is unsupported since 2014 # As such, we only support 64-bit env["bits"] = "64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_ROOT" in os.environ: env["osxcross"] = True if env["arch"] == "arm64": print("Building for macOS 10.15+, platform arm64.") env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"]) env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"]) else: print("Building for macOS 10.12+, platform x86-64.") env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) if not "osxcross" in env: # regular native build if env["macports_clang"] != "no": mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] env["CC"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang" env["CXX"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env["AR"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar" env["RANLIB"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" env["AS"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" else: env["CC"] = "clang" env["CXX"] = "clang++" detect_darwin_sdk_path("osx", env) env.Append(CCFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) env.Append(LINKFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) if env["arch"] == "arm64": basecmd = root + "/target/bin/arm64-apple-" + env[ "osxcross_sdk"] + "-" else: basecmd = root + "/target/bin/x86_64-apple-" + env[ "osxcross_sdk"] + "-" ccache_path = os.environ.get("CCACHE") if ccache_path is None: env["CC"] = basecmd + "cc" env["CXX"] = basecmd + "c++" else: # there aren't any ccache wrappers available for OS X cross-compile, # to enable caching we need to prepend the path to the ccache binary env["CC"] = ccache_path + " " + basecmd + "cc" env["CXX"] = ccache_path + " " + basecmd + "c++" env["AR"] = basecmd + "ar" env["RANLIB"] = basecmd + "ranlib" env["AS"] = basecmd + "as" if env["use_ubsan"] or env["use_asan"] or env["use_tsan"]: env.extra_suffix += "s" if env["use_ubsan"]: env.Append(CCFLAGS=[ "-fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin" ]) env.Append(LINKFLAGS=["-fsanitize=undefined"]) env.Append(CCFLAGS=[ "-fsanitize=nullability-return,nullability-arg,function,nullability-assign" ]) if env["use_asan"]: env.Append(CCFLAGS=[ "-fsanitize=address,pointer-subtract,pointer-compare" ]) env.Append(LINKFLAGS=["-fsanitize=address"]) if env["use_tsan"]: env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) if env["use_coverage"]: env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"]) env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"]) ## Dependencies if env["builtin_libtheora"]: if env["arch"] != "arm64": env["x86_libtheora_opt_gcc"] = True ## Flags env.Prepend(CPPPATH=["#platform/osx"]) env.Append(CPPDEFINES=[ "OSX_ENABLED", "UNIX_ENABLED", "APPLE_STYLE_KEYS", "COREAUDIO_ENABLED", "COREMIDI_ENABLED" ]) env.Append(LINKFLAGS=[ "-framework", "Cocoa", "-framework", "Carbon", "-framework", "AudioUnit", "-framework", "CoreAudio", "-framework", "CoreMIDI", "-framework", "IOKit", "-framework", "ForceFeedback", "-framework", "CoreVideo", "-framework", "AVFoundation", "-framework", "CoreMedia", ]) env.Append(LIBS=["pthread", "z"]) if env["opengl3"]: env.Append(CPPDEFINES=["GLES_ENABLED", "GLES3_ENABLED"]) env.Append(CCFLAGS=["-Wno-deprecated-declarations" ]) # Disable deprecation warnings env.Append(LINKFLAGS=["-framework", "OpenGL"]) if env["vulkan"]: env.Append(CPPDEFINES=["VULKAN_ENABLED"]) env.Append(LINKFLAGS=[ "-framework", "Metal", "-framework", "QuartzCore", "-framework", "IOSurface" ]) if not env["use_volk"]: env.Append(LINKFLAGS=[ "-L$VULKAN_SDK_PATH/MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/", "-lMoltenVK" ])
def configure(env): ## Build type if env["target"] == "release": if env["optimize"] == "speed": # optimize for speed (default) env.Prepend(CCFLAGS=[ "-O3", "-fomit-frame-pointer", "-ftree-vectorize", "-msse2" ]) else: # optimize for size env.Prepend(CCFLAGS=["-Os", "-ftree-vectorize", "-msse2"]) if env["debug_symbols"] == "yes": env.Prepend(CCFLAGS=["-g1"]) if env["debug_symbols"] == "full": env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "release_debug": if env["optimize"] == "speed": # optimize for speed (default) env.Prepend(CCFLAGS=["-O2"]) else: # optimize for size env.Prepend(CCFLAGS=["-Os"]) env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) if env["debug_symbols"] == "yes": env.Prepend(CCFLAGS=["-g1"]) if env["debug_symbols"] == "full": env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "debug": env.Prepend(CCFLAGS=["-g3"]) env.Prepend(CPPDEFINES=["DEBUG_ENABLED"]) env.Prepend(LINKFLAGS=["-Xlinker", "-no_deduplicate"]) ## Architecture # Mac OS X no longer runs on 32-bit since 10.7 which is unsupported since 2014 # As such, we only support 64-bit env["bits"] = "64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_ROOT" in os.environ: env["osxcross"] = True if not "osxcross" in env: # regular native build if env["arch"] == "arm64": print("Building for macOS 10.15+, platform arm64.") env.Append(CCFLAGS=[ "-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15" ]) env.Append(LINKFLAGS=[ "-arch", "arm64", "-mmacosx-version-min=10.15", "-target", "arm64-apple-macos10.15" ]) else: print("Building for macOS 10.9+, platform x86-64.") env.Append( CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"]) env.Append( LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.9"]) if env["macports_clang"] != "no": mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] env["CC"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang" env["LINK"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env["CXX"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env["AR"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar" env["RANLIB"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" env["AS"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" env.Append(CPPDEFINES=[ "__MACPORTS__" ]) # hack to fix libvpx MM256_BROADCASTSI128_SI256 define else: env["CC"] = "clang" env["CXX"] = "clang++" detect_darwin_sdk_path("osx", env) env.Append(CCFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) env.Append(LINKFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" ccache_path = os.environ.get("CCACHE") if ccache_path is None: env["CC"] = basecmd + "cc" env["CXX"] = basecmd + "c++" else: # there aren't any ccache wrappers available for OS X cross-compile, # to enable caching we need to prepend the path to the ccache binary env["CC"] = ccache_path + " " + basecmd + "cc" env["CXX"] = ccache_path + " " + basecmd + "c++" env["AR"] = basecmd + "ar" env["RANLIB"] = basecmd + "ranlib" env["AS"] = basecmd + "as" env.Append(CPPDEFINES=[ "__MACPORTS__" ]) # hack to fix libvpx MM256_BROADCASTSI128_SI256 define if env["CXX"] == "clang++": env.Append(CPPDEFINES=["TYPED_METHOD_BIND"]) env["CC"] = "clang" env["LINK"] = "clang++" if env["use_ubsan"] or env["use_asan"] or env["use_tsan"]: env.extra_suffix += "s" if env["use_ubsan"]: env.Append(CCFLAGS=["-fsanitize=undefined"]) env.Append(LINKFLAGS=["-fsanitize=undefined"]) if env["use_asan"]: env.Append(CCFLAGS=["-fsanitize=address"]) env.Append(LINKFLAGS=["-fsanitize=address"]) if env["use_tsan"]: env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) ## Dependencies if env["builtin_libtheora"]: if env["arch"] != "arm64": env["x86_libtheora_opt_gcc"] = True ## Flags env.Prepend(CPPPATH=["#platform/osx"]) env.Append(CPPDEFINES=[ "OSX_ENABLED", "UNIX_ENABLED", "GLES_ENABLED", "APPLE_STYLE_KEYS", "COREAUDIO_ENABLED", "COREMIDI_ENABLED", "GL_SILENCE_DEPRECATION", ]) env.Append(LINKFLAGS=[ "-framework", "Cocoa", "-framework", "Carbon", "-framework", "OpenGL", "-framework", "AGL", "-framework", "AudioUnit", "-framework", "CoreAudio", "-framework", "CoreMIDI", "-lz", "-framework", "IOKit", "-framework", "ForceFeedback", "-framework", "AVFoundation", "-framework", "CoreMedia", "-framework", "CoreVideo", ]) env.Append(LIBS=["pthread"])
def configure(env): ## Build type if env["target"].startswith("release"): env.Append(CPPDEFINES=["NDEBUG", ("NS_BLOCK_ASSERTIONS", 1)]) if env["optimize"] == "speed": # optimize for speed (default) env.Append( CCFLAGS=["-O2", "-ftree-vectorize", "-fomit-frame-pointer"]) env.Append(LINKFLAGS=["-O2"]) else: # optimize for size env.Append(CCFLAGS=["-Os", "-ftree-vectorize"]) env.Append(LINKFLAGS=["-Os"]) if env["target"] == "release_debug": env.Append(CPPDEFINES=["DEBUG_ENABLED"]) elif env["target"] == "debug": env.Append(CCFLAGS=["-gdwarf-2", "-O0"]) env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1), "DEBUG_ENABLED"]) if env["use_lto"]: env.Append(CCFLAGS=["-flto"]) env.Append(LINKFLAGS=["-flto"]) ## Architecture if env["arch"] == "x86": # i386 env["bits"] = "32" elif env["arch"] == "x86_64": env["bits"] = "64" elif env["arch"] == "arm" or env["arch"] == "arm32" or env[ "arch"] == "armv7" or env["bits"] == "32": # arm env["arch"] = "arm" env["bits"] = "32" else: # armv64 env["arch"] = "arm64" env["bits"] = "64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_IOS" in os.environ: env["osxcross"] = True env["ENV"]["PATH"] = env["IPHONEPATH"] + "/Developer/usr/bin/:" + env[ "ENV"]["PATH"] compiler_path = "$IPHONEPATH/usr/bin/${ios_triple}" s_compiler_path = "$IPHONEPATH/Developer/usr/bin/" ccache_path = os.environ.get("CCACHE") if ccache_path is None: env["CC"] = compiler_path + "clang" env["CXX"] = compiler_path + "clang++" env["S_compiler"] = s_compiler_path + "gcc" else: # there aren't any ccache wrappers available for iOS, # to enable caching we need to prepend the path to the ccache binary env["CC"] = ccache_path + " " + compiler_path + "clang" env["CXX"] = ccache_path + " " + compiler_path + "clang++" env["S_compiler"] = ccache_path + " " + s_compiler_path + "gcc" env["AR"] = compiler_path + "ar" env["RANLIB"] = compiler_path + "ranlib" ## Compile flags if env["arch"] == "x86" or env["arch"] == "x86_64": detect_darwin_sdk_path("iphonesimulator", env) env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.9" arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(CCFLAGS=( "-arch " + arch_flag + " -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=10.0" ).split()) elif env["arch"] == "arm": detect_darwin_sdk_path("iphone", env) env.Append( CCFLAGS= '-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=10.0 -MMD -MT dependencies' .split()) elif env["arch"] == "arm64": detect_darwin_sdk_path("iphone", env) env.Append( CCFLAGS= "-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=10.0 -isysroot $IPHONESDK" .split()) env.Append(CPPDEFINES=["NEED_LONG_INT"]) env.Append(CPPDEFINES=["LIBYUV_DISABLE_NEON"]) # Disable exceptions on non-tools (template) builds if not env["tools"]: if env["ios_exceptions"]: env.Append(CCFLAGS=["-fexceptions"]) else: env.Append(CCFLAGS=["-fno-exceptions"]) ## Link flags if env["arch"] == "x86" or env["arch"] == "x86_64": arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(LINKFLAGS=[ "-arch", arch_flag, "-mios-simulator-version-min=10.0", "-isysroot", "$IPHONESDK", "-Xlinker", "-objc_abi_version", "-Xlinker", "2", "-F$IPHONESDK", ]) elif env["arch"] == "arm": env.Append(LINKFLAGS=[ "-arch", "armv7", "-Wl,-dead_strip", "-miphoneos-version-min=10.0" ]) if env["arch"] == "arm64": env.Append(LINKFLAGS=[ "-arch", "arm64", "-Wl,-dead_strip", "-miphoneos-version-min=10.0" ]) env.Append(LINKFLAGS=[ "-isysroot", "$IPHONESDK", "-framework", "AudioToolbox", "-framework", "AVFoundation", "-framework", "CoreAudio", "-framework", "CoreGraphics", "-framework", "CoreMedia", "-framework", "CoreVideo", "-framework", "CoreMotion", "-framework", "Foundation", "-framework", "GameController", "-framework", "MediaPlayer", "-framework", "Metal", "-framework", "QuartzCore", "-framework", "Security", "-framework", "SystemConfiguration", "-framework", "UIKit", "-framework", "ARKit", ]) # Feature options if env["game_center"]: env.Append(CPPDEFINES=["GAME_CENTER_ENABLED"]) env.Append(LINKFLAGS=["-framework", "GameKit"]) if env["store_kit"]: env.Append(CPPDEFINES=["STOREKIT_ENABLED"]) env.Append(LINKFLAGS=["-framework", "StoreKit"]) if env["icloud"]: env.Append(CPPDEFINES=["ICLOUD_ENABLED"]) env.Prepend(CPPPATH=[ "$IPHONESDK/usr/include", "$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers", ]) env["ENV"][ "CODESIGN_ALLOCATE"] = "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate" env.Prepend(CPPPATH=["#platform/iphone"]) env.Append( CPPDEFINES=["IPHONE_ENABLED", "UNIX_ENABLED", "COREAUDIO_ENABLED"]) env.Append(CPPDEFINES=["VULKAN_ENABLED"]) env.Append(LINKFLAGS=["-framework", "IOSurface"]) if env["use_static_mvk"]: env.Append(LINKFLAGS=["-framework", "MoltenVK"]) env["builtin_vulkan"] = False elif not env["builtin_vulkan"]: env.Append(LIBS=["vulkan"])
def configure(env): # Validate arch. supported_arches = ["x86_64", "arm64"] if env["arch"] not in supported_arches: print( 'Unsupported CPU architecture "%s" for macOS. Supported architectures are: %s.' % (env["arch"], ", ".join(supported_arches))) sys.exit() ## Build type if env["target"] == "release": if env["optimize"] == "speed": # optimize for speed (default) env.Prepend( CCFLAGS=["-O3", "-fomit-frame-pointer", "-ftree-vectorize"]) elif env["optimize"] == "size": # optimize for size env.Prepend(CCFLAGS=["-Os", "-ftree-vectorize"]) if env["arch"] != "arm64": env.Prepend(CCFLAGS=["-msse2"]) if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "release_debug": if env["optimize"] == "speed": # optimize for speed (default) env.Prepend(CCFLAGS=["-O2"]) elif env["optimize"] == "size": # optimize for size env.Prepend(CCFLAGS=["-Os"]) if env["debug_symbols"]: env.Prepend(CCFLAGS=["-g2"]) elif env["target"] == "debug": env.Prepend(CCFLAGS=["-g3"]) env.Prepend(LINKFLAGS=["-Xlinker", "-no_deduplicate"]) ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_ROOT" in os.environ: env["osxcross"] = True # CPU architecture. if env["arch"] == "arm64": print("Building for macOS 11.0+.") env.Append(ASFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.0"]) env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.0"]) env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=11.0"]) elif env["arch"] == "x86_64": print("Building for macOS 10.12+.") env.Append(ASFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(CCFLAGS=["-fobjc-arc"]) if not "osxcross" in env: # regular native build if env["macports_clang"] != "no": mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] env["CC"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang" env["CXX"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env["AR"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar" env["RANLIB"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" env["AS"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" else: env["CC"] = "clang" env["CXX"] = "clang++" detect_darwin_sdk_path("macos", env) env.Append(CCFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) env.Append(LINKFLAGS=["-isysroot", "$MACOS_SDK_PATH"]) else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) if env["arch"] == "arm64": basecmd = root + "/target/bin/arm64-apple-" + env[ "osxcross_sdk"] + "-" else: basecmd = root + "/target/bin/x86_64-apple-" + env[ "osxcross_sdk"] + "-" ccache_path = os.environ.get("CCACHE") if ccache_path is None: env["CC"] = basecmd + "cc" env["CXX"] = basecmd + "c++" else: # there aren't any ccache wrappers available for OS X cross-compile, # to enable caching we need to prepend the path to the ccache binary env["CC"] = ccache_path + " " + basecmd + "cc" env["CXX"] = ccache_path + " " + basecmd + "c++" env["AR"] = basecmd + "ar" env["RANLIB"] = basecmd + "ranlib" env["AS"] = basecmd + "as" if env["use_ubsan"] or env["use_asan"] or env["use_tsan"]: env.extra_suffix += ".san" env.Append(CCFLAGS=["-DSANITIZERS_ENABLED"]) if env["use_ubsan"]: env.Append(CCFLAGS=[ "-fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin" ]) env.Append(LINKFLAGS=["-fsanitize=undefined"]) env.Append(CCFLAGS=[ "-fsanitize=nullability-return,nullability-arg,function,nullability-assign" ]) if env["use_asan"]: env.Append(CCFLAGS=[ "-fsanitize=address,pointer-subtract,pointer-compare" ]) env.Append(LINKFLAGS=["-fsanitize=address"]) if env["use_tsan"]: env.Append(CCFLAGS=["-fsanitize=thread"]) env.Append(LINKFLAGS=["-fsanitize=thread"]) if env["use_coverage"]: env.Append(CCFLAGS=["-ftest-coverage", "-fprofile-arcs"]) env.Append(LINKFLAGS=["-ftest-coverage", "-fprofile-arcs"]) ## Dependencies if env["builtin_libtheora"] and env["arch"] == "x86_64": env["x86_libtheora_opt_gcc"] = True ## Flags env.Prepend(CPPPATH=["#platform/macos"]) env.Append(CPPDEFINES=[ "MACOS_ENABLED", "UNIX_ENABLED", "APPLE_STYLE_KEYS", "COREAUDIO_ENABLED", "COREMIDI_ENABLED" ]) env.Append(LINKFLAGS=[ "-framework", "Cocoa", "-framework", "Carbon", "-framework", "AudioUnit", "-framework", "CoreAudio", "-framework", "CoreMIDI", "-framework", "IOKit", "-framework", "ForceFeedback", "-framework", "CoreVideo", "-framework", "AVFoundation", "-framework", "CoreMedia", ]) env.Append(LIBS=["pthread", "z"]) if env["opengl3"]: env.Append(CPPDEFINES=["GLES_ENABLED", "GLES3_ENABLED"]) env.Append(CCFLAGS=["-Wno-deprecated-declarations" ]) # Disable deprecation warnings env.Append(LINKFLAGS=["-framework", "OpenGL"]) env.Append(LINKFLAGS=[ "-rpath", "@executable_path/../Frameworks", "-rpath", "@executable_path" ]) if env["vulkan"]: env.Append(CPPDEFINES=["VULKAN_ENABLED"]) env.Append(LINKFLAGS=[ "-framework", "Metal", "-framework", "QuartzCore", "-framework", "IOSurface" ]) if not env["use_volk"]: env.Append(LINKFLAGS=["-lMoltenVK"]) mvk_found = False if env["vulkan_sdk_path"] != "": mvk_path = os.path.join( os.path.expanduser(env["vulkan_sdk_path"]), "MoltenVK/MoltenVK.xcframework/macos-arm64_x86_64/") if os.path.isfile(os.path.join(mvk_path, "libMoltenVK.a")): mvk_found = True env.Append(LINKFLAGS=["-L" + mvk_path]) if not mvk_found: mvk_path = get_mvk_sdk_path() if os.path.isfile(os.path.join(mvk_path, "libMoltenVK.a")): mvk_found = True env.Append(LINKFLAGS=["-L" + mvk_path]) if not mvk_found: print( "MoltenVK SDK installation directory not found, use 'vulkan_sdk_path' SCons parameter to specify SDK path." ) sys.exit(255)
def configure(env): ## Build type if env["target"].startswith("release"): env.Append(CPPDEFINES=["NDEBUG", ("NS_BLOCK_ASSERTIONS", 1)]) if env["optimize"] == "speed": # optimize for speed (default) # `-O2` is more friendly to debuggers than `-O3`, leading to better crash backtraces # when using `target=release_debug`. opt = "-O3" if env["target"] == "release" else "-O2" env.Append( CCFLAGS=[opt, "-ftree-vectorize", "-fomit-frame-pointer"]) env.Append(LINKFLAGS=[opt]) elif env["optimize"] == "size": # optimize for size env.Append(CCFLAGS=["-Os", "-ftree-vectorize"]) env.Append(LINKFLAGS=["-Os"]) elif env["target"] == "debug": env.Append(CCFLAGS=["-gdwarf-2", "-O0"]) env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1)]) if env["use_lto"]: env.Append(CCFLAGS=["-flto"]) env.Append(LINKFLAGS=["-flto"]) ## Architecture env["bits"] = "64" if env["arch"] != "x86_64": env["arch"] = "arm64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_IOS" in os.environ: env["osxcross"] = True env["ENV"]["PATH"] = env[ "IOS_TOOLCHAIN_PATH"] + "/Developer/usr/bin/:" + env["ENV"]["PATH"] compiler_path = "$IOS_TOOLCHAIN_PATH/usr/bin/${ios_triple}" s_compiler_path = "$IOS_TOOLCHAIN_PATH/Developer/usr/bin/" ccache_path = os.environ.get("CCACHE") if ccache_path is None: env["CC"] = compiler_path + "clang" env["CXX"] = compiler_path + "clang++" env["S_compiler"] = s_compiler_path + "gcc" else: # there aren't any ccache wrappers available for iOS, # to enable caching we need to prepend the path to the ccache binary env["CC"] = ccache_path + " " + compiler_path + "clang" env["CXX"] = ccache_path + " " + compiler_path + "clang++" env["S_compiler"] = ccache_path + " " + s_compiler_path + "gcc" env["AR"] = compiler_path + "ar" env["RANLIB"] = compiler_path + "ranlib" ## Compile flags if env["ios_simulator"]: detect_darwin_sdk_path("iossimulator", env) env.Append(ASFLAGS=["-mios-simulator-version-min=13.0"]) env.Append(CCFLAGS=["-mios-simulator-version-min=13.0"]) env.extra_suffix = ".simulator" + env.extra_suffix else: detect_darwin_sdk_path("ios", env) env.Append(ASFLAGS=["-miphoneos-version-min=11.0"]) env.Append(CCFLAGS=["-miphoneos-version-min=11.0"]) if env["arch"] == "x86_64": env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.9" env.Append(CCFLAGS=( "-fobjc-arc -arch x86_64" " -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks" " -fasm-blocks -isysroot $IOS_SDK_PATH").split()) env.Append(ASFLAGS=["-arch", "x86_64"]) elif env["arch"] == "arm64": env.Append(CCFLAGS=( "-fobjc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing" " -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits" " -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies" " -isysroot $IOS_SDK_PATH".split())) env.Append(ASFLAGS=["-arch", "arm64"]) env.Append(CPPDEFINES=["NEED_LONG_INT"]) # Disable exceptions on non-tools (template) builds if not env["tools"]: if env["ios_exceptions"]: env.Append(CCFLAGS=["-fexceptions"]) else: env.Append(CCFLAGS=["-fno-exceptions"]) # Temp fix for ABS/MAX/MIN macros in iOS SDK blocking compilation env.Append(CCFLAGS=["-Wno-ambiguous-macro"]) env.Prepend(CPPPATH=[ "$IOS_SDK_PATH/usr/include", "$IOS_SDK_PATH/System/Library/Frameworks/AudioUnit.framework/Headers", ]) env.Prepend(CPPPATH=["#platform/ios"]) env.Append(CPPDEFINES=["IOS_ENABLED", "UNIX_ENABLED", "COREAUDIO_ENABLED"]) if env["vulkan"]: env.Append(CPPDEFINES=["VULKAN_ENABLED"])
def configure(env): ## Build type if (env["target"] == "release"): if (env["optimize"] == "speed"): #optimize for speed (default) env.Prepend(CCFLAGS=[ '-O3', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2' ]) else: #optimize for size env.Prepend(CCFLAGS=['-Os', '-ftree-vectorize', '-msse2']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) if (env["debug_symbols"] == "full"): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "release_debug"): if (env["optimize"] == "speed"): #optimize for speed (default) env.Prepend(CCFLAGS=['-O2', '-DDEBUG_ENABLED']) else: #optimize for size env.Prepend(CCFLAGS=['-Os', '-DDEBUG_ENABLED']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) if (env["debug_symbols"] == "full"): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "debug"): env.Prepend( CCFLAGS=['-g3', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) ## Architecture # Mac OS X no longer runs on 32-bit since 10.7 which is unsupported since 2014 # As such, we only support 64-bit env["bits"] = "64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_ROOT" in os.environ: env["osxcross"] = True if not "osxcross" in env: # regular native build env.Append(CCFLAGS=['-arch', 'x86_64']) env.Append(LINKFLAGS=['-arch', 'x86_64']) if (env["macports_clang"] != 'no'): mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] env["CC"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang" env["LINK"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env["CXX"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env['AR'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar" env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" env.Append(CCFLAGS=[ '-D__MACPORTS__' ]) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define detect_darwin_sdk_path('osx', env) env.Append(CPPFLAGS=['-isysroot', '$MACOS_SDK_PATH']) env.Append(LINKFLAGS=['-isysroot', '$MACOS_SDK_PATH']) else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" ccache_path = os.environ.get("CCACHE") if ccache_path is None: env['CC'] = basecmd + "cc" env['CXX'] = basecmd + "c++" else: # there aren't any ccache wrappers available for OS X cross-compile, # to enable caching we need to prepend the path to the ccache binary env['CC'] = ccache_path + ' ' + basecmd + "cc" env['CXX'] = ccache_path + ' ' + basecmd + "c++" env['AR'] = basecmd + "ar" env['RANLIB'] = basecmd + "ranlib" env['AS'] = basecmd + "as" env.Append(CCFLAGS=[ '-D__MACPORTS__' ]) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define if (env["CXX"] == "clang++"): env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) env["CC"] = "clang" env["LINK"] = "clang++" ## Dependencies if env['builtin_libtheora']: env["x86_libtheora_opt_gcc"] = True ## Flags env.Append(CPPPATH=['#platform/osx']) env.Append(CPPFLAGS=[ '-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES_ENABLED', '-DAPPLE_STYLE_KEYS', '-DCOREAUDIO_ENABLED', '-DCOREMIDI_ENABLED' ]) env.Append(LINKFLAGS=[ '-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-framework', 'CoreMIDI', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback', '-framework', 'CoreVideo' ]) env.Append(LIBS=['pthread']) env.Append(CPPFLAGS=['-mmacosx-version-min=10.9']) env.Append(LINKFLAGS=['-mmacosx-version-min=10.9'])
def configure(env): ## Build type if (env["target"].startswith("release")): env.Append(CPPDEFINES=['NDEBUG', ('NS_BLOCK_ASSERTIONS', 1)]) if (env["optimize"] == "speed"): #optimize for speed (default) env.Append(CCFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer']) env.Append(LINKFLAGS=['-O2']) else: #optimize for size env.Append(CCFLAGS=['-Os', '-ftree-vectorize']) env.Append(LINKFLAGS=['-Os']) if env["target"] == "release_debug": env.Append(CPPDEFINES=['DEBUG_ENABLED']) elif (env["target"] == "debug"): env.Append(CCFLAGS=['-gdwarf-2', '-O0']) env.Append(CPPDEFINES=['_DEBUG', ('DEBUG', 1), 'DEBUG_ENABLED', 'DEBUG_MEMORY_ENABLED']) if (env["use_lto"]): env.Append(CCFLAGS=['-flto']) env.Append(LINKFLAGS=['-flto']) ## Architecture if env["arch"] == "x86": # i386 env["bits"] = "32" elif env["arch"] == "x86_64": env["bits"] = "64" elif (env["arch"] == "arm" or env["arch"] == "arm32" or env["arch"] == "armv7" or env["bits"] == "32"): # arm env["arch"] = "arm" env["bits"] = "32" else: # armv64 env["arch"] = "arm64" env["bits"] = "64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_IOS" in os.environ: env["osxcross"] = True env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH'] compiler_path = '$IPHONEPATH/usr/bin/${ios_triple}' s_compiler_path = '$IPHONEPATH/Developer/usr/bin/' ccache_path = os.environ.get("CCACHE") if ccache_path is None: env['CC'] = compiler_path + 'clang' env['CXX'] = compiler_path + 'clang++' env['S_compiler'] = s_compiler_path + 'gcc' else: # there aren't any ccache wrappers available for iOS, # to enable caching we need to prepend the path to the ccache binary env['CC'] = ccache_path + ' ' + compiler_path + 'clang' env['CXX'] = ccache_path + ' ' + compiler_path + 'clang++' env['S_compiler'] = ccache_path + ' ' + s_compiler_path + 'gcc' env['AR'] = compiler_path + 'ar' env['RANLIB'] = compiler_path + 'ranlib' ## Compile flags if (env["arch"] == "x86" or env["arch"] == "x86_64"): detect_darwin_sdk_path('iphonesimulator', env) env['ENV']['MACOSX_DEPLOYMENT_TARGET'] = '10.9' arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(CCFLAGS=('-arch ' + arch_flag + ' -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks -fasm-blocks -isysroot $IPHONESDK -mios-simulator-version-min=10.0').split()) elif (env["arch"] == "arm"): detect_darwin_sdk_path('iphone', env) env.Append(CCFLAGS='-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=10.0 -MMD -MT dependencies'.split()) elif (env["arch"] == "arm64"): detect_darwin_sdk_path('iphone', env) env.Append(CCFLAGS='-fno-objc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies -miphoneos-version-min=10.0 -isysroot $IPHONESDK'.split()) env.Append(CPPDEFINES=['NEED_LONG_INT']) env.Append(CPPDEFINES=['LIBYUV_DISABLE_NEON']) # Disable exceptions on non-tools (template) builds if not env['tools']: if env['ios_exceptions']: env.Append(CCFLAGS=['-fexceptions']) else: env.Append(CCFLAGS=['-fno-exceptions']) ## Link flags if (env["arch"] == "x86" or env["arch"] == "x86_64"): arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(LINKFLAGS=['-arch', arch_flag, '-mios-simulator-version-min=10.0', '-isysroot', '$IPHONESDK', '-Xlinker', '-objc_abi_version', '-Xlinker', '2', '-F$IPHONESDK', ]) elif (env["arch"] == "arm"): env.Append(LINKFLAGS=['-arch', 'armv7', '-Wl,-dead_strip', '-miphoneos-version-min=10.0']) if (env["arch"] == "arm64"): env.Append(LINKFLAGS=['-arch', 'arm64', '-Wl,-dead_strip', '-miphoneos-version-min=10.0']) env.Append(LINKFLAGS=['-isysroot', '$IPHONESDK', '-framework', 'AudioToolbox', '-framework', 'AVFoundation', '-framework', 'CoreAudio', '-framework', 'CoreGraphics', '-framework', 'CoreMedia', '-framework', 'CoreVideo', '-framework', 'CoreMotion', '-framework', 'Foundation', '-framework', 'GameController', '-framework', 'MediaPlayer', '-framework', 'OpenGLES', '-framework', 'QuartzCore', '-framework', 'Security', '-framework', 'SystemConfiguration', '-framework', 'UIKit', '-framework', 'ARKit', ]) # Feature options if env['game_center']: env.Append(CPPDEFINES=['GAME_CENTER_ENABLED']) env.Append(LINKFLAGS=['-framework', 'GameKit']) if env['store_kit']: env.Append(CPPDEFINES=['STOREKIT_ENABLED']) env.Append(LINKFLAGS=['-framework', 'StoreKit']) if env['icloud']: env.Append(CPPDEFINES=['ICLOUD_ENABLED']) env.Prepend(CPPPATH=['$IPHONESDK/usr/include', '$IPHONESDK/System/Library/Frameworks/OpenGLES.framework/Headers', '$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers', ]) env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' env.Prepend(CPPPATH=['#platform/iphone']) env.Append(CPPDEFINES=['IPHONE_ENABLED', 'UNIX_ENABLED', 'GLES_ENABLED', 'COREAUDIO_ENABLED', '-DEBUG_INFORMATION_FORMAT=dwarf-with-dsym'])
def configure(env): ## Build type if env["target"].startswith("release"): env.Append(CPPDEFINES=["NDEBUG", ("NS_BLOCK_ASSERTIONS", 1)]) if env["optimize"] == "speed": # optimize for speed (default) env.Append( CCFLAGS=["-O2", "-ftree-vectorize", "-fomit-frame-pointer"]) env.Append(LINKFLAGS=["-O2"]) elif env["optimize"] == "size": # optimize for size env.Append(CCFLAGS=["-Os", "-ftree-vectorize"]) env.Append(LINKFLAGS=["-Os"]) elif env["target"] == "debug": env.Append(CCFLAGS=["-gdwarf-2", "-O0"]) env.Append(CPPDEFINES=["_DEBUG", ("DEBUG", 1)]) if env["use_lto"]: env.Append(CCFLAGS=["-flto"]) env.Append(LINKFLAGS=["-flto"]) ## Architecture if env["arch"] == "x86": # i386 env["bits"] = "32" elif env["arch"] == "x86_64": env["bits"] = "64" elif env["arch"] == "arm" or env["arch"] == "arm32" or env[ "arch"] == "armv7" or env["bits"] == "32": # arm env["arch"] = "arm" env["bits"] = "32" else: # armv64 env["arch"] = "arm64" env["bits"] = "64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_IOS" in os.environ: env["osxcross"] = True env["ENV"]["PATH"] = env["IPHONEPATH"] + "/Developer/usr/bin/:" + env[ "ENV"]["PATH"] compiler_path = "$IPHONEPATH/usr/bin/${ios_triple}" s_compiler_path = "$IPHONEPATH/Developer/usr/bin/" ccache_path = os.environ.get("CCACHE") if ccache_path is None: env["CC"] = compiler_path + "clang" env["CXX"] = compiler_path + "clang++" env["S_compiler"] = s_compiler_path + "gcc" else: # there aren't any ccache wrappers available for iOS, # to enable caching we need to prepend the path to the ccache binary env["CC"] = ccache_path + " " + compiler_path + "clang" env["CXX"] = ccache_path + " " + compiler_path + "clang++" env["S_compiler"] = ccache_path + " " + s_compiler_path + "gcc" env["AR"] = compiler_path + "ar" env["RANLIB"] = compiler_path + "ranlib" ## Compile flags if env["ios_simulator"]: detect_darwin_sdk_path("iphonesimulator", env) env.Append(CCFLAGS=["-mios-simulator-version-min=13.0"]) env.extra_suffix = ".simulator" + env.extra_suffix else: detect_darwin_sdk_path("iphone", env) env.Append(CCFLAGS=["-miphoneos-version-min=11.0"]) if env["arch"] == "x86" or env["arch"] == "x86_64": env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.9" arch_flag = "i386" if env["arch"] == "x86" else env["arch"] env.Append(CCFLAGS=( "-fobjc-arc -arch " + arch_flag + " -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fblocks" " -fasm-blocks -isysroot $IPHONESDK").split()) elif env["arch"] == "arm": env.Append(CCFLAGS=( "-fobjc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing" " -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits" " -fpascal-strings -fblocks -isysroot $IPHONESDK -fvisibility=hidden -mthumb" ' "-DIBOutlet=__attribute__((iboutlet))"' ' "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))"' ' "-DIBAction=void)__attribute__((ibaction)" -MMD -MT dependencies' .split())) elif env["arch"] == "arm64": env.Append(CCFLAGS=( "-fobjc-arc -arch arm64 -fmessage-length=0 -fno-strict-aliasing" " -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits" " -fpascal-strings -fblocks -fvisibility=hidden -MMD -MT dependencies" " -isysroot $IPHONESDK".split())) env.Append(CPPDEFINES=["NEED_LONG_INT"]) env.Append(CPPDEFINES=["LIBYUV_DISABLE_NEON"]) # Disable exceptions on non-tools (template) builds if not env["tools"]: if env["ios_exceptions"]: env.Append(CCFLAGS=["-fexceptions"]) else: env.Append(CCFLAGS=["-fno-exceptions"]) # Temp fix for ABS/MAX/MIN macros in iPhone SDK blocking compilation env.Append(CCFLAGS=["-Wno-ambiguous-macro"]) env.Prepend(CPPPATH=[ "$IPHONESDK/usr/include", "$IPHONESDK/System/Library/Frameworks/AudioUnit.framework/Headers", ]) env.Prepend(CPPPATH=["#platform/iphone"]) env.Append( CPPDEFINES=["IPHONE_ENABLED", "UNIX_ENABLED", "COREAUDIO_ENABLED"]) if env["vulkan"]: env.Append(CPPDEFINES=["VULKAN_ENABLED"])
def configure(env): ## Build type if (env["target"] == "release"): if (env["optimize"] == "speed"): #optimize for speed (default) env.Prepend(CCFLAGS=['-O3', '-fomit-frame-pointer', '-ftree-vectorize', '-msse2']) else: #optimize for size env.Prepend(CCFLAGS=['-Os','-ftree-vectorize', '-msse2']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) if (env["debug_symbols"] == "full"): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "release_debug"): if (env["optimize"] == "speed"): #optimize for speed (default) env.Prepend(CCFLAGS=['-O2']) else: #optimize for size env.Prepend(CCFLAGS=['-Os']) env.Prepend(CPPFLAGS=['-DDEBUG_ENABLED']) if (env["debug_symbols"] == "yes"): env.Prepend(CCFLAGS=['-g1']) if (env["debug_symbols"] == "full"): env.Prepend(CCFLAGS=['-g2']) elif (env["target"] == "debug"): env.Prepend(CCFLAGS=['-g3']) env.Prepend(CPPFLAGS=['-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED']) ## Architecture # Mac OS X no longer runs on 32-bit since 10.7 which is unsupported since 2014 # As such, we only support 64-bit env["bits"] = "64" ## Compiler configuration # Save this in environment for use by other modules if "OSXCROSS_ROOT" in os.environ: env["osxcross"] = True if not "osxcross" in env: # regular native build env.Append(CCFLAGS=['-arch', 'x86_64']) env.Append(LINKFLAGS=['-arch', 'x86_64']) if (env["macports_clang"] != 'no'): mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpclangver = env["macports_clang"] env["CC"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang" env["LINK"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env["CXX"] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/clang++" env['AR'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ar" env['RANLIB'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-ranlib" env['AS'] = mpprefix + "/libexec/llvm-" + mpclangver + "/bin/llvm-as" env.Append(CPPFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define detect_darwin_sdk_path('osx', env) env.Append(CCFLAGS=['-isysroot', '$MACOS_SDK_PATH']) env.Append(LINKFLAGS=['-isysroot', '$MACOS_SDK_PATH']) else: # osxcross build root = os.environ.get("OSXCROSS_ROOT", 0) basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" ccache_path = os.environ.get("CCACHE") if ccache_path is None: env['CC'] = basecmd + "cc" env['CXX'] = basecmd + "c++" else: # there aren't any ccache wrappers available for OS X cross-compile, # to enable caching we need to prepend the path to the ccache binary env['CC'] = ccache_path + ' ' + basecmd + "cc" env['CXX'] = ccache_path + ' ' + basecmd + "c++" env['AR'] = basecmd + "ar" env['RANLIB'] = basecmd + "ranlib" env['AS'] = basecmd + "as" env.Append(CPPFLAGS=['-D__MACPORTS__']) #hack to fix libvpx MM256_BROADCASTSI128_SI256 define if (env["CXX"] == "clang++"): env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) env["CC"] = "clang" env["LINK"] = "clang++" ## Dependencies if env['builtin_libtheora']: env["x86_libtheora_opt_gcc"] = True ## Flags env.Prepend(CPPPATH=['#platform/osx']) env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES_ENABLED', '-DAPPLE_STYLE_KEYS', '-DCOREAUDIO_ENABLED', '-DCOREMIDI_ENABLED']) env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-framework', 'CoreMIDI', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback', '-framework', 'CoreVideo']) env.Append(LIBS=['pthread']) env.Append(CCFLAGS=['-mmacosx-version-min=10.9']) env.Append(LINKFLAGS=['-mmacosx-version-min=10.9'])