Esempio n. 1
0
 def add_build_tasks_for_first_host_multilib(cfg, host, component,
                                             host_group, multilib):
     if multilib.libc is not component:
         return
     host_b = host.build_cfg
     inst_1 = cfg.install_tree_path(host_b, 'toolchain-1')
     bindir_1 = os.path.join(inst_1, cfg.bindir_rel.get())
     target_build = multilib.build_cfg
     srcdir = component.vars.srcdir.get()
     objdir = cfg.objdir_path(target_build, 'glibc')
     instdir = cfg.install_tree_path(target_build, 'glibc')
     group = BuildTask(cfg, host_group, 'glibc-%s' % target_build.name)
     group.depend_install(host_b, 'toolchain-1')
     group.env_prepend('PATH', bindir_1)
     group.provide_install(target_build, 'glibc')
     init_task = BuildTask(cfg, group, 'init')
     init_task.add_empty_dir(objdir)
     init_task.add_empty_dir(instdir)
     cfg_task = BuildTask(cfg, group, 'configure')
     cfg_cmd = [
         os.path.join(srcdir, 'configure'),
         '--build=%s' % host_b.triplet,
         '--host=%s' % target_build.triplet, '--prefix=/usr'
     ]
     cfg_cmd.extend(component.vars.configure_opts.get())
     cfg_cmd.extend(target_build.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)
     install_task = BuildTask(cfg, group, 'install')
     install_task.add_make(
         ['-j1', 'install', 'install_root=%s' % instdir], objdir)
     _contribute_sysroot_tree(cfg, host, host_group, True, multilib)
Esempio n. 2
0
 def add_build_tasks_for_first_host(cfg, host, component, host_group):
     host_b = host.build_cfg
     srcdir = component.vars.srcdir.get()
     objdir = cfg.objdir_path(host_b, 'linux')
     instdir = cfg.install_tree_path(host_b, _INST_NAME)
     task = BuildTask(cfg, host_group, 'linux-headers')
     task.provide_install(host_b, _INST_NAME)
     task.add_empty_dir(objdir)
     task.add_empty_dir(instdir)
     linux_arch = None
     target = cfg.target.get()
     for gnu_arch in _LINUX_ARCH_MAP:
         if target.startswith(gnu_arch):
             linux_arch = _LINUX_ARCH_MAP[gnu_arch]
             break
     if linux_arch is None:
         cfg.context.error('unknown Linux kernel architecture for %s' %
                           target)
     task.add_make([
         '-C', srcdir,
         'O=%s' % objdir,
         'ARCH=%s' % linux_arch,
         'INSTALL_HDR_PATH=%s' % instdir, 'headers_install'
     ], objdir)
     _contribute_headers_tree(cfg, host, host_group, True)
