Exemple #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)
Exemple #2
0
def configure_general_compile_settings(conf):
    """
    Perform all the necessary configurations
    :param conf:        Configuration context
    """
    # Load general compile settings
    load_setting_count = 0
    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()

    for compile_settings in PLATFORM_COMPILE_SETTINGS:
        t_path = os.path.join(absolute_lmbr_waf_tool_path, "{}.py".format(compile_settings))
        if os.path.exists(os.path.join(absolute_lmbr_waf_tool_path, "{}.py".format(compile_settings))):
            conf.load(compile_settings, tooldir=[LMBR_WAF_TOOL_DIR])
            load_setting_count += 1
    if load_setting_count == 0:
        conf.fatal('[ERROR] Unable to load any general compile settings modules')

    # load the android specific tools, if enabled
    if any(platform for platform in conf.get_available_platforms() if platform.startswith('android')):
        # 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])
Exemple #3
0
def remove_platform_from_available_platforms(conf, platform_to_remove):

    current_available_platforms = conf.get_available_platforms()
    updated_available_platforms = []
    for current_available_platform in current_available_platforms:
        if current_available_platform != platform_to_remove:
            updated_available_platforms.append(current_available_platform)

    global AVAILABLE_PLATFORMS
    AVAILABLE_PLATFORMS = updated_available_platforms
Exemple #4
0
def update_validated_platforms(conf):

    current_available_platforms = conf.get_available_platforms()
    validated_platforms_node = conf.get_validated_platforms_node()

    # write out the list of platforms that were successfully configured
    json_data = json.dumps(current_available_platforms)
    try:
        validated_platforms_node.write(json_data)
    except Exception as e:
        # If the file cannot be written to, warn, but dont fail.
        Logs.warn("[WARN] Unable to update validated configurations file '{}' ({})".format(validated_platforms_node.abspath(),e.message))
Exemple #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 = 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)
Exemple #6
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)