Beispiel #1
0
def filter_target_platforms(conf):
    """
    Filter out any target platforms based on settings or options from the configuration/options

    :param conf:                Configuration context
    """

    # handle disabling android here to avoid having the same block of code in each of the compile_rules
    # for all the current and future android targets
    android_enabled = conf.get_env_file_var('ENABLE_ANDROID',
                                            required=False,
                                            silent=True)
    if android_enabled == 'True':
        # We need to validate the JDK path from SetupAssistant before loading the javaw tool.
        # This way we don't introduce a dependency on lmbrwaflib in the core waflib.
        jdk_home = conf.get_env_file_var('LY_JDK', required=True)
        if not jdk_home:
            conf.fatal(
                '[ERROR] Missing JDK path from Setup Assistant detected.  Please re-run Setup Assistant with "Compile For Android" enabled and run the configure command again.'
            )

        conf.env['JAVA_HOME'] = jdk_home

        conf.load('javaw')
        conf.load('android', tooldir=LMBR_WAF_TOOL_DIR)
    else:
        android_targets = [
            target for target in conf.get_available_platforms()
            if 'android' in target
        ]
        Logs.warn(
            '[WARN] Removing the following Android target platforms due to "Compile For Android" not checked in Setup Assistant.\n'
            '\t-> {}'.format(', '.join(android_targets)))
        for android in android_targets:
            conf.remove_platform_from_available_platforms(android)
def load_android_armv8_common_settings(conf):
    """
    Setup all compiler and linker settings shared over all android armv8 configurations
    """

    # remove the armv8 android build target if it doesn't meet the min API requirement.
    # letting the platform finish configuring is harmless.
    if (not conf.is_android_armv8_api_valid()) and (
            'android_armv8_clang' in conf.get_supported_platforms()):
        Logs.warn(
            '[WARN] Attempting to configure Android ARMv8 with an API that is lower than the min spec: API 21.  Disabling the Android ARMv8 build target.'
        )
        conf.remove_platform_from_available_platforms('android_armv8_clang')

    env = conf.env
    env['ANDROID_ARCH'] = 'arm64-v8a'

    ndk_root = env['ANDROID_NDK_HOME']
    ndk_rev = env['ANDROID_NDK_REV_MAJOR']

    is_ndk_19_plus = (ndk_rev >= 19)

    defines = [
        'LINUX64',
        '__ARM_NEON__',
    ]
    append_to_unique_list(env['DEFINES'], defines)

    if not is_ndk_19_plus:
        platform_root_compile = os.path.join(ndk_root, 'sysroot')
        platform_root_link = os.path.join(ndk_root, 'platforms',
                                          env['ANDROID_NDK_PLATFORM'],
                                          'arch-arm64')

        env['INCLUDES'] += [
            os.path.join(platform_root_compile, 'usr', 'include'),
        ]

        common_flags = [
            '--sysroot={}'.format(platform_root_compile),
            '-isystem',
            os.path.join(platform_root_compile, 'usr', 'include',
                         'aarch64-linux-android'),
        ]

        env['CFLAGS'] += common_flags[:]
        env['CXXFLAGS'] += common_flags[:]

        env['LIBPATH'] += [os.path.join(platform_root_link, 'usr', 'lib')]

        env['LINKFLAGS'] += [
            '--sysroot={}'.format(platform_root_link),
        ]
Beispiel #3
0
def mark_supported_platform_for_removal(conf, platform_to_remove):
    """
    Deprecated in favor of remove_platform_from_available_platforms()
    """
    conf.remove_platform_from_available_platforms(platform_to_remove)
