Skip to content

Commit 7a0a44e

Browse files
committed
[CMake] Stop using globs on the apinotes directory.
The problem here is that there isn't an obvious way to force a CMake reconfiguration when you need to add new apinotes. This dates back to when we (internally) had the apinotes in a separate repo, but that hasn't been the case for a long time. We're still not using a /normal/ CMake add_subdirectory for these because we compile the apinotes as part of building overlays for frameworks that have both overlays and apinotes, and I didn't want to touch any of that stuff right now.
1 parent 4091e54 commit 7a0a44e

File tree

3 files changed

+47
-15
lines changed

3 files changed

+47
-15
lines changed

CMakeLists.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -771,21 +771,17 @@ endif()
771771
#
772772
# Set up global CMake variables for API notes.
773773
#
774-
# API notes version 1.0.0
775-
#
776-
# Change the above comment to 'touch' this file and keep incremental builds
777-
# working when adding a new apinotes file.
778-
#
779774
set(SWIFT_API_NOTES_PATH "${SWIFT_SOURCE_DIR}/apinotes")
780-
if(NOT EXISTS "${SWIFT_API_NOTES_PATH}/Foundation.apinotes")
775+
include("${SWIFT_API_NOTES_PATH}/CMakeLists.txt")
776+
if(NOT DEFINED SWIFT_API_NOTES_INPUTS)
781777
message(FATAL_ERROR "API notes are not available in ${SWIFT_API_NOTES_PATH}")
782778
endif()
783-
784-
file(GLOB SWIFT_API_NOTES_INPUT_FILES "${SWIFT_API_NOTES_PATH}/*.apinotes")
785-
foreach(file ${SWIFT_API_NOTES_INPUT_FILES})
786-
get_filename_component(name "${file}" NAME_WE)
787-
list(APPEND SWIFT_API_NOTES_INPUTS ${name})
788-
endforeach()
779+
#
780+
# file(GLOB SWIFT_API_NOTES_INPUT_FILES "${SWIFT_API_NOTES_PATH}/*.apinotes")
781+
# foreach(file ${SWIFT_API_NOTES_INPUT_FILES})
782+
# get_filename_component(name "${file}" NAME_WE)
783+
# list(APPEND SWIFT_API_NOTES_INPUTS ${name})
784+
# endforeach()
789785

790786
# Add all of the subdirectories, where we actually do work.
791787
if(SWIFT_BUILD_TOOLS)

apinotes/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
set(SWIFT_API_NOTES_INPUTS
2+
AppKit
3+
AVFoundation
4+
CoreData
5+
CoreGraphics
6+
CoreLocation
7+
Dispatch
8+
Foundation
9+
GameKit
10+
HomeKit
11+
NotificationCenter
12+
ObjectiveC
13+
SpriteKit
14+
TVMLKit
15+
TVServices
16+
UIKit
17+
WatchKit
18+
WebKit)
19+
20+
if(NOT DEFINED SWIFT_API_NOTES_PATH)
21+
message(FATAL_ERROR "Define SWIFT_API_NOTES_PATH before including this file")
22+
endif()
23+
24+
foreach(module ${SWIFT_API_NOTES_INPUTS})
25+
if(NOT EXISTS "${SWIFT_API_NOTES_PATH}/${module}.apinotes")
26+
message(SEND_ERROR "Missing apinotes for ${module}")
27+
endif()
28+
endforeach()
29+
30+
file(GLOB SWIFT_API_NOTES_INPUT_FILES "${SWIFT_API_NOTES_PATH}/*.apinotes")
31+
foreach(file ${SWIFT_API_NOTES_INPUT_FILES})
32+
get_filename_component(name "${file}" NAME_WE)
33+
list(FIND SWIFT_API_NOTES_INPUTS "${name}" name_index)
34+
if(name_index EQUAL -1)
35+
message(WARNING "Found apinotes for ${name}; please add to CMakeLists.txt")
36+
endif()
37+
endforeach()

apinotes/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ xcrun swift -apinotes -yaml-to-binary -target x64_64-apple-ios7.0 -o $SWIFT_EXEC
7070
```
7171

7272
To add API notes for a system module `$MODULE` that does not have them yet,
73-
create a new source file `$MODULE.apinotes`. Newly-added API notes will require
74-
re-running CMake. Updated API notes will be found by the build system during
75-
the next build.
73+
create a new source file `$MODULE.apinotes` and update CMakeLists.txt.
74+
Updated API notes will be found by the build system during the next build.
7675

7776
Note that Swift provides decompilation of binary API notes files via
7877
the `-apinotes -binary-to-yaml` option, which allows one to inspect

0 commit comments

Comments
 (0)