def check_win_x64_durango_installed(conf):
	"""
	Check compiler is actually installed on executing machine
	"""
	if not conf.is_option_true('auto_detect_compiler'):
		durango_compiler_folder = conf.CreateRootRelativePath('Code/SDKs/DurangoSDK/')
	
		if not os.path.exists(durango_compiler_folder):
			Logs.warn('[WARNING] Could not find Windows Durango SDK toolchain path: %s' % durango_compiler_folder)
			return False
		return True
	else:
			# try to read the path from the registry
			try:
				import _winreg
				sdk_folder_entry = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Microsoft\\Durango XDK", 0, _winreg.KEY_READ)
				(durango_sdk_dir,type) = _winreg.QueryValueEx(sdk_folder_entry, 'InstallPath')
				durango_sdk_xdk_dir = durango_sdk_dir + 'xdk'
				
				for path in [durango_sdk_dir, durango_sdk_xdk_dir]:
					if not os.path.exists(path):
						Logs.warn('[WARNING] Could not find Windows Durango SDK toolchain path: %s' % path)
						return False
					return True				
			except:
				Logs.warn('[WARNING] Could not find Windows Durango SDK toolchain')
				return False
Example #2
0
def load_profile_msvc_settings(conf):
    """
    Setup all compiler/linker flags with are shared over all targets using the microsoft compiler
    for the "profile" configuration 
    """
    v = conf.env
    conf.load_msvc_common_settings()
    
    COMPILER_FLAGS = [
        '/Ox',      # Full optimization
        '/Ob2',     # Inline any suitable function
        '/Ot',      # Favor fast code over small code
        '/Oi',      # Use Intrinsic Functions
        '/Oy-',     # Don't omit the frame pointer      
        ]
        
    v['CFLAGS'] += COMPILER_FLAGS
    v['CXXFLAGS'] += COMPILER_FLAGS
    
    if conf.is_option_true('use_recode'):
        Logs.pprint('CYAN', 'Enabling Recode-safe linker settings and defines for Profile build')
        v['DEFINES'] += ['AZ_PROFILE_DISABLE_THREAD_LOCAL'] # Disable AZ Profiler's thread-local optimization, as it conflicts with Recode
        v['LINKFLAGS'] += [
                                   # No /OPT:REF or /OPT:ICF for Recode builds
            '/FUNCTIONPADMIN:14'   # Reserve function padding for patch injection (improves Recoding)
            ]
    else:
        v['LINKFLAGS'] += [
            '/OPT:REF',            # elimination of unreferenced functions/data
            '/OPT:ICF',            # comdat folding
            ]
Example #3
0
def get_available_platforms(conf):

    is_configure_context = isinstance(conf, ConfigurationContext)
    validated_platforms_node = conf.get_validated_platforms_node()
    validated_platforms_json = conf.parse_json_file(
        validated_platforms_node) if os.path.exists(
            validated_platforms_node.abspath()) else None

    global AVAILABLE_PLATFORMS
    if AVAILABLE_PLATFORMS is None:

        # Get all of the available target platforms for the current host platform
        host_platform = Utils.unversioned_sys_platform()

        # fallback option for android if the bootstrap params is empty
        android_enabled_var = conf.get_env_file_var('ENABLE_ANDROID',
                                                    required=False,
                                                    silent=True)
        android_enabled = (android_enabled_var == 'True')

        # Check the enabled capabilities from the bootstrap parameter.  This value is set by the setup assistant
        enabled_capabilities = conf.get_enabled_capabilities()
        validated_platforms = []
        for platform in PLATFORMS[host_platform]:

            platform_capability = PLATFORM_TO_CAPABILITY_MAP.get(
                platform, None)
            if platform_capability is not None:
                if len(enabled_capabilities) > 0 and platform_capability[
                        0] not in enabled_capabilities:
                    # Only log the target platform removal during the configure process
                    if isinstance(conf, ConfigurationContext):
                        Logs.info(
                            '[INFO] Removing target platform {} due to "{}" not checked in Setup Assistant.'
                            .format(platform, platform_capability[1]))
                    continue

            # Perform extra validation of platforms that can be disabled through options
            if platform.startswith('android') and not android_enabled:
                continue

            if platform.endswith('clang') and platform.startswith('win'):
                if not conf.is_option_true('win_enable_clang_for_windows'):
                    continue
                elif not conf.find_program(
                        'clang', mandatory=False, silent_output=True):
                    Logs.warn(
                        '[INFO] Removing target platform {}. Could not find Clang for Windows executable.'
                        .format(platform))
                    continue

            if not is_configure_context and validated_platforms_json:
                if platform not in validated_platforms_json:
                    continue

            validated_platforms.append(platform)

        AVAILABLE_PLATFORMS = validated_platforms
    return AVAILABLE_PLATFORMS
Example #4
0
 def _add_optioned_command(option, command):
     if conf.is_option_true(option):
         # Workflow improvement: for all builds generate projects after the build
         # except when using the default build target 'utilities' then do it before
         if 'build' in Options.commands:
             build_cmd_idx = Options.commands.index('build')
             Options.commands.insert(build_cmd_idx, command)
         else:
             Options.commands.append(command)
def load_cryengine_common_settings(conf):
    """
    Setup all platform, compiler and configuration agnostic settings
    """
    v = conf.env

    if conf.is_option_true('enable_memory_tracking'):
        append_to_unique_list(v['DEFINES'], 'AZCORE_ENABLE_MEMORY_TRACKING')
    
    # To allow pragma comment (lib, 'SDKs/...) uniformly, pass Code to the libpath
    append_to_unique_list(v['LIBPATH'], conf.CreateRootRelativePath('Code'))
Example #6
0
def apply_incremental_linking(conf):
    if conf.is_option_true('use_incremental_linking'):
        conf.env['LINKFLAGS'] += [
            '/INCREMENTAL',  # Enable Incremental Linking
        ]
    else:
        conf.env['LINKFLAGS'] += [
            '/OPT:REF',  # Eliminate not referenced functions/data (incompatible with incremental linking)
            '/OPT:ICF',  # Perform Comdat folding (incompatible with incremental linking)
            '/INCREMENTAL:NO',  # Disable Incremental Linking
        ]
Example #7
0
def set_cmd_coordinator(conf, coordinator_name):

    if coordinator_name == 'Local':
        conf.is_build_master = True
        conf.cmd_coordinator = Local_CommandCoordinator()
    elif coordinator_name == 'IB':
        jobs_backup = conf.jobs
        conf.options.jobs = int(
            conf.options.incredibuild_max_cores) + conf.options.jobs
        conf.jobs = conf.options.jobs

        # If a multi core licence is available, run IB as build master
        run_ib_as_service = conf.is_option_true('run_ib_as_service')
        is_recursive_ib_instance = conf.is_option_true(
            'internal_dont_check_recursive_execution')

        if not is_recursive_ib_instance:
            if run_ib_as_service and "Cores" in get_ib_licence_string():
                Logs.warn(
                    'Incredibuild multicore licence detected. Consider disabling "run_ib_as_service" for faster build times.'
                )

            conf.is_build_master = run_ib_as_service

            if not execute_waf_via_ib(conf):
                conf.is_build_master = True
                conf.options.jobs = jobs_backup
                conf.jobs = jobs_backup
                return

            if run_ib_as_service:
                conf.cmd_coordinator = IB_CommandCoordinator_Client(conf)

        elif run_ib_as_service:
            Logs.info("[WAF] Run Incredibuild as a service")
            conf.is_build_master = False
            conf.cmd_coordinator = IB_CommandCoordinator_Server()
            conf.cmd_coordinator.enter_command_loop(conf)
        else:
            conf.is_build_master = True
Example #8
0
def check_win_x64_android_arm_gcc_installed(conf):
    """
	Check compiler is actually installed on executing machine
	"""
    v = conf.env

    # Setup Tools for GCC Cross Compile Toolchain
    if not conf.is_option_true('auto_detect_compiler'):
        android_sdk_home = conf.CreateRootRelativePath('Code/SDKs/android-sdk')
        android_ndk_home = conf.CreateRootRelativePath('Code/SDKs/android-ndk')
        android_java_home = conf.CreateRootRelativePath('Code/SDKs/jdk')
        android_ant_home = conf.CreateRootRelativePath('Code/SDKs/apache-ant')
    else:
        android_sdk_home = os.getenv('ANDROID_HOME', "")
        android_ndk_home = os.getenv('NDK_ROOT', "")
        android_java_home = os.getenv('JAVA_HOME', "")
        android_ant_home = os.getenv('ANT_HOME', "")

    # Validate paths
    for path in [
            android_sdk_home, android_ndk_home, android_java_home,
            android_ant_home
    ]:
        if not os.path.exists(path):
            conf.cry_warning("Requiered Android SDK path does not exist: %s." %
                             path)
            return False

    # Configure platform and compiler mutations
    platform_target = '/platforms/android-' + str(android_target_version)
    compiler_target = '/arch-arm'
    compiler_version = str(android_compiler_version)
    toolchain = 'arm-linux-androideabi-' + compiler_version

    android_sdk_platform_target = android_sdk_home + platform_target
    android_ndk_platform_compiler_target = android_ndk_home + platform_target + compiler_target
    android_ndk_toolchain_target = android_ndk_home + '/toolchains/' + toolchain + '/prebuilt/windows-x86_64'
    if not os.path.exists(android_ndk_toolchain_target
                          ):  # Fallback if the 64 bit compiler is not found
        android_ndk_toolchain_target = android_ndk_home + '/toolchains/' + toolchain + '/prebuilt/windows'

    # Validate paths
    for path in [
            android_sdk_platform_target, android_ndk_platform_compiler_target,
            android_ndk_toolchain_target
    ]:
        if not os.path.exists(path):
            conf.cry_warning("Requiered Android SDK path does not exist: %s." %
                             path)
            return False

    return True
def load_cryengine_common_settings(conf):
    """
    Setup all platform, compiler and configuration agnostic settings
    """
    v = conf.env

    # Generate CODE_BASE_FOLDER define to allow to create absolute paths in source to use for pragma comment lib
    code_node = conf.engine_node.make_node('Code')
    code_path = code_node.abspath()
    code_path = code_path.replace('\\', '/')
    v['DEFINES'] += ['CODE_BASE_FOLDER="' + code_path + '/"']
    if conf.is_option_true('enable_memory_tracking'):
        append_to_unique_list(v['DEFINES'], 'AZCORE_ENABLE_MEMORY_TRACKING')

    # To allow pragma comment (lib, 'SDKs/...) uniformly, pass Code to the libpath
    append_to_unique_list(v['LIBPATH'], conf.CreateRootRelativePath('Code'))