Esempio n. 3
0
 def add_build_tasks_for_host(cfg, host, component, host_group):
     # The package-input install tree is contributed to by each
     # component that installs files intended to go in the final
     # release package.  This is an install tree for a PkgHost, not
     # for a BuildCfg.  This install tree is then subject to global
     # manipulations (such as hard-linking identical files,
     # replacing symlinks by hard links on hosts not supporting
     # symlinks, and stripping binaries) to produce the
     # package-output tree that corresponds to the exact data for
     # the release package.  Most manipulations, such as moving
     # files to different locations or removing files that are
     # installed by default but should not go in the final release
     # packages, should be done at the level of the individual
     # components; only a few manipulations are most appropriately
     # done globally just before packaging.
     host_group.declare_implicit_install(host, 'package-input')
     pkg_out_task = BuildTask(cfg, host_group, 'package-output')
     pkg_out_task.depend_install(host, 'package-input')
     pkg_out_task.provide_install(host, 'package-output')
     inst_in_path = cfg.install_tree_path(host, 'package-input')
     inst_out_path = cfg.install_tree_path(host, 'package-output')
     pkg_out_task.add_empty_dir_parent(inst_out_path)
     pkg_out_task.add_command(['cp', '-a', inst_in_path, inst_out_path])
     # The top-level directory in a package corresponds to the
     # contents of installdir.  In degenerate cases of nothing in a
     # package, installdir may not have been created (although the
     # package-input tree will always have been created, even if
     # empty).
     inst_out_main = os.path.join(inst_out_path, cfg.installdir_rel.get())
     pkg_out_task.add_create_dir(inst_out_main)
     if not host.have_symlinks():
         pkg_out_task.add_python(replace_symlinks,
                                 (cfg.context, inst_out_main))
     pkg_out_task.add_python(fix_perms, (inst_out_main,))
     pkg_out_task.add_python(hard_link_files, (cfg.context, inst_out_main))
     # Creating the package-output install tree is separated from
     # creating a .tar.xz package from it so that .tar.xz creation
     # can run in parallel with other package format creation using
     # the same tree.
     pkg_task = BuildTask(cfg, host_group, 'package-tar-xz')
     pkg_task.depend_install(host, 'package-output')
     pkg_path = cfg.pkgdir_path(host, '.tar.xz')
     pkg_task.add_command(tar_command(
         pkg_path, cfg.pkg_name_no_target_build.get(),
         cfg.source_date_epoch.get()),
                              cwd=inst_out_main)
Esempio n. 4
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)
Esempio n. 5
0
 def add_build_tasks_for_host(cfg, host, component, host_group):
     task = BuildTask(cfg, host_group, 'example')
     host_b = host.build_cfg
     instdir = cfg.install_tree_path(host_b, 'example')
     instdir = os.path.join(instdir, cfg.installdir_rel.get())
     task.add_empty_dir(instdir)
     task.provide_install(host_b, 'example')
     tree = cfg.install_tree_fstree(host_b, 'example')
     host_group.contribute_package(host, tree)
     task.add_command(['sh', '-c', 'echo a > %s/a1' % instdir])
     task.add_command(['ln', '%s/a1' % instdir, '%s/a2' % instdir])
     task.add_command(['sh', '-c', 'echo a > %s/a3' % instdir])
     task.add_command(['chmod', 'a-w', '%s/a3' % instdir])
     instdir2 = cfg.install_tree_path(host_b, 'example2')
     instdir2 = os.path.join(instdir2, cfg.installdir_rel.get())
     task.add_empty_dir(instdir2)
     task.provide_install(host_b, 'example2')
     tree2 = cfg.install_tree_fstree(host_b, 'example2')
     host_group.contribute_package(host, tree2)
     task.add_command(['sh', '-c', 'echo b > %s/b' % instdir2])
     task.add_command(['ln', '-s', 'b', '%s/c' % instdir2])
Esempio n. 6
0
 def add_build_tasks_for_first_host(cfg, host, component, host_group):
     task = BuildTask(cfg, host_group, 'first-host')
     host_b = host.build_cfg
     objdir = cfg.objdir_path(host_b, '%s-first' % component.copy_name)
     task.add_empty_dir(objdir)
     instdir_1 = cfg.install_tree_path(host_b, 'first-inst-1')
     task.add_empty_dir(instdir_1)
     task.provide_install(host_b, 'first-inst-1')
     instdir_2 = cfg.install_tree_path(host_b, 'first-inst-2')
     task.add_empty_dir(instdir_2)
     task.provide_install(host_b, 'first-inst-2')
     instdir_3 = cfg.install_tree_path(host_b, 'first-inst-3')
     task.add_empty_dir(instdir_3)
     task.provide_install(host_b, 'first-inst-3')
     task.add_command(['sh', '-c', 'echo a > %s/a' % instdir_1])
     task.add_command(['sh', '-c', 'echo b > %s/b' % instdir_2])
     task.add_command(['sh', '-c', 'echo c > %s/c' % instdir_3])
     tree_1 = cfg.install_tree_fstree(host_b, 'first-inst-1')
     tree_1 = FSTreeMove(tree_1, 'q')
     tree_2 = cfg.install_tree_fstree(host_b, 'first-inst-2')
     tree_3 = cfg.install_tree_fstree(host_b, 'first-inst-3')
     task.define_implicit_install(host_b, 'impl-def', tree_1)
     task.declare_implicit_install(host_b, 'impl-empty')
     task.declare_implicit_install(host_b, 'impl-one')
     task.contribute_implicit_install(host_b, 'impl-one', tree_2)
     task.declare_implicit_install(host_b, 'impl-two')
     task.contribute_implicit_install(host_b, 'impl-two', tree_2)
     task.contribute_implicit_install(host_b, 'impl-two', tree_3)
