Skip to content

Commit a83e94e

Browse files
committedMar 13, 2025·
Ensure CMake install instructions are consistent
1 parent 299541a commit a83e94e

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed
 

‎pycheribuild/projects/cmake_project.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from ..config.chericonfig import BuildType
4040
from ..processutils import commandline_to_str
4141
from ..targets import target_manager
42-
from ..utils import InstallInstructions, OSInfo, include_local_file
42+
from ..utils import InstallInstructions, include_local_file
4343

4444
__all__ = ["CMakeProject"]
4545

@@ -80,16 +80,7 @@ def _bool_to_str(self, value: bool) -> str:
8080
return "TRUE" if value else "FALSE"
8181

8282
def _configure_tool_install_instructions(self) -> InstallInstructions:
83-
return OSInfo.install_instructions(
84-
"cmake",
85-
False,
86-
default="cmake",
87-
homebrew="cmake",
88-
zypper="cmake",
89-
apt="cmake",
90-
freebsd="cmake",
91-
cheribuild_target="cmake",
92-
)
83+
return InstallInstructions.cmake()
9384

9485
@property
9586
def _get_version_args(self) -> dict:

‎pycheribuild/projects/kdevelop.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from .cross.llvm import BuildCheriLLVM
3232
from .project import BuildType, DefaultInstallDir, GitRepository
3333
from .simple_project import SimpleProject
34+
from ..utils import InstallInstructions
3435

3536

3637
# doesn't seem to be part of distro packages
@@ -70,9 +71,7 @@ class StartKDevelop(SimpleProject):
7071

7172
def check_system_dependencies(self) -> None:
7273
super().check_system_dependencies()
73-
self.check_required_system_tool(
74-
"cmake", default="cmake", homebrew="cmake", zypper="cmake", apt="cmake", freebsd="cmake"
75-
)
74+
self.check_required_system_tool("cmake", instructions=InstallInstructions.cmake())
7675
self.check_required_system_tool("qtpaths")
7776

7877
def process(self):

‎pycheribuild/projects/project.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,7 @@ def __infer_command(self) -> str:
238238
self.__project.check_required_system_tool("ninja", homebrew="ninja", apt="ninja-build")
239239
return "ninja"
240240
elif self.kind == MakeCommandKind.CMake:
241-
self.__project.check_required_system_tool(
242-
"cmake", default="cmake", homebrew="cmake", zypper="cmake", apt="cmake", freebsd="cmake"
243-
)
241+
self.__project.check_required_system_tool("cmake", instructions=InstallInstructions.cmake())
244242
assert self.subkind is not None
245243
return "cmake"
246244
else:

‎pycheribuild/projects/simple_project.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1168,10 +1168,11 @@ def check_required_system_tool(
11681168
)
11691169
if executable in self.__checked_system_tools:
11701170
# If we already checked for this tool, the install instructions should match
1171-
assert instructions.fixit_hint() == self.__checked_system_tools[executable].fixit_hint(), executable
1171+
existing = self.__checked_system_tools[executable]
1172+
assert instructions.cheribuild_target == existing.cheribuild_target
1173+
assert instructions.alternative == existing.alternative
1174+
assert instructions.fixit_hint() == existing.fixit_hint(), f"mismatched instructions for {executable}"
11721175
return # already checked
1173-
assert instructions.cheribuild_target == cheribuild_target
1174-
assert instructions.alternative == alternative_instructions
11751176
self._validate_cheribuild_target_for_system_deps(instructions.cheribuild_target)
11761177
if not shutil.which(str(executable)):
11771178
self.dependency_error(
@@ -1212,7 +1213,10 @@ def check_required_pkg_config(
12121213
)
12131214
if package in self.__checked_pkg_config:
12141215
# If we already checked for this pkg-config .pc file, the install instructions should match
1215-
assert instructions.fixit_hint() == self.__checked_pkg_config[package].fixit_hint(), package
1216+
existing = self.__checked_pkg_config[package]
1217+
assert instructions.cheribuild_target == existing.cheribuild_target
1218+
assert instructions.alternative == existing.alternative
1219+
assert instructions.fixit_hint() == existing.fixit_hint(), f"mismatched instructions for {package}"
12161220
return # already checked
12171221
self._validate_cheribuild_target_for_system_deps(instructions.cheribuild_target)
12181222
try:

‎pycheribuild/utils.py

+13
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,19 @@ def fixit_hint(self) -> str:
369369
result += "\nAlternatively " + self.alternative
370370
return result
371371

372+
@classmethod
373+
def cmake(cls):
374+
return OSInfo.install_instructions(
375+
"cmake",
376+
False,
377+
default="cmake",
378+
homebrew="cmake",
379+
zypper="cmake",
380+
apt="cmake",
381+
freebsd="cmake",
382+
cheribuild_target="cmake",
383+
)
384+
372385

373386
class OSInfo:
374387
IS_LINUX: bool = sys.platform.startswith("linux")

‎tests/run_smoke_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ try_run "${srcdir}/cheribuild.py" --dump-config
5454
try_run sh -c "\"${srcdir}/combine-files.py\" | \"$(command -v python3)\" - --get-config-option output-root"
5555
try_run "${srcdir}/cheribuild.py" -p __run_everything__ --clean --build --test --benchmark
5656
# Also check that we can run --pretend mode with all tools missing.
57-
try_run env PATH=/does/not/exist "$(command -v python3)" "${srcdir}/cheribuild.py" -p __run_everything__ --clean --build --test --benchmark
57+
try_run env PATH=/does/not/exist "$(command -v python3)" "${srcdir}/cheribuild.py" -p __run_everything__ --clean --build --test --benchmark --source-root=/tmp/does-not-exist
5858
try_run env WORKSPACE=/tmp "${srcdir}/jenkins-cheri-build.py" --allow-more-than-one-target --build --test --cpu=default -p __run_everything__
5959
# Check that the CheriBSD test script works
6060
try_run "${srcdir}/test-scripts/run_cheribsd_tests.py" -p --architecture morello-purecap --ssh-key path/to/test/ssh_key.pub --qemu-cmd /path/to/sdk/bin/qemu-system-morello --disk-image /path/to/output/cheribsd-morello-purecap.img --test-output-dir=/path/to/build/test-results/run-morello-purecap

0 commit comments

Comments
 (0)
Please sign in to comment.