mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
copy-overlay. ./build broken btw :-)
This commit is contained in:
@@ -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[].
|
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
|
=== Test this repo
|
||||||
|
|
||||||
This section describes how to run the most complete set of tests possible.
|
This section describes how to run the most complete set of tests possible.
|
||||||
|
|||||||
16
build
16
build
@@ -24,8 +24,8 @@ class BaremetalComponent(Component):
|
|||||||
|
|
||||||
def add_bool_arg(parser, name, default=False):
|
def add_bool_arg(parser, name, default=False):
|
||||||
group = parser.add_mutually_exclusive_group(required=False)
|
group = parser.add_mutually_exclusive_group(required=False)
|
||||||
group.add_argument('--' + 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')
|
group.add_argument('--no-' + name, default=False, action='store_true', dest=name)
|
||||||
|
|
||||||
def run_cmd(cmd, dry_run):
|
def run_cmd(cmd, dry_run):
|
||||||
cmd_abs = cmd.copy()
|
cmd_abs = cmd.copy()
|
||||||
@@ -38,9 +38,13 @@ name_to_component_map = {
|
|||||||
True,
|
True,
|
||||||
lambda arch, dry_run: run_cmd(['build-buildroot', '--arch', arch], dry_run=dry_run),
|
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(
|
'gem5': Component(
|
||||||
False,
|
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(
|
'linux': Component(
|
||||||
True,
|
True,
|
||||||
@@ -56,7 +60,7 @@ name_to_component_map = {
|
|||||||
),
|
),
|
||||||
'qemu': Component(
|
'qemu': Component(
|
||||||
True,
|
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(
|
'userland': Component(
|
||||||
True,
|
True,
|
||||||
@@ -71,6 +75,7 @@ component_order = [
|
|||||||
# Need one extra one here to build the toolchain.
|
# Need one extra one here to build the toolchain.
|
||||||
'buildroot',
|
'buildroot',
|
||||||
'linux',
|
'linux',
|
||||||
|
'copy-overlay',
|
||||||
'modules',
|
'modules',
|
||||||
'userland',
|
'userland',
|
||||||
'm5',
|
'm5',
|
||||||
@@ -81,6 +86,7 @@ linux_component_names = {
|
|||||||
'gem5',
|
'gem5',
|
||||||
'qemu',
|
'qemu',
|
||||||
'linux',
|
'linux',
|
||||||
|
'copy-overlay',
|
||||||
'modules',
|
'modules',
|
||||||
'userland',
|
'userland',
|
||||||
'm5',
|
'm5',
|
||||||
@@ -91,6 +97,8 @@ parser = argparse.ArgumentParser(
|
|||||||
description= '''
|
description= '''
|
||||||
Shallow helper to build everything, or a subset of everything conveniently.
|
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
|
While developing something however, you will likely want to just run the
|
||||||
required sub-build commands manually to speed things up and better understand
|
required sub-build commands manually to speed things up and better understand
|
||||||
what is going on.
|
what is going on.
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ usually extra Buildroot targets.
|
|||||||
self._path_relative_to_buildroot(os.path.join(common.root_dir, 'buildroot_override'))
|
self._path_relative_to_buildroot(os.path.join(common.root_dir, 'buildroot_override'))
|
||||||
),
|
),
|
||||||
'BR2_ROOTFS_OVERLAY="{} {}"'.format(
|
'BR2_ROOTFS_OVERLAY="{} {}"'.format(
|
||||||
self._path_relative_to_buildroot(common.rootfs_overlay_dir),
|
|
||||||
self._path_relative_to_buildroot(common.out_rootfs_overlay_dir),
|
self._path_relative_to_buildroot(common.out_rootfs_overlay_dir),
|
||||||
),
|
),
|
||||||
'BR2_ROOTFS_POST_BUILD_SCRIPT="{}"'.format(
|
'BR2_ROOTFS_POST_BUILD_SCRIPT="{}"'.format(
|
||||||
|
|||||||
@@ -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()
|
|
||||||
@@ -117,7 +117,9 @@ class Component:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def clean(self, args):
|
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):
|
def do_build(self, args):
|
||||||
'''
|
'''
|
||||||
@@ -133,9 +135,9 @@ class Component:
|
|||||||
|
|
||||||
def get_build_dir(self, args):
|
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):
|
def get_default_args(self):
|
||||||
'''
|
'''
|
||||||
|
|||||||
29
copy-overlay
Executable file
29
copy-overlay
Executable file
@@ -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()
|
||||||
Reference in New Issue
Block a user