def add_host_cfg_build_tasks(relcfg, host, component, parent, name, srcdir,
                             prefix, pkg_cfg_opts, target, make_target,
                             install_target, parallel):
    """Add and return a group of tasks using configure / make / make install.

    The parent task passed is the main task group for the host, or any
    other group within which this group is to be contained.  The host
    passed is a BuildCfg object.  The component passed is the
    ComponentInConfig object.  The name passed is a name to use for
    build directories and install trees as well as for task names; if
    None, the name of the component (copy) is used (this is
    appropriate unless a component is built multiple times for one
    host, e.g. multiple GCC builds for bootstrapping a cross
    compiler).  If srcdir is None, the source directory of that
    component is used (this is appropriate unless configuring a
    subdirectory, e.g. for gdbserver).  If prefix is None, the path to
    the install tree is used as the configured prefix (this is only
    appropriate for host libraries not referring to files in their
    configured prefix at runtime).  A --target configure option is
    passed unless target is None.  Any configure options from the
    configure_opts variable and component hook are added
    automatically.  If make_target is not None, it is the target
    passed to make for the main build step; install_target likewise
    specifies the target for the install step.

    If additional steps are required after installation, the caller
    should add a postinstall task or tasks to the group returned.

    """
    build = relcfg.build.get().build_cfg
    if name is None:
        name = component.copy_name
    if srcdir is None:
        srcdir = component.vars.srcdir.get()
    objdir = relcfg.objdir_path(host, name)
    instdir = relcfg.install_tree_path(host, name)
    if prefix is None:
        cfg_prefix = instdir
        destdir = None
    else:
        cfg_prefix = prefix
        destdir = instdir
    task_group = BuildTask(relcfg, parent, name)
    task_group.provide_install(host, name)
    init_task = BuildTask(relcfg, task_group, 'init')
    init_task.add_empty_dir(objdir)
    init_task.add_empty_dir(instdir)
    cfg_task = BuildTask(relcfg, task_group, 'configure')
    cfg_cmd = [os.path.join(srcdir, 'configure'),
               '--build=%s' % build.triplet,
               '--host=%s' % host.triplet,
               '--prefix=%s' % cfg_prefix]
    if target is not None:
        cfg_cmd.append('--target=%s' % target)
    cfg_cmd.extend(pkg_cfg_opts)
    cfg_cmd.extend(component.vars.configure_opts.get())
    cfg_cmd.extend(component.cls.configure_opts(relcfg, host))
    cfg_cmd.extend(host.configure_vars())
    cfg_cmd.extend(['CC_FOR_BUILD=%s'
                    % ' '.join(build.tool('c-compiler')),
                    'CXX_FOR_BUILD=%s'
                    % ' '.join(build.tool('c++-compiler'))])
    cfg_task.add_command(cfg_cmd, cwd=objdir)
    build_task = BuildTask(relcfg, task_group, 'build')
    if parallel:
        build_cmd = []
    else:
        build_cmd = ['-j1']
    if make_target is not None:
        build_cmd.append(make_target)
    build_task.add_make(build_cmd, objdir)
    install_task = BuildTask(relcfg, task_group, 'install')
    install_cmd = ['-j1', install_target]
    if destdir is not None:
        install_cmd.append('DESTDIR=%s' % destdir)
    install_task.add_make(install_cmd, objdir)
    return task_group