File tree Expand file tree Collapse file tree 10 files changed +58
-9
lines changed Expand file tree Collapse file tree 10 files changed +58
-9
lines changed Original file line number Diff line number Diff line change 6
6
# See http://swift.org/LICENSE.txt for license information
7
7
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8
8
9
+ # cmake generation for Swift adds an order only dependency, which matches how C-family languages
10
+ # works. In that case, however, ninja (and presumably other generators) will rebuild on header
11
+ # changes. That's not the case for Swift, and thus if A -> B, A is not being rebuilt when the
12
+ # ABI/API of B changes.
13
+ #
14
+ # For now workaround this by touching a file whenever B is rebuilt and then compiling that file as
15
+ # part of A. Ideally this file would be generated by each of the targets, but that dependency didn't
16
+ # seem to be being tracked.
17
+ function (add_forced_dependency TARGET DEPENDENCY )
18
+ target_link_libraries (${TARGET} PUBLIC
19
+ ${DEPENDENCY}
20
+ )
21
+
22
+ add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /forced-${DEPENDENCY}-dep.swift
23
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR} /forced-${DEPENDENCY}-dep.swift
24
+ DEPENDS ${DEPENDENCY}
25
+ )
26
+ target_sources (${TARGET} PRIVATE
27
+ ${CMAKE_CURRENT_BINARY_DIR} /forced-${DEPENDENCY}-dep.swift
28
+ )
29
+ endfunction ()
30
+
9
31
add_subdirectory (SwiftBasicFormat )
10
32
add_subdirectory (SwiftSyntax )
11
33
add_subdirectory (SwiftDiagnostics )
Original file line number Diff line number Diff line change @@ -12,7 +12,9 @@ add_library(IDEUtils STATIC
12
12
SyntaxClassifier.swift
13
13
)
14
14
15
- target_link_libraries (IDEUtils PUBLIC
15
+ # TODO: Change to `target_link_libraries(IDEUtils PUBLIC
16
+ # when cmake is fixed
17
+ add_forced_dependency (IDEUtils
16
18
SwiftSyntax )
17
19
18
20
set_property (GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS IDEUtils )
Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ add_library(SwiftBasicFormat STATIC
13
13
Utils.swift
14
14
)
15
15
16
- target_link_libraries (SwiftBasicFormat PUBLIC
16
+ # TODO: Change to `target_link_libraries(SwiftBasicFormat PUBLIC
17
+ # when cmake is fixed
18
+ add_forced_dependency (SwiftBasicFormat
17
19
SwiftSyntax )
18
20
19
21
set_property (GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftBasicFormat )
Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ add_library(SwiftCompilerSupport STATIC
10
10
ConsistencyCheck.swift
11
11
)
12
12
13
- target_link_libraries (SwiftCompilerSupport PUBLIC
13
+ # TODO: Change to `target_link_libraries(SwiftCompilerSupport PUBLIC
14
+ # when cmake is fixed
15
+ add_forced_dependency (SwiftCompilerSupport
14
16
SwiftSyntax
15
17
SwiftDiagnostics
16
18
SwiftParser
Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ add_library(SwiftDiagnostics STATIC
14
14
Note.swift
15
15
)
16
16
17
- target_link_libraries (SwiftDiagnostics PUBLIC
17
+ # TODO: Change to `target_link_libraries(SwiftDiagnostics PUBLIC
18
+ # when cmake is fixed
19
+ add_forced_dependency (SwiftDiagnostics
18
20
SwiftSyntax )
19
21
20
22
set_property (GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftDiagnostics )
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ add_library(SwiftOperators STATIC
19
19
SyntaxSynthesis.swift
20
20
)
21
21
22
- target_link_libraries (SwiftOperators PUBLIC
22
+ # TODO: Change to `target_link_libraries(SwiftOperators PUBLIC
23
+ # when cmake is fixed
24
+ add_forced_dependency (SwiftOperators
23
25
SwiftSyntax
24
26
SwiftDiagnostics
25
27
SwiftParser )
Original file line number Diff line number Diff line change @@ -36,7 +36,9 @@ add_library(SwiftParser STATIC
36
36
gyb_generated/DeclarationModifier.swift
37
37
gyb_generated/TypeAttribute.swift )
38
38
39
- target_link_libraries (SwiftParser PUBLIC
39
+ # TODO: Change to `target_link_libraries(SwiftParser PUBLIC
40
+ # when cmake is fixed
41
+ add_forced_dependency (SwiftParser
40
42
SwiftSyntax
41
43
SwiftDiagnostics )
42
44
@@ -47,6 +49,15 @@ set_target_properties(SwiftParser PROPERTIES
47
49
INTERFACE_INCLUDE_DIRECTORIES
48
50
"${CMAKE_Swift_MODULE_DIRECTORY} " )
49
51
52
+ #file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/SwiftParser-complete.swift)
53
+ #add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SwiftParser-complete.swift
54
+ # COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/SwiftParser-complete.swift
55
+ # DEPENDS SwiftParser
56
+ #)
57
+ #set_target_properties(SwiftParser
58
+ # PROPERTIES FORCE_DEP_PATH ${CMAKE_CURRENT_BINARY_DIR}/SwiftParser-complete.swift
59
+ #)
60
+
50
61
install (TARGETS SwiftParser
51
62
EXPORT SwiftSyntaxTargets
52
63
ARCHIVE DESTINATION lib
Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ add_library(SwiftParserDiagnostics STATIC
15
15
SyntaxExtensions.swift
16
16
Utils.swift )
17
17
18
- target_link_libraries (SwiftParserDiagnostics PUBLIC
18
+ # TODO: Change to `target_link_libraries(SwiftParserDiagnostics PUBLIC
19
+ # when cmake is fixed
20
+ add_forced_dependency (SwiftParserDiagnostics
19
21
SwiftBasicFormat
20
22
SwiftDiagnostics
21
23
SwiftParser
Original file line number Diff line number Diff line change @@ -23,7 +23,9 @@ add_library(SwiftSyntaxBuilder STATIC
23
23
gyb_generated/SyntaxExpressibleByStringInterpolationConformances.swift
24
24
)
25
25
26
- target_link_libraries (SwiftSyntaxBuilder PUBLIC
26
+ # TODO: Change to `target_link_libraries(SwiftSyntaxBuilder PUBLIC
27
+ # when cmake is fixed
28
+ add_forced_dependency (SwiftSyntaxBuilder
27
29
SwiftBasicFormat
28
30
SwiftParser
29
31
SwiftParserDiagnostics
Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ add_library(_SwiftSyntaxMacros STATIC
17
17
Syntax+MacroEvaluation.swift
18
18
)
19
19
20
- target_link_libraries (_SwiftSyntaxMacros PUBLIC
20
+ # TODO: Change to `target_link_libraries(_SwiftSyntaxMacros PUBLIC
21
+ # when cmake is fixed
22
+ add_forced_dependency (_SwiftSyntaxMacros
21
23
SwiftParser
22
24
SwiftSyntaxBuilder
23
25
)
You can’t perform that action at this time.
0 commit comments