diff --git a/pycheribuild/config/target_info.py b/pycheribuild/config/target_info.py index 1f710caf6..28e55df08 100644 --- a/pycheribuild/config/target_info.py +++ b/pycheribuild/config/target_info.py @@ -163,6 +163,7 @@ class AbstractProject(FileSystemUtils): _xtarget: "ClassVar[Optional[CrossCompileTarget]]" = None default_architecture: "ClassVar[Optional[CrossCompileTarget]]" needs_sysroot: "ClassVar[bool]" + is_rootfs_target: typing.ClassVar[bool] = False # Whether this project installation directory is a rootfs dir auto_var_init: AutoVarInit # Needed for essential_compiler_flags config: CheriConfig diff --git a/pycheribuild/jenkins_utils.py b/pycheribuild/jenkins_utils.py index 99e6528eb..55d997c67 100644 --- a/pycheribuild/jenkins_utils.py +++ b/pycheribuild/jenkins_utils.py @@ -79,6 +79,8 @@ def expected_install_root(tgt: Target) -> Path: def expected_install_prefix(tgt: Target) -> Path: if install_prefix_arg is None: + if tgt.project_class.is_rootfs_target: + return Path("/") return default_install_prefix(tgt.xtarget, cheri_config) else: return install_prefix_arg diff --git a/pycheribuild/projects/cross/cheribsd.py b/pycheribuild/projects/cross/cheribsd.py index 8e65bb502..efaf43b36 100644 --- a/pycheribuild/projects/cross/cheribsd.py +++ b/pycheribuild/projects/cross/cheribsd.py @@ -632,6 +632,7 @@ class BuildFreeBSD(BuildFreeBSDBase): target: str = "freebsd" repository: GitRepository = GitRepository("https://github.com/freebsd/freebsd.git") needs_sysroot: bool = False # We are building the full OS so we don't need a sysroot + is_rootfs_target: typing.ClassVar[bool] = True # All derived classes are also rootfs targets # We still allow building FreeBSD for MIPS64. While the main branch no longer has support, this allows building # the stable/13 branch using cheribuild. However, MIPS is no longer included in ALL_SUPPORTED_FREEBSD_TARGETS. supported_architectures: "typing.ClassVar[tuple[CrossCompileTarget, ...]]" = ( diff --git a/pycheribuild/projects/cross/newlib.py b/pycheribuild/projects/cross/newlib.py index 4fa5446a3..6ba402d25 100644 --- a/pycheribuild/projects/cross/newlib.py +++ b/pycheribuild/projects/cross/newlib.py @@ -42,6 +42,7 @@ class BuildNewlib(CrossCompileAutotoolsProject): target = "newlib" make_kind = MakeCommandKind.GnuMake is_sdk_target = True + is_rootfs_target = True needs_sysroot = False # We are building newlib so we don't need a sysroot add_host_target_build_config_options = False _configure_supports_libdir = False diff --git a/pycheribuild/projects/cross/picolibc.py b/pycheribuild/projects/cross/picolibc.py index c72f364c9..574e29968 100644 --- a/pycheribuild/projects/cross/picolibc.py +++ b/pycheribuild/projects/cross/picolibc.py @@ -39,6 +39,7 @@ class BuildPicoLibc(CrossCompileMesonProject): # Installing the native headers and libraries to /local breaks other native project builds. native_install_dir = DefaultInstallDir.DO_NOT_INSTALL needs_sysroot = False + is_rootfs_target = True include_os_in_target_suffix = False # Avoid adding -picolibc- as we are building picolibc here # ld.lld: error: -r and --gdb-index may not be used together add_gdb_index = False diff --git a/pycheribuild/projects/project.py b/pycheribuild/projects/project.py index 15f2f1d2e..557a1a380 100644 --- a/pycheribuild/projects/project.py +++ b/pycheribuild/projects/project.py @@ -1183,7 +1183,9 @@ def add_lto_build_options(self, ccinfo: CompilerInfo) -> bool: def rootfs_dir(self) -> Path: xtarget = self.crosscompile_target.get_rootfs_target() # noinspection PyProtectedMember - return self.target_info._get_rootfs_class(xtarget).get_install_dir(self, xtarget) + rootfs_cls: "type[AbstractProject]" = self.target_info._get_rootfs_class(xtarget) + assert rootfs_cls.is_rootfs_target + return rootfs_cls.get_install_dir(self, xtarget) @property def _no_overwrite_allowed(self) -> "Sequence[str]": diff --git a/tests/test_argument_parsing.py b/tests/test_argument_parsing.py index 88bcd1284..0936938cc 100644 --- a/tests/test_argument_parsing.py +++ b/tests/test_argument_parsing.py @@ -1493,17 +1493,14 @@ def test_jenkins_hack_hybrid_for_purecap_rootfs_prefix_none(monkeypatch): cheribsd_morello_purecap = _get_target_instance("cheribsd-morello-purecap", config, BuildCHERIBSD) # FIXME: we implicitly add /opt/morello-purecap for the rootfs dir here which does not make any sense assert cheribsd_morello_purecap.target_info.install_prefix_dirname == "morello-purecap" - assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball/opt/morello-purecap") - assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap") - # FIXME: assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball") - # FIXME: assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball") + assert cheribsd_morello_purecap.install_dir == Path("/tmp/tarball") + assert cheribsd_morello_purecap.rootfs_dir == Path("/tmp/tarball") # When building against the rootfs we do want the prefix though: gmp_morello_purecap = _get_target_instance("gmp-morello-purecap", config, Project) assert gmp_morello_purecap.crosscompile_target.is_cheri_purecap() assert gmp_morello_purecap.target_info.install_prefix_dirname == "morello-purecap" assert gmp_morello_purecap.install_dir == Path("/tmp/tarball/opt/morello-purecap") - assert gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap") - # FIXME: gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball") + assert gmp_morello_purecap.rootfs_dir == Path("/tmp/tarball") assert gmp_morello_purecap.rootfs_dir == cheribsd_morello_purecap.install_dir # The -hybrid-for-purecap-rootfs should install to the same rootfs but a different prefix: @@ -1511,11 +1508,10 @@ def test_jenkins_hack_hybrid_for_purecap_rootfs_prefix_none(monkeypatch): assert gmp_morello_hybrid_for_purecap.crosscompile_target.is_cheri_hybrid() assert gmp_morello_hybrid_for_purecap.target_info.install_prefix_dirname == "morello-hybrid" assert gmp_morello_hybrid_for_purecap.install_dir == Path("/tmp/tarball/opt/morello-hybrid") + # The rootfs should be the same as the gmp-purecap one: + assert gmp_morello_hybrid_for_purecap.rootfs_dir == gmp_morello_purecap.rootfs_dir assert gmp_morello_hybrid_for_purecap.rootfs_dir == cheribsd_morello_purecap.install_dir - # FIXME: rootfs should be the same as the gmp-purecap - # FIXME: assert gmp_morello_hybrid_for_purecap.rootfs_dir == gmp_morello_purecap.rootfs_dir - # FIXME: gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball") - assert gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball/opt/morello-purecap") + assert gmp_morello_hybrid_for_purecap.rootfs_dir == Path("/tmp/tarball") # Another regression test, explicitly overriding the installation directory triggered an assertion