def check_win_x64_orbis_installed(conf):
	"""
	Check compiler is actually installed on executing machine
	"""
	if not conf.is_option_true('auto_detect_compiler'):
		orbis_sdk_folder = conf.CreateRootRelativePath('Code/SDKs/Orbis')
		
		if not os.path.exists(orbis_sdk_folder):
			Logs.warn('[WARNING] Could not find ORBIS SDK toolchain path: %s' % orbis_sdk_folder)
			return False		
	else:
		# Orbis stored the values in the env
		if not 'SCE_ORBIS_SDK_DIR' in os.environ:
			Logs.warn('[WARNING] Could not find environment variable "SCE_ORBIS_SDK_DIR". Please verify your Orbis SDK installation')
			return False
		
	return True
def load_orbis_common_settings(conf):
	"""
	Setup all compiler and linker settings shared over all orbis configurations
	"""
	v = conf.env
	
	# Setup common defines for orbis
	v['DEFINES'] += [ 'ORBIS', '_ORBIS', '__ORBIS__' ]
	
	# Since Orbis is only build on windows right now it is fine to set the output format here
	v['CFLAGS'] += [ '-fdiagnostics-format=msvc' ]
	v['CXXFLAGS'] += [ '-fdiagnostics-format=msvc' ]
	
	# Pattern to transform outputs
	v['cprogram_PATTERN'] 	= '%s.elf'
	v['cxxprogram_PATTERN'] = '%s.elf'
	v['cshlib_PATTERN'] 	= '%s.prx'
	v['cxxshlib_PATTERN'] 	= '%s.prx'
	v['cstlib_PATTERN']      = 'lib%s.a'
	v['cxxstlib_PATTERN']    = 'lib%s.a'

	# Since Orbis is only build in a single configuration on windows, we can specify the compile tools here
	if not conf.is_option_true('auto_detect_compiler'):
		orbis_sdk_folder = conf.CreateRootRelativePath('Code/SDKs/Orbis')
		
		# Adjust SCE_ORBIS_SDK_DIR for correct compiler execution when using the bootstraped one
		v.env = os.environ.copy()
		v.env['SCE_ORBIS_SDK_DIR'] 	= orbis_sdk_folder
	else:
		# Orbis stored the values in the env
		if not 'SCE_ORBIS_SDK_DIR' in os.environ:
			conf.fatal('[ERROR] Could not find environment variable "SCE_ORBIS_SDK_DIR". Please verify your Orbis SDK installation')
		orbis_sdk_folder =  os.environ['SCE_ORBIS_SDK_DIR']
		
	orbis_target_folder 		= orbis_sdk_folder + '/target'
	orbis_toolchain_folder	= orbis_sdk_folder + '/host_tools/bin'	
		
	v['INCLUDES'] += [ os.path.normpath(orbis_target_folder + '/include') ]
	v['INCLUDES'] += [ os.path.normpath(orbis_target_folder + '/include_common') ]
	v['INCLUDES'] += [ os.path.normpath(orbis_toolchain_folder + '/../lib/clang/include') ] # Orbis intrinsics + stdarg.h (for Intellisense)

	v['AR'] = os.path.normpath(orbis_toolchain_folder + '/orbis-ar.exe')
	v['CC'] = os.path.normpath(orbis_toolchain_folder + '/orbis-clang.exe')
	v['CXX'] = os.path.normpath(orbis_toolchain_folder + '/orbis-clang++.exe')
	v['LINK'] = v['LINK_CC'] = v['LINK_CXX'] = os.path.normpath(orbis_toolchain_folder + '/orbis-ld.exe')
def check_win_x64_android_arm_gcc_installed(conf):
	"""
	Check compiler is actually installed on executing machine
	"""
	v = conf.env
	
	# Setup Tools for GCC Cross Compile Toolchain
	if not conf.is_option_true('auto_detect_compiler'):	
		android_sdk_home		= conf.CreateRootRelativePath('Code/SDKs/android-sdk')
		android_ndk_home		= conf.CreateRootRelativePath('Code/SDKs/android-ndk')
		android_java_home		= conf.CreateRootRelativePath('Code/SDKs/jdk')
		android_ant_home 		= conf.CreateRootRelativePath('Code/SDKs/apache-ant')
	else:
		android_sdk_home 		= os.getenv('ANDROID_HOME', "")	
		android_ndk_home 		= os.getenv('NDK_ROOT', "")
		android_java_home 	= os.getenv('JAVA_HOME', "")
		android_ant_home 		= os.getenv('ANT_HOME', "")
		
	# Validate paths
	for path in [android_sdk_home, android_ndk_home, android_java_home, android_ant_home]:
		if not os.path.exists(path):
			conf.cry_warning("Requiered Android SDK path does not exist: %s." % path)
			return False

	# Configure platform and compiler mutations		
	platform_target = '/platforms/android-' + str(android_target_version)
	compiler_target = '/arch-arm'
	compiler_version = str(android_compiler_version)
	toolchain = 'arm-linux-androideabi-' + compiler_version
	
	android_sdk_platform_target 	= android_sdk_home + platform_target
	android_ndk_platform_compiler_target 	= android_ndk_home + platform_target + compiler_target
	android_ndk_toolchain_target 	= android_ndk_home + '/toolchains/' + toolchain + '/prebuilt/windows-x86_64'
	if not os.path.exists(android_ndk_toolchain_target): # Fallback if the 64 bit compiler is not found
		android_ndk_toolchain_target 	= android_ndk_home + '/toolchains/' + toolchain + '/prebuilt/windows'
		
	# Validate paths
	for path in [android_sdk_platform_target, android_ndk_platform_compiler_target, android_ndk_toolchain_target]:
		if not os.path.exists(path):
			conf.cry_warning("Requiered Android SDK path does not exist: %s." % path)
			return False
		
	return  True
def initialize_lumberyard(ctx):
    """
    Setup all platform, compiler and configuration agnostic settings
    """
    v = ctx.env

    if conf.is_option_true('enable_memory_tracking'):
        append_to_unique_list(v['DEFINES'], 'AZCORE_ENABLE_MEMORY_TRACKING')

    # BEGIN JAVELIN MOD: https://jira.agscollab.com/browse/JAV-18779 Allows for an AZ Allocator to be used for memory management
    # removed below if check because of issues related to https://jira.agscollab.com/browse/LYAJAV-126
    # if conf.is_option_true('use_az_allocator_for_cry_memory_manager'):
    #    append_to_unique_list(v['DEFINES'], 'USE_AZ_ALLOCATOR_FOR_CRY_MEMORY_MANAGER')
    v['DEFINES'] += ['USE_AZ_ALLOCATOR_FOR_CRY_MEMORY_MANAGER']
    # END JAVELIN MOD

    # To allow pragma comment (lib, 'SDKs/...) uniformly, pass Code to the libpath
    append_to_unique_list(v['LIBPATH'], conf.CreateRootRelativePath('Code'))
    return True
Example #14
0
def load_debug_msvc_settings(conf):
    """
    Setup all compiler/linker flags with are shared over all targets using the microsoft compiler
    for the "debug" configuration   
    """
    v = conf.env    
    conf.load_msvc_common_settings()
    
    COMPILER_FLAGS = [
        '/Od',      # Disable all optimizations
        '/Ob0',     # Disable all inling
        '/Oy-',     # Don't omit the frame pointer
        '/RTC1',    # Add basic Runtime Checks
        '/bigobj',  # Ensure we can store enough objects files
        ]
        
    v['CFLAGS'] += COMPILER_FLAGS
    v['CXXFLAGS'] += COMPILER_FLAGS

    if conf.is_option_true('use_recode'):
        Logs.pprint('CYAN', 'Enabling Recode-safe defines for Debug build')
        v['DEFINES'] += ['AZ_PROFILE_DISABLE_THREAD_LOCAL'] # Disable AZ Profiler's thread-local optimization, as it conflicts with Recode
def load_win_x64_android_arm_common_settings(conf):
    """Setup all compiler and linker settings shared over all win_x64_arm_linux_androideabi_4_8 configurations
	"""

    v = conf.env

    # Setup Tools for GCC Cross Compile Toolchain
    if not conf.is_option_true('auto_detect_compiler'):
        android_sdk_home = conf.CreateRootRelativePath('Code/SDKs/android-sdk')
        android_ndk_home = conf.CreateRootRelativePath('Code/SDKs/android-ndk')
        android_java_home = conf.CreateRootRelativePath('Code/SDKs/jdk')
        android_ant_home = conf.CreateRootRelativePath('Code/SDKs/apache-ant')

        # Validate paths
        for path in [
                android_sdk_home, android_ndk_home, android_java_home,
                android_ant_home
        ]:
            if not os.path.exists(path):
                conf.cry_error(
                    "Requiered Android SDK path does not exist: %s. Fix path or try running WAF with 'auto_detect_compiler' option enabled."
                    % path)
    else:
        android_sdk_home = os.getenv('ANDROID_HOME', "")
        android_ndk_home = os.getenv('NDK_ROOT', "")
        android_java_home = os.getenv('JAVA_HOME', "")
        android_ant_home = os.getenv('ANT_HOME', "")

        # Validate paths
        if not os.path.exists(android_sdk_home):
            conf.cry_error(
                "Unable to locate ANDROID SDK. Environment variable 'ANDROID_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?"
            )
        if not os.path.exists(android_ndk_home):
            conf.cry_error(
                "Unable to locate ANDROID NDK. Environment variable 'NDK_ROOT' not set? Do you have Tegra Android Development Pack (TADP) installed?"
            )
        if not os.path.exists(android_java_home):
            conf.cry_error(
                "Unable to locate JAVA. Environment variable 'JAVA_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?"
            )
        if not os.path.exists(android_ant_home):
            conf.cry_error(
                "Unable to locate APACHE ANT. Environment variable 'ANT_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?"
            )

    # Configure platform and compiler mutations
    platform_target = '/platforms/android-' + str(android_target_version)
    compiler_target = '/arch-arm'

    clang_toolchain = 'llvm'
    gnu_toolchain = 'arm-linux-androideabi-' + str(android_gcc_version)

    android_sdk_platform_target = android_sdk_home + platform_target
    android_ndk_platform_compiler_target = android_ndk_home + platform_target + compiler_target

    # Clang
    android_ndk_clang_toolchain_target = android_ndk_home + '/toolchains/' + clang_toolchain + '/prebuilt/windows-x86_64'

    # GNU
    android_ndk_gcc_toolchain_target = android_ndk_home + '/toolchains/' + gnu_toolchain + '/prebuilt/windows-x86_64'

    # LLVM STL
    #android_stl_home = android_ndk_home + '/sources/cxx-stl/llvm-libc++'
    #android_stl_include_paths =  [android_stl_home + '/libcxx/include']
    #android_stl_lib_name = 'c++_shared'

    # GNU STL
    android_stl_home = android_ndk_home + '/sources/cxx-stl/gnu-libstdc++/' + str(
        android_gcc_version)
    android_stl_include_paths = [
        android_stl_home + '/include',
        android_stl_home + 'libs/armeabi-v7a/include',
        android_stl_home + 'include/backward'
    ]
    android_stl_lib_name = 'gnustl_shared'

    android_stl_lib = android_stl_home + '/libs/armeabi-v7a/lib' + android_stl_lib_name + '.so'

    v['AR'] = android_ndk_gcc_toolchain_target + '/arm-linux-androideabi/bin/ar.exe'
    v['CC'] = android_ndk_clang_toolchain_target + '/bin/clang.exe'
    v['CXX'] = android_ndk_clang_toolchain_target + '/bin/clang++.exe'
    v['LINK'] = v['LINK_CC'] = v[
        'LINK_CXX'] = android_ndk_clang_toolchain_target + '/bin/clang++.exe'
    v['STRIP'] = android_ndk_gcc_toolchain_target + '/arm-linux-androideabi/bin/strip.exe'

    v['JAR'] = android_java_home + '/bin/jar.exe'
    v['JAVAC'] = android_java_home + '/bin/javac.exe'
    v['ANDROID_CLASSPATH'] = android_sdk_platform_target + '/android.jar'
    v['ANDROID_TARGET_VERSION'] = android_target_version

    v['ANT'] = android_ant_home + '/bin/ant.bat'

    v['ANDROID_NDK_HOME'] = android_ndk_home
    v['ANDROID_SDL_HOME'] = android_stl_home
    v['ANDROID_SDK_HOME'] = android_sdk_home
    v['ANDROID_JAVA_HOME'] = android_java_home
    v['ANDROID_ANT_HOME'] = android_ant_home

    v['ANDROID_SDL_LIB_PATH'] = android_stl_lib
    v['ANDROID_SDL_LIB_NAME'] = android_stl_lib_name

    v['cprogram_PATTERN'] = '%s'
    v['cxxprogram_PATTERN'] = '%s'
    v['cshlib_PATTERN'] = 'lib%s.so'
    v['cxxshlib_PATTERN'] = 'lib%s.so'
    v['cstlib_PATTERN'] = 'lib%s.a'
    v['cxxstlib_PATTERN'] = 'lib%s.a'

    v['DEFINES'] += ['_LINUX', 'LINUX', 'LINUX32', 'ANDROID', '_HAS_C9X']

    if android_target_version >= 21:
        v['DEFINES'] += ['HAS_STPCPY=1']

    # Setup global include paths
    v['INCLUDES'] += android_stl_include_paths + [
        android_ndk_platform_compiler_target + '/usr/include', android_stl_home
        + '/include', android_stl_home + '/libs/armeabi-v7a/include',
        android_ndk_home + '/sources/android/support/include',
        android_ndk_home + '/sources/android/native_app_glue'
    ]

    # Setup global library search path
    v['LIBPATH'] += [
        android_stl_home + '/libs/armeabi-v7a',
        android_ndk_home + platform_target + '/arch-arm/usr/lib'
    ]

    v['LIB'] = [
        'c',
        android_stl_lib_name,
        'log',
        'm',
        'android',
    ] + v['LIB']
    # Introduce the compiler to generate 32 bit code
    #-ffunction-sections
    #-funwind-tables
    #-fstack-protector-strong
    #-no-canonical-prefixes
    #-march=armv7-a
    #-mfloat-abi=softfp
    #-mfpu=vfpv3-d16
    #-fno-integrated-as
    #-mthumb
    #-Wa,--noexecstack
    #-Wformat -Werror=format-security
    #-fno-exceptions
    #-fno-rtti -g
    #
    #-DANDROID
    #-ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-integrated-as -mthumb -Wa,--noexecstack -Wformat -Werror=format-security -fno-exceptions -fno-rtti -std=c++11 -O0 -fno-limit-debug-info -O0 -fno-limit-debug-info  -fPIC -MD

    common_flag = [
        '-target', 'armv7-none-linux-androideabi', '-gcc-toolchain',
        android_ndk_gcc_toolchain_target,
        '--sysroot=' + android_ndk_platform_compiler_target, '-march=armv7-a'
    ]

    compiler_flags = common_flag + ['-g', '-mfpu=neon', '-fpic']

    # LINKER
    #-DANDROID
    #-ffunction-sections
    #-funwind-tables
    #-fstack-protector-strong
    #-no-canonical-prefixes
    #-march=armv7-a
    #-mfloat-abi=softfp
    #-mfpu=vfpv3-d16
    #-fno-integrated-as
    #-mthumb
    #-Wa,--noexecstack -Wformat
    #-Werror=format-security
    #-Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,-z,nocopyreloc
    #-pie
    #-fPIE  -lm

    # Compiler
    #cxx_flags = [
    #-cc1
    #-triple armv7-none-linux-android
    #-S -disable-free
    #-disable-llvm-verifier
    #-main-file-name Cry3DEngine_main_2_uber.cpp
    #-mrelocation-model pic
    #-pic-level 2
    #-mthread-model posix
    #-mdisable-fp-elim
    #-relaxed-aliasing
    #-fmath-errno
    #-masm-verbose
    #-no-integrated-as
    #-mconstructor-aliases
    #-munwind-tables
    #-fuse-init-array
    #-target-cpu cortex-a8
    #-target-feature
    #+soft-float-abi
    #-target-feature
    #-fp-only-sp
    #-target-feature
    #-d16
    #-target-feature +vfp3
    #-target-feature -fp16
    #-target-feature -vfp4
    #-target-feature -fp-armv8
    #-target-feature +neon
    #-target-feature -crypto
    #-target-abi aapcs-linux
    #-mfloat-abi soft
    #-target-linker-version 2.24
    #-dwarf-column-info
    #-debug-info-kind=standalone
    #-dwarf-version=4
    #-debugger-tuning=gdb
    #-ffunction-sections
    #-fdata-sections
    #-resource-dir "C:\NVPACK\android-sdk-windows\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\..\lib64\clang\3.8.256229"
    #-dependency-file "Code\CryEngine\Cry3DEngine\CMakeFiles\Cry3DEngine.dir\Cry3DEngine_main_2_uber.cpp.o.d"
    #-sys-header-deps
    #-MT Code/CryEngine/Cry3DEngine/CMakeFiles/Cry3DEngine.dir/Cry3DEngine_main_2_uber.cpp.o
    #-isystem D:/code/marioc_FRWP1MARIOC_cemain/Code/CryEngine/CryCommon
    #-isystem D:/code/marioc_FRWP1MARIOC_cemain/Code/SDKs/boost
    #-isystem C:/NVPACK/android-sdk-windows/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include
    #-isystem C:/NVPACK/android-sdk-windows/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include
    #-isystem C:/NVPACK/android-sdk-windows/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/include/backward
    #-D ANDROID
    #-D ANDROID_NDK
    #-D CRY_IS_MONOLITHIC_BUILD
    #-D CRY_MOBILE
    #-D DISABLE_IMPORTGL
    #-D HAS_STPCPY=1 -D LINUX -D LINUX32 -D PROFILE -D _DLL -D _LIB -D _LINUX -D _MT -D _PROFILE -D __ANDROID__ -D __ARM_ARCH_7A__ -I D:/code/marioc_FRWP1MARIOC_cemain/Code/CryEngine/Cry3DEngine -I D:/code/marioc_FRWP1MARIOC_cemain/Code/Libs/yasli -I D:/code/marioc_FRWP1MARIOC_cemain/Code/Libs/yasli/../../SDKs/yasli -I D:/code/marioc_FRWP1MARIOC_cemain/Code/Libs/lz4/../../SDKs/lz4/lib -D ANDROID -D ANDROID -isysroot C:/NVPACK/android-sdk-windows/ndk-bundle/platforms/android-21/arch-arm -internal-isystem C:/NVPACK/android-sdk-windows/ndk-bundle/platforms/android-21/arch-arm/usr/local/include -internal-isystem "C:\NVPACK\android-sdk-windows\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\..\lib64\clang\3.8.256229\include" -internal-externc-isystem C:/NVPACK/android-sdk-windows/ndk-bundle/platforms/android-21/arch-arm/include -internal-externc-isystem C:/NVPACK/android-sdk-windows/ndk-bundle/platforms/android-21/arch-arm/usr/include -O0 -Wformat -Werror=format-security -Wformat -Werror=format-security -Wno-switch -Wno-parentheses -Wno-multichar -Wno-format-security -Wno-unused-value -Wno-comment -Wno-sizeof-pointer-memaccess -Wno-empty-body -Wno-writable-strings -Wno-logical-op-parentheses -Wno-invalid-offsetof -Wno-tautological-compare -Wno-shift-negative-value -Wno-null-conversion -Wno-c++11-narrowing -Wno-write-strings -Wno-narrowing -std=c++11 -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir "E:\AndroidStudioProjects\MyFirstCmakeTest\app\.externalNativeBuild\cmake\debug\armeabi-v7a"
    #-ferror-limit 19 -fmessage-length 0 -femulated-tls -stack-protector 2 -fallow-half-arguments-and-returns -fno-rtti -fobjc-runtime=gcc
    #-fdiagnostics-show-option

    v['CFLAGS'] += compiler_flags
    v['CXXFLAGS'] += compiler_flags

    #v['CFLAGS'] += ['-march=armeabi-v7a']
    #v['CXXFLAGS'] += ['-march=armeabi-v7a']

    #v['CFLAGS'] += [ '--sysroot=' + android_ndk_platform_compiler_target ]
    #v['CXXFLAGS'] += [ '--sysroot=' + android_ndk_platform_compiler_target ]
    v['LINKFLAGS'] += common_flag + [v['ANDROID_SDL_LIB_PATH']]
