diff --git a/README.adoc b/README.adoc index 97ead54..2fcffc5 100644 --- a/README.adoc +++ b/README.adoc @@ -11145,6 +11145,10 @@ We use it for: + C files for example need compilation, and must go through the regular package system, e.g. through link:kernel_modules/user[]. +This directory gets <<9p>> mounted on the guest at: `/mnt/9p/rootfs_overlay` + +Furthermore, link:copy-overlay[] copies it to our generated overlay, which appears on the guest at `/mnt/9p/out_rootfs_overlay`. + === Test this repo This section describes how to run the most complete set of tests possible. diff --git a/build b/build index 440de42..319ad87 100755 --- a/build +++ b/build @@ -24,8 +24,8 @@ class BaremetalComponent(Component): def add_bool_arg(parser, name, default=False): group = parser.add_mutually_exclusive_group(required=False) - group.add_argument('--' + name, default=False, action='store_true') - group.add_argument('--no-' + name, default=False, action='store_true') + group.add_argument('--' + name, default=False, action='store_true', dest=name) + group.add_argument('--no-' + name, default=False, action='store_true', dest=name) def run_cmd(cmd, dry_run): cmd_abs = cmd.copy() @@ -38,9 +38,13 @@ name_to_component_map = { True, lambda arch, dry_run: run_cmd(['build-buildroot', '--arch', arch], dry_run=dry_run), ), + 'copy-overlay': Component( + True, + lambda arch, dry_run: run_cmd(['copy-overlay', '--arch', arch], dry_run=dry_run) + ), 'gem5': Component( False, - lambda arch, dry_run: run_cmd(['build-gem5', '--arch', arch], dry_run) + lambda arch, dry_run: run_cmd(['build-gem5', '--arch', arch], dry_run=dry_run) ), 'linux': Component( True, @@ -56,7 +60,7 @@ name_to_component_map = { ), 'qemu': Component( True, - lambda arch, dry_run: run_cmd(['build-qemu', '--arch', arch], dry_run) + lambda arch, dry_run: run_cmd(['build-qemu', '--arch', arch], dry_run=dry_run) ), 'userland': Component( True, @@ -71,6 +75,7 @@ component_order = [ # Need one extra one here to build the toolchain. 'buildroot', 'linux', + 'copy-overlay', 'modules', 'userland', 'm5', @@ -81,6 +86,7 @@ linux_component_names = { 'gem5', 'qemu', 'linux', + 'copy-overlay', 'modules', 'userland', 'm5', @@ -91,6 +97,8 @@ parser = argparse.ArgumentParser( description= ''' Shallow helper to build everything, or a subset of everything conveniently. +Our build-* scripts don't build any dependencies. + While developing something however, you will likely want to just run the required sub-build commands manually to speed things up and better understand what is going on. diff --git a/build-buildroot b/build-buildroot index 272b21d..d39b205 100755 --- a/build-buildroot +++ b/build-buildroot @@ -108,7 +108,6 @@ usually extra Buildroot targets. self._path_relative_to_buildroot(os.path.join(common.root_dir, 'buildroot_override')) ), 'BR2_ROOTFS_OVERLAY="{} {}"'.format( - self._path_relative_to_buildroot(common.rootfs_overlay_dir), self._path_relative_to_buildroot(common.out_rootfs_overlay_dir), ), 'BR2_ROOTFS_POST_BUILD_SCRIPT="{}"'.format( diff --git a/build-overlay b/build-overlay deleted file mode 100644 index 8201320..0000000 --- a/build-overlay +++ /dev/null @@ -1,73 +0,0 @@ - -#!/usr/bin/env python3 - -import os -import platform -import shutil -import subprocess - -import common - -class UserlandComponent(common.Component): - def add_parser_arguments(self, parser): - parser.add_argument( - '--has-package', - action='append', - default=[], - help='''\ -Indicate that a given package is present in the root filesystem, which -allows us to build examples that rely on it. -''', - ) - parser.add_argument( - 'targets', - default=[], - help='''\ -Build only the given userland programs. -Default: build all examples that have their package dependencies met. -For example, an OpenBLAS example can only be built if the target root filesystem -has the OpenBLAS libraries and headers installed. -''', - metavar='programs', - nargs='*', - ) - - def do_build(self, args): - build_dir = self.get_build_dir(args) - os.makedirs(build_dir, exist_ok=True) - allowed_toolchains = ['buildroot'] - cc = common.get_toolchain_tool('gcc', allowed_toolchains=allowed_toolchains) - cxx = common.get_toolchain_tool('g++', allowed_toolchains=allowed_toolchains) - common.run_cmd( - ( - [ - 'make', - '-j', str(args.nproc), - 'CC={}'.format(cc), - 'CXX={}'.format(cxx), - 'PKG_CONFIG={}'.format(common.buildroot_pkg_config), - 'STAGING_DIR={}'.format(common.buildroot_staging_dir), - 'OUT_DIR={}'.format(build_dir), - ] + - ['HAS_{}=y'.format(package.upper()) for package in args.has_package] + - [os.path.join(build_dir, os.path.splitext(os.path.split(target)[1])[0]) + common.executable_ext for target in args.targets] - ), - cwd=common.userland_src_dir, - extra_paths=[common.ccache_dir], - ) - common.copy_dir_if_update_non_recursive( - srcdir=build_dir, - destdir=common.out_rootfs_overlay_dir, - filter_ext=common.executable_ext, - ) - - def get_argparse_args(self): - return { - 'description': 'Build our compiled userland examples', - } - - def get_build_dir(self, args): - return common.userland_build_dir - -if __name__ == '__main__': - UserlandComponent().build() diff --git a/common.py b/common.py index 9082d33..c586efc 100644 --- a/common.py +++ b/common.py @@ -117,7 +117,9 @@ class Component: pass def clean(self, args): - this_module.rmrf(self.get_build_dir(args)) + build_dir = self.get_build_dir(args) + if build_dir is not None: + this_module.rmrf(build_dir) def do_build(self, args): ''' @@ -133,9 +135,9 @@ class Component: def get_build_dir(self, args): ''' - Build directory, gets cleaned by --clean. + Build directory, gets cleaned by --clean if not None. ''' - raise NotImplementedError() + return None def get_default_args(self): ''' diff --git a/copy-overlay b/copy-overlay new file mode 100755 index 0000000..bbf3470 --- /dev/null +++ b/copy-overlay @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + +import distutils.dir_util +import os +import shutil + +import common + +class CopyOverlayComponent(common.Component): + def do_build(self, args): + distutils.dir_util.copy_tree( + common.rootfs_overlay_dir, + common.out_rootfs_overlay_dir, + update=1, + ) + + def get_argparse_args(self): + return { + 'description': '''\ +Copy our git tracked rootfs_overlay to the final generated rootfs_overlay +that also contains generated build outputs. This has the following advantages +over just adding that to BR2_ROOTFS_OVERLAY: +- also works for non Buildroot root filesystesms +- places everything in one place for a nice 9P mount +''', + } + +if __name__ == '__main__': + CopyOverlayComponent().build()