Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding --prefix in spin build #241

Merged
merged 9 commits into from
Nov 5, 2024
Merged
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
14 changes: 13 additions & 1 deletion spin/cmds/meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ def _check_coverage_tool_installation(coverage_type: GcovReportFormat, build_dir
)


if sys.platform.startswith("win"):
DEFAULT_PREFIX = "C:/"
else:
DEFAULT_PREFIX = "/usr"

build_dir_option = click.option(
"-C",
"--build-dir",
Expand All @@ -251,6 +256,12 @@ def _check_coverage_tool_installation(coverage_type: GcovReportFormat, build_dir
is_flag=True,
help="Enable C code coverage using `gcov`. Use `spin test --gcov` to generate reports.",
)
@click.option(
"--prefix",
help="The build prefix, passed directly to meson.",
type=str,
default=DEFAULT_PREFIX,
)
@click.argument("meson_args", nargs=-1)
@build_dir_option
def build(
Expand All @@ -262,6 +273,7 @@ def build(
gcov=False,
quiet=False,
build_dir=None,
prefix=None,
):
"""🔧 Build package with Meson/ninja

Expand Down Expand Up @@ -312,7 +324,7 @@ def build(
if gcov:
meson_args = meson_args + ["-Db_coverage=true"]

setup_cmd = _meson_cli() + ["setup", build_dir, "--prefix=/usr"] + meson_args
setup_cmd = _meson_cli() + ["setup", build_dir, f"--prefix={prefix}"] + meson_args

if clean:
print(f"Removing `{build_dir}`")
Expand Down
6 changes: 6 additions & 0 deletions spin/tests/test_build_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def test_debug_builds():
assert len(list(debug_files)) != 0, "debug files not generated for gcov build"


def test_prefix_builds():
"""does spin build --prefix create a build-install directory with the correct structure?"""
spin("build", "--prefix=/foobar/")
assert (Path("build-install") / Path("foobar")).exists()


def test_coverage_builds():
"""Does gcov test generate coverage files?"""
spin("test", "--gcov")
Expand Down
Loading