Skip to content

Commit

Permalink
cheribsd: Set MAKEOBJDIRPREFIX lazily pre-setup()
Browse files Browse the repository at this point in the history
We can't just do it eagerly in __init__ since we need _init_called to be
set to true by Target.create_project for cheribsd-mfs-root-kernel (its
builddir will call cheribsd_reuse_build_dir, which then gets the base
cheribsd instance, which asserts that the caller is already
initialised).

This is all a bit of a mess still, as it seems that all the make_args
setting in setup() should be done in _setup_make_args(), with setup()
either calling _setup_make_args() if needed or just letting the laziness
do its job if not, but I don't want to untangle all that.
  • Loading branch information
jrtc27 committed Jul 18, 2024
1 parent 4a4ebef commit 50a9406
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pycheribuild/projects/cross/cheribsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,13 +525,22 @@ def check_system_dependencies(self) -> None:

def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self._setup_core_make_args_called = False

def _setup_core_make_args(self) -> None:
if self._setup_core_make_args_called:
return

# Needed pre-setup for _query_make_var() (e.g. via objdir)
self.make_args.set_env(MAKEOBJDIRPREFIX=str(self.build_dir))
# TODO? Avoid lots of nested child directories by using MAKEOBJDIR instead of MAKEOBJDIRPREFIX
# self.make_args.set_env(MAKEOBJDIR=str(self.build_dir))

self._setup_core_make_args_called = True

def setup(self) -> None:
super().setup()
self._setup_core_make_args()

if self.crossbuild:
# Use the script that I added for building on Linux/MacOS:
Expand Down Expand Up @@ -828,6 +837,9 @@ def _setup_make_args(self) -> None:
# Same as setup() but can be called multiple times.
if self._setup_make_args_called:
return

self._setup_core_make_args()

# Must be called after __init__() to ensure that CHERI LLVM/upstream LLVM have been built
# before querying the compiler.
if self.crossbuild:
Expand Down

0 comments on commit 50a9406

Please sign in to comment.