Skip to content

Commit

Permalink
[Meta] Ensure caller-provided environment always takes precedence whe…
Browse files Browse the repository at this point in the history
…n build system spawns a subprocess
  • Loading branch information
codyd51 committed Mar 25, 2024
1 parent 1e4c085 commit 943e1b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions scripts/build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from typing import Dict, List, Optional



def second_file_is_older(file1: Path, file2: Path) -> bool:
return os.stat(file1.as_posix()).st_mtime - os.stat(file2.as_posix()).st_mtime > 1

Expand All @@ -34,14 +33,17 @@ def is_on_macos() -> bool:
def run_and_check(cmd_list: List[str], cwd: Path = None, env_additions: Optional[Dict[str, str]] = None) -> None:
print(" ".join(cmd_list), cwd)
env = os.environ.copy()
if env_additions:
for k, v in env_additions.items():
env[k] = v

# PT: Ensure the M1 Homebrew prefix is always in PATH
# TODO(PT): Conditionally enable this on M1 hosts?
# And ensure we do this before we add in the environment additions from the caller, so those always have
# highest precedence.
env["PATH"] = f"/opt/homebrew/bin:{env['PATH']}"

if env_additions:
for k, v in env_additions.items():
env[k] = v

status = subprocess.run(cmd_list, cwd=cwd.as_posix() if cwd else None, env=env)
if status.returncode != 0:
raise RuntimeError(f'Running "{" ".join(cmd_list)}" failed with exit code {status.returncode}')
Expand Down
2 changes: 1 addition & 1 deletion scripts/newlib.patch
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ new file mode 100644
index 0000000..c2926ca
--- /dev/null
+++ b/newlib/libc/sys/axle/syscalls.c
@@ -0,0 +1,187 @@
@@ -0,0 +1,191 @@
+/* note these headers are all provided by newlib - you don't need to provide them */
+#include <sys/stat.h>
+#include <sys/types.h>
Expand Down

0 comments on commit 943e1b4

Please sign in to comment.