Beispiel #4
0
def load_compile_rules_for_supported_platforms(conf,
                                               platform_configuration_filter):
    """
    Load the compile rules for all the supported target platforms for the current host platform

    :param conf:                            Configuration context
    :param platform_configuration_filter:   List of target platforms to filter out
    """

    host_platform = conf.get_waf_host_platform()

    absolute_lmbr_waf_tool_path = conf.path.make_node(
        LMBR_WAF_TOOL_DIR).abspath()

    vanilla_conf = conf.env.derive(
    )  # grab a snapshot of conf before you pollute it.

    host_function_name = load_compile_rules_for_host(conf, host_platform)

    installed_platforms = []

    for platform in conf.get_available_platforms():

        platform_spec_vanilla_conf = vanilla_conf.derive()
        platform_spec_vanilla_conf.detach()

        # Determine the compile rules module file and remove it and its support if it does not exist
        compile_rule_script = 'compile_rules_' + host_platform + '_' + platform
        if not os.path.exists(
                os.path.join(absolute_lmbr_waf_tool_path,
                             compile_rule_script + '.py')):
            conf.remove_platform_from_available_platforms(platform)
            continue

        Logs.info(
            '[INFO] Configure "%s - [%s]"' %
            (platform, ', '.join(conf.get_supported_configurations(platform))))
        conf.load(compile_rule_script, tooldir=LMBR_WAF_TOOL_DIR)

        # platform installed
        installed_platforms.append(platform)

        # Keep track of uselib's that we found in the 3rd party config files
        conf.env['THIRD_PARTY_USELIBS'] = [
            uselib_name for uselib_name in conf.read_and_mark_3rd_party_libs()
        ]

        for configuration in conf.get_supported_configurations():
            # if the platform isn't going to generate a build command, don't require that the configuration exists either
            if platform in platform_configuration_filter:
                if configuration not in platform_configuration_filter[
                        platform]:
                    continue

            conf.setenv(platform + '_' + configuration,
                        platform_spec_vanilla_conf.derive())
            conf.init_compiler_settings()

            # add the host settings into the current env
            getattr(conf, host_function_name)()

            # make a copy of the config for certain variant loading redirection (e.g. test, dedicated)
            # this way we can pass the raw configuration to the third pary reader to properly configure
            # each library
            config_redirect = configuration

            # Use the normal configurations as a base for dedicated server
            is_dedicated = False
            if config_redirect.endswith('_dedicated'):
                config_redirect = config_redirect.replace('_dedicated', '')
                is_dedicated = True

            # Use the normal configurations as a base for test
            is_test = False
            if '_test' in config_redirect:
                config_redirect = config_redirect.replace('_test', '')
                is_test = True

            # Use the specialized function to load platform specifics
            function_name = 'load_%s_%s_%s_settings' % (
                config_redirect, host_platform, platform)
            if not hasattr(conf, function_name):
                conf.fatal(
                    '[ERROR] Required Configuration Function \'%s\' not found'
                    % function_name)

            # Try to load the function
            getattr(conf, function_name)()

            # Apply specific dedicated server settings
            if is_dedicated:
                getattr(conf, 'load_dedicated_settings')()

            # Apply specific test settings
            if is_test:
                getattr(conf, 'load_test_settings')()

            if platform in conf.get_supported_platforms():
                # If the platform is still supported (it will be removed if the load settings function fails), then
                # continue to attempt to load the 3rd party uselib defs for the platform
                path_alias_map = {'ROOT': conf.srcnode.abspath()}

                config_3rdparty_folder_legacy = conf.root.make_node(
                    Context.launch_dir).make_node('_WAF_/3rd_party')
                config_3rdparty_folder_legacy_path = config_3rdparty_folder_legacy.abspath(
                )

                config_3rdparty_folder = conf.root.make_node(
                    Context.launch_dir).make_node('_WAF_/3rdParty')
                config_3rdparty_folder_path = config_3rdparty_folder.abspath()

                if os.path.exists(
                        config_3rdparty_folder_legacy_path) and os.path.exists(
                            config_3rdparty_folder_path):

                    has_legacy_configs = len(
                        os.listdir(config_3rdparty_folder_legacy_path)) > 0

                    # Both legacy and current 3rd party exists.  Print a warning and use the current 3rd party
                    if has_legacy_configs:
                        conf.warn_once(
                            'Legacy 3rd Party configuration path ({0}) will be ignored in favor of ({1}).  '
                            'Merge & remove the configuration files from the legacy path ({0}) to the current path ({1})'
                            .format(config_3rdparty_folder_legacy_path,
                                    config_3rdparty_folder_path))
                    thirdparty_error_msgs, uselib_names = conf.detect_all_3rd_party_libs(
                        config_3rdparty_folder, platform, configuration,
                        path_alias_map)

                elif os.path.exists(config_3rdparty_folder_legacy_path):

                    # Only the legacy 3rd party config folder exists.
                    thirdparty_error_msgs, uselib_names = conf.detect_all_3rd_party_libs(
                        config_3rdparty_folder_legacy, platform, configuration,
                        path_alias_map)

                elif os.path.exists(config_3rdparty_folder_path):

                    # Only the current 3rd party config folder exists.
                    thirdparty_error_msgs, uselib_names = conf.detect_all_3rd_party_libs(
                        config_3rdparty_folder, platform, configuration,
                        path_alias_map)

                else:
                    # Neither folder exists, report a warning
                    thirdparty_error_msgs = [
                        'Unable to find 3rd party configuration path ({}).  No 3rd party libraries will '
                        'be configured.'.format(config_3rdparty_folder_path)
                    ]

                for thirdparty_error_msg in thirdparty_error_msgs:
                    conf.warn_once(thirdparty_error_msg)
