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)
 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)
 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)