Skip to content

Commit

Permalink
Revert "Jenkins: change installation directories before calling setup()"
Browse files Browse the repository at this point in the history
This reverts commit 39941e1
  • Loading branch information
arichardson committed Aug 10, 2023
1 parent f88311c commit 2edc5e4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 51 deletions.
28 changes: 12 additions & 16 deletions pycheribuild/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

# noinspection PyUnresolvedReferences
from .projects.cross import * # noqa: F401, F403, RUF100
from .projects.cross.crosscompileproject import CrossCompileMixin
from .projects.project import Project
from .projects.simple_project import SimpleProject
from .targets import MultiArchTargetAlias, SimpleTargetAlias, Target, target_manager
Expand Down Expand Up @@ -243,15 +244,15 @@ def _jenkins_main() -> None:
fatal_error("More than one target is not supported yet.", pretend=False)
sys.exit()

expected_install_path = Path(f"{cheri_config.output_root}{cheri_config.installation_prefix}")
if JenkinsAction.BUILD in cheri_config.action or JenkinsAction.TEST in cheri_config.action:
# Ugly workaround to override all install dirs to go to the tarball
for tgt in target_manager.targets(cheri_config):
if isinstance(tgt, SimpleTargetAlias):
continue
cls = tgt.project_class
if issubclass(cls, Project) and not isinstance(tgt, MultiArchTargetAlias):
cls._default_install_dir_fn = Path(expected_install_path)
cls._default_install_dir_fn = Path(
str(cheri_config.output_root) + str(cheri_config.installation_prefix))
i = inspect.getattr_static(cls, "_install_dir")
assert isinstance(i, CommandLineConfigOption)
# But don't change it if it was specified on the command line. Note: This also does the config
Expand All @@ -261,33 +262,28 @@ def _jenkins_main() -> None:
if from_cmdline is not None:
status_update("Install directory for", cls.target, "was specified on commandline:", from_cmdline)
else:
cls._install_dir = cheri_config.output_root
cls._install_dir = Path(str(cheri_config.output_root) + str(cheri_config.installation_prefix))
cls._check_install_dir_conflict = False

Target.instantiating_targets_should_warn = False
# Override the installation directory for all enabled targets
for name in cheri_config.targets:
target = target_manager.get_target_raw(name)
# noinspection PyProtectedMember
project = target._get_or_create_project_no_setup(None, cheri_config, caller=None)
if isinstance(project, Project):
project._install_prefix = cheri_config.installation_prefix
project.destdir = cheri_config.output_root
assert project.real_install_root_dir == expected_install_path
for tgt in cheri_config.targets:
build_target(cheri_config, target_manager.get_target_raw(tgt))
for target in cheri_config.targets:
build_target(cheri_config, target_manager.get_target_raw(target))

if JenkinsAction.CREATE_TARBALL in cheri_config.action:
create_tarball(cheri_config)


def build_target(cheri_config, target: Target) -> None:
# Note: This if exists for now to avoid a large diff.
target.check_system_deps(cheri_config)
# need to set destdir after check_system_deps:
project = target.get_or_create_project(None, cheri_config, caller=None)
assert project
_ = project.all_dependency_names(cheri_config) # Ensure dependencies are cached.
if isinstance(project, Project):
assert project.real_install_root_dir == Path(f"{cheri_config.output_root}{cheri_config.installation_prefix}")
if isinstance(project, CrossCompileMixin):
project.destdir = cheri_config.output_root
project._install_prefix = cheri_config.installation_prefix
project._install_dir = cheri_config.output_root

if cheri_config.debug_output:
status_update("Configuration options for building", project.target, file=sys.stderr)
Expand Down
3 changes: 0 additions & 3 deletions pycheribuild/projects/bluespec_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ def check_system_dependencies(self):
self.check_required_system_tool("gperf", homebrew="gperf", apt="gperf")
for i in ("autoconf", "bison", "flex"):
self.check_required_system_tool(i, homebrew=i)

def setup(self):
super().setup()
self.make_args.set(PREFIX=self.install_dir)

def compile(self, **kwargs):
Expand Down
8 changes: 2 additions & 6 deletions pycheribuild/projects/cross/cheribsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,19 +767,15 @@ def _try_find_compatible_system_clang(self) -> "tuple[Optional[Path], Optional[s
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self._setup_make_args_called = False
self.destdir = self.install_dir
self._install_prefix = Path("/")
self.kernel_toolchain_exists: bool = False
self.cross_toolchain_config = MakeOptions(MakeCommandKind.BsdMake, self)
if self.has_default_buildkernel_kernel_config:
assert self.kernel_config is not None
self.make_args.set(**self.arch_build_flags)
self.extra_kernels = []

def setup(self) -> None:
super().setup()
self.destdir = self.install_dir
self._install_prefix = Path("/")
assert self.real_install_root_dir == self.destdir

@cached_property
def build_toolchain_root_dir(self) -> "Optional[Path]":
if self.build_toolchain == FreeBSDToolchainKind.BOOTSTRAPPED:
Expand Down
1 change: 1 addition & 0 deletions pycheribuild/projects/cross/compiler_rt.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def setup(self):

def install(self, **kwargs):
super().install(**kwargs)

libname = "libclang_rt.builtins-" + self.triple_arch + ".a"
if self.target_info.is_rtems():
self.move_file(self.install_dir / "lib/rtems5" / libname, self.install_dir / "lib" / libname)
Expand Down
3 changes: 2 additions & 1 deletion pycheribuild/projects/go.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ def setup_config_options(cls, **kwargs):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

# It does not seem possible to change this in the go build scripts (easily).
self.make_dir = self.source_dir / "src"
self.bin_dir = self.source_dir / "bin"
self.pkg_dir = self.source_dir / "pkg"
self.goroot_dir = self.real_install_root_dir / "go"
self.goroot_dir = self.install_dir / "go"
self.go_cache = Path("~").expanduser() / ".cache" / "go-build"

def build_dir_for_target(self, target: CrossCompileTarget):
Expand Down
9 changes: 1 addition & 8 deletions pycheribuild/projects/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,7 @@ def __init__(self, *args, **kwargs) -> None:
elif install_dir_kind in (DefaultInstallDir.ROOTFS_OPTBASE, DefaultInstallDir.KDE_PREFIX):
relative_to_rootfs = os.path.relpath(str(self._install_dir), str(self.rootfs_dir))
if relative_to_rootfs.startswith(os.path.pardir):
self.verbose_print("Custom install dir", self._install_dir,
"-> using / as install prefix for", self.target)
self.verbose_print("Custom install dir", self._install_dir, "-> using / as install prefix")
self._install_prefix = Path("/")
self.destdir = self._install_dir
else:
Expand Down Expand Up @@ -945,10 +944,6 @@ def host_dependency_prefixes(self) -> "list[Path]":

def setup(self):
super().setup()
self.verbose_print(
self.target, f"INSTALLDIR={self._install_dir}", f"INSTALL_PREFIX={self._install_prefix}",
f"DESTDIR={self.destdir}",
)
if self.set_pkg_config_path:
pkg_config_args = dict()
if self.compiling_for_host():
Expand Down Expand Up @@ -1268,12 +1263,10 @@ def real_install_root_dir(self) -> Path:

@property
def install_dir(self) -> Path:
assert self._setup_called, "Should be called after base class setup()"
return self.real_install_root_dir

@property
def install_prefix(self) -> Path:
assert self._setup_called, "Should be called after base class setup()"
if self._install_prefix is not None:
return self._install_prefix
return self._install_dir
Expand Down
26 changes: 9 additions & 17 deletions tests/test_async_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,18 @@ class MockProject(Project):
def __init__(self, config: MockConfig, name: str):
self.target = name
self.default_directory_basename = name
self.expected_src = config.source_root / "sources" / name
self._initial_source_dir = self.expected_src
self.expected_install = config.source_root / "install" / name
self._install_dir = self.expected_install
self.expected_build = Path(config.source_root, "build", name + "-build")
self.build_dir = self.expected_build
expected_src = config.source_root / "sources" / name
self._initial_source_dir = expected_src
expected_install = config.source_root / "install" / name
self._install_dir = expected_install
expected_build = Path(config.source_root, "build", name + "-build")
self.build_dir = expected_build
super().__init__(config, crosscompile_target=CompilationTargets.NATIVE)

def setup(self):
super().setup()
assert self.source_dir == self.expected_src
assert self.build_dir == self.expected_build
assert self.install_dir == self.expected_install
assert self.source_dir == expected_src
assert self.build_dir == expected_build
assert self.install_dir == expected_install
self.source_dir.mkdir(parents=True)

@classmethod
def cached_full_dependencies(cls):
return []

def _delete_directories(self, *dirs):
if self.config.sleep_before_delete:
print("SLEEPING")
Expand All @@ -64,7 +57,6 @@ def setUp(self):
assert self.tempRoot == self.config.source_root
assert self.tempRoot / "build" == self.config.build_root
self.project = MockProject(self.config, "foo")
self.project.setup()
assert self.project.source_dir.exists(), self.project.source_dir

def tearDown(self):
Expand Down

0 comments on commit 2edc5e4

Please sign in to comment.