Example #16
0
def load_msvc_compiler(conf, target, arch):
	"""
	Loads the MSVC compiler for the given target/arch tuple into the current environment
	"""
	v = conf.env

	# Check if we already have diagnosed problem output for this target/arch tuple
	# Note: Even if we diagnose a potential problem, this is no longer a fatal error
	# Any fatal errors will already have occurred during the detect function call above
	global HAS_DIAGNOSED
	has_diagnosed = True
	if not target + '_' + arch in HAS_DIAGNOSED:
		HAS_DIAGNOSED += [ target + '_' + arch ]
		has_diagnosed = False
	verbose = conf.is_option_true('auto_detect_verbose') and not has_diagnosed

	# Get the compiler and SDK to use
	if not conf.is_option_true('auto_detect_compiler'):
		sdk, compiler = conf.detect_bootstrapped_msvc_compiler(target, arch)
		type = 'bootstrapped'
		if verbose:
			print '[NOTE] Ignoring --auto-detect-verbose when --auto-detect-compiler is disabled'
	else:
		sdk, compiler = conf.auto_detect_msvc_compiler(target, arch, verbose)
		type = 'auto-detected'

	if not has_diagnosed:
		# Show diagnostics for this target/arch pair
		print '[NOTE] Using %s MSVC %s (%s) with Windows SDK %s' % (type, compiler['version'], os.path.split(compiler['bin'])[1], sdk['version'])

	# Apply general paths
	v['PATH'] = compiler['path'] + sdk['path']
	v['INCLUDES'] = compiler['include'] + sdk['include']
	v['LIBPATH'] = compiler['lib'] + sdk['lib']

	# Apply programs to use for build
	v['AR'] = os.path.join(compiler['bin'], 'lib.exe')
	v['CC'] = v['CXX'] = os.path.join(compiler['bin'], 'cl.exe')
	v['LINK'] = v['LINK_CC'] = v['LINK_CXX'] = os.path.join(compiler['bin'], 'link.exe')
	v['MT'] = os.path.join(sdk['bin'], 'mt.exe')
	v['WINRC'] = os.path.join(sdk['bin'], 'rc.exe')
	
	# Verify the tools exist
	if not os.path.isfile(v['AR']):
		conf.fatal('C/C++ archiver not found at ' + v['AR'])
	if not os.path.isfile(v['CC']):
		conf.fatal('C/C++ compiler not found at ' + v['CC'])
	if not os.path.isfile(v['LINK']):
		conf.fatal('C/C++ linker not found at ' + v['LINK'])
	if not os.path.isfile(v['MT']):
		conf.fatal('Windows Manifest tool not found at ' + v['MT'])
	if not os.path.isfile(v['WINRC']):
		conf.fatal('Windows Resource Compiler tool not found at ' + v['WINRC'])

	# Apply MSVC paths (for later use by MSVC specific build steps)
	v['MSVC_PATH'] = compiler['root']
	v['MSVC_VERSION'] = compiler['version']
	v['MSVC_COMPILER'] = v['CC_NAME'] = v['CXX_NAME'] = 'msvc'
	v['MSVC_TARGETS'] = [ target ]

	# Apply WINSDK paths (for later use by Windows specific build steps)
	v['WINSDK_PATH'] = sdk['root']
	v['WINSDK_VERSION'] = sdk['version']
	
	# Apply merged redist path dictionaries
	v['REDIST_PATH'] = {}
	v['REDIST_PATH'].update(compiler['redist'])
	v['REDIST_PATH'].update(sdk['redist'])

	# Add MSVC required path to global path
	v.env = os.environ.copy()
	if not 'PATH' in v.env:
		v.env['PATH'] = ''
	v.env['PATH'] = ';'.join(v['PATH']) + ';' + v.env['PATH']

	# Strip duplicate paths
	v.env['PATH'] =';'.join(set(v.env['PATH'].split(';')))
Example #17
0
def load_msvc_common_settings(conf):
    """
    Setup all compiler/linker flags with are shared over all targets using the microsoft compiler
    
    !!! But not the actual compiler, since the compiler depends on the target !!!
    """
    v = conf.env

    # MT Tool
    v['MTFLAGS'] = ['/nologo']

    # AR Tools
    v['ARFLAGS'] += ['/NOLOGO']
    v['AR_TGT_F'] = '/OUT:'

    # CC/CXX Compiler
    v['CC_NAME'] = v['CXX_NAME'] = 'msvc'
    v['CC_SRC_F'] = v['CXX_SRC_F'] = []
    v['CC_TGT_F'] = v['CXX_TGT_F'] = ['/c', '/Fo']

    v['CPPPATH_ST'] = '/I%s'
    v['DEFINES_ST'] = '/D%s'

    v['PCH_FILE_ST'] = '/Fp%s'
    v['PCH_CREATE_ST'] = '/Yc%s'
    v['PCH_USE_ST'] = '/Yu%s'

    v['ARCH_ST'] = ['/arch:']

    # Linker
    v['CCLNK_SRC_F'] = v['CXXLNK_SRC_F'] = []
    v['CCLNK_TGT_F'] = v['CXXLNK_TGT_F'] = '/OUT:'

    v['LIB_ST'] = '%s.lib'
    v['LIBPATH_ST'] = '/LIBPATH:%s'
    v['STLIB_ST'] = '%s.lib'
    v['STLIBPATH_ST'] = '/LIBPATH:%s'

    v['cprogram_PATTERN'] = '%s.exe'
    v['cxxprogram_PATTERN'] = '%s.exe'

    # shared library settings
    v['CFLAGS_cshlib'] = v['CFLAGS_cxxshlib'] = []
    v['CXXFLAGS_cshlib'] = v['CXXFLAGS_cxxshlib'] = []

    v['LINKFLAGS_cshlib'] = ['/DLL']
    v['LINKFLAGS_cxxshlib'] = ['/DLL']

    v['cshlib_PATTERN'] = '%s.dll'
    v['cxxshlib_PATTERN'] = '%s.dll'

    # static library settings
    v['CFLAGS_cstlib'] = v['CFLAGS_cxxstlib'] = []
    v['CXXFLAGS_cstlib'] = v['CXXFLAGS_cxxstlib'] = []

    v['LINKFLAGS_cxxstlib'] = []
    v['LINKFLAGS_cxxshtib'] = []

    v['cstlib_PATTERN'] = '%s.lib'
    v['cxxstlib_PATTERN'] = '%s.lib'

    # Set common compiler flags
    COMMON_COMPILER_FLAGS = [
        '/nologo',  # Suppress Copyright and version number message
        '/W3',  # Warning Level 3
        '/WX',  # Treat Warnings as Errors
        '/MP',  # Allow Multicore compilation
        '/Gy',  # Enable Function-Level Linking
        '/GF',  # Enable string pooling
        '/Gm-',  # Disable minimal rebuild (causes issues with IB)
        '/fp:fast',  # Use fast (but not as precisce floatin point model)
        '/Zc:wchar_t',  # Use compiler native wchar_t
        '/Zc:forScope',  # Force Conformance in for Loop Scope
        '/Zc:inline',  # Remove unreferenced COMDAT
        '/GR-',  # Disable RTTI
        '/Gd',  # Use _cdecl calling convention for all functions
        #        '/FC'      #debug
        '/wd4530',  # Known issue, Disabling "C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc" until it is fixed
        '/wd4577',  # Known issue, disabling "C4577: 'noexcept' used with no exception handling mode specified; termination on exception is not guaranteed. Specify /EHsc"
    ]

    # Enable timing reports in the output
    if conf.is_option_true('enable_msvc_timings'):
        COMMON_COMPILER_FLAGS += ['/Bt+']  # debug, show compile times
        v['LINKFLAGS'] += ['/time+']  # debug, show link times

    # Copy common flags to prevent modifing references
    v['CFLAGS'] += COMMON_COMPILER_FLAGS[:]
    v['CXXFLAGS'] += COMMON_COMPILER_FLAGS[:]

    # Linker Flags
    v['LINKFLAGS'] += [
        '/NOLOGO',  # Suppress Copyright and version number message
        '/MANIFEST',  # Create a manifest file        
        '/LARGEADDRESSAWARE',  # tell the linker that the application can handle addresses larger than 2 gigabytes.        
        '/INCREMENTAL:NO',  # Disable Incremental Linking
    ]

    # Compile options appended if compiler optimization is disabled
    v['COMPILER_FLAGS_DisableOptimization'] = ['/Od']

    # Compile options appended if debug symbols are generated
    # Create a external Program Data Base (PDB) for debugging symbols
    #v['COMPILER_FLAGS_DebugSymbols'] = [ '/Zi' ]
    v['COMPILER_FLAGS_DebugSymbols'] = ['/Z7']

    # Linker flags when building with debug symbols
    v['LINKFLAGS_DebugSymbols'] = ['/DEBUG', '/PDBALTPATH:%_PDB%']

    # Store settings for show includes option
    v['SHOWINCLUDES_cflags'] = ['/showIncludes']
    v['SHOWINCLUDES_cxxflags'] = ['/showIncludes']

    # Store settings for preprocess to file option
    v['PREPROCESS_cflags'] = ['/P', '/C']
    v['PREPROCESS_cxxflags'] = ['/P', '/C']
    v['PREPROCESS_cc_tgt_f'] = ['/c', '/Fi']
    v['PREPROCESS_cxx_tgt_f'] = ['/c', '/Fi']

    # Store settings for preprocess to file option
    v['DISASSEMBLY_cflags'] = ['/FAcs']
    v['DISASSEMBLY_cxxflags'] = ['/FAcs']
    v['DISASSEMBLY_cc_tgt_f'] = ['/c', '/Fa']
    v['DISASSEMBLY_cxx_tgt_f'] = ['/c', '/Fa']

    # ASAN and ASLR
    v['LINKFLAGS_ASLR'] = ['/DYNAMICBASE']
    v['ASAN_cflags'] = ['/GS']
    v['ASAN_cxxflags'] = ['/GS']
Example #18
0
def find_msvc(conf):
    """Due to path format limitations, limit operation only to native Win32. Yeah it sucks."""
    if sys.platform == 'cygwin':
        conf.fatal('MSVC module does not work under cygwin Python!')

    # the autodetection is supposed to be performed before entering in this method
    v = conf.env
    path = v['PATH']
    compiler = v['MSVC_COMPILER']
    version = v['MSVC_VERSION']

    compiler_name, linker_name, lib_name = _get_prog_names(conf, compiler)
    v.MSVC_MANIFEST = (compiler == 'msvc' and version >= 8) or (
        compiler == 'wsdk' and version >= 6) or (compiler == 'intel'
                                                 and version >= 11)

    # compiler
    cxx = None
    if v['CXX']: cxx = v['CXX']
    elif 'CXX' in conf.environ: cxx = conf.environ['CXX']
    cxx = conf.find_program(compiler_name,
                            var='CXX',
                            path_list=path,
                            silent_output=True)
    cxx = conf.cmd_to_list(cxx)

    # before setting anything, check if the compiler is really msvc
    env = dict(conf.environ)
    if path: env.update(PATH=';'.join(path))
    if not conf.cmd_and_log(cxx + ['/nologo', '/help'], env=env):
        conf.fatal('the msvc compiler could not be identified')

    # c/c++ compiler
    v['CC'] = v['CXX'] = cxx[0]
    v['CC_NAME'] = v['CXX_NAME'] = 'msvc'

    # Bullseye code coverage
    if conf.is_option_true('use_bullseye_coverage'):
        # TODO: Error handling for this is opaque. This will fail the MSVS 2015 tool check,
        # and not say anything about bullseye being missing.
        try:
            covc = conf.find_program('covc',
                                     var='BULL_COVC',
                                     path_list=path,
                                     silent_output=True)
            covlink = conf.find_program('covlink',
                                        var='BULL_COVLINK',
                                        path_list=path,
                                        silent_output=True)
            covselect = conf.find_program('covselect',
                                          var='BULL_COVSELECT',
                                          path_list=path,
                                          silent_output=True)
            v['BULL_COVC'] = covc
            v['BULL_COVLINK'] = covlink
            v['BULL_COV_FILE'] = conf.CreateRootRelativePath(
                conf.options.bullseye_cov_file)
            # Update the coverage file with the region selections detailed in the settings regions parameters
            # NOTE: should we clear other settings at this point, or allow them to accumulate?
            # Maybe we need a flag for that in the setup?
            regions = conf.options.bullseye_coverage_regions.replace(
                ' ', '').split(',')
            conf.cmd_and_log(
                ([covselect] + ['--file', v['BULL_COV_FILE'], '-a'] + regions))
        except:
            Logs.error(
                'Could not find the Bullseye Coverage tools on the path, or coverage tools are not correctly installed. Coverage build disabled.'
            )

    # linker
    if not v['LINK_CXX']:
        link = conf.find_program(linker_name,
                                 path_list=path,
                                 silent_output=True)
        if link: v['LINK_CXX'] = link
        else: conf.fatal('%s was not found (linker)' % linker_name)
        v['LINK'] = link

    if not v['LINK_CC']:
        v['LINK_CC'] = v['LINK_CXX']

    # staticlib linker
    if not v['AR']:
        stliblink = conf.find_program(lib_name,
                                      path_list=path,
                                      var='AR',
                                      silent_output=True)
        if not stliblink: return
        v['ARFLAGS'] = ['/NOLOGO']

    # manifest tool. Not required for VS 2003 and below. Must have for VS 2005 and later
    if v.MSVC_MANIFEST:
        conf.find_program('MT', path_list=path, var='MT', silent_output=True)
        v['MTFLAGS'] = ['/NOLOGO']

    # call configure on the waflib winres module to setup the environment for configure
    # conf.load('winres') caches the environment as part of the module load key, and we just modified
    # the environment, causing the cache to miss, and extra calls import/load the module
    # winres is loaded
    try:
        module = sys.modules['waflib.Tools.winres']
        func = getattr(module, 'configure', None)
        if func:
            func(conf)
    except Error as e:
        warn(
            'Resource compiler not found. Compiling resource file is disabled')
Example #19
0
def process_custom_configure_commands(conf):
    """
    Add any additional custom commands that need to be run during the configure phase

    :param conf:                Configuration context
    """

    host = Utils.unversioned_sys_platform()

    if host == 'win32':
        # Win32 platform optional commands

        # Generate the visual studio projects & solution if specified
        if conf.is_option_true('generate_vs_projects_automatically'):
            Options.commands.insert(0, 'msvs')

    elif host == 'darwin':

        # Darwin/Mac platform optional commands

        # Create Xcode-iOS-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_ios_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_ios')
            else:
                Options.commands.append('xcode_ios')

        # Create Xcode-AppleTV-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_appletv_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_appletv')
            else:
                Options.commands.append('xcode_appletv')

        # Create Xcode-darwin-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_mac_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_mac')
            else:
                Options.commands.append('xcode_mac')

    # Android target platform commands
    if any(platform for platform in conf.get_supported_platforms() if platform.startswith('android')):

        # this is required for building any android projects. It adds the Android launchers
        # to the list of build directories
        android_builder_func = getattr(conf, 'create_and_add_android_launchers_to_build', None)
        if android_builder_func != None and android_builder_func():
            SUBFOLDERS.append(conf.get_android_project_absolute_path())

        # rebuild the project if invoked from android studio or sepcifically requested to do so
        if conf.options.from_android_studio or conf.is_option_true('generate_android_studio_projects_automatically'):
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'android_studio')
            else:
                Options.commands.append('android_studio')

    # Make sure the intermediate files are generated and updated
    if len(Options.commands) == 0:
        Options.commands.insert(0, 'generate_uber_files')
        Options.commands.insert(1, 'generate_module_def_files')
    else:
        has_generate_uber_files = 'generate_uber_files' in Options.commands
        has_generate_module_def_files = 'generate_module_def_files' in Options.commands
        if not has_generate_uber_files:
            Options.commands.insert(0, 'generate_uber_files')
        if not has_generate_module_def_files:
            Options.commands.insert(1, 'generate_module_def_files')
def load_durango_common_settings(conf):
	"""
	Setup all compiler and linker settings shared over all durango configurations
	"""
	v = conf.env	
		
	# Since Durango is only build in a single configuration on windows, we can specify the compile tools here
	if not conf.is_option_true('auto_detect_compiler'):
		durango_sdk_dir = conf.CreateRootRelativePath('Code/SDKs/DurangoSDK/')		
		durango_sdk_xdk_dir = durango_sdk_dir
	else:
			# try to read the path from the registry
			try:
				import _winreg
				sdk_folder_entry = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Wow6432Node\\Microsoft\\Durango XDK", 0, _winreg.KEY_READ)
				(durango_sdk_dir,type) = _winreg.QueryValueEx(sdk_folder_entry, 'InstallPath')
				durango_sdk_dir = durango_sdk_dir.encode('ascii') # Make asci string (as we get unicode)
				durango_sdk_xdk_dir = durango_sdk_dir + 'xdk'
			except:
				conf.fatal('[ERROR] Cannot find Durango XDK Registry Entry. Please verify your Durango XDK installation')
			
	# Same for both
	durango_sdk_xdk_wrl_dir = conf.CreateRootRelativePath('Code/SDKs/DurangoSDK_WRL/')
	
	v['DURANGO_XDK_DIR'] = durango_sdk_xdk_dir
	# Setup common defines for durango
	v['DEFINES'] += [ '_WIN32', '_WIN64', '_DURANGO', 'DURANGO', '_XBOX_ONE' ]

	# Ensure WINAPI version is consistent everywhere
	v['DEFINES'] += [ '_WIN32_WINNT=0x0602', 'NTDDI_VERSION=0x06020000', 'WINVER=0x0602' ]
	
	# Durango requieres some addional defines 
	v['DEFINES'] += [
		'_UITHREADCTXT_SUPPORT=0',
		'_CRT_USE_WINAPI_PARTITION_APP',
		'__WRL_NO_DEFAULT_LIB__',
		'WIN32_LEAN_AND_MEAN',
		'GSI_WINSOCK2',		
		'WINAPI_FAMILY=WINAPI_FAMILY_TV_TITLE',		
		]
		
	# For durango, always create code favoring AVX 
	v['ARCH'] = ['AVX']
	

	# Set up compiler flags
	COMMON_COMPILER_FLAGS = [															
		'/favor:AMD64',	# Create Code optimized for 64 bit				
		# Add Metadata Directories with /AI
		'/AI' + durango_sdk_xdk_dir + '/crt/platform/amd64',
		'/AI' + durango_sdk_xdk_dir + '/References/CommonConfiguration/Neutral'
		]
	
	# Copy common flags to prevent modifing references
	v['CFLAGS'] += COMMON_COMPILER_FLAGS[:]
	v['CXXFLAGS'] += COMMON_COMPILER_FLAGS[:]
	
	# Linker Flags
	v['LINKFLAGS'] += [
		'/MACHINE:X64',						# Create 64 Bit Files				
		
		# Disable a whole bunch of default libraries on durango
		'/NODEFAULTLIB:advapi32.lib',
		'/NODEFAULTLIB:atl.lib',
		'/NODEFAULTLIB:atls.lib',
		'/NODEFAULTLIB:atlsd.lib',
		'/NODEFAULTLIB:atlsn.lib',
		'/NODEFAULTLIB:atlsnd.lib',
		'/NODEFAULTLIB:comctl32.lib',
		'/NODEFAULTLIB:comsupp.lib',
		'/NODEFAULTLIB:dbghelp.lib',
		'/NODEFAULTLIB:gdi32.lib',
		'/NODEFAULTLIB:gdiplus.lib',
		'/NODEFAULTLIB:guardcfw.lib',
		'/NODEFAULTLIB:kernel32.lib',
		'/NODEFAULTLIB:mmc.lib',
		'/NODEFAULTLIB:msimg32.lib',
		'/NODEFAULTLIB:msvcole.lib',
		'/NODEFAULTLIB:msvcoled.lib',
		'/NODEFAULTLIB:mswsock.lib',
		'/NODEFAULTLIB:ntstrsafe.lib',
		'/NODEFAULTLIB:ole2.lib',
		'/NODEFAULTLIB:ole2autd.lib',
		'/NODEFAULTLIB:ole2auto.lib',
		'/NODEFAULTLIB:ole2d.lib',
		'/NODEFAULTLIB:ole2ui.lib',
		'/NODEFAULTLIB:ole2uid.lib',
		'/NODEFAULTLIB:ole32.lib',
		'/NODEFAULTLIB:oleacc.lib',
		'/NODEFAULTLIB:oleaut32.lib',
		'/NODEFAULTLIB:oledlg.lib',
		'/NODEFAULTLIB:oledlgd.lib',
		'/NODEFAULTLIB:oldnames.lib',
		'/NODEFAULTLIB:runtimeobject.lib',
		'/NODEFAULTLIB:shell32.lib',
		'/NODEFAULTLIB:shlwapi.lib',
		'/NODEFAULTLIB:strsafe.lib',
		'/NODEFAULTLIB:urlmon.lib',
		'/NODEFAULTLIB:user32.lib',
		'/NODEFAULTLIB:userenv.lib',
		'/NODEFAULTLIB:uuid.lib',
		'/NODEFAULTLIB:wlmole.lib',
		'/NODEFAULTLIB:wlmoled.lib',
		]
		
	
	# Set up Library search path
	v['LIBPATH'] += [		
		durango_sdk_xdk_dir + '/lib/amd64',
		durango_sdk_xdk_dir + '/crt/lib/amd64',
		durango_sdk_xdk_dir + '/PC/lib/amd64'
		]
		
	# Setup default libraries to link
	v['LIB'] += [
		'combase', 
		'kernelx'
		]
			
	# Default Include path
	v['INCLUDES'] += [
		durango_sdk_xdk_wrl_dir + '/INCLUDE/winrt',  # WRL headers need to be included before originals
		durango_sdk_xdk_dir + '/INCLUDE/um',
		durango_sdk_xdk_dir + '/INCLUDE/shared',
		durango_sdk_xdk_dir + '/INCLUDE/winrt',		
		durango_sdk_xdk_dir + '/crt/INCLUDE',
		durango_sdk_xdk_dir + '/VC/ATLMFC/INCLUDE',
		]		
		
	# Store setting for static code analyzer	
	v['STATIC_CODE_ANALYZE_cflags'] = ['/analyze', '/WX']
	v['STATIC_CODE_ANALYZE_cxxflags'] = ['/analyze', '/WX']
	
	v['AR'] 			= durango_sdk_xdk_dir + '/vc/bin/amd64/LIB.exe'		
	v['CC']				= v['CXX'] = durango_sdk_xdk_dir + '/vc/bin/amd64/CL.exe'
	v['LINK'] 		= v['LINK_CC'] = v['LINK_CXX'] = durango_sdk_xdk_dir + '/vc/bin/amd64/LINK.exe'
	v['MAKEPGK'] 	= durango_sdk_dir + '/bin/makepkg.exe'
	
	v['MSVC_VERSION'] = '11.0'
Example #21
0
def process_custom_configure_commands(conf):
    """
    Add any additional custom commands that need to be run during the configure phase

    :param conf:                Configuration context
    """

    host = Utils.unversioned_sys_platform()

    if host == 'win32':
        # Win32 platform optional commands

        # Generate the visual studio projects & solution if specified
        if conf.is_option_true('generate_vs_projects_automatically'):
            Options.commands.insert(0, 'msvs')

    elif host == 'darwin':

        # Darwin/Mac platform optional commands

        # Create Xcode-iOS-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_ios_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_ios')
            else:
                Options.commands.append('xcode_ios')

        # Create Xcode-AppleTV-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_appletv_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_appletv')
            else:
                Options.commands.append('xcode_appletv')

        # Create Xcode-darwin-Projects automatically during configure when running on mac
        if conf.is_option_true('generate_mac_projects_automatically'):
            # Workflow improvement: for all builds generate projects after the build
            # except when using the default build target 'utilities' then do it before
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'xcode_mac')
            else:
                Options.commands.append('xcode_mac')

    # Android target platform commands
    if any(platform for platform in conf.get_supported_platforms()
           if 'android' in platform):

        # this is required for building any android projects. It adds the Android launchers
        # to the list of build directories
        android_builder_func = getattr(
            conf, 'create_and_add_android_launchers_to_build', None)
        if android_builder_func != None and android_builder_func():
            SUBFOLDERS.append(conf.get_android_project_relative_path())

        # rebuild the project if invoked from android studio or sepcifically requested to do so
        if conf.options.from_android_studio or conf.is_option_true(
                'generate_android_studio_projects_automatically'):
            if 'build' in Options.commands:
                build_cmd_idx = Options.commands.index('build')
                Options.commands.insert(build_cmd_idx, 'android_studio')
            else:
                Options.commands.append('android_studio')

        # generate header
        def _indent_text(indent_level, text, *args):
            indent_space = ' ' * indent_level * 4
            return str.format('{}{}', indent_space, text % args)

        recordingMode = [
            'AZ::Debug::AllocationRecords::Mode::RECORD_NO_RECORDS',
            'AZ::Debug::AllocationRecords::Mode::RECORD_STACK_NEVER',
            'AZ::Debug::AllocationRecords::Mode::RECORD_STACK_IF_NO_FILE_LINE',
            'AZ::Debug::AllocationRecords::Mode::RECORD_FULL',
            'AZ::Debug::AllocationRecords::Mode::RECORD_MAX',
        ]

        outputString = ""

        outputString += "////////////////////////////////////////////////////////////////\n"
        outputString += "// This file was automatically created by WAF\n"
        outputString += "// WARNING! All modifications will be lost!\n"
        outputString += "////////////////////////////////////////////////////////////////\n\n"

        outputString += "void SetupAndroidDescriptor(const char* gameName, AZ::ComponentApplication::Descriptor &desc)\n{\n"

        for project in conf.get_enabled_game_project_list():
            targetFile = os.path.join(conf.path.abspath(), project, "Config",
                                      "Game.xml")

            tree = ET.parse(targetFile)
            root = tree.getroot()
            descriptor = root[0]

            outputString += _indent_text(
                1, "if(stricmp(gameName, \"%s\") == 0)\n", project)
            outputString += _indent_text(1, "{\n")
            outputString += _indent_text(
                2, "desc.m_useExistingAllocator = %s;\n",
                descriptor.findall("*[@field='useExistingAllocator']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_grabAllMemory = %s;\n",
                descriptor.findall("*[@field='grabAllMemory']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_allocationRecords = %s;\n",
                descriptor.findall("*[@field='allocationRecords']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_autoIntegrityCheck = %s;\n",
                descriptor.findall("*[@field='autoIntegrityCheck']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_markUnallocatedMemory = %s;\n",
                descriptor.findall("*[@field='markUnallocatedMemory']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_doNotUsePools = %s;\n",
                descriptor.findall("*[@field='doNotUsePools']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_pageSize = %s;\n",
                descriptor.findall("*[@field='pageSize']")[0].get("value"))
            outputString += _indent_text(
                2, "desc.m_poolPageSize = %s;\n",
                descriptor.findall("*[@field='poolPageSize']")[0].get("value"))
            outputString += _indent_text(
                2, "desc.m_memoryBlockAlignment = %s;\n",
                descriptor.findall("*[@field='blockAlignment']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_memoryBlocksByteSize = %s;\n",
                descriptor.findall("*[@field='blockSize']")[0].get("value"))
            outputString += _indent_text(
                2, "desc.m_reservedOS = %s;\n",
                descriptor.findall("*[@field='reservedOS']")[0].get("value"))
            outputString += _indent_text(
                2, "desc.m_reservedDebug = %s;\n",
                descriptor.findall("*[@field='reservedDebug']")[0].get(
                    "value"))

            if descriptor.find("*[@field='recordingMode']") is not None:
                field = "recordingMode"
            else:
                field = "recordsMode"

            id = int(
                descriptor.findall(str.format("*[@field='{}']",
                                              field))[0].get("value"))
            outputString += _indent_text(2, "desc.m_recordingMode = %s;\n",
                                         recordingMode[id])

            outputString += _indent_text(
                2, "desc.m_stackRecordLevels = %s;\n",
                descriptor.findall("*[@field='stackRecordLevels']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_enableDrilling = %s;\n",
                descriptor.findall("*[@field='enableDrilling']")[0].get(
                    "value"))
            outputString += _indent_text(
                2, "desc.m_x360IsPhysicalMemory = %s;\n",
                descriptor.findall("*[@field='x360PhysicalMemory']")[0].get(
                    "value"))

            modulesElement = descriptor.findall("*[@field='modules']")[0]
            for moduleEntry in modulesElement.findall("*[@field='element']"):
                outputString += _indent_text(2,
                                             "desc.m_modules.push_back();\n")
                outputString += _indent_text(
                    2,
                    "desc.m_modules.back().m_dynamicLibraryPath = \"%s\";\n",
                    moduleEntry.findall(
                        "*[@field='dynamicLibraryPath']")[0].get("value"))
            outputString += _indent_text(1, "}\n")

        outputString += "}\n"

        filePath = os.path.join(conf.path.abspath(), "Code", "Launcher",
                                "AndroidLauncher", "android_descriptor.h")
        fp = open(filePath, 'w')
        fp.write(outputString)
        fp.close()

    # Make sure the intermediate files are generated and updated
    if len(Options.commands) == 0:
        Options.commands.insert(0, 'generate_uber_files')
        Options.commands.insert(1, 'generate_module_def_files')
    else:
        has_generate_uber_files = 'generate_uber_files' in Options.commands
        has_generate_module_def_files = 'generate_module_def_files' in Options.commands
        if not has_generate_uber_files:
            Options.commands.insert(0, 'generate_uber_files')
        if not has_generate_module_def_files:
            Options.commands.insert(1, 'generate_module_def_files')
def load_win_x64_android_arm_gcc_common_settings(conf):
	"""
	Setup all compiler and linker settings shared over all win_x64_arm_linux_androideabi_4_8 configurations
	"""
	
	v = conf.env
	
	# Setup Tools for GCC Cross Compile Toolchain
	if not conf.is_option_true('auto_detect_compiler'):	
		android_sdk_home		= conf.CreateRootRelativePath('Code/SDKs/android-sdk')
		android_ndk_home		= conf.CreateRootRelativePath('Code/SDKs/android-ndk')
		android_java_home		= conf.CreateRootRelativePath('Code/SDKs/jdk')
		android_ant_home 		= conf.CreateRootRelativePath('Code/SDKs/apache-ant')
		
		# Validate paths
		for path in [android_sdk_home, android_ndk_home, android_java_home, android_ant_home]:
			if not os.path.exists(path):
				conf.cry_error("Requiered Android SDK path does not exist: %s. Fix path or try running WAF with 'auto_detect_compiler' option enabled." % path)
	else:
		android_sdk_home 		= os.getenv('ANDROID_HOME', "")	
		android_ndk_home 		= os.getenv('NDK_ROOT', "")
		android_java_home 	= os.getenv('JAVA_HOME', "")
		android_ant_home 		= os.getenv('ANT_HOME', "")

		# Validate paths
		if not os.path.exists(android_sdk_home):
			conf.cry_error("Unable to locate ANDROID SDK. Environment variable 'ANDROID_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?")
		if not os.path.exists(android_ndk_home):
			conf.cry_error("Unable to locate ANDROID NDK. Environment variable 'NDK_ROOT' not set? Do you have Tegra Android Development Pack (TADP) installed?")
		if not os.path.exists(android_java_home):
			conf.cry_error("Unable to locate JAVA. Environment variable 'JAVA_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?")
		if not os.path.exists(android_ant_home):
			conf.cry_error("Unable to locate APACHE ANT. Environment variable 'ANT_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?")

	# Configure platform and compiler mutations		
	platform_target = '/platforms/android-' + str(android_target_version)
	compiler_target = '/arch-arm'
	compiler_version = str(android_compiler_version)
	toolchain = 'arm-linux-androideabi-' + compiler_version
	
	android_sdk_platform_target 	= android_sdk_home + platform_target
	android_ndk_platform_compiler_target 	= android_ndk_home + platform_target + compiler_target
	android_ndk_toolchain_target 	= android_ndk_home + '/toolchains/' + toolchain + '/prebuilt/windows-x86_64'
	if not os.path.exists(android_ndk_toolchain_target): # Fallback if the 64 bit compiler is not found
		android_ndk_toolchain_target 	= android_ndk_home + '/toolchains/' + toolchain + '/prebuilt/windows'

	android_stl_home = android_ndk_home + '/sources/cxx-stl/gnu-libstdc++/' + compiler_version
	
	v['AR'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-ar'
	v['CC'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-gcc.exe'
	v['CXX'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-g++.exe'
	v['LINK'] = v['LINK_CC'] = v['LINK_CXX'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-g++.exe'
	v['STRIP'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-strip.exe'
	
	v['JAR'] = android_java_home + '/bin/jar.exe'
	v['JAVAC'] = android_java_home +'/bin/javac.exe'
	v['ANDROID_CLASSPATH'] = android_sdk_platform_target + '/android.jar'
	v['ANDROID_TARGET_VERSION'] = android_target_version
	
	v['ANT'] = android_ant_home + '/bin/ant.bat'
	
	v['ANDROID_NDK_HOME'] = android_ndk_home 
	v['ANDROID_SDL_HOME'] = android_stl_home 
	v['ANDROID_SDK_HOME'] = android_sdk_home 
	v['ANDROID_JAVA_HOME'] = android_java_home
	
	v['cprogram_PATTERN'] 	= '%s'
	v['cxxprogram_PATTERN'] = '%s'
	v['cshlib_PATTERN'] 	= 'lib%s.so'
	v['cxxshlib_PATTERN'] 	= 'lib%s.so'
	v['cstlib_PATTERN']     = 'lib%s.a'
	v['cxxstlib_PATTERN']   = 'lib%s.a'
	
	v['DEFINES'] += ['_LINUX', 'LINUX', 'LINUX32', 'ANDROID', '_HAS_C9X' ]

	# Setup global include paths
	v['INCLUDES'] += [ 
		android_ndk_platform_compiler_target + '/usr/include', 
		android_stl_home + '/include', 
		android_stl_home + '/libs/armeabi-v7a/include',
		android_ndk_home + '/sources/android/support/include',
		android_ndk_home + '/sources/android/native_app_glue',
		conf.CreateRootRelativePath('Code/Tools/SDLExtension/src/include'),
		]
	
	# Setup global library search path
	v['LIBPATH'] += [		
		android_stl_home + 'libs/armeabi-v7a',
		platform_target + '/usr/lib'
	]	 
	# Introduce the compiler to generate 32 bit code
	v['CFLAGS'] += [ '-mfpu=neon', '-mfloat-abi=softfp', '-march=armv7-a' ]
	v['CXXFLAGS'] += [ '-mfpu=neon', '-mfloat-abi=softfp', '-march=armv7-a' ]	
	
	v['CFLAGS'] += [ '--sysroot=' + android_ndk_platform_compiler_target ]
	v['CXXFLAGS'] += [ '--sysroot=' + android_ndk_platform_compiler_target ]
	v['LINKFLAGS'] += [ '--sysroot=' + android_ndk_platform_compiler_target, android_stl_home + '/libs/armeabi-v7a/libgnustl_shared.so']
Example #23
0
def load_win_x64_android_arm_gcc_common_settings(conf):
    """Setup all compiler and linker settings shared over all win_x64_arm_linux_androideabi_4_8 configurations
	"""

    v = conf.env

    # Setup Tools for GCC Cross Compile Toolchain
    if not conf.is_option_true('auto_detect_compiler'):
        android_sdk_home = conf.CreateRootRelativePath('Code/SDKs/android-sdk')
        android_ndk_home = conf.CreateRootRelativePath('Code/SDKs/android-ndk')
        android_java_home = conf.CreateRootRelativePath('Code/SDKs/jdk')
        android_ant_home = conf.CreateRootRelativePath('Code/SDKs/apache-ant')

        # Validate paths
        for path in [
                android_sdk_home, android_ndk_home, android_java_home,
                android_ant_home
        ]:
            if not os.path.exists(path):
                conf.cry_error(
                    "Requiered Android SDK path does not exist: %s. Fix path or try running WAF with 'auto_detect_compiler' option enabled."
                    % path)
    else:
        android_sdk_home = os.getenv('ANDROID_HOME', "")
        android_ndk_home = os.getenv('NDK_ROOT', "")
        android_java_home = os.getenv('JAVA_HOME', "")
        android_ant_home = os.getenv('ANT_HOME', "")

        # Validate paths
        if not os.path.exists(android_sdk_home):
            conf.cry_error(
                "Unable to locate ANDROID SDK. Environment variable 'ANDROID_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?"
            )
        if not os.path.exists(android_ndk_home):
            conf.cry_error(
                "Unable to locate ANDROID NDK. Environment variable 'NDK_ROOT' not set? Do you have Tegra Android Development Pack (TADP) installed?"
            )
        if not os.path.exists(android_java_home):
            conf.cry_error(
                "Unable to locate JAVA. Environment variable 'JAVA_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?"
            )
        if not os.path.exists(android_ant_home):
            conf.cry_error(
                "Unable to locate APACHE ANT. Environment variable 'ANT_HOME' not set? Do you have Tegra Android Development Pack (TADP) installed?"
            )

    # Configure platform and compiler mutations
    platform_target = '/platforms/android-' + str(android_target_version)
    compiler_target = '/arch-arm'
    compiler_version = str(android_compiler_version)
    toolchain = 'arm-linux-androideabi-' + compiler_version

    android_sdk_platform_target = android_sdk_home + platform_target
    android_ndk_platform_compiler_target = android_ndk_home + platform_target + compiler_target
    android_ndk_toolchain_target = android_ndk_home + '/toolchains/' + toolchain + '/prebuilt/windows-x86_64'
    if not os.path.exists(android_ndk_toolchain_target
                          ):  # Fallback if the 64 bit compiler is not found
        android_ndk_toolchain_target = android_ndk_home + '/toolchains/' + toolchain + '/prebuilt/windows'

    android_stl_home = android_ndk_home + '/sources/cxx-stl/gnu-libstdc++/' + compiler_version

    v['AR'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-ar'
    v['CC'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-gcc.exe'
    v['CXX'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-g++.exe'
    v['LINK'] = v['LINK_CC'] = v[
        'LINK_CXX'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-g++.exe'
    v['STRIP'] = android_ndk_toolchain_target + '/bin/arm-linux-androideabi-strip.exe'

    v['JAR'] = android_java_home + '/bin/jar.exe'
    v['JAVAC'] = android_java_home + '/bin/javac.exe'
    v['ANDROID_CLASSPATH'] = android_sdk_platform_target + '/android.jar'
    v['ANDROID_TARGET_VERSION'] = android_target_version

    v['ANT'] = android_ant_home + '/bin/ant.bat'

    v['ANDROID_NDK_HOME'] = android_ndk_home
    v['ANDROID_SDL_HOME'] = android_stl_home
    v['ANDROID_SDK_HOME'] = android_sdk_home
    v['ANDROID_JAVA_HOME'] = android_java_home

    v['cprogram_PATTERN'] = '%s'
    v['cxxprogram_PATTERN'] = '%s'
    v['cshlib_PATTERN'] = 'lib%s.so'
    v['cxxshlib_PATTERN'] = 'lib%s.so'
    v['cstlib_PATTERN'] = 'lib%s.a'
    v['cxxstlib_PATTERN'] = 'lib%s.a'

    v['DEFINES'] += ['_LINUX', 'LINUX', 'LINUX32', 'ANDROID', '_HAS_C9X']

    # Setup global include paths
    v['INCLUDES'] += [
        android_ndk_platform_compiler_target + '/usr/include',
        android_stl_home + '/include',
        android_stl_home + '/libs/armeabi-v7a/include',
        android_ndk_home + '/sources/android/support/include',
        android_ndk_home + '/sources/android/native_app_glue',
        conf.CreateRootRelativePath('Code/Tools/SDLExtension/src/include'),
    ]

    # Setup global library search path
    v['LIBPATH'] += [
        android_stl_home + 'libs/armeabi-v7a', platform_target + '/usr/lib'
    ]
    # Introduce the compiler to generate 32 bit code
    v['CFLAGS'] += ['-mfpu=neon', '-mfloat-abi=softfp', '-march=armv7-a']
    v['CXXFLAGS'] += ['-mfpu=neon', '-mfloat-abi=softfp', '-march=armv7-a']

    v['CFLAGS'] += ['--sysroot=' + android_ndk_platform_compiler_target]
    v['CXXFLAGS'] += ['--sysroot=' + android_ndk_platform_compiler_target]
    v['LINKFLAGS'] += [
        '--sysroot=' + android_ndk_platform_compiler_target,
        android_stl_home + '/libs/armeabi-v7a/libgnustl_shared.so'
    ]
Example #24
0
def get_msvc_versions(conf, target, arch):
	"""
	Requests from cache all the installed MSVC and WinSDK that support the given target/arch tuple
	Returns two dictionaries of key (version) and value (installation)
	The type of the returned installation is the same as returned from get_winsdk_for_target() and get_msvc_for_target_arch()
	"""

	# Configuration
	verbose = conf.is_option_true('auto_detect_verbose')
	min_version = float(conf.options.minimum_msvc_compiler)

	# Get the WinSDK versions installed on this machine, and cache it for future inspection
	global WINSDK_INSTALLED_VERSIONS
	if len(WINSDK_INSTALLED_VERSIONS) == 0:
		WINSDK_INSTALLED_VERSIONS['all'] = gather_wsdk_versions(verbose)
		if len(WINSDK_INSTALLED_VERSIONS['all']) == 0:
			conf.fatal('[ERROR] No Windows SDK installed on this machine')

	# Get the MSVC versions installed on this machine, and cache it for future inspection
	global MSVC_INSTALLED_VERSIONS
	if len(MSVC_INSTALLED_VERSIONS) == 0:
		MSVC_INSTALLED_VERSIONS['all'] = gather_msvc_versions(verbose, min_version)
		if len(MSVC_INSTALLED_VERSIONS['all']) == 0:
			conf.fatal('[ERROR] No MSVC compiler installed on this machine')

	# Get the SDKs for this target
	sdks = WINSDK_INSTALLED_VERSIONS.get(target, {})
	if len(sdks) == 0:
		suitable = []
		unsuitable = []
		for (version, path) in WINSDK_INSTALLED_VERSIONS['all'].items():
			sdk = get_winsdk_for_target(path, version, target)
			if len(sdk) != 0:
				sdk['version'] = version
				sdks[version] = sdk
				suitable += [ version ]
			else:
				unsuitable += [ version ]
		if verbose:
			print '[NOTE] There are %u suitable Windows SDKs for target %s: %s (unsuitable: %u)' % (len(suitable), target, ', '.join(suitable), len(unsuitable))
		if len(sdks) == 0:
			conf.fatal('[ERROR] None of the installed Windows SDK provides support for target %s (installed: %s)' % (target, ', '.join(WINSDK_INSTALLED_VERSIONS['all'].keys())))
		WINSDK_INSTALLED_VERSIONS[target] = sdks

	# Get the MSVCs for this target/arch tuple
	msvcs = MSVC_INSTALLED_VERSIONS.get(target + '@' + arch, {})
	if len(msvcs) == 0:
		suitable = []
		unsuitable = []
		for (version, path) in MSVC_INSTALLED_VERSIONS['all'].items():
			msvc = get_msvc_for_target_arch(path, target, arch)
			if len(msvc) != 0:
				msvc['version'] = version
				msvcs[version] = msvc
				suitable += [ version ]
			else:
				unsuitable += [ version ]
		if verbose:
			print '[NOTE] There are %u suitable MSVC for target (%s, %s): %s (unsuitable: %u)' % (len(suitable), target, arch, ', '.join(suitable), len(unsuitable))
		if len(msvcs) == 0:
			conf.fatal('[ERROR] None of the installed MSVC provides support for target %s (host: %s, installed %s)' % (target, arch, ','.join(MSVC_INSTALLED_VERSIONS['all'].keys())))
		MSVC_INSTALLED_VERSIONS[target + '@' + arch] = msvcs

	return sdks, msvcs
Example #25
0
def load_msvc_common_settings(conf):
    """
    Setup all compiler/linker flags with are shared over all targets using the microsoft compiler
    
    !!! But not the actual compiler, since the compiler depends on the target !!!
    """
    v = conf.env

    # MT Tool
    v['MTFLAGS'] = ['/NOLOGO']

    # AR Tools
    v['ARFLAGS'] += ['/NOLOGO']
    v['AR_TGT_F'] = '/OUT:'

    # CC/CXX Compiler
    v['CC_NAME'] = v['CXX_NAME'] = 'msvc'
    v['CC_SRC_F'] = v['CXX_SRC_F'] = []
    v['CC_TGT_F'] = v['CXX_TGT_F'] = ['/c', '/Fo']

    v['CPPPATH_ST'] = '/I%s'
    v['SYSTEM_CPPPATH_ST'] = '/external:I%s'
    v['DEFINES_ST'] = '/D%s'

    v['PCH_FILE_ST'] = '/Fp%s'
    v['PCH_CREATE_ST'] = '/Yc%s'
    v['PCH_USE_ST'] = '/Yu%s'

    v['ARCH_ST'] = ['/arch:']

    # Linker
    v['CCLNK_SRC_F'] = v['CXXLNK_SRC_F'] = []
    v['CCLNK_TGT_F'] = v['CXXLNK_TGT_F'] = '/OUT:'

    v['LIB_ST'] = '%s.lib'
    v['LIBPATH_ST'] = '/LIBPATH:%s'
    v['STLIB_ST'] = '%s.lib'
    v['STLIBPATH_ST'] = '/LIBPATH:%s'

    v['cprogram_PATTERN'] = '%s.exe'
    v['cxxprogram_PATTERN'] = '%s.exe'

    # shared library settings
    v['CFLAGS_cshlib'] = v['CFLAGS_cxxshlib'] = []
    v['CXXFLAGS_cshlib'] = v['CXXFLAGS_cxxshlib'] = []

    v['LINKFLAGS_cshlib'] = ['/DLL']
    v['LINKFLAGS_cxxshlib'] = ['/DLL']

    v['cshlib_PATTERN'] = '%s.dll'
    v['cxxshlib_PATTERN'] = '%s.dll'

    # static library settings
    v['CFLAGS_cstlib'] = v['CFLAGS_cxxstlib'] = []
    v['CXXFLAGS_cstlib'] = v['CXXFLAGS_cxxstlib'] = []

    v['LINKFLAGS_cxxstlib'] = []
    v['LINKFLAGS_cxxshtib'] = []

    v['cstlib_PATTERN'] = '%s.lib'
    v['cxxstlib_PATTERN'] = '%s.lib'

    # Compile options appended if compiler optimization is disabled
    v['COMPILER_FLAGS_DisableOptimization'] = ['/Od']

    # Compile options appended if debug symbols are generated
    # Create a external Program Data Base (PDB) for debugging symbols
    #v['COMPILER_FLAGS_DebugSymbols'] = [ '/Zi' ]
    v['COMPILER_FLAGS_DebugSymbols'] = ['/Z7']

    # Linker flags when building with debug symbols
    v['LINKFLAGS_DebugSymbols'] = ['/DEBUG', '/PDBALTPATH:%_PDB%']

    # Store settings for show includes option
    v['SHOWINCLUDES_cflags'] = ['/showIncludes']
    v['SHOWINCLUDES_cxxflags'] = ['/showIncludes']

    # Store settings for preprocess to file option
    v['PREPROCESS_cflags'] = ['/P', '/C']
    v['PREPROCESS_cxxflags'] = ['/P', '/C']
    v['PREPROCESS_cc_tgt_f'] = ['/c', '/Fi']
    v['PREPROCESS_cxx_tgt_f'] = ['/c', '/Fi']

    # Store settings for preprocess to file option
    v['DISASSEMBLY_cflags'] = ['/FAcs']
    v['DISASSEMBLY_cxxflags'] = ['/FAcs']
    v['DISASSEMBLY_cc_tgt_f'] = ['/c', '/Fa']
    v['DISASSEMBLY_cxx_tgt_f'] = ['/c', '/Fa']

    # ASAN and ASLR
    v['LINKFLAGS_ASLR'] = ['/DYNAMICBASE']
    v['ASAN_cflags'] = ['/GS']
    v['ASAN_cxxflags'] = ['/GS']
    """
    LTCG defaults to 4 threads, and can be set as high as 8.  Any setting over 8 is overridden to 1 by the linker.
    Any setting over the number of available hw threads incurs some thread scheduling overhead in a multiproc system.
    If the hw thread count is > 4, scale the setting up to 8.  This is independent of jobs or link_jobs running, and
    these threads are only active during the LTCG portion of the linker.  The overhead is ~50k/thread, and execution
    time doesn't scale linearly with threads.  Use the undocument linkflag /Time+ for extended information on the amount
    of time the linker spends in link time code generation
    """

    hw_thread_count = Options.options.jobs
    if hw_thread_count > 4:
        v['SET_LTCG_THREADS_FLAG'] = True
        ltcg_thread_count = min(hw_thread_count, 8)
        v['LTCG_THREADS_COUNT'] = str(ltcg_thread_count)
    else:
        v['SET_LTCG_THREADS_FLAG'] = False

    # Bullseye code coverage
    if conf.is_option_true('use_bullseye_coverage'):
        # TODO: Error handling for this is opaque. This will fail the MSVS 2015 tool check,
        # and not say anything about bullseye being missing.
        try:
            path = v['PATH']
            covc = conf.find_program('covc',
                                     var='BULL_COVC',
                                     path_list=path,
                                     silent_output=True)
            covlink = conf.find_program('covlink',
                                        var='BULL_COVLINK',
                                        path_list=path,
                                        silent_output=True)
            covselect = conf.find_program('covselect',
                                          var='BULL_COVSELECT',
                                          path_list=path,
                                          silent_output=True)
            v['BULL_COVC'] = covc
            v['BULL_COVLINK'] = covlink
            v['BULL_COV_FILE'] = conf.CreateRootRelativePath(
                conf.options.bullseye_cov_file)
            # Update the coverage file with the region selections detailed in the settings regions parameters
            # NOTE: should we clear other settings at this point, or allow them to accumulate?
            # Maybe we need a flag for that in the setup?
            regions = conf.options.bullseye_coverage_regions.replace(
                ' ', '').split(',')
            conf.cmd_and_log(
                ([covselect] + ['--file', v['BULL_COV_FILE'], '-a'] + regions))
        except Exception as e:
            Logs.error(
                'Could not find the Bullseye Coverage tools on the path, or coverage tools '
                'are not correctly installed. Coverage build disabled. '
                'Error: {}'.format(e))

    # Adds undocumented time flags for cl.exe and link.exe for measuring compiler frontend, code generation and link time code generation
    # timings
    compile_timing_flags = []

    if conf.is_option_true('report_compile_timing'):
        compile_timing_flags.append('/Bt+')
    if conf.is_option_true('report_cxx_frontend_timing'):
        compile_timing_flags.append('/d1reportTime')
    if conf.is_option_true('output_msvc_code_generation_summary'):
        compile_timing_flags.append('/d2cgsummary')
    v['CFLAGS'] += compile_timing_flags
    v['CXXFLAGS'] += compile_timing_flags

    link_timing_flags = []
    if conf.is_option_true('report_link_timing'):
        link_timing_flags.append('/time+')
    v['LINKFLAGS'] += link_timing_flags