Ejemplo n.º 1
0
def _GetPlatformInfosDict():
    """Find Starboard ports that support building packages.

  Returns:
    A dict of [platform_name, Class] where Class inherits from PackageBase
  """
    packager_modules = {}
    for platform_name in platform.GetAll():
        platform_info = platform.Get(platform_name)
        # From the relative path to the starboard directory, construct a full
        # python package name and attempt to load it.
        package_class = _GetPackageClass(platform_info)
        if not package_class:
            continue
        # Populate a mapping from platform name to the module containing the
        # Package class.
        try:
            for supported_name in package_class.SupportedPlatforms():
                if supported_name in packager_modules:
                    logging.warning(
                        'Packager for %s is defined in multiple modules.',
                        supported_name)
                else:
                    packager_modules[supported_name] = platform_info
        except Exception as e:  # pylint: disable=broad-except
            # Catch all exceptions to avoid an error in one platform's Packager
            # halting the script for other platforms' packagers.
            logging.warning(
                'Exception iterating supported platform for platform '
                '%s: %s.', platform_info.name, e)

    return packager_modules
Ejemplo n.º 2
0
    def GetIncludes(self):
        """Get a list of absolute paths to gypi files to include in order.

    These files will be included by GYP before any processed .gyp file. The
    application may add more gypi files to be processed before or after the
    files specified by this function.

    Returns:
      An ordered list containing absolute paths to .gypi files.
    """
        platform_info = platform.Get(self.GetName())
        if not platform_info:
            return []

        return [os.path.join(platform_info.path, 'gyp_configuration.gypi')]
Ejemplo n.º 3
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
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def main():
    platform_info = platform.Get(sys.argv[1])
    if not platform_info:
        return 1
    print platform_info.path
    return 0