Date: Sat, 10 Apr 2021 13:29:59 GMT From: Alex Richardson <arichardson@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 0a0e327fad67 - stable/13 - tools/build/make.py: Don't call brew --prefix if --cross-bindir is set Message-ID: <202104101329.13ADTxwx001964@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=0a0e327fad6745fa48091cbdaeb6fea36ac5dd69 commit 0a0e327fad6745fa48091cbdaeb6fea36ac5dd69 Author: Alex Richardson <arichardson@FreeBSD.org> AuthorDate: 2021-02-26 17:49:03 +0000 Commit: Alex Richardson <arichardson@FreeBSD.org> CommitDate: 2021-04-10 12:56:02 +0000 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 (cherry picked from commit a26ace4db6d974215a4d882948da80eae2b3b0d4) --- tools/build/make.py | 15 +++++++++++---- 1 file 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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202104101329.13ADTxwx001964>