Skip to content

Commit

Permalink
setup.py: Add TEST_TOOLCHAIN support.
Browse files Browse the repository at this point in the history
Build against an alternate toolchain installed at the specified path.

Signed-off-by: Chris PeBenito <[email protected]>
  • Loading branch information
pebenito committed Oct 10, 2024
1 parent 305c8fa commit b5a4641
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@
lib_dirs: list[str] = ['.', '/usr/lib64', '/usr/lib', '/usr/local/lib']
include_dirs: list[str] = []

userspace_src = os.getenv("USERSPACE_SRC", "")
if userspace_src:
test_toolchain: str | None = os.getenv("TEST_TOOLCHAIN")
userspace_src: str | None = os.getenv("USERSPACE_SRC")
if test_toolchain:
toolchain_path = Path(test_toolchain)
include_dirs.insert(0, str(toolchain_path / "usr/include"))
lib_dirs.insert(0, str(toolchain_path / "lib"))
lib_dirs.insert(1, str(toolchain_path / "usr/lib"))
elif userspace_src:
userspace_path = Path(userspace_src)
include_dirs.insert(0, str(userspace_path / "libsepol/include"))
include_dirs.insert(1, str(userspace_path / "libselinux/include"))
Expand Down
9 changes: 6 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,16 @@ def _do_compile(source_file: str, output_file: str, /, *, mls: bool = True,
Return:
A SELinuxPolicy object.
"""
test_toolchain = os.getenv("TEST_TOOLCHAIN")
user_src = os.getenv("USERSPACE_SRC")
checkpol = os.getenv("CHECKPOLICY")

if user_src:
command = [user_src + "/checkpolicy/checkpolicy"]
elif checkpol:
if checkpol:
command = [checkpol]
elif test_toolchain:
command = [test_toolchain + "/usr/bin/checkpolicy"]
elif user_src:
command = [user_src + "/checkpolicy/checkpolicy"]
else:
command = ["/usr/bin/checkpolicy"]

Expand Down

0 comments on commit b5a4641

Please sign in to comment.