Esempio n. 1
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
Esempio n. 2
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))
Esempio n. 3
0
def get_available_platforms(conf):

    global AVAILABLE_PLATFORMS
    if AVAILABLE_PLATFORMS is None:
        # Check to see if there is already a validated platform list and set the available platforms to that
        # if possible, otherwise initialize with the default supported platform for the current host platform
        validated_platforms = []
        try:
            validated_platforms_node = conf.get_validated_platforms_node()
            parsed_validated_platforms = conf.parse_json_file(validated_platforms_node)
            validated_platforms = [x.encode('ascii') for x in parsed_validated_platforms]  # Loaded data is unicode so convert it to ASCII
        except:
            pass

        if len(validated_platforms) == 0:
            host = Utils.unversioned_sys_platform()
            validated_platforms = list(PLATFORMS[host])

        AVAILABLE_PLATFORMS = validated_platforms

    return AVAILABLE_PLATFORMS