File tree Expand file tree Collapse file tree 10 files changed +53
-9
lines changed Expand file tree Collapse file tree 10 files changed +53
-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_dependencies TARGET )
18
+ cmake_parse_arguments (ARGS "" "" "PUBLIC" ${ARGN} )
19
+
20
+ foreach (DEPENDENCY ${ARGS_PUBLIC} )
21
+ target_link_libraries (${TARGET} PUBLIC
22
+ ${DEPENDENCY}
23
+ )
24
+
25
+ add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR} /forced-${DEPENDENCY}-dep.swift
26
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR} /forced-${DEPENDENCY}-dep.swift
27
+ DEPENDS ${DEPENDENCY}
28
+ )
29
+ target_sources (${TARGET} PRIVATE
30
+ ${CMAKE_CURRENT_BINARY_DIR} /forced-${DEPENDENCY}-dep.swift
31
+ )
32
+ endforeach ()
33
+ endfunction ()
34
+
9
35
add_subdirectory (SwiftBasicFormat )
10
36
add_subdirectory (SwiftSyntax )
11
37
add_subdirectory (SwiftDiagnostics )
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ 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 when cmake is fixed
16
+ add_forced_dependencies (IDEUtils PUBLIC
16
17
SwiftSyntax )
17
18
18
19
set_property (GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS IDEUtils )
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ 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 when cmake is fixed
17
+ add_forced_dependencies (SwiftBasicFormat PUBLIC
17
18
SwiftSyntax )
18
19
19
20
set_property (GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftBasicFormat )
Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ 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 when cmake is fixed
14
+ add_forced_dependencies (SwiftCompilerSupport PUBLIC
14
15
SwiftSyntax
15
16
SwiftDiagnostics
16
17
SwiftParser
Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ 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 when cmake is fixed
18
+ add_forced_dependencies (SwiftDiagnostics PUBLIC
18
19
SwiftSyntax )
19
20
20
21
set_property (GLOBAL APPEND PROPERTY SWIFTSYNTAX_EXPORTS SwiftDiagnostics )
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ 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 when cmake is fixed
23
+ add_forced_dependencies (SwiftOperators PUBLIC
23
24
SwiftSyntax
24
25
SwiftDiagnostics
25
26
SwiftParser )
Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ 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 when cmake is fixed
40
+ add_forced_dependencies (SwiftParser PUBLIC
40
41
SwiftSyntax
41
42
SwiftDiagnostics )
42
43
@@ -47,6 +48,15 @@ set_target_properties(SwiftParser PROPERTIES
47
48
INTERFACE_INCLUDE_DIRECTORIES
48
49
"${CMAKE_Swift_MODULE_DIRECTORY} " )
49
50
51
+ #file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/SwiftParser-complete.swift)
52
+ #add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SwiftParser-complete.swift
53
+ # COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/SwiftParser-complete.swift
54
+ # DEPENDS SwiftParser
55
+ #)
56
+ #set_target_properties(SwiftParser
57
+ # PROPERTIES FORCE_DEP_PATH ${CMAKE_CURRENT_BINARY_DIR}/SwiftParser-complete.swift
58
+ #)
59
+
50
60
install (TARGETS SwiftParser
51
61
EXPORT SwiftSyntaxTargets
52
62
ARCHIVE DESTINATION lib
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ 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 when cmake is fixed
19
+ add_forced_dependencies (SwiftParserDiagnostics PUBLIC
19
20
SwiftBasicFormat
20
21
SwiftDiagnostics
21
22
SwiftParser
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ 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 when cmake is fixed
27
+ add_forced_dependencies (SwiftSyntaxBuilder PUBLIC
27
28
SwiftBasicFormat
28
29
SwiftParser
29
30
SwiftParserDiagnostics
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ 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 when cmake is fixed
21
+ add_forced_dependencies (_SwiftSyntaxMacros PUBLIC
21
22
SwiftParser
22
23
SwiftSyntaxBuilder
23
24
)
You can’t perform that action at this time.
0 commit comments