コード例 #1
0
def _CheckPlatform(key, raw_value, value):
    if platform.IsValid(value):
        return True

    logging.warning("Environment variable '%s' is '%s', which is invalid.",
                    key, raw_value)
    logging.warning('Valid platforms: %s', platform.GetAll())
    return False
コード例 #2
0
def _LoadPlatformConfig(platform_name):
    """Loads a platform specific configuration.

  The function will use the provided platform name to load
  a python file with a matching name that contains the platform
  specific configuration.

  Args:
    platform_name: Platform name.

  Returns:
    Instance of a class derived from PlatformConfigBase.
  """
    try:
        logging.debug('Loading platform configuration for "%s".',
                      platform_name)
        if platform.IsValid(platform_name):
            platform_path = os.path.join(paths.REPOSITORY_ROOT,
                                         platform.Get(platform_name).path)
            module_path = os.path.join(platform_path, 'gyp_configuration.py')
            if not _ModuleLoaded('platform_module', module_path):
                platform_module = imp.load_source('platform_module',
                                                  module_path)
            else:
                platform_module = sys.modules['platform_module']
        else:
            module_path = os.path.join('config', '%s.py' % platform_name)
            platform_module = importlib.import_module('config.%s' %
                                                      platform_name)
    except ImportError:
        logging.exception('Unable to import "%s".', module_path)
        return None

    if not hasattr(platform_module, 'CreatePlatformConfig'):
        logging.error('"%s" does not contain CreatePlatformConfig.',
                      module_path)
        return None

    try:
        platform_configuration = platform_module.CreatePlatformConfig()
        platform_configuration.SetDirectory(platform_path)
        return platform_configuration
    except RuntimeError:
        logging.exception('Exception in CreatePlatformConfig.')
        return None
コード例 #3
0
    def _MakeCommonArguments(self):
        """Makes a list of GYP arguments that are common to all configurations."""

        platform_name = self.platform_configuration.GetName()
        if not platform.IsValid(platform_name):
            raise RuntimeError('Invalid platform: %s' % platform_name)

        source_tree_dir = paths.REPOSITORY_ROOT
        self.common_args = [
            # Set the build format.
            '--format={}-{}'.format(
                self.platform_configuration.GetBuildFormat(), platform_name),

            # Set the depth argument to the top level directory. This will define
            # the DEPTH variable which is the relative path between the directory
            # containing the processed build file and the top level directory.
            '--depth={}'.format(source_tree_dir),

            # Set the top of the source tree.
            '--toplevel-dir={}'.format(source_tree_dir),
        ]

        # Pass through the debug options.
        for debug in self.options.debug:
            self.common_args.append('--debug=%s' % debug)

        if self.options.check:
            self.common_args.append('--check')

        # Append common GYP variables.
        common_variables = {
            'OS':
            'starboard',
            'CC_HOST':
            os.environ.get('CC_HOST', os.environ.get('CC', '')),
            'host_os':
            _GetHostOS(),
            'starboard_path':
            os.path.relpath(platform.Get(platform_name).path, source_tree_dir),
            'starboard_platform_name':
            platform_name,
        }

        _AppendVariables(common_variables, self.common_args)

        # Append generator variables.
        generator_variables = {
            # Set the output folder name; affects all generators but MSVS.
            'output_dir': 'out',
        }
        _AppendGeneratorVariables(generator_variables, self.common_args)

        # Append GYPI includes which will be included by GYP before any processed
        # build file.
        gyp_includes = [
            os.path.join(paths.REPOSITORY_ROOT, 'starboard', 'build',
                         'base_configuration.gypi'),

            # TODO: Remove dependency on common.gypi by moving the required bits
            # into base_configuration.gypi.
            os.path.join(paths.REPOSITORY_ROOT, 'build', 'common.gypi'),
        ]
        gyp_includes.extend(self.platform_configuration.GetIncludes())
        if self.app_configuration:
            gyp_includes[:0] = self.app_configuration.GetPreIncludes()
            gyp_includes.extend(self.app_configuration.GetPostIncludes())
        _AppendIncludes(gyp_includes, self.common_args)