Skip to content

Commit

Permalink
Use correct path within /opt for jenkins-cheri-build
Browse files Browse the repository at this point in the history
In particular this will strip the -for-<arch>-rootfs suffix, but it also
stops us assuming we're only building for one architecture (whilst we
only have one sysroot, we could in theory be building both purecap and
hybrid-for-purecap-rootfs at the same time, for example).
  • Loading branch information
jrtc27 committed Sep 11, 2024
1 parent 3e952d2 commit 471043a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
7 changes: 1 addition & 6 deletions pycheribuild/config/jenkinsconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
from ..utils import OSInfo, default_make_jobs_count, fatal_error, warning_message


def default_install_prefix(conf: "JenkinsConfig", _):
return "/opt/" + conf.targets[0]


def default_jenkins_make_jobs_count(conf: "JenkinsConfig", _):
if conf.use_all_cores:
return os.cpu_count()
Expand Down Expand Up @@ -169,8 +165,7 @@ def __init__(self, loader: ConfigLoaderBase, available_targets: "list[str]") ->
self.installation_prefix = loader.add_commandline_only_option(
"install-prefix",
type=absolute_path_only,
default=default_install_prefix,
help="The install prefix for cross compiled projects (the path in the install image)",
help="Override the install prefix for cross compiled projects (the path in the install image)",
)
self.use_system_compiler_for_native = loader.add_commandline_only_bool_option(
"use-system-compiler-for-native",
Expand Down
12 changes: 8 additions & 4 deletions pycheribuild/config/target_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,18 @@ def pkgconfig_dirs(self) -> "list[str]":
def pkg_config_libdir_override(self) -> "Optional[str]":
return None

@classmethod
def _install_prefix_dirname(cls, target: "CrossCompileTarget", config: CheriConfig) -> str:
result = target.generic_arch_suffix
if config.cross_target_suffix:
result += "-" + config.cross_target_suffix
return result

@property
def install_prefix_dirname(self) -> str:
"""The name of the root directory to install to: i.e. for CheriBSD /usr/local/mips64-purecap or
/usr/local/riscv64-hybrid"""
result = self.target.generic_arch_suffix
if self.config.cross_target_suffix:
result += "-" + self.config.cross_target_suffix
return result
return self._install_prefix_dirname(self.target, self.config)

@property
def config(self) -> CheriConfig:
Expand Down
18 changes: 15 additions & 3 deletions pycheribuild/jenkins_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
from .utils import fatal_error, status_update


def jenkins_override_install_dirs_hack(cheri_config: CheriConfig, install_prefix: Path):
def default_install_prefix(xtarget, cheri_config: CheriConfig):
dirname = xtarget.target_info_cls._install_prefix_dirname(xtarget, cheri_config)
return Path("/opt", dirname)


def jenkins_override_install_dirs_hack(cheri_config: CheriConfig, install_prefix_arg: Path):
# Ugly workaround to override all install dirs to go to the tarball
all_targets = [
x
Expand Down Expand Up @@ -69,8 +74,15 @@ def expected_install_root(target):
else:
return cheri_config.output_root

def expected_install_prefix(target):
if install_prefix_arg is None:
return default_install_prefix(target.xtarget, cheri_config)
else:
return install_prefix_arg

def expected_install_path(target):
root_dir = expected_install_root(target)
install_prefix = expected_install_prefix(target)
return Path(f"{root_dir}{install_prefix}")

for target in all_targets:
Expand Down Expand Up @@ -98,11 +110,11 @@ def expected_install_path(target):
project._check_install_dir_conflict = False
# Using "/" as the install prefix results inconsistently prefixing some paths with '/usr/'.
# To avoid this, just use the full install path as the prefix.
if install_prefix == Path("/"):
if expected_install_prefix(target) == Path("/"):
project._install_prefix = expected_install_path(target)
project.destdir = Path("/")
else:
project._install_prefix = install_prefix
project._install_prefix = expected_install_prefix(target)
project.destdir = expected_install_root(target)
assert project.real_install_root_dir == expected_install_path(target)
assert isinstance(inspect.getattr_static(project, "_install_dir"), Path)
17 changes: 15 additions & 2 deletions pycheribuild/projects/run_fvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@
from ..config.compilation_targets import CompilationTargets
from ..config.target_info import CrossCompileTarget
from ..processutils import extract_version, popen
from ..utils import AnsiColour, OSInfo, SocketAndPort, cached_property, classproperty, coloured, find_free_port
from ..utils import (
AnsiColour,
OSInfo,
SocketAndPort,
cached_property,
classproperty,
coloured,
find_free_port,
is_jenkins_build,
)


class InstallMorelloFVP(SimpleProject):
Expand Down Expand Up @@ -723,7 +732,11 @@ def add_hostbridge_params(*params):
mcp_fw_bin = self.ensure_file_exists(
"MCP firmware", flash_images.mcp_ram_firmware_image, fixit_hint=firmware_fixit
)
assert uefi_bin.parent == scp_fw_bin.parent and scp_fw_bin.parent == scp_rom_bin.parent, "Different dirs?"
# XXX: jenkins-cheri-build overrides install directories so this currently doesn't hold there
if not is_jenkins_build():
assert (
uefi_bin.parent == scp_fw_bin.parent and scp_fw_bin.parent == scp_rom_bin.parent
), "Different dirs?"
# fmt: off
fvp_args += [
# "-a", "Morello_Top.css.scp.armcortexm7ct=" + str(scp_romfw_elf),
Expand Down

0 comments on commit 471043a

Please sign in to comment.