Skip to content

Commit d343478

Browse files
committed
SwiftCore: Cache computed platform info
Implements a similar caching mechanism to what CMake uses for detecting the compiler. The file is created based on the computed values and allows us to avoid calling the compiler if we aren't going to extract out any platform info.
1 parent 1d4e9d0 commit d343478

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,4 @@ Runtimes/**/*.inc
9797
Runtimes/**/*.json
9898
Runtimes/**/*.modulemap
9999
Runtimes/**/*.in
100+
!Runtimes/**/*.cmake.in
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set(SwiftCore_SIZEOF_POINTER @SwiftCore_SIZEOF_POINTER@)
2+
set(SwiftCore_MODULE_TRIPLE @SwiftCore_MODULE_TRIPLE@)
3+
set(SwiftCore_PLATFORM_SUBIDR @SwiftCore_PLATFORM_SUBIDR@)
4+
set(SwiftCore_ARCH_SUBDIR @SwiftCore_ARCH_SUBDIR@)
5+
6+
set(SwiftCore_SWIFT_AVAILABILITY_PLATFORM @SwiftCore_SWIFT_AVAILABILITY_PLATFORM@)
7+
8+
set(SwiftCore_PLATFORM_INFO_SET 1)

Runtimes/Core/cmake/modules/PlatformInfo.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
include("${PROJECT_BINARY_DIR}/build/DetectedPlatformInfo.cmake" OPTIONAL)
2+
3+
if(SwiftCore_PLATFORM_INFO_SET)
4+
return()
5+
endif()
6+
17
if(NOT SwiftCore_SIZEOF_POINTER)
28
set(SwiftCore_SIZEOF_POINTER "${CMAKE_SIZEOF_VOID_P}" CACHE STRING "Size of a pointer in bytes")
39
message(CONFIGURE_LOG "Stdlib Pointer size: ${CMAKE_SIZEOF_VOID_P}")
@@ -80,3 +86,7 @@ if(SwiftCore_VARIANT_MODULE_TRIPLE)
8086
message(WARNING "Unknown platform ${platform} for variant availability")
8187
endif()
8288
endif()
89+
90+
configure_file("${CMAKE_CURRENT_LIST_DIR}/DetectedPlatformInfo.cmake.in"
91+
"${PROJECT_BINARY_DIR}/build/DetectedPlatformInfo.cmake"
92+
@ONLY)

0 commit comments

Comments
 (0)