From 7a04ecf4291de6f8c06a126024479725a9405326 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 10 Sep 2025 08:40:37 +1000 Subject: [PATCH 1/4] MDBF-143: prep - CompileCmakeCommand - optional targets Add optional targets to the CompileCMakeCommand --- configuration/steps/commands/compile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configuration/steps/commands/compile.py b/configuration/steps/commands/compile.py index f3bb2b06..42b7a50d 100644 --- a/configuration/steps/commands/compile.py +++ b/configuration/steps/commands/compile.py @@ -80,10 +80,12 @@ def __init__( builddir: str = ".", verbose: bool = False, workdir: PurePath = PurePath("."), + targets: list[str] = None, ): self.verbose = verbose self.builddir = builddir self.jobs = jobs + self.targets = targets super().__init__(name="Compile", workdir=workdir) def as_cmd_arg(self) -> list[str]: @@ -96,6 +98,9 @@ def as_cmd_arg(self) -> list[str]: ] if self.verbose: r_list.append("--verbose") + if self.targets: + r_list.append("--targets") + r_list.append(self.targets) return r_list From 5ee37268d11e3b2d267472ed09533ba718f9b452 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 10 Sep 2025 08:42:19 +1000 Subject: [PATCH 2/4] MDBF-143: prep - GitInitFromCommand - depth configurable Non-impacting change; now depth is optional, and depth 0 means there is no depth limit. --- configuration/steps/commands/download.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/configuration/steps/commands/download.py b/configuration/steps/commands/download.py index 32b8541b..06b44edf 100644 --- a/configuration/steps/commands/download.py +++ b/configuration/steps/commands/download.py @@ -46,13 +46,19 @@ def __init__( repo_url: str, workdir: PurePath = PurePath("."), jobs: int = 1, + depth: int = 1, ): super().__init__(name="Git", workdir=workdir) self.commit = commit self.repo_url = repo_url self.jobs = jobs + self.depth = depth def as_cmd_arg(self) -> list[str]: + if self.depth != 0: + depth = "--depth " + str(self.depth) + else: + depth = "" return [ "bash", "-exc", @@ -60,9 +66,9 @@ def as_cmd_arg(self) -> list[str]: ( "git init && " f"git remote add origin {self.repo_url} && " - f"git fetch --depth 1 origin {self.commit} && " + f"git fetch {depth} origin {self.commit} && " "git checkout FETCH_HEAD && " - f"git submodule update --init --recursive --depth 1 --jobs={self.jobs}" + f"git submodule update --init --recursive {depth} --jobs={self.jobs}" ) ), ] From c3c3fd1223927a9634e1e61701052425cc214033 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 10 Sep 2025 08:45:27 +1000 Subject: [PATCH 3/4] MDBF-143: prep - CMakeGenerator - add builddir The builddir doesn't need to be the current dir. This adds builddir as an option with its default value of None meaning that the previous default behaviour is observed. builddir as chosen for consistency with the CompileCMake command and it looks a little out of place beside source_path in consistency of naming. Also source_path uses a CMake -S argument rather than just defaulting to this source_path value for additional clarity. --- configuration/steps/generators/cmake/generator.py | 7 ++++++- configuration/test/unit/test_cmake_generator.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/configuration/steps/generators/cmake/generator.py b/configuration/steps/generators/cmake/generator.py index e15a1ef6..0bc66f1d 100644 --- a/configuration/steps/generators/cmake/generator.py +++ b/configuration/steps/generators/cmake/generator.py @@ -21,6 +21,7 @@ def __init__( use_ccache: bool = False, compiler: CompilerCommand = None, source_path: str = ".", + builddir: str = None, ): """ Initializes the CMakeGenerator with an optional list of flags. @@ -31,8 +32,12 @@ def __init__( compiler: An instance of CompilerCommand if you want to set it explicitly. source_path: The source path to the base CMakeLists.txt file. Default path is "in source build". + builddir: The path of the build directory. Default is None. """ - super().__init__(base_cmd=["cmake", source_path], flags=flags) + base_command = ["cmake", "-S", source_path] + if builddir: + base_command += ["-B", builddir] + super().__init__(base_cmd=base_command, flags=flags) if use_ccache: self._use_ccache() diff --git a/configuration/test/unit/test_cmake_generator.py b/configuration/test/unit/test_cmake_generator.py index ed24c80d..422ee465 100644 --- a/configuration/test/unit/test_cmake_generator.py +++ b/configuration/test/unit/test_cmake_generator.py @@ -28,6 +28,7 @@ def test_initialization_with_flags(self): command, [ "cmake", + "-S", ".", "-DCMAKE_BUILD_TYPE=RelWithDebInfo", "-DCMAKE_INSTALL_PREFIX=/usr/local", @@ -52,6 +53,7 @@ def test_append_flags_successful(self): command, [ "cmake", + "-S", ".", "-DCMAKE_AR=ar", "-DCMAKE_LIBRARY_PATH=/usr/lib", @@ -79,6 +81,7 @@ def test_set_compiler(self): command, [ "cmake", + "-S", ".", "-DCMAKE_CXX_COMPILER=g++", "-DCMAKE_C_COMPILER=gcc", @@ -95,6 +98,7 @@ def test_use_ccache(self): command, [ "cmake", + "-S", ".", "-DCMAKE_CXX_COMPILER_LAUNCHER=ccache", "-DCMAKE_C_COMPILER_LAUNCHER=ccache", @@ -108,7 +112,7 @@ def test_generate_with_no_flags(self): """ generator = CMakeGenerator(flags=[]) command = generator.generate() - self.assertEqual(command, ["cmake", "."]) + self.assertEqual(command, ["cmake", "-S", "."]) def test_set_build_config(self): """ @@ -124,6 +128,7 @@ def test_set_build_config(self): command, [ "cmake", + "-S", ".", "-DBUILD_CONFIG=mysql_release", ], @@ -158,6 +163,7 @@ def test_set_build_config_with_other_flags(self): command, [ "cmake", + "-S", ".", "-DBUILD_CONFIG=mysql_release", "-DCMAKE_INSTALL_PREFIX=/usr/lib/test", From b9c822c01ddc371d51ed9bc7013b9839c379a764 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 10 Sep 2025 08:46:10 +1000 Subject: [PATCH 4/4] MDBF-143: prep - Add EXPORT_COMPILE_COMMANDS as CMAKE option --- configuration/steps/generators/cmake/options.py | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration/steps/generators/cmake/options.py b/configuration/steps/generators/cmake/options.py index b7e5bfde..f444549f 100644 --- a/configuration/steps/generators/cmake/options.py +++ b/configuration/steps/generators/cmake/options.py @@ -25,6 +25,7 @@ class CMAKE(StrEnum): C_COMPILER_LAUNCHER = "C_COMPILER_LAUNCHER" CXX_COMPILER_LAUNCHER = "CXX_COMPILER_LAUNCHER" EXE_LINKER_FLAGS = "EXE_LINKER_FLAGS" + EXPORT_COMPILE_COMMANDS = "EXPORT_COMPILE_COMMANDS" INSTALL_PREFIX = "INSTALL_PREFIX" LIBRARY_PATH = "LIBRARY_PATH" MODULE_LINKER_FLAGS = "MODULE_LINKER_FLAGS"