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)
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): task = BuildTask(cfg, host_group, 'all-hosts') host_b = host.build_cfg objdir = cfg.objdir_path(host_b, '%s-all' % component.copy_name) objdir2 = cfg.objdir_path(host_b, '%s-all2' % component.copy_name) task.add_empty_dir(objdir) # Create objdir2 with some contents to test add_empty_dir # removal of an existing directory. os.makedirs(os.path.join(objdir2, 'x', 'y')) task.add_empty_dir(objdir2) task.add_command(['sh', '-c', 'echo all-hosts > %s/out1' % objdir]) task.add_command(['sh', '-c', 'echo all-hosts-2 > out2'], cwd=objdir)
def add_build_tasks_for_other_hosts_multilib(cfg, host, component, host_group, multilib): task = BuildTask(cfg, host_group, 'other-multi-%s' % multilib.build_cfg.name) host_b = host.build_cfg objdir = cfg.objdir_path(host_b, '%s-other-%s' % (component.copy_name, multilib.build_cfg.name)) task.add_empty_dir(objdir) task.add_command(['sh', '-c', 'echo "test %s" > %s/out' % (multilib.build_cfg.name, objdir)])
def add_build_tasks_for_other_hosts(cfg, host, component, host_group): task = BuildTask(cfg, host_group, 'other-hosts') host_b = host.build_cfg objdir = cfg.objdir_path(host_b, '%s-other' % component.copy_name) task.add_empty_dir(objdir) def py_test_fn(arg1, arg2): """Test Python build step.""" out_name = os.path.join(objdir, 'out') with open(out_name, 'w', encoding='utf-8') as outfile: outfile.write('%s %s\n' % (arg1, arg2)) task.add_python(py_test_fn, ('test', 'python'))
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_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) objdir2 = cfg.objdir_path(host_b, '%s-first2' % component.copy_name) task.add_empty_dir(objdir) # Test add_empty_dir_parent with and without the directory # existing. task.add_empty_dir_parent(os.path.join(objdir, 'x', 'y', 'z')) os.makedirs(os.path.join(objdir2, 'x', 'y', 'z')) task.add_empty_dir_parent(os.path.join(objdir2, 'x', 'y', 'z')) task.add_command(['sh', '-c', 'echo "all:; echo first-host \\$(X) > out" > ' '%s/GNUmakefile' % objdir]) task.add_make(['all', 'X=Y'], objdir)
def add_build_tasks_host_indep(cfg, component, host_indep_group): if not cfg.args.build_source_packages: return # The source package has the sources of open source # components; the backup package has the sources of closed # source components. source_group = BuildTask(cfg, host_indep_group, 'source-package') source_objdir = cfg.objdir_path(None, 'source-package') source_init_task = BuildTask(cfg, source_group, 'init') source_init_task.add_empty_dir(source_objdir) source_components_group = BuildTask(cfg, source_group, 'components', True) source_package_task = BuildTask(cfg, source_group, 'package') source_pkg_path = cfg.pkgdir_path(None, '.src.tar.xz') source_package_task.add_command(tar_command( source_pkg_path, cfg.pkg_name_full.get(), cfg.source_date_epoch.get()), cwd=source_objdir) backup_group = BuildTask(cfg, host_indep_group, 'backup-package') backup_objdir = cfg.objdir_path(None, 'backup-package') backup_init_task = BuildTask(cfg, backup_group, 'init') backup_init_task.add_empty_dir(backup_objdir) backup_components_group = BuildTask(cfg, backup_group, 'components', True) backup_package_task = BuildTask(cfg, backup_group, 'package') backup_pkg_path = cfg.pkgdir_path(None, '.backup.tar.xz') backup_package_task.add_command(tar_command( backup_pkg_path, '%s.backup' % cfg.pkg_name_full.get(), cfg.source_date_epoch.get()), cwd=backup_objdir) copy_objdir = cfg.objdir_path(None, 'source-copy') for src_component in cfg.list_source_components(): name = src_component.copy_name srcdir_copy = os.path.join(copy_objdir, name) if src_component.vars.source_type.get() == 'open': group = source_components_group objdir = source_objdir else: group = backup_components_group objdir = backup_objdir task = BuildTask(cfg, group, name) pkg_dir = '%s-%s' % (name, cfg.version.get()) pkg_path = os.path.join(objdir, '%s.tar.xz' % pkg_dir) task.add_command(tar_command(pkg_path, pkg_dir, cfg.source_date_epoch.get()), cwd=srcdir_copy)
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)
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])
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
def add_build_tasks_fini(cfg, component, fini_group): task = BuildTask(cfg, fini_group, 'fini') objdir = cfg.objdir_path(None, '%s-fini' % component.copy_name) task.add_empty_dir(objdir) task.add_command(['sh', '-c', 'echo fini > %s/out' % objdir])
def add_build_tasks_host_indep(cfg, component, host_indep_group): task = BuildTask(cfg, host_indep_group, 'host-indep') objdir = cfg.objdir_path(None, '%s-host-indep' % component.copy_name) task.add_empty_dir(objdir) task.add_command(['sh', '-c', 'echo host-indep > %s/out' % objdir])
def add_build_tasks_init(cfg, component, init_group): task = BuildTask(cfg, init_group, 'init') objdir = cfg.objdir_path(None, '%s-init' % component.copy_name) task.add_empty_dir(objdir) task.add_command(['sh', '-c', 'echo init > %s/out' % objdir])