def add_build_tasks_init(cfg, component, init_group): pkgdir_task = BuildTask(cfg, init_group, 'pkgdir') pkgdir_task.add_create_dir(cfg.args.pkgdir) if not cfg.args.build_source_packages: return # Component sources are copied in an init task to ensure that # source packages contain the sources at the start of the # build, even if a bug in a component's build process # (e.g. missing or insufficient configuration of files to # touch on checkout) results in the source directory being # modified during the build. If a component's build process # is known to modify the source directory intentionally, that # component's build tasks must create a separate copy for use # in the build. source_copy_group = BuildTask(cfg, init_group, 'source-copy', True) objdir = cfg.objdir_path(None, 'source-copy') for src_component in cfg.list_source_components(): name = src_component.copy_name srcdir = src_component.vars.srcdir.get() srcdir_copy = os.path.join(objdir, name) copy_task = BuildTask(cfg, source_copy_group, name) copy_task.add_empty_dir_parent(srcdir_copy) copy_task.add_python( src_component.vars.vc.get().copy_without_metadata, (srcdir, srcdir_copy))
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_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)