Beispiel #5
0
def load_compile_rules_for_supported_platforms(conf, platform_configuration_filter):
    """
    Load the compile rules for all the supported target platforms for the current host platform

    :param conf:                            Configuration context
    :param platform_configuration_filter:   List of target platforms to filter out
    """

    host_platform = conf.get_waf_host_platform()

    absolute_lmbr_waf_tool_path = LMBR_WAF_TOOL_DIR if os.path.isabs(LMBR_WAF_TOOL_DIR) else conf.path.make_node(LMBR_WAF_TOOL_DIR).abspath()

    vanilla_conf = conf.env.derive()  # grab a snapshot of conf before you pollute it.

    host_function_name = load_compile_rules_for_host(conf, host_platform)

    installed_platforms = []

    for platform in conf.get_available_platforms():

        platform_spec_vanilla_conf = vanilla_conf.derive()
        platform_spec_vanilla_conf.detach()

        # Determine the compile rules module file and remove it and its support if it does not exist
        compile_rule_script = 'compile_rules_' + host_platform + '_' + platform
        if not os.path.exists(os.path.join(absolute_lmbr_waf_tool_path, compile_rule_script + '.py')):
            conf.remove_platform_from_available_platforms(platform)
            continue

        Logs.info('[INFO] Configure "%s - [%s]"' % (platform, ', '.join(conf.get_supported_configurations(platform))))
        conf.load(compile_rule_script, tooldir=[LMBR_WAF_TOOL_DIR])

        # platform installed
        installed_platforms.append(platform)

        # Keep track of uselib's that we found in the 3rd party config files
        third_party_uselib_map = conf.read_and_mark_3rd_party_libs()
        conf.env['THIRD_PARTY_USELIBS'] = [uselib_name for uselib_name in third_party_uselib_map]

        # Save off configuration values from the uselib which are necessary during build for modules built with the uselib
        configuration_settings_map = {}
        for uselib_name in third_party_uselib_map:
            configuration_values = conf.get_configuration_settings(uselib_name)
            if configuration_values:
                configuration_settings_map[uselib_name] = configuration_values
        conf.env['THIRD_PARTY_USELIB_SETTINGS'] = configuration_settings_map

        for supported_configuration in conf.get_supported_configurations():
            # if the platform isn't going to generate a build command, don't require that the configuration exists either
            if platform in platform_configuration_filter:
                if supported_configuration not in platform_configuration_filter[platform]:
                    continue

            conf.setenv(platform + '_' + supported_configuration, platform_spec_vanilla_conf.derive())
            conf.init_compiler_settings()

            # add the host settings into the current env
            getattr(conf, host_function_name)()

            # make a copy of the config for certain variant loading redirection (e.g. test, dedicated)
            # this way we can pass the raw configuration to the third pary reader to properly configure
            # each library
            config_redirect = supported_configuration

            # Use the normal configurations as a base for dedicated server
            is_dedicated = False
            if config_redirect.endswith('_dedicated'):
                config_redirect = config_redirect.replace('_dedicated', '')
                is_dedicated = True

            # Use the normal configurations as a base for test
            is_test = False
            if '_test' in config_redirect:
                config_redirect = config_redirect.replace('_test', '')
                is_test = True

            # Use the specialized function to load platform specifics
            function_name = 'load_%s_%s_%s_settings' % ( config_redirect, host_platform, platform )
            if not hasattr(conf, function_name):
                conf.fatal('[ERROR] Required Configuration Function \'%s\' not found' % function_name)

            # Try to load the function
            getattr(conf, function_name)()

            # Apply specific dedicated server settings
            if is_dedicated:
                getattr(conf, 'load_dedicated_settings')()

            # Apply specific test settings
            if is_test:
                getattr(conf, 'load_test_settings')()

            if platform in conf.get_supported_platforms():
                # If the platform is still supported (it will be removed if the load settings function fails), then
                # continue to attempt to load the 3rd party uselib defs for the platform

                for uselib_info in third_party_uselib_map:

                    third_party_config_file = third_party_uselib_map[uselib_info][0]
                    path_alias_map = third_party_uselib_map[uselib_info][1]

                    thirdparty_error_msgs, uselib_names = conf.read_3rd_party_config(third_party_config_file, platform, supported_configuration, path_alias_map)

                    for thirdparty_error_msg in thirdparty_error_msgs:
                        conf.warn_once(thirdparty_error_msg)