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 specifying depending binaries in build deps #39

Merged
merged 1 commit into from
Aug 12, 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
3 changes: 3 additions & 0 deletions metapkg/packages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def get_shlibs(self, build: targets.Build) -> list[str]:
def get_include_paths(self, build: targets.Build) -> list[pathlib.Path]:
return []

def get_dep_commands(self) -> list[str]:
return []

def write_file_list_script(
self, build: targets.Build, listname: str, entries: list[str]
) -> str:
Expand Down
5 changes: 5 additions & 0 deletions metapkg/packages/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ def get_build_script(self, build: targets.Build) -> str:
if ldflags:
build.sh_append_quoted_ldflags(env, ldflags)

paths = build.sh_get_command_paths(self.get_dep_commands(), self)

if paths:
build.sh_append_paths(env, paths)

binary = True

all_build_deps = build.get_bundled_build_reqs(self, recursive=True)
Expand Down
30 changes: 30 additions & 0 deletions metapkg/targets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,23 @@ def sh_get_bundled_shlibs_cflags(

return flags

def sh_get_command_paths(
self,
commands: Iterable[str],
pkg: mpkg_base.BasePackage,
) -> list[str]:
paths = set()
src_root = self.get_source_abspath()
for cmd in commands:
cmd_txt = self.sh_get_command(
cmd, package=pkg, relative_to="sourceroot"
)
if os.path.sep not in cmd_txt:
# Skip global commands
continue
paths.add(src_root / pathlib.Path(cmd_txt).parent)
return [str(p) for p in paths]

def sh_append_global_flags(
self,
args: Mapping[str, str | pathlib.Path | None] | None = None,
Expand Down Expand Up @@ -1651,6 +1668,19 @@ def sh_append_ldflags(
) -> None:
self.sh_append_quoted_ldflags(args, self.sh_quote_flags(flags))

def sh_append_paths(
self,
args: dict[str, str | pathlib.Path | None],
paths: list[str] | tuple[str, ...],
) -> None:
new_paths = self.sh_quote_flags(paths)
old_path = args.get("PATH")
if not old_path:
old_path = os.getenv("PATH")
if old_path:
new_paths = [str(old_path), *new_paths]
args["PATH"] = os.pathsep.join(new_paths)

def sh_configure(
self,
path: str | pathlib.Path,
Expand Down
Loading