[PATCH] D70835: (not for landing) gn build: use xcrun on mac to find sdk path

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 28 16:28:00 PST 2019


thakis created this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This makes both Xcode and no-Xcode-but-commandline-tools-only builds Just Work, and it's The Right Thing To Do, but it makes gn take twice as long (35ms->77ms) and almost everyone has Xcode installed.

So don't land this, at least for now.


https://reviews.llvm.org/D70835

Files:
  llvm/utils/gn/.gn
  llvm/utils/gn/build/mac_sdk.gni
  llvm/utils/gn/build/mac_sdk.py


Index: llvm/utils/gn/build/mac_sdk.py
===================================================================
--- /dev/null
+++ llvm/utils/gn/build/mac_sdk.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+
+import subprocess
+
+print(subprocess.check_output(['xcrun', '--show-sdk-path']).rstrip(), end='')
Index: llvm/utils/gn/build/mac_sdk.gni
===================================================================
--- llvm/utils/gn/build/mac_sdk.gni
+++ llvm/utils/gn/build/mac_sdk.gni
@@ -1,4 +1,2 @@
 # Location of the mac sdk.
-# If that's not fixed, might want to shell out to xcrun at gn time to
-# retrieve this, but for now this seems to do the trick.
-mac_sdk_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
+mac_sdk_path = exec_script("mac_sdk.py", [], "string")
Index: llvm/utils/gn/.gn
===================================================================
--- llvm/utils/gn/.gn
+++ llvm/utils/gn/.gn
@@ -6,7 +6,9 @@
 
 # Disallow all calls to exec_script. We should be very conservative about
 # whitelisting things here.
-exec_script_whitelist = []
+exec_script_whitelist = [
+  "//llvm/utils/gn/build/mac_sdk.gni",
+]
 
 # The normal GN setup is to have BUILD.gn files in-tree and a root BUILD.gn
 # file.  Since LLVM's GN build is unofficial, set secondary_source to tell GN


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70835.231471.patch
Type: text/x-patch
Size: 1373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191129/86691107/attachment.bin>


More information about the llvm-commits mailing list