aboutsummaryrefslogtreecommitdiff
path: root/tools/build/make.py
diff options
context:
space:
mode:
authorAlex Richardson <arichardson@FreeBSD.org>2021-02-26 17:49:03 +0000
committerAlex Richardson <arichardson@FreeBSD.org>2021-03-01 12:53:46 +0000
commita26ace4db6d974215a4d882948da80eae2b3b0d4 (patch)
treee11cfcea1fb1a63cd259d93e138ea330c79ffdfb /tools/build/make.py
parentaac21e66f94e0a8ad52c1f8cd8dce50fcdd35cca (diff)
downloadsrc-a26ace4db6d974215a4d882948da80eae2b3b0d4.tar.gz
src-a26ace4db6d974215a4d882948da80eae2b3b0d4.zip
tools/build/make.py: Don't call brew --prefix if --cross-bindir is set
Also updated the logic to use subprocess.run() instead of the old subprocess.getoutput() which also includes stderr and therefore can trigger an exception inside Path().exists(). Reported by: gnn
Diffstat (limited to 'tools/build/make.py')
-rwxr-xr-xtools/build/make.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/build/make.py b/tools/build/make.py
index bc6d8fb449bb..c34147f6ac21 100755
--- a/tools/build/make.py
+++ b/tools/build/make.py
@@ -124,9 +124,14 @@ def default_cross_toolchain():
# default to homebrew-installed clang on MacOS if available
if sys.platform.startswith("darwin"):
if shutil.which("brew"):
- llvm_dir = subprocess.getoutput("brew --prefix llvm")
- if llvm_dir and Path(llvm_dir, "bin").exists():
- return str(Path(llvm_dir, "bin"))
+ llvm_dir = subprocess.run(["brew", "--prefix", "llvm"],
+ capture_output=True).stdout.strip()
+ debug("Inferred LLVM dir as", llvm_dir)
+ try:
+ if llvm_dir and Path(llvm_dir.decode("utf-8"), "bin").exists():
+ return str(Path(llvm_dir.decode("utf-8"), "bin"))
+ except OSError:
+ return None
return None
@@ -137,7 +142,7 @@ if __name__ == "__main__":
help="Directory to look for cc/c++/cpp/ld to build "
"host (" + sys.platform + ") binaries",
default="/usr/bin")
- parser.add_argument("--cross-bindir", default=default_cross_toolchain(),
+ parser.add_argument("--cross-bindir", default=None,
help="Directory to look for cc/c++/cpp/ld to build "
"target binaries (only needed if XCC/XCPP/XLD "
"are not set)")
@@ -165,6 +170,8 @@ if __name__ == "__main__":
except ImportError:
pass
parsed_args, bmake_args = parser.parse_known_args()
+ if parsed_args.cross_bindir is None:
+ parsed_args.cross_bindir = default_cross_toolchain()
MAKEOBJDIRPREFIX = os.getenv("MAKEOBJDIRPREFIX")
if not MAKEOBJDIRPREFIX: