def mkspec_get_toolchain_paths(conf): """ Return the common paths where the g++ binaries are located. :return: the common paths where we may find the g++ binary """ # The default path to search path_list = os.environ.get('PATH', '').split(os.pathsep) if conf.is_mkspec_platform('mac'): # If the compiler is installed using macports path_list += ['/opt/local/bin'] if conf.is_mkspec_platform('android'): # If specified, the android_ndk_dir option overrides the OS path if conf.has_tool_option('android_ndk_dir'): ndk = conf.get_tool_option('android_ndk_dir') ndk = os.path.abspath(os.path.expanduser(ndk)) ndk_path = [ndk, os.path.join(ndk, 'bin')] return ndk_path if conf.is_mkspec_platform('ios'): if conf.has_tool_option('ios_toolchain_dir'): toolchain = conf.get_tool_option('ios_toolchain_dir') else: toolchain = "/Applications/Xcode.app/Contents/Developer/" \ "Toolchains/XcodeDefault.xctoolchain/usr/bin/" toolchain = os.path.abspath(os.path.expanduser(toolchain)) return toolchain return path_list
def mkspec_get_toolchain_paths(conf): """ :return: the common paths where we may find the g++ binary """ # The default path to search path_list = os.environ.get("PATH", "").split(os.pathsep) if conf.is_mkspec_platform("mac"): # If the compiler is installed using macports path_list += ["/opt/local/bin"] if conf.is_mkspec_platform("android"): # If specified, the android_ndk_dir option overrides the OS path if conf.has_tool_option("android_ndk_dir"): ndk = conf.get_tool_option("android_ndk_dir") ndk = os.path.abspath(os.path.expanduser(ndk)) ndk_path = [ndk, os.path.join(ndk, "bin")] return ndk_path if conf.is_mkspec_platform("ios"): if conf.has_tool_option("ios_toolchain_dir"): toolchain = conf.get_tool_option("ios_toolchain_dir") else: toolchain = "/Applications/Xcode.app/Contents/Developer/" "Toolchains/XcodeDefault.xctoolchain/usr/bin/" toolchain = os.path.abspath(os.path.expanduser(toolchain)) # toolchain_path = [toolchain, os.path.join(toolchain,'bin')] return toolchain return path_list
def mkspec_get_toolchain_paths(conf): """ :return: the common paths where we may find the g++ binary """ # The default path to search path_list = os.environ.get('PATH', '').split(os.pathsep) if conf.is_mkspec_platform('mac'): # If the compiler is installed using macports path_list += ['/opt/local/bin'] if conf.is_mkspec_platform('android'): # If specified, the android_ndk_dir option overrides the OS path if conf.has_tool_option('android_ndk_dir'): ndk = conf.get_tool_option('android_ndk_dir') ndk = os.path.abspath(os.path.expanduser(ndk)) ndk_path = [ndk, os.path.join(ndk, 'bin')] return ndk_path if conf.is_mkspec_platform('ios'): if conf.has_tool_option('ios_toolchain_dir'): toolchain = conf.get_tool_option('ios_toolchain_dir') else: toolchain = "/Applications/Xcode.app/Contents/Developer/" \ "Toolchains/XcodeDefault.xctoolchain/usr/bin/" toolchain = os.path.abspath(os.path.expanduser(toolchain)) #toolchain_path = [toolchain, os.path.join(toolchain,'bin')] return toolchain return path_list
def mkspec_set_ios_options(conf, min_ios_version, cpu): sdk = conf.get_tool_option("ios_sdk_dir") sdk = os.path.abspath(os.path.expanduser(sdk)) # Set the IPHONE define - some libraries rely on this define being # present conf.env.DEFINES += ["IPHONE"] # Add common libraries for iOS here conf.env["LINKFLAGS"] += ["-lSystem"] # links with libSystem.dylib # Define what are the necessary common compiler and linker options # to build for the iOS platform. Here, tell the ARM cross-compiler # to target the specified arm-apple-ios platform triplet, specify # the location of the iOS SDK, use the compiler's integrated # assembler and set the minimal supported iOS version triple = "{}-apple-ios{}.0".format(cpu, min_ios_version) ios_flags = [ "-target", triple, "-integrated-as", "-isysroot", sdk, "-miphoneos-version-min={}".format(min_ios_version), ] conf.env["CFLAGS"] += ios_flags conf.env["CXXFLAGS"] += ios_flags conf.env["LINKFLAGS"] += ios_flags
def cxx_poky_gxx63_armv7(conf): """ Detect and setup the g++ 6.3 cross compiler for the Yocto based Poky distribution. """ conf.mkspec_gxx_configure( major=6, minor=3, prefix='arm-poky-linux-gnueabi') # Note: A static version of libstdc++ is not available in the # poky SDK so we cannot use -static-libstdc++ for statically # linking. flags = ['-march=armv7-a', '-marm', '-mfpu=neon', '-mfloat-abi=hard', '-mcpu=cortex-a9'] if conf.has_tool_option('poky_sdk_path'): sdk_path = conf.get_tool_option('poky_sdk_path') sysroot = os.path.join( sdk_path, 'sysroots', 'cortexa9hf-neon-poky-linux-gnueabi') flags.append('--sysroot=%s' % sysroot) conf.env['LINKFLAGS'] += flags conf.env['CXXFLAGS'] += flags # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def cxx_poky_gxx63_armv7(conf): """ Detect and setup the g++ 6.3 cross compiler for the Yocto based Poky distribution. """ conf.mkspec_gxx_configure(major=6, minor=3, prefix="arm-poky-linux-gnueabi") # Note: A static version of libstdc++ is not available in the # poky SDK so we cannot use -static-libstdc++ for statically # linking. flags = [ "-march=armv7-a", "-marm", "-mfpu=neon", "-mfloat-abi=hard", "-mcpu=cortex-a9", ] if conf.has_tool_option("poky_sdk_path"): sdk_path = conf.get_tool_option("poky_sdk_path") sysroot = os.path.join(sdk_path, "sysroots", "cortexa9hf-neon-poky-linux-gnueabi") flags.append("--sysroot=%s" % sysroot) conf.env["LINKFLAGS"] += flags conf.env["CXXFLAGS"] += flags # Set the target CPU conf.env["DEST_CPU"] = "arm"
def cxx_poky_gxx63_armv7(conf): """ Detect and setup the g++ 6.3 cross compiler for the Yocto based Poky distribution. """ conf.mkspec_gxx_configure(major=6, minor=3, prefix='arm-poky-linux-gnueabi') # Note: A static version of libstdc++ is not available in the # poky SDK so we cannot use -static-libstdc++ for statically # linking. flags = [ '-march=armv7-a', '-marm', '-mfpu=neon', '-mfloat-abi=hard', '-mcpu=cortex-a9' ] if conf.has_tool_option('poky_sdk_path'): sdk_path = conf.get_tool_option('poky_sdk_path') sysroot = os.path.join(sdk_path, 'sysroots', 'cortexa9hf-neon-poky-linux-gnueabi') flags.append('--sysroot=%s' % sysroot) conf.env['LINKFLAGS'] += flags conf.env['CXXFLAGS'] += flags # Set the target CPU conf.env['DEST_CPU'] = 'arm'
def mkspec_set_ios_options(conf, min_ios_version, cpu): sdk = conf.get_tool_option('ios_sdk_dir') sdk = os.path.abspath(os.path.expanduser(sdk)) # Set the IPHONE define - some libraries rely on this define being # present conf.env.DEFINES += ['IPHONE'] # Add common libraries for iOS here conf.env['LINKFLAGS'] += ['-lSystem'] # links with libSystem.dylib # Define what are the necessary common compiler and linker options # to build for the iOS platform. Here, tell the ARM cross-compiler # to target the specified arm-apple-ios platform triplet, specify # the location of the iOS SDK, use the compiler's integrated # assembler and set the minimal supported iOS version triple = "{}-apple-ios{}.0".format(cpu, min_ios_version) ios_flags = \ [ "-target", triple, "-integrated-as", "-isysroot", sdk, "-miphoneos-version-min={}".format(min_ios_version) ] conf.env['CFLAGS'] += ios_flags conf.env['CXXFLAGS'] += ios_flags conf.env['LINKFLAGS'] += ios_flags
def mkspec_get_toolchain_paths(conf): """ Return the common paths where the g++ binaries are located. :return: the common paths where we may find the g++ binary """ # The default path to search path_list = os.environ.get("PATH", "").split(os.pathsep) if conf.is_mkspec_platform("mac"): # If the compiler is installed using macports path_list += ["/opt/local/bin"] if conf.is_mkspec_platform("android"): # If specified, the android_ndk_dir option overrides the OS path if conf.has_tool_option("android_ndk_dir"): ndk = conf.get_tool_option("android_ndk_dir") ndk = os.path.abspath(os.path.expanduser(ndk)) ndk_path = [ndk, os.path.join(ndk, "bin")] return ndk_path if conf.is_mkspec_platform("ios"): if conf.has_tool_option("ios_toolchain_dir"): toolchain = conf.get_tool_option("ios_toolchain_dir") else: toolchain = ("/Applications/Xcode.app/Contents/Developer/" "Toolchains/XcodeDefault.xctoolchain/usr/bin/") toolchain = os.path.abspath(os.path.expanduser(toolchain)) return toolchain if conf.has_tool_option("poky_sdk_path"): sdk_path = conf.get_tool_option("poky_sdk_path") cross_compiler = os.path.join( sdk_path, "sysroots", "x86_64-pokysdk-linux", "usr", "bin", "arm-poky-linux-gnueabi", ) path_list = [cross_compiler] + path_list return path_list
def configure(conf): # Which mkspec should we use, by default, use the cxx_default # that simply fallbacks to use waf auto detect of compiler etc. mkspec = "cxx_default" if conf.has_tool_option('cxx_mkspec'): mkspec = conf.get_tool_option('cxx_mkspec') conf.msg('Using the mkspec:', mkspec) # Find and call the mkspec function on the conf object if hasattr(conf, mkspec): getattr(conf, mkspec)() else: conf.fatal("The mkspec is not available: {0}".format(mkspec)) # Additional flags for C/C++ compiler and linker if conf.has_tool_option('cflags'): conf.env['CFLAGS'] += conf.get_tool_option('cflags').split(';') if conf.has_tool_option('cxxflags'): conf.env['CXXFLAGS'] += conf.get_tool_option('cxxflags').split(';') if conf.has_tool_option('linkflags'): conf.env['LINKFLAGS'] += conf.get_tool_option('linkflags').split(';') # Common flags to be set for C/C++ compiler and linker if conf.has_tool_option('commonflags'): conf.env['CFLAGS'] += conf.get_tool_option('commonflags').split(';') conf.env['CXXFLAGS'] += conf.get_tool_option('commonflags').split(';') conf.env['LINKFLAGS'] += conf.get_tool_option('commonflags').split(';')
def configure(conf): # Which mkspec should we use, by default, use the cxx_default # that simply fallbacks to use waf auto detect of compiler etc. mkspec = "cxx_default" if conf.has_tool_option('cxx_mkspec'): mkspec = conf.get_tool_option('cxx_mkspec') conf.msg('Using the mkspec:', mkspec) if mkspec == "cxx_default": conf.load_external_tool('mkspec', mkspec) else: # Find and call the mkspec function on the conf object if hasattr(conf, mkspec): getattr(conf, mkspec)() else: conf.fatal("The mkspec is not available: {0}".format(mkspec)) # Additional flags for C/C++ compiler and linker if conf.has_tool_option('cflags'): conf.env['CFLAGS'] += conf.get_tool_option('cflags').split(';') if conf.has_tool_option('cxxflags'): conf.env['CXXFLAGS'] += conf.get_tool_option('cxxflags').split(';') if conf.has_tool_option('linkflags'): conf.env['LINKFLAGS'] += conf.get_tool_option('linkflags').split(';') # Common flags to be set for C/C++ compiler and linker if conf.has_tool_option('commonflags'): conf.env['CFLAGS'] += conf.get_tool_option('commonflags').split(';') conf.env['CXXFLAGS'] += conf.get_tool_option('commonflags').split(';') conf.env['LINKFLAGS'] += conf.get_tool_option('commonflags').split(';')
def configure(conf): # Which mkspec should we use, by default, use the cxx_default # that simply fallbacks to use waf auto detect of compiler etc. mkspec = "cxx_default" if conf.has_tool_option("cxx_mkspec"): mkspec = conf.get_tool_option("cxx_mkspec") conf.msg("Using the mkspec:", mkspec) # Additional flags for C/C++ compiler and linker if conf.has_tool_option("cflags"): conf.env["CFLAGS"] += conf.get_tool_option("cflags").split(";") if conf.has_tool_option("cxxflags"): conf.env["CXXFLAGS"] += conf.get_tool_option("cxxflags").split(";") if conf.has_tool_option("linkflags"): conf.env["LINKFLAGS"] += conf.get_tool_option("linkflags").split(";") # Common flags to be set for C/C++ compiler and linker if conf.has_tool_option("commonflags"): conf.env["CFLAGS"] += conf.get_tool_option("commonflags").split(";") conf.env["CXXFLAGS"] += conf.get_tool_option("commonflags").split(";") conf.env["LINKFLAGS"] += conf.get_tool_option("commonflags").split(";") # Find and call the mkspec function on the conf object if hasattr(conf, mkspec): getattr(conf, mkspec)() else: conf.fatal("The mkspec is not available: {0}".format(mkspec))
def mkspec_get_toolchain_paths(conf): """ Return the common paths where the g++ binaries are located. :return: the common paths where we may find the g++ binary """ # The default path to search path_list = os.environ.get('PATH', '').split(os.pathsep) if conf.is_mkspec_platform('mac'): # If the compiler is installed using macports path_list += ['/opt/local/bin'] if conf.is_mkspec_platform('android'): # If specified, the android_ndk_dir option overrides the OS path if conf.has_tool_option('android_ndk_dir'): ndk = conf.get_tool_option('android_ndk_dir') ndk = os.path.abspath(os.path.expanduser(ndk)) ndk_path = [ndk, os.path.join(ndk, 'bin')] return ndk_path if conf.is_mkspec_platform('ios'): if conf.has_tool_option('ios_toolchain_dir'): toolchain = conf.get_tool_option('ios_toolchain_dir') else: toolchain = "/Applications/Xcode.app/Contents/Developer/" \ "Toolchains/XcodeDefault.xctoolchain/usr/bin/" toolchain = os.path.abspath(os.path.expanduser(toolchain)) return toolchain if conf.has_tool_option('poky_sdk_path'): sdk_path = conf.get_tool_option('poky_sdk_path') cross_compiler = os.path.join(sdk_path, 'sysroots', 'x86_64-pokysdk-linux', 'usr', 'bin', 'arm-poky-linux-gnueabi') path_list = [cross_compiler] + path_list return path_list
def mkspec_set_ios_options(conf, min_ios_version, cpu): using_simulator = bool(cpu in ["i386", "x86_64"]) sdk_type = "iPhoneOS" # If cpu is 'i386', then we are building for the iOS simulator if using_simulator: sdk_type = "iPhoneSimulator" if conf.has_tool_option("ios_sdk_dir"): sdk = conf.get_tool_option("ios_sdk_dir") else: # Use the standard location of the iOS SDK sdk = ("/Applications/Xcode.app/Contents/Developer/Platforms" "/{}.platform/Developer/SDKs/{}.sdk".format(sdk_type, sdk_type)) sdk = os.path.abspath(os.path.expanduser(sdk)) # Set the IPHONE define - some libraries rely on this define being # present conf.env.DEFINES += ["IPHONE"] # Add common libraries for iOS here conf.env["LINKFLAGS"] += ["-lSystem"] # links with libSystem.dylib # Define what are the necessary common compiler and linker options # to build for the iOS platform. We tell the ARM cross-compiler # to target the specified arm-apple-ios platform triplet, specify # the location of the iOS SDK, use the compiler's integrated # assembler and set the minimal supported iOS version triple = "{}-apple-ios{}.0".format(cpu, min_ios_version) ios_version_arg = "-miphoneos-version-min={}" if using_simulator: ios_version_arg = "-mios-simulator-version-min={}" ios_flags = [ "-target", triple, "-integrated-as", "-isysroot", sdk, ios_version_arg.format(min_ios_version), ] conf.env["CFLAGS"] += ios_flags conf.env["CXXFLAGS"] += ios_flags conf.env["LINKFLAGS"] += ios_flags
def mkspec_set_android_options(conf): # The android_sdk_dir option is optional, if adb is in the OS path if conf.has_tool_option("android_sdk_dir"): sdk = conf.get_tool_option("android_sdk_dir") sdk = os.path.abspath(os.path.expanduser(sdk)) sdk_path = [sdk, os.path.join(sdk, "platform-tools")] conf.find_program("adb", path_list=sdk_path, var="ADB") else: conf.find_program("adb", var="ADB") # Set the android define - some libraries rely on this define # being present conf.env.DEFINES += ["ANDROID"] # Add common libraries for Android here conf.env["LINKFLAGS"] += ["-llog"]
def mkspec_set_android_options(conf): # The android_sdk_dir option is optional, if adb is in the OS path if conf.has_tool_option('android_sdk_dir'): sdk = conf.get_tool_option('android_sdk_dir') sdk = os.path.abspath(os.path.expanduser(sdk)) sdk_path = [sdk, os.path.join(sdk, 'platform-tools')] conf.find_program('adb', path_list=sdk_path, var='ADB') else: conf.find_program('adb', var='ADB') # Set the android define - some libraries rely on this define # being present conf.env.DEFINES += ['ANDROID'] # Add common libraries for Android here conf.env['LINKFLAGS'] += ['-llog']
def mkspec_set_ios_options(conf, min_ios_version, cpu): using_simulator = bool(cpu in ['i386', 'x86_64']) sdk_type = 'iPhoneOS' # If cpu is 'i386', then we are building for the iOS simulator if using_simulator: sdk_type = 'iPhoneSimulator' if conf.has_tool_option('ios_sdk_dir'): sdk = conf.get_tool_option('ios_sdk_dir') else: # Use the standard location of the iOS SDK sdk = "/Applications/Xcode.app/Contents/Developer/Platforms" \ "/{}.platform/Developer/SDKs/{}.sdk".format(sdk_type, sdk_type) sdk = os.path.abspath(os.path.expanduser(sdk)) # Set the IPHONE define - some libraries rely on this define being # present conf.env.DEFINES += ['IPHONE'] # Add common libraries for iOS here conf.env['LINKFLAGS'] += ['-lSystem'] # links with libSystem.dylib # Define what are the necessary common compiler and linker options # to build for the iOS platform. We tell the ARM cross-compiler # to target the specified arm-apple-ios platform triplet, specify # the location of the iOS SDK, use the compiler's integrated # assembler and set the minimal supported iOS version triple = "{}-apple-ios{}.0".format(cpu, min_ios_version) ios_version_arg = '-miphoneos-version-min={}' if using_simulator: ios_version_arg = '-mios-simulator-version-min={}' ios_flags = [ "-target", triple, "-integrated-as", "-isysroot", sdk, ios_version_arg.format(min_ios_version) ] conf.env['CFLAGS'] += ios_flags conf.env['CXXFLAGS'] += ios_flags conf.env['LINKFLAGS'] += ios_flags
def mkspec_emscripten_configure(conf, major, minor, minimum=False, force_debug=False): print('***emscripten_common.py::mkspec_emscripten_configure') """ :param force_debug: Always compile with debugging flags, if true """ conf.set_mkspec_platform('emscripten') # The path to the emscripten compiler paths = conf.get_tool_option('emscripten_path') # The node.js binary can be "nodejs" or simply "node" conf.find_program(['nodejs', 'node'], var='NODEJS') # Find the clang++ compiler cxx = conf.find_program(['em++'], path_list=paths) cxx = conf.cmd_to_list(cxx) conf.env['CXX'] = cxx conf.env['CXX_NAME'] = os.path.basename(conf.env.get_flat('CXX')) conf.check_emscripten_version(cxx, major, minor, minimum) # Find clang as the C compiler cc = conf.find_program(['emcc'], path_list=paths) cc = conf.cmd_to_list(cc) conf.env['CC'] = cc conf.env['CC_NAME'] = os.path.basename(conf.env.get_flat('CC')) conf.check_emscripten_version(cc, major, minor, minimum) # Find the archiver conf.find_program('emar', path_list=paths, var='AR') conf.env.ARFLAGS = ['rcs'] # Set up C++ tools and flags conf.gxx_common_flags() conf.cxx_load_tools() conf.cxx_add_flags() # Also set up C tools and flags conf.gcc_common_flags() conf.cc_load_tools() conf.cc_add_flags() # Add linker flags conf.link_add_flags() # Add the special flags required for emscripten conf.env.cshlib_PATTERN = '%s.js' conf.env.cxxshlib_PATTERN = '%s.js' conf.env.cstlib_PATTERN = '%s.a' conf.env.cxxstlib_PATTERN = '%s.a' conf.env.cprogram_PATTERN = conf.env.cxxprogram_PATTERN = '%s.js' conf.env.CXX_TGT_F = ['-c', '-o', ''] conf.env.CC_TGT_F = ['-c', '-o', ''] conf.env.CXXLNK_TGT_F = ['-o', ''] conf.env.CCLNK_TGT_F = ['-o', ''] conf.env.append_value('LINKFLAGS',['-Wl,--enable-auto-import']) # Add our own cxx flags conf.env['CXXFLAGS'] += \ ['-O2', '-Wextra', '-Wall', '-Wno-warn-absolute-paths'] if conf.has_tool_option('cxx_debug') or force_debug: conf.env['CXXFLAGS'] += ['-g'] conf.env['LINKFLAGS'] += ['-s'] if conf.has_tool_option('cxx_nodebug'): conf.env['DEFINES'] += ['NDEBUG'] conf.env['CXXFLAGS'] += ['-std=c++11'] # Add our own cc flags conf.env['CFLAGS'] += \ ['-O2', '-Wextra', '-Wall', '-Wno-warn-absolute-paths'] if conf.has_tool_option('cxx_debug') or force_debug: conf.env['CFLAGS'] += ['-g'] if conf.has_tool_option('cxx_nodebug'): conf.env['DEFINES'] += ['NDEBUG']
def mkspec_emscripten_configure(conf, major, minor, minimum=False, force_debug=False): """ :param force_debug: Always compile with debugging flags, if true """ # The path to the emscripten compiler paths = conf.get_tool_option('emscripten_path') # The node.js binary can be "nodejs" or simply "node" conf.find_program(['nodejs', 'node'], var='NODEJS') # Find the clang++ compiler cxx = conf.find_program(['em++'], path_list=paths) cxx = conf.cmd_to_list(cxx) conf.env['CXX'] = cxx conf.env['CXX_NAME'] = os.path.basename(conf.env.get_flat('CXX')) conf.check_emscripten_version(cxx, major, minor, minimum) # Find clang as the C compiler cc = conf.find_program(['emcc'], path_list=paths) cc = conf.cmd_to_list(cc) conf.env['CC'] = cc conf.env['CC_NAME'] = os.path.basename(conf.env.get_flat('CC')) conf.check_emscripten_version(cc, major, minor, minimum) # Find the archiver conf.find_program('emar', path_list=paths, var='AR') conf.env.ARFLAGS = 'rcs' # Set up C++ tools and flags conf.gxx_common_flags() #conf.gxx_modifier_platform() conf.cxx_load_tools() conf.cxx_add_flags() # Also set up C tools and flags conf.gcc_common_flags() #conf.gcc_modifier_platform() conf.cc_load_tools() conf.cc_add_flags() # Add linker flags conf.link_add_flags() # Add our own cxx flags conf.env['CXXFLAGS'] += ['-O2', '-Wextra', '-Wall'] if conf.has_tool_option('cxx_debug') or force_debug: conf.env['CXXFLAGS'] += ['-g'] conf.env['LINKFLAGS'] += ['-s'] if conf.has_tool_option('cxx_nodebug'): conf.env['DEFINES'] += ['NDEBUG'] conf.env['CXXFLAGS'] += ['-std=c++0x'] # Add our own cc flags conf.env['CFLAGS'] += ['-O2', '-Wextra', '-Wall'] if conf.has_tool_option('cxx_debug') or force_debug: conf.env['CFLAGS'] += ['-g'] if conf.has_tool_option('cxx_nodebug'): conf.env['DEFINES'] += ['NDEBUG'] conf.env['cprogram_PATTERN'] = conf.env['cxxprogram_PATTERN'] = '%s.js' conf.set_mkspec_platform('emscripten')
def mkspec_emscripten_configure(conf, major, minor, minimum=False, force_debug=False): """ :param force_debug: Always compile with debugging flags, if true """ conf.set_mkspec_platform("emscripten") # The path to the emscripten compiler paths = conf.get_tool_option("emscripten_path") # The node.js binary can be "nodejs" or simply "node" conf.find_program(["nodejs", "node"], var="NODEJS") # Find the clang++ compiler cxx = conf.find_program(["em++"], path_list=paths) cxx = conf.cmd_to_list(cxx) conf.env["CXX"] = cxx conf.env["CXX_NAME"] = os.path.basename(conf.env.get_flat("CXX")) conf.check_emscripten_version(cxx, major, minor, minimum) # Find clang as the C compiler cc = conf.find_program(["emcc"], path_list=paths) cc = conf.cmd_to_list(cc) conf.env["CC"] = cc conf.env["CC_NAME"] = os.path.basename(conf.env.get_flat("CC")) conf.check_emscripten_version(cc, major, minor, minimum) # Find the archiver conf.find_program("emar", path_list=paths, var="AR") conf.env.ARFLAGS = ["rcs"] # Set up C++ tools and flags conf.gxx_common_flags() conf.cxx_load_tools() conf.cxx_add_flags() # Also set up C tools and flags conf.gcc_common_flags() conf.cc_load_tools() conf.cc_add_flags() # Add linker flags conf.link_add_flags() # Add the special flags required for emscripten conf.env.cshlib_PATTERN = "%s.js" conf.env.cxxshlib_PATTERN = "%s.js" conf.env.cstlib_PATTERN = "%s.a" conf.env.cxxstlib_PATTERN = "%s.a" conf.env.cprogram_PATTERN = conf.env.cxxprogram_PATTERN = "%s.js" conf.env.CXX_TGT_F = ["-c", "-o", ""] conf.env.CC_TGT_F = ["-c", "-o", ""] conf.env.CXXLNK_TGT_F = ["-o", ""] conf.env.CCLNK_TGT_F = ["-o", ""] conf.env.append_value("LINKFLAGS", ["-Wl,--enable-auto-import"]) # Add our own cxx flags conf.env["CXXFLAGS"] += ["-Wextra", "-Wall", "-Wno-warn-absolute-paths"] if conf.has_tool_option("cxx_debug") or force_debug: conf.env["CXXFLAGS"] += ["-g"] conf.env["LINKFLAGS"] += ["-s"] # Don't add any optimization flags conf.env["MKSPEC_DISABLE_OPTIMIZATION"] = True cxxoptflags = ["-O2"] if not conf.env["MKSPEC_DISABLE_OPTIMIZATION"]: conf.env["CXXFLAGS"] += cxxoptflags if conf.has_tool_option("cxx_nodebug"): conf.env["DEFINES"] += ["NDEBUG"] conf.env["CXXFLAGS"] += ["-std=c++11"] if conf.has_tool_option("cxx_debug") or force_debug: conf.env["CFLAGS"] += ["-g"] # Don't add any optimization flags conf.env["MKSPEC_DISABLE_OPTIMIZATION"] = True coptflags = ["-O2"] if not conf.env["MKSPEC_DISABLE_OPTIMIZATION"]: conf.env["CFLAGS"] += coptflags # Add our own cc flags conf.env["CFLAGS"] += ["-Wextra", "-Wall", "-Wno-warn-absolute-paths"] if conf.has_tool_option("cxx_nodebug"): conf.env["DEFINES"] += ["NDEBUG"]
def mkspec_emscripten_configure(conf, major, minor, minimum=False, force_debug=False): """ :param force_debug: Always compile with debugging flags, if true """ conf.set_mkspec_platform('emscripten') # The path to the emscripten compiler paths = conf.get_tool_option('emscripten_path') # The node.js binary can be "nodejs" or simply "node" conf.find_program(['nodejs', 'node'], var='NODEJS') # Find the clang++ compiler cxx = conf.find_program(['em++'], path_list=paths) cxx = conf.cmd_to_list(cxx) conf.env['CXX'] = cxx conf.env['CXX_NAME'] = os.path.basename(conf.env.get_flat('CXX')) conf.check_emscripten_version(cxx, major, minor, minimum) # Find clang as the C compiler cc = conf.find_program(['emcc'], path_list=paths) cc = conf.cmd_to_list(cc) conf.env['CC'] = cc conf.env['CC_NAME'] = os.path.basename(conf.env.get_flat('CC')) conf.check_emscripten_version(cc, major, minor, minimum) # Find the archiver conf.find_program('emar', path_list=paths, var='AR') conf.env.ARFLAGS = ['rcs'] # Set up C++ tools and flags conf.gxx_common_flags() conf.cxx_load_tools() conf.cxx_add_flags() # Also set up C tools and flags conf.gcc_common_flags() conf.cc_load_tools() conf.cc_add_flags() # Add linker flags conf.link_add_flags() # Add the special flags required for emscripten conf.env.cshlib_PATTERN = '%s.js' conf.env.cxxshlib_PATTERN = '%s.js' conf.env.cstlib_PATTERN = '%s.a' conf.env.cxxstlib_PATTERN = '%s.a' conf.env.cprogram_PATTERN = conf.env.cxxprogram_PATTERN = '%s.js' conf.env.CXX_TGT_F = ['-c', '-o', ''] conf.env.CC_TGT_F = ['-c', '-o', ''] conf.env.CXXLNK_TGT_F = ['-o', ''] conf.env.CCLNK_TGT_F = ['-o', ''] conf.env.append_value('LINKFLAGS',['-Wl,--enable-auto-import']) # Add our own cxx flags conf.env['CXXFLAGS'] += \ ['-O2', '-Wextra', '-Wall', '-Wno-warn-absolute-paths'] if conf.has_tool_option('cxx_debug') or force_debug: conf.env['CXXFLAGS'] += ['-g'] conf.env['LINKFLAGS'] += ['-s'] if conf.has_tool_option('cxx_nodebug'): conf.env['DEFINES'] += ['NDEBUG'] conf.env['CXXFLAGS'] += ['-std=c++11'] # Add our own cc flags conf.env['CFLAGS'] += \ ['-O2', '-Wextra', '-Wall', '-Wno-warn-absolute-paths'] if conf.has_tool_option('cxx_debug') or force_debug: conf.env['CFLAGS'] += ['-g'] if conf.has_tool_option('cxx_nodebug'): conf.env['DEFINES'] += ['NDEBUG']