Ejemplo n.º 1
0
 def add_build_tasks_for_first_host(cfg, host, component, host_group):
     _contribute_headers_tree(cfg, host, component, host_group, True)
     _contribute_shared_tree(cfg, host, component, host_group, True)
     # Build glibc for the build system, and use its localedef to
     # build locales.  The normal glibc configure options are not
     # used for this (they may only be appropriate for the target),
     # so the common support for autoconf-based components isn't
     # used either.
     host_b = host.build_cfg
     srcdir = component.vars.srcdir.get()
     objdir = cfg.objdir_path(host_b, 'glibc-host')
     group = BuildTask(cfg, host_group, 'glibc-host')
     init_task = BuildTask(cfg, group, 'init')
     init_task.add_empty_dir(objdir)
     cfg_task = BuildTask(cfg, group, 'configure')
     cfg_cmd = [
         os.path.join(srcdir, 'configure'),
         '--build=%s' % host_b.triplet,
         '--host=%s' % host_b.triplet, '--prefix=/usr'
     ]
     cfg_cmd.extend(host_b.configure_vars())
     cfg_cmd.append('BUILD_CC=%s' % ' '.join(host_b.tool('c-compiler')))
     cfg_task.add_command(cfg_cmd, cwd=objdir)
     build_task = BuildTask(cfg, group, 'build')
     build_task.add_make([], objdir)
     group = BuildTask(cfg, host_group, 'glibc-locales')
     group.depend('/%s/glibc-host' % host.name)
     # Building the host glibc itself does not depend on the target
     # compiler.  Building the locales does depend on the target
     # compiler (but not on the target libc), as it is used to
     # determine the endianness of each locale.
     group.depend_install(host_b, 'toolchain-1')
     group.provide_install(host_b, 'glibc-locales')
     objdir2 = cfg.objdir_path(host_b, 'glibc-locales')
     instdir = cfg.install_tree_path(host_b, 'glibc-locales')
     init_task = BuildTask(cfg, group, 'init')
     init_task.add_empty_dir(objdir2)
     init_task.add_empty_dir(instdir)
     build_task = BuildTask(cfg, group, 'build')
     build_task.add_python(
         _generate_locales_makefile,
         (cfg, component, srcdir, objdir, objdir2, instdir))
     build_task.add_make([], objdir2)
Ejemplo n.º 2
0
    def setup_build_dir(self):
        """Set up tasks and build directory for a configuration.

        This function creates the specified directory for files
        related to the build process (not files used in the build of
        individual components), removing and recreating it as
        necessary; logs go in the specified directory for logs.  The
        separate directory for sockets is expected to exist and to be
        empty; that directory is separate because paths to Unix-domain
        sockets have a small length limit, so a short path in /tmp is
        appropriate rather than the longer paths used for the rest of
        the build.

        As well as other files, a GNUmakefile is created in the
        specified directory for controlling the build, via 'make all'
        unless a more selective build of particular tasks is required.

        """
        relcfg = self.relcfg
        top_task = BuildTask(relcfg, None, '', True)
        init_task = BuildTask(relcfg, top_task, 'init', True)
        host_indep_task = BuildTask(relcfg, top_task, 'host-indep', True)
        fini_task = BuildTask(relcfg, top_task, 'fini', True)
        host_indep_task.depend('/init')
        fini_task.depend('/host-indep')
        for component in relcfg.list_components():
            component.cls.add_build_tasks_init(relcfg, component, init_task)
            component.cls.add_build_tasks_host_indep(relcfg, component,
                                                     host_indep_task)
            component.cls.add_build_tasks_fini(relcfg, component, fini_task)
        first_host = True
        for host in relcfg.hosts.get():
            host_task = BuildTask(relcfg, top_task, host.name, True)
            host_task.depend('/init')
            fini_task.depend('/%s' % host.name)
            for component in relcfg.list_components():
                component.cls.add_build_tasks_for_host(relcfg, host, component,
                                                       host_task)
                if first_host:
                    component.cls.add_build_tasks_for_first_host(
                        relcfg, host, component, host_task)
                else:
                    component.cls.add_build_tasks_for_other_hosts(
                        relcfg, host, component, host_task)
                for multilib in relcfg.multilibs.get():
                    if first_host:
                        component.cls.add_build_tasks_for_first_host_multilib(
                            relcfg, host, component, host_task, multilib)
                    else:
                        component.cls.add_build_tasks_for_other_hosts_multilib(
                            relcfg, host, component, host_task, multilib)
            first_host = False
        build_objdir = self.build_objdir
        if os.access(build_objdir, os.F_OK):
            shutil.rmtree(build_objdir)
        os.makedirs(build_objdir)
        os.makedirs(self.logdir, exist_ok=True)
        makefile_text = top_task.makefile_text(self)
        makefile_name = os.path.join(build_objdir, 'GNUmakefile')
        with open(makefile_name, 'w', encoding='utf-8') as file:
            file.write(makefile_text)