Beispiel #1
0
    def start(self):
        # Use a common prefix for the build tools for all the configurations
        # so that it can be reused
        config = Config()
        os.environ.clear()
        os.environ.update(self.config._pre_environ)
        config.prefix = self.config.build_tools_prefix
        config.home_dir = self.config.home_dir
        config.load()

        config.prefix = self.config.build_tools_prefix
        config.build_tools_prefix = self.config.build_tools_prefix
        config.sources = self.config.build_tools_sources
        config.build_tools_sources = self.config.build_tools_sources
        config.cache_file = self.config.build_tools_cache
        config.build_tools_cache = self.config.build_tools_cache
        config.external_recipes = self.config.external_recipes

        if config.toolchain_prefix and not os.path.exists(
                config.toolchain_prefix):
            raise ConfigurationError(
                _("Please run bootstrap without any '-c' arguments first to setup build-tools for this machine"
                  ))
        if not os.path.exists(config.prefix):
            os.makedirs(config.prefix)
        if not os.path.exists(config.sources):
            os.makedirs(config.sources)

        config.do_setup_env()
        cookbook = CookBook(config)
        recipes = self.BUILD_TOOLS
        recipes += self.PLAT_BUILD_TOOLS.get(self.config.platform, [])
        oven = Oven(recipes, cookbook)
        oven.start_cooking()
        self.config.do_setup_env()
Beispiel #2
0
    def start(self):
        if not git.check_line_endings(self.config.platform):
            raise ConfigurationError(
                "git is configured to use automatic line "
                "endings conversion. You can fix it running:\n"
                "$git config core.autocrlf false")
        self.prefix = self.config.toolchain_prefix
        self.platform = self.config.target_platform
        self.arch = self.config.target_arch
        if self.arch == Architecture.X86:
            self.version = 'w32'
        else:
            self.version = 'w64'
        self.platform = self.config.platform

        self.check_dirs()
        if self.platform == Platform.WINDOWS:
            # For wget
            self.install_mingwget_deps()
        self.install_mingw()
        self.remove_mingw_cpp()
        self.add_non_prefixed_strings()
        if self.platform == Platform.WINDOWS:
            # After mingw is beeing installed
            self.install_bin_deps()
        self.install_gl_headers()
        self.install_python_sdk()
Beispiel #3
0
    def start(self):
        if not git.check_line_endings(self.config.platform):
            raise ConfigurationError(
                "git is configured to use automatic line "
                "endings conversion. You can fix it running:\n"
                "$git config core.autocrlf false")
        self.prefix = self.config.toolchain_prefix
        self.perl_prefix = self.config.mingw_perl_prefix
        self.platform = self.config.target_platform
        self.arch = self.config.target_arch
        if self.arch == Architecture.X86:
            self.version = 'w32'
        else:
            self.version = 'w64'
        self.platform = self.config.platform

        self.check_dirs()
        if self.platform == Platform.WINDOWS:
            self.msys_mingw_bindir = Path(shutil.which('mingw-get')).parent
            self.install_mingwget_deps()
        self.install_mingw()
        if self.platform == Platform.WINDOWS:
            self.remove_mingw_cpp()
        self.add_non_prefixed_strings()
        if self.platform == Platform.WINDOWS:
            # After mingw has been installed
            self.install_bin_deps()
        self.install_gl_headers()
        if self.platform == Platform.WINDOWS:
            self.install_openssl_mingw_perl()
Beispiel #4
0
 def _load_cmd_config(self, filename):
     if filename is not None:
         if os.path.exists(filename):
             self._parse(filename, reset=False)
             self.filename = DEFAULT_CONFIG_FILE
         else:
             raise ConfigurationError(_("Configuration file %s doesn't "
                                        "exists") % filename)
Beispiel #5
0
 def recipe_remotes(self, recipe_name):
     if recipe_name in self.recipes_remotes:
         rrs = self.recipes_remotes[recipe_name]
         if not isinstance(rrs, dict):
             raise ConfigurationError(
                 'recipes_remotes value for recipe %s '
                 'must be a dict in the form '
                 '{ \'remote-name\' : \'remote-url\' }' % recipe_name)
         return rrs
     return {}
Beispiel #6
0
    def _load_cmd_config(self, filenames):
        if filenames is not None:
            for f in filenames:
                if not os.path.exists(f):
                    f = os.path.join(CONFIG_DIR, f + "." + CONFIG_EXT)

                if os.path.exists(f):
                    self._parse(f, reset=False)
                else:
                    raise ConfigurationError(_("Configuration file %s doesn't "
                                               "exist") % f)
Beispiel #7
0
 def check_arch():
     native_arch = shell.check_call('dpkg --print-architecture')
     if native_arch == arch:
         return
     foreign_archs = shell.check_call('dpkg --print-foreign-architectures')
     if arch in foreign_archs.split():
         return
     raise ConfigurationError(('Architecture %s is missing from your setup. ' + \
                               'You can add it with: "dpkg --add-architecture %s",' + \
                               ' then run "apt-get update."') \
                               % (arch, arch))
Beispiel #8
0
    def _load_cmd_config(self, filenames):
        if filenames is not None:
            for f in filenames:
                # Check if the config specified is a complete path, else search
                # in the user config directory
                if not os.path.exists(f):
                    f = os.path.join(USER_CONFIG_DIR, f + "." + CONFIG_EXT)

                if os.path.exists(f):
                    self._parse(f, reset=False)
                else:
                    raise ConfigurationError(_("Configuration file %s doesn't "
                                               "exist") % f)
Beispiel #9
0
 def start(self, jobs=0):
     if not git.check_line_endings(self.config.platform):
         raise ConfigurationError("git is configured to use automatic line "
                 "endings conversion. Please change that by running:\n"
                 "`git config --global core.autocrlf false` inside the MSYS shell")
     self.check_dirs()
     if self.platform == Platform.WINDOWS:
         self.fix_mingw()
         self.fix_openssl_mingw_perl()
         self.fix_bin_deps()
         # FIXME: This uses the network
         self.install_mingwget_deps()
         self.fix_mingw_unused()
Beispiel #10
0
 def start(self):
     if not git.check_line_endings(self.config.platform):
         raise ConfigurationError(
             "git is configured to use automatic line "
             "endings conversion. You can fix it running:\n"
             "$git config core.autocrlf false")
     self.check_dirs()
     self.fix_mingw()
     if self.platform == Platform.WINDOWS:
         self.fix_openssl_mingw_perl()
         self.fix_bin_deps()
         # FIXME: This uses the network
         self.install_mingwget_deps()
         self.fix_mingw_unused()
Beispiel #11
0
    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)
Beispiel #12
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)
Beispiel #13
0
 def _load_last_defaults(self, default_variants):
     # Set build tools defaults
     self.set_property('build_tools_prefix',
                       os.path.join(self.home_dir, 'build-tools'))
     self.set_property(
         'build_tools_sources',
         os.path.join(self.home_dir, 'sources', 'build-tools'))
     self.set_property('build_tools_cache', 'build-tools.cache')
     # Set target platform defaults
     target_platform = self.target_platform
     if target_platform == Platform.WINDOWS and not self.prefix_is_build_tools(
     ):
         if default_variants.visualstudio:
             target_platform = 'msvc'
             # Debug CRT needs a separate prefix
             if default_variants.vscrt == 'mdd':
                 target_platform += '-debug'
             # Check for invalid configuration of a custom Visual Studio path
             if self.vs_install_path and not self.vs_install_version:
                 raise ConfigurationError(
                     'vs_install_path was set, but vs_install_version was not'
                 )
         else:
             target_platform = 'mingw'
         # If the cmd config set the prefix, append the variant modifier to
         # it so that we don't clobber different toolchain builds
         if self.prefix is not None:
             self.prefix += '.' + target_platform
     self.set_property(
         'prefix',
         os.path.join(self.home_dir, "dist",
                      "%s_%s" % (target_platform, self.target_arch)))
     self.set_property(
         'sources',
         os.path.join(self.home_dir, "sources",
                      "%s_%s" % (target_platform, self.target_arch)))
     self.set_property(
         'logs',
         os.path.join(self.home_dir, "logs",
                      "%s_%s" % (target_platform, self.target_arch)))
     self.set_property('cache_file',
                       "%s_%s.cache" % (target_platform, self.target_arch))
     self.set_property('install_dir', self.prefix)
     self.set_property('local_sources', self._default_local_sources_dir())
Beispiel #14
0
    def _get_toolchain_target_platform_arch(self):
        platform_arch = '{}_' + self.target_arch
        if self.target_platform != Platform.WINDOWS or self.prefix_is_build_tools():
            return platform_arch.format(self.target_platform)
        if not self.variants.visualstudio:
            return platform_arch.format('mingw')
        # When building with Visual Studio, we can target (MSVC, UWP) x (debug, release)
        if self.variants.uwp:
            target_platform = 'uwp'
        else:
            target_platform = 'msvc'
        # Debug CRT needs a separate prefix
        if self.variants.vscrt == 'mdd':
            target_platform += '-debug'
        # Check for invalid configuration of a custom Visual Studio path
        if self.vs_install_path and not self.vs_install_version:
            raise ConfigurationError('vs_install_path was set, but vs_install_version was not')

        return platform_arch.format(target_platform)
Beispiel #15
0
 def set_property(self, name, value, force=False):
     if name not in self._properties:
         raise ConfigurationError('Unkown key %s' % name)
     if force or getattr(self, name) is None:
         setattr(self, name, value)
Beispiel #16
0
    def load(self, filename=None, variants_override=None):
        if variants_override is None:
            variants_override = []

        # First load the default configuration
        self.load_defaults()

        # Next parse the user configuration file USER_CONFIG_FILE
        # which overrides the defaults
        self._load_user_config()

        # Ensure that Cerbero config files know about these variants, and that
        # they override the values from the user configuration file above
        self.variants += variants_override

        # Next, if a config file is provided use it to override the settings
        # again (set the target, f.ex.)
        self._load_cmd_config(filename)

        # Create a copy of the config for each architecture in case we are
        # building Universal binaries
        if self.target_arch == Architecture.UNIVERSAL:
            arch_config = {}

            if isinstance(self.universal_archs, list):
                # Simple list of architectures, just duplicate all the config
                for arch in self.universal_archs:
                    arch_config[arch] = self._copy(arch)
            elif isinstance(self.universal_archs, dict):
                # Map of architectures to the corresponding config file. We
                # do this so that we don't need to duplicate arch specific
                # config again in the universal config.
                for arch, config_file in list(self.universal_archs.items()):
                    arch_config[arch] = self._copy(arch)
                    # Allow the config to detect whether this config is
                    # running under a universal setup and some
                    # paths/configuration need to change
                    arch_config[arch].variants += ['universal']
                    if config_file is not None:
                        # This works because the override config files are
                        # fairly light. Things break if they are more complex
                        # as load config can have side effects in global state
                        d = os.path.dirname(filename[0])
                        for f in filename:
                            if 'universal' in f:
                                d = os.path.dirname(f)
                        arch_config[arch]._load_cmd_config(
                            [os.path.join(d, config_file)])
            else:
                raise ConfigurationError(
                    'universal_archs must be a list or a dict')

            self.arch_config = arch_config

        # Parse the currently-known list of variants and use it to set the last
        # defaults
        default_variants = Variants(self.variants)
        # Fill the defaults in the config which depend on the configuration we
        # loaded above
        self._load_last_defaults(default_variants)
        # Load the platform-specific (linux|windows|android|darwin).config
        self._load_platform_config()
        # And validate properties
        self._validate_properties()

        for config in list(self.arch_config.values()):
            if self.target_arch == Architecture.UNIVERSAL:
                config.sources = os.path.join(self.sources, config.target_arch)
                config.prefix = os.path.join(self.prefix)
            # qmake_path is different for each arch in android-universal, but
            # not in ios-universal.
            qtpkgdir, qmake5 = detect_qt5(
                config.target_platform, config.target_arch,
                self.target_arch == Architecture.UNIVERSAL)
            config.set_property('qt5_qmake_path', qmake5)
            config.set_property('qt5_pkgconfigdir', qtpkgdir)
            # We already called these functions on `self` above
            if config is not self:
                config._load_last_defaults(default_variants)
                config._load_platform_config()
                config._validate_properties()

        # Ensure that variants continue to override all other configuration
        self.variants += variants_override
        # Build variants before copying any config
        self.variants = Variants(self.variants)
        if not self.prefix_is_executable() and self.variants.gi:
            m.warning(
                _("gobject introspection requires an executable "
                  "prefix, 'gi' variant will be removed"))
            self.variants.gi = False

        for c in list(self.arch_config.values()):
            c.variants = self.variants

        self.do_setup_env()

        if self.can_use_msvc():
            m.message(
                'Building recipes with Visual Studio {} whenever possible'.
                format(get_vs_year_version(self.msvc_version)))
            if self.vs_install_path:
                m.message('Using Visual Studio installed at {!r}'.format(
                    self.vs_install_path))

        # Store current os.environ data
        for c in list(self.arch_config.values()):
            self._create_path(c.local_sources)
            self._create_path(c.sources)
            self._create_path(c.logs)
        m.message('Install prefix will be {}'.format(self.prefix))
Beispiel #17
0
    def load(self, filename=None):

        # First load the default configuration
        self.load_defaults()

        # Next parse the main configuration file
        self._load_main_config()

        # Next, if a config file is provided use it to override the settings
        # from the main configuration file
        self._load_cmd_config(filename)

        # We need to set py_prefix as soon as possible
        if "python3" in self.variants:
            # FIXME Find a smarter way to figure out what version of python3
            # is built.
            self.py_prefix = 'lib/python3.3'

        # Create a copy of the config for each architecture in case we are
        # building Universal binaries
        if self.target_arch == Architecture.UNIVERSAL:
            arch_config = {}

            if isinstance(self.universal_archs, list):
                # Simple list of architectures, just duplicate all the config
                for arch in self.universal_archs:
                    arch_config[arch] = self._copy(arch)
            elif isinstance(self.universal_archs, dict):
                # Map of architectures to the corresponding config file. We
                # do this so that we don't need to duplicate arch specific
                # config again in the universal config.
                for arch, config_file in self.universal_archs.items():
                    arch_config[arch] = self._copy(arch)
                    if config_file is not None:
                        # This works because the override config files are
                        # fairly light. Things break if they are more complex
                        # as load config can have side effects in global state
                        d = os.path.dirname(filename[0])
                        arch_config[arch]._load_cmd_config(
                            [os.path.join(d, config_file)])
            else:
                raise ConfigurationError(
                    'universal_archs must be a list or a dict')

            self.arch_config = arch_config

        # Finally fill the missing gaps in the config
        self._load_last_defaults()

        self._load_platform_config()

        # And validate properties
        self._validate_properties()
        self._raw_environ = os.environ.copy()

        for config in self.arch_config.values():
            config._restore_environment()
            if self.target_arch == Architecture.UNIVERSAL:
                config.sources = os.path.join(self.sources, config.target_arch)
                config.prefix = os.path.join(self.prefix)
            config._load_platform_config()
            config._load_last_defaults()
            config._validate_properties()
            config._raw_environ = os.environ.copy()

        # Build variants before copying any config
        self.variants = Variants(self.variants)
        if not self.prefix_is_executable() and self.variants.gi:
            m.warning(
                _("gobject introspection requires an executable "
                  "prefix, 'gi' variant will be removed"))
            self.variants.gi = False

        for c in self.arch_config.values():
            c.variants = self.variants

        self.do_setup_env()

        # Store current os.environ data
        for c in self.arch_config.values():
            self._create_path(c.local_sources)
            self._create_path(c.sources)
            self._create_path(c.logs)
Beispiel #18
0
 def _check_windows_is_x86_64(self):
     if self.target_platform == Platform.WINDOWS and \
            self.arch == Architecture.X86:
         raise ConfigurationError(
             'The GCC/MinGW toolchain requires an x86 64-bit OS.')