-
Notifications
You must be signed in to change notification settings - Fork 266
framework: stage tool runtime closures into EXT_BUILD_DEPS #1529
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,18 @@ https://docs.bazel.build/versions/main/install-compile-source.html#bootstrap-uni | |||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| load(":commands.bzl", "FunctionAndCallInfo") | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def _strip_outer_quotes(val): | ||||||||||||||||||||||||||||||||||||||||||||||
| """Remove one layer of surrounding double-quotes if present. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| The ##command## arg1 arg2 directive parser (split_arguments) keeps quoted | ||||||||||||||||||||||||||||||||||||||||||||||
| tokens together but includes the quotes in the value. Platform command | ||||||||||||||||||||||||||||||||||||||||||||||
| functions already add their own quotes, so we strip the outer layer to | ||||||||||||||||||||||||||||||||||||||||||||||
| avoid double-quoting. | ||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||
| if len(val) >= 2 and val[0] == '"' and val[-1] == '"': | ||||||||||||||||||||||||||||||||||||||||||||||
| return val[1:-1] | ||||||||||||||||||||||||||||||||||||||||||||||
| return val | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def shebang(): | ||||||||||||||||||||||||||||||||||||||||||||||
| return "#!/usr/bin/env bash" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -48,7 +60,7 @@ def disable_tracing(): | |||||||||||||||||||||||||||||||||||||||||||||
| return "set +x" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def mkdirs(path): | ||||||||||||||||||||||||||||||||||||||||||||||
| return "mkdir -p \"{path}\"".format(path = path) | ||||||||||||||||||||||||||||||||||||||||||||||
| return "mkdir -p \"{path}\"".format(path = _strip_outer_quotes(path)) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def rm_rf(path): | ||||||||||||||||||||||||||||||||||||||||||||||
| return "rm -rf \"{path}\"".format(path = path) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -94,17 +106,63 @@ fi | |||||||||||||||||||||||||||||||||||||||||||||
| """, | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def copy_dir_contents_to_dir(source, target): | ||||||||||||||||||||||||||||||||||||||||||||||
| def copy_dir_contents_to_dir(source, target, flatten_timestamps): | ||||||||||||||||||||||||||||||||||||||||||||||
| """Copy directory contents to target, optionally flattening timestamps. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||||||||||||||||||||||||
| source: Source directory whose contents are copied. | ||||||||||||||||||||||||||||||||||||||||||||||
| target: Target directory. | ||||||||||||||||||||||||||||||||||||||||||||||
| flatten_timestamps: If "True", set all file timestamps to the source | ||||||||||||||||||||||||||||||||||||||||||||||
| directory mtime (prevents autotools regeneration). | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||||||||||||||||||||||||
| str: Shell command string. | ||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||
| source = _strip_outer_quotes(source) | ||||||||||||||||||||||||||||||||||||||||||||||
| target = _strip_outer_quotes(target) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Beause FreeBSD `cp` doesn't have `--no-target-directory`, we have to | ||||||||||||||||||||||||||||||||||||||||||||||
| # do something more complex for this environment. | ||||||||||||||||||||||||||||||||||||||||||||||
| return """\ | ||||||||||||||||||||||||||||||||||||||||||||||
| if flatten_timestamps == "True": | ||||||||||||||||||||||||||||||||||||||||||||||
| return """\ | ||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -d "{source}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| cp -L -R "{source}"/. "{target}" | ||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||
| cp -L -R "{source}" "{target}" | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
| find "{target}" -type f -exec touch -r "{source}" "{{}}" \\; | ||||||||||||||||||||||||||||||||||||||||||||||
| """.format( | ||||||||||||||||||||||||||||||||||||||||||||||
| source = source, | ||||||||||||||||||||||||||||||||||||||||||||||
| target = target, | ||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # Without flatten_timestamps we skip -L (dereference symlinks) and | ||||||||||||||||||||||||||||||||||||||||||||||
| # tolerate "File exists" errors. Runfiles trees contain repo-mapping | ||||||||||||||||||||||||||||||||||||||||||||||
| # symlinks (apparent → canonical) that create duplicate destination | ||||||||||||||||||||||||||||||||||||||||||||||
| # paths; cp errors on the second copy but the file is already present. | ||||||||||||||||||||||||||||||||||||||||||||||
| return """\ | ||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -d "{source}" ]]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| cp -R "{source}"/. "{target}" 2>&1 | grep -v "File exists" >&2 || true | ||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||
| cp -R "{source}" "{target}" 2>&1 | grep -v "File exists" >&2 || true | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+144
to
+148
|
||||||||||||||||||||||||||||||||||||||||||||||
| if [[ -d "{source}" ]]; then | |
| cp -R "{source}"/. "{target}" 2>&1 | grep -v "File exists" >&2 || true | |
| else | |
| cp -R "{source}" "{target}" 2>&1 | grep -v "File exists" >&2 || true | |
| fi | |
| _copy_dir_contents_stderr="$(mktemp)" | |
| _copy_dir_contents_status=0 | |
| if [[ -d "{source}" ]]; then | |
| cp -R "{source}"/. "{target}" 2>"${{_copy_dir_contents_stderr}}" || _copy_dir_contents_status=$? | |
| else | |
| cp -R "{source}" "{target}" 2>"${{_copy_dir_contents_stderr}}" || _copy_dir_contents_status=$? | |
| fi | |
| if grep -qv "File exists" "${{_copy_dir_contents_stderr}}"; then | |
| grep -v "File exists" "${{_copy_dir_contents_stderr}}" >&2 | |
| rm -f "${{_copy_dir_contents_stderr}}" | |
| exit "${{_copy_dir_contents_status:-1}}" | |
| fi | |
| if [[ "${{_copy_dir_contents_status}}" -ne 0 ]] && ! grep -q "File exists" "${{_copy_dir_contents_stderr}}"; then | |
| rm -f "${{_copy_dir_contents_stderr}}" | |
| exit "${{_copy_dir_contents_status}}" | |
| fi | |
| rm -f "${{_copy_dir_contents_stderr}}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_define_inputs()now only stages tool artifacts intotools_fileswhentool.stage_runtimeis true. This drops non-staged tools (e.g. the ninja wrapper) from$EXT_BUILD_DEPS/binand therefore fromPATH, which can break builds that rely on PATH discovery (Meson’s CMake fallback is one example). Consider restoring the previous behavior for non-staged tools (symlink/copy the tool launcher into$EXT_BUILD_DEPS/bin) while keeping the new runtime-closure staging for staged tools.