Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions configuration/steps/commands/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ def __init__(
builddir: str = ".",
verbose: bool = False,
workdir: PurePath = PurePath("."),
targets: list[str] = [],
):
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]:
Expand All @@ -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


Expand Down
10 changes: 8 additions & 2 deletions configuration/steps/commands/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,29 @@ 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",
util.Interpolate(
(
"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}"
)
),
]
Expand Down
7 changes: 6 additions & 1 deletion configuration/steps/generators/cmake/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions configuration/steps/generators/cmake/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion configuration/test/unit/test_cmake_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_initialization_with_flags(self):
command,
[
"cmake",
"-S",
".",
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
"-DCMAKE_INSTALL_PREFIX=/usr/local",
Expand All @@ -52,6 +53,7 @@ def test_append_flags_successful(self):
command,
[
"cmake",
"-S",
".",
"-DCMAKE_AR=ar",
"-DCMAKE_LIBRARY_PATH=/usr/lib",
Expand Down Expand Up @@ -79,6 +81,7 @@ def test_set_compiler(self):
command,
[
"cmake",
"-S",
".",
"-DCMAKE_CXX_COMPILER=g++",
"-DCMAKE_C_COMPILER=gcc",
Expand All @@ -95,6 +98,7 @@ def test_use_ccache(self):
command,
[
"cmake",
"-S",
".",
"-DCMAKE_CXX_COMPILER_LAUNCHER=ccache",
"-DCMAKE_C_COMPILER_LAUNCHER=ccache",
Expand All @@ -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):
"""
Expand All @@ -124,6 +128,7 @@ def test_set_build_config(self):
command,
[
"cmake",
"-S",
".",
"-DBUILD_CONFIG=mysql_release",
],
Expand Down Expand Up @@ -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",
Expand Down