示例#1
0
 def _load_packages_from_file(self, filepath, custom=None):
     packages = []
     d = {
         'Platform': Platform,
         'Architecture': Architecture,
         'Distro': Distro,
         'DistroVersion': DistroVersion,
         'License': License,
         'package': package,
         'PackageType': PackageType,
         'custom': custom
     }
     d_keys = set(list(d.keys()))
     try:
         new_d = d.copy()
         parse_file(filepath, new_d)
         # List new objects parsed added to the globals dict
         diff_vals = [new_d[x] for x in set(new_d.keys()) - d_keys]
         # Find all objects inheriting from Package
         for package_cls in [
                 x for x in diff_vals if self._is_package_class(x)
         ]:
             pkg = self._load_package_from_file(package_cls, filepath,
                                                custom)
             if pkg is not None:
                 packages.append(pkg)
     except Exception:
         m.warning("Error loading package from file %s" % filepath)
         traceback.print_exc()
     return packages
示例#2
0
 def _load_universal_recipe(self,
                            globals_dict,
                            recipe_cls,
                            recipe_cls_key,
                            filepath,
                            custom=None):
     if self._config.target_platform in [Platform.IOS, Platform.DARWIN]:
         recipe = crecipe.UniversalFlatRecipe(self._config)
     else:
         recipe = crecipe.UniversalRecipe(self._config)
     for c in list(self._config.arch_config.keys()):
         conf = self._config.arch_config[c]
         conf.prefix = os.path.join(self._config.prefix, c)
         # For univeral recipes, we need to parse again the recipe file.
         # Otherwise, class variables with mutable types like the "deps"
         # dictionary are reused in new instances
         if recipe_cls is None:
             parsed_dict = dict(globals_dict)
             parse_file(filepath, parsed_dict)
             recipe_cls = parsed_dict[recipe_cls_key]
         r = self._load_recipe_from_class(recipe_cls, conf, filepath)
         if r is not None:
             recipe.add_recipe(r)
         recipe_cls = None
     if recipe.is_empty():
         return None
     return recipe
示例#3
0
    def _load_recipes_from_file(self, filepath, custom=None):
        recipes = []
        d = {'Platform': Platform, 'Architecture': Architecture,
                'BuildType': BuildType, 'SourceType': SourceType,
                'Distro': Distro, 'DistroVersion': DistroVersion,
                'License': License, 'recipe': crecipe, 'os': os,
                'BuildSteps': crecipe.BuildSteps,
                'InvalidRecipeError': InvalidRecipeError,
                'FatalError': FatalError,
                'custom': custom, '_': _, 'shell': shell}
        d_keys = set(list(d.keys()))
        try:
            new_d = d.copy ()
            parse_file(filepath, new_d)
            # List new objects parsed added to the globals dict
            diff_keys = [x for x in set(new_d.keys()) - d_keys]
            # Find all objects inheriting from Recipe
            for recipe_cls_key in [x for x in diff_keys if self._is_recipe_class(new_d[x])]:
                if self._config.target_arch != Architecture.UNIVERSAL:
                    recipe = self._load_recipe_from_class(
                        new_d[recipe_cls_key], self._config, filepath, custom)
                else:
                    recipe = self._load_universal_recipe(d, new_d[recipe_cls_key],
                        recipe_cls_key, filepath)

                if recipe is not None:
                    recipes.append(recipe)
        except Exception:
            m.warning("Error loading recipe in file %s" % (filepath))
            print(traceback.format_exc())
        return recipes
示例#4
0
    def _load_package_from_file(self, filepath):
        mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])

        try:
            d = {'Platform': Platform, 'Architecture': Architecture,
                 'Distro': Distro, 'DistroVersion': DistroVersion,
                 'License': License, 'package': package,
                 'PackageType': PackageType}
            parse_file(filepath, d)
            if 'Package' in d:
                p = d['Package'](self._config, self, self.cookbook)
            elif 'SDKPackage' in d:
                p = d['SDKPackage'](self._config, self)
            elif 'InstallerPackage' in d:
                p = d['InstallerPackage'](self._config, self)
            elif 'App' in d:
                p = d['App'](self._config, self, self.cookbook)
            elif 'AppExtensionPackage' in d:
                p = d['AppExtensionPackage'](self._config, self, self.cookbook)
            else:
                raise Exception('Package, SDKPackage, InstallerPackage or App '
                                'class not found')
            p.__file__ = os.path.abspath(filepath)
            p.prepare()
            # reload files from package now that we called prepare that
            # may have changed it
            p.load_files()
            return p
        except Exception, ex:
            import traceback
            traceback.print_exc()
            m.warning("Error loading package %s" % ex)
示例#5
0
文件: config.py 项目: fluendo/cerbero
    def _parse(self, filename):
        config = {'os': os, '__file__': filename}
        for prop in self._properties:
            if hasattr(self, prop):
                config[prop] = getattr(self, prop)

        try:
            parse_file(filename, config)
        except:
            raise ConfigurationError(_('Could not include config file (%s)') %
                             filename)
        for key in self._properties:
            if key in config:
                self.set_property(key, config[key], True)
示例#6
0
文件: config.py 项目: kuggaa/cerbero
    def _parse(self, filename):
        config = {'os': os, '__file__': filename}
        for prop in self._properties:
            if hasattr(self, prop):
                config[prop] = getattr(self, prop)

        try:
            parse_file(filename, config)
        except:
            raise ConfigurationError(
                _('Could not include config file (%s)') % filename)
        for key in self._properties:
            if key in config:
                self.set_property(key, config[key], True)
示例#7
0
 def _load_recipe_from_file(self, filepath, custom=None):
     mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])
     if self._config.target_arch == Architecture.UNIVERSAL:
         if self._config.target_platform in [Platform.IOS, Platform.DARWIN]:
             recipe = crecipe.UniversalFlatRecipe(self._config)
         else:
             recipe = crecipe.UniversalRecipe(self._config)
     for c in self._config.arch_config.keys():
         try:
             d = {
                 'Platform': Platform,
                 'Architecture': Architecture,
                 'BuildType': BuildType,
                 'SourceType': SourceType,
                 'Distro': Distro,
                 'DistroVersion': DistroVersion,
                 'License': License,
                 'recipe': crecipe,
                 'os': os,
                 'BuildSteps': crecipe.BuildSteps,
                 'InvalidRecipeError': InvalidRecipeError,
                 'FatalError': FatalError,
                 'custom': custom,
                 '_': _,
                 'shell': shell
             }
             parse_file(filepath, d)
             conf = self._config.arch_config[c]
             if self._config.target_arch == Architecture.UNIVERSAL:
                 if self._config.target_platform not in [
                         Platform.IOS, Platform.DARWIN
                 ]:
                     conf.prefix = os.path.join(self._config.prefix, c)
             r = d['Recipe'](conf)
             r.__file__ = os.path.abspath(filepath)
             self._config.arch_config[c].do_setup_env()
             r.prepare()
             if self._config.target_arch == Architecture.UNIVERSAL:
                 recipe.add_recipe(r)
             else:
                 return r
         except InvalidRecipeError as e:
             self._invalid_recipes[r.name] = e
         except Exception as ex:
             m.warning("Error loading recipe in file %s %s" %
                       (filepath, ex))
     if self._config.target_arch == Architecture.UNIVERSAL:
         if not recipe.is_empty():
             return recipe
     return None
示例#8
0
    def _parse(self, filename, reset=True):
        config = {'os': os, '__file__': filename, 'env': self.config_env,
                  'cross': self.cross_compiling()}
        if not reset:
            for prop in self._properties:
                if hasattr(self, prop):
                    config[prop] = getattr(self, prop)

        try:
            parse_file(filename, config)
        except:
            raise ConfigurationError(_('Could not include config file (%s)') %
                             filename)
        for key in self._properties:
            if key in config:
                self.set_property(key, config[key], True)
示例#9
0
def upstream_recipe(name):
    env = {
        'Platform': Platform, 'Architecture': Architecture,
        'BuildType': BuildType, 'SourceType': SourceType,
        'Distro': Distro, 'DistroVersion': DistroVersion,
        'License': License, 'recipe': crecipe, 'os': os,
        'BuildSteps': crecipe.BuildSteps,
        'InvalidRecipeError': InvalidRecipeError,
        'FatalError': FatalError,
        'custom': custom, '_': _, 'shell': shell,
        'LibraryType' : LibraryType
    }
    filepath = os.path.join(upstream_recipes_path, name + CookBook.RECIPE_EXT)
    parse_file(filepath, env)
    recipe = env['Recipe']
    if hasattr(recipe, 'patches') and recipe.patches is not None:
        recipe.patches = [os.path.join(upstream_recipes_path, x) for x in recipe.patches]
    return recipe
示例#10
0
 def _load_recipe_from_file(self, filepath, custom=None):
     mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])
     if self._config.target_arch == Architecture.UNIVERSAL:
         if self._config.target_platform in [Platform.IOS, Platform.DARWIN]:
             recipe = crecipe.UniversalFlatRecipe(self._config)
         else:
             recipe = crecipe.UniversalRecipe(self._config)
     for c in list(self._config.arch_config.keys()):
         try:
             d = {'Platform': Platform, 'Architecture': Architecture,
                  'BuildType': BuildType, 'SourceType': SourceType,
                  'Distro': Distro, 'DistroVersion': DistroVersion,
                  'License': License, 'recipe': crecipe, 'os': os,
                  'BuildSteps': crecipe.BuildSteps,
                  'InvalidRecipeError': InvalidRecipeError,
                  'FatalError': FatalError,
                  'custom': custom, '_': _, 'shell': shell}
             parse_file(filepath, d)
             conf = self._config.arch_config[c]
             if self._config.target_arch == Architecture.UNIVERSAL:
                 if self._config.target_platform not in [Platform.IOS,
                         Platform.DARWIN]:
                     conf.prefix = os.path.join(self._config.prefix, c)
             r = d['Recipe'](conf)
             r.__file__ = os.path.abspath(filepath)
             self._config.arch_config[c].do_setup_env()
             r.prepare()
             if self._config.target_arch == Architecture.UNIVERSAL:
                 recipe.add_recipe(r)
             else:
                 return r
         except InvalidRecipeError as e:
             self._invalid_recipes[r.name] = e
         except Exception as ex:
             m.warning("Error loading recipe in file %s %s" %
                       (filepath, ex))
     if self._config.target_arch == Architecture.UNIVERSAL:
         if not recipe.is_empty():
             return recipe
     return None
示例#11
0
    def _get(self):

        tools = Build_Tools(self.config)
        store  = PackagesStore(self.config)
        cookbook = CookBook(self.config)

        names  = tools.BUILD_TOOLS
        names += tools.PLAT_BUILD_TOOLS.get(self.config.platform, [])
        recipes ={}
        path = os.path.join(self.config.packages_dir,'custom.py')
        d={}
        parse_file(path,d )
        version = d['GStreamer'].version

        for name in names:
            recipes[name] = cookbook.get_recipe(name).version

        pkgname ='build-tools'

        tarball = '%s-%s-%s-%s'%( pkgname,
            self.config.platform,
            self.config.arch,
            version
        )

        return {
            'name':pkgname,
            'version': version,
            'prefix':self.config.build_tools_prefix,
            'deps':[],
            'platform':self.config.platform,
            'arch':self.config.arch,

            'tarball':{
                'runtime':{ 'filename':tarball +'.tar.bz2'}
            },
            'recipes': recipes
        }
示例#12
0
    def _load_package_from_file(self, filepath):
        mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])

        try:
            d = {
                'Platform': Platform,
                'Architecture': Architecture,
                'Distro': Distro,
                'DistroVersion': DistroVersion,
                'License': License,
                'package': package,
                'PackageType': PackageType
            }
            parse_file(filepath, d)
            if 'Package' in d:
                p = d['Package'](self._config, self, self.cookbook)
            elif 'SDKPackage' in d:
                p = d['SDKPackage'](self._config, self)
            elif 'InstallerPackage' in d:
                p = d['InstallerPackage'](self._config, self)
            elif 'App' in d:
                p = d['App'](self._config, self, self.cookbook)
            elif 'AppExtensionPackage' in d:
                p = d['AppExtensionPackage'](self._config, self, self.cookbook)
            else:
                raise Exception('Package, SDKPackage, InstallerPackage or App '
                                'class not found')
            p.__file__ = os.path.abspath(filepath)
            p.prepare()
            # reload files from package now that we called prepare that
            # may have changed it
            p.load_files()
            return p
        except Exception, ex:
            import traceback
            traceback.print_exc()
            m.warning("Error loading package %s" % ex)