[PATCH] D34736: [cmake] Cache results of find_darwin_sdk_dir and add an option to prefer public SDK

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 22:14:45 PDT 2017


kubamracek created this revision.
kubamracek added a project: Sanitizers.
Herald added a subscriber: mgorny.

This improves find_darwin_sdk_dir to:

1. Cache the results of executing `xcodebuild` to find the SDK.  Should significantly reduce the CMake re-configure time.
2. Add a CMake option `DARWIN_PREFER_PUBLIC_SDK`, off by default.  When on, this prefers to use the public SDK, even when an internal one is present.  With this, it's easy to emulate a build that the public buildbots are doing.


Repository:
  rL LLVM

https://reviews.llvm.org/D34736

Files:
  cmake/Modules/CompilerRTDarwinUtils.cmake


Index: cmake/Modules/CompilerRTDarwinUtils.cmake
===================================================================
--- cmake/Modules/CompilerRTDarwinUtils.cmake
+++ cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -4,14 +4,21 @@
 # set the default Xcode to use. This function finds the SDKs that are present in
 # the current Xcode.
 function(find_darwin_sdk_dir var sdk_name)
-  # Let's first try the internal SDK, otherwise use the public SDK.
-  execute_process(
-    COMMAND xcodebuild -version -sdk ${sdk_name}.internal Path
-    RESULT_VARIABLE result_process
-    OUTPUT_VARIABLE var_internal
-    OUTPUT_STRIP_TRAILING_WHITESPACE
-    ERROR_FILE /dev/null
-  )
+  if(NOT "${DARWIN_${sdk_name}_CACHED_SYSROOT}" STREQUAL "")
+    set(${var} ${DARWIN_${sdk_name}_CACHED_SYSROOT} PARENT_SCOPE)
+    return()
+  endif()
+  set(DARWIN_PREFER_PUBLIC_SDK OFF CACHE BOOL "Prefer Darwin public SDK, even when an internal SDK is present.")
+  if(NOT DARWIN_PREFER_PUBLIC_SDK)
+    # Let's first try the internal SDK, otherwise use the public SDK.
+    execute_process(
+      COMMAND xcodebuild -version -sdk ${sdk_name}.internal Path
+      RESULT_VARIABLE result_process
+      OUTPUT_VARIABLE var_internal
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+      ERROR_FILE /dev/null
+    )
+  endif()
   if((NOT result_process EQUAL 0) OR "" STREQUAL "${var_internal}")
     execute_process(
       COMMAND xcodebuild -version -sdk ${sdk_name} Path
@@ -26,6 +33,7 @@
   if(result_process EQUAL 0)
     set(${var} ${var_internal} PARENT_SCOPE)
   endif()
+  set(DARWIN_${sdk_name}_CACHED_SYSROOT ${var_internal} CACHE STRING "Darwin SDK path for SDK ${sdk_name}.")
 endfunction()
 
 # There isn't a clear mapping of what architectures are supported with a given


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34736.104348.patch
Type: text/x-patch
Size: 1750 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170628/a8104e06/attachment.bin>


More information about the llvm-commits mailing list