File tree 10 files changed +31
-11
lines changed
10 files changed +31
-11
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,8 @@ func swiftSettings(languageMode: SwiftLanguageMode) -> [SwiftSetting] {
45
45
46
46
. swiftLanguageMode( . v5) ,
47
47
48
- . define( " USE_STATIC_PLUGIN_INITIALIZATION " )
48
+ . define( " USE_STATIC_PLUGIN_INITIALIZATION " ) ,
49
+ . define( " SEARCH_TOOLCHAIN_FOR_RESOURCES " )
49
50
]
50
51
case . v6:
51
52
return [
@@ -55,7 +56,8 @@ func swiftSettings(languageMode: SwiftLanguageMode) -> [SwiftSetting] {
55
56
56
57
. swiftLanguageMode( . v6) ,
57
58
58
- . define( " USE_STATIC_PLUGIN_INITIALIZATION " )
59
+ . define( " USE_STATIC_PLUGIN_INITIALIZATION " ) ,
60
+ . define( " SEARCH_TOOLCHAIN_FOR_RESOURCES " )
59
61
]
60
62
default :
61
63
fatalError ( " unexpected language mode " )
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import Foundation
25
25
26
26
struct AndroidPlatformSpecsExtension : SpecificationsExtension {
27
27
func specificationFiles( ) -> Bundle ? {
28
- . module
28
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBAndroidPlatform " , defaultBundle : Bundle . module)
29
29
}
30
30
31
31
func specificationDomains( ) -> [ String : [ String ] ] {
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ struct ApplePlatformSpecsExtension: SpecificationsExtension {
99
99
}
100
100
101
101
func specificationFiles( ) -> Bundle ? {
102
- . module
102
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBApplePlatform " , defaultBundle : Bundle . module)
103
103
}
104
104
105
105
func specificationDomains( ) -> [ String : [ String ] ] {
Original file line number Diff line number Diff line change @@ -69,4 +69,22 @@ extension SpecificationsExtension {
69
69
public func specificationClassesClassic( ) -> [ any SpecClassType . Type ] { [ ] }
70
70
public func specificationImplementations( ) -> [ any SpecImplementationType . Type ] { [ ] }
71
71
public func specificationSearchPaths( ) -> [ URL ] { [ ] }
72
+
73
+ public func findResourceBundle( nameWhenInstalledInToolchain: String , defaultBundle: Bundle ? ) -> Bundle ? {
74
+ #if SEARCH_TOOLCHAIN_FOR_RESOURCES
75
+ let resourceBundleExtension : String
76
+ #if canImport(Darwin)
77
+ resourceBundleExtension = " bundle "
78
+ #else
79
+ resourceBundleExtension = " resources "
80
+ #endif
81
+ if let executablePath = try ? Path ( CommandLine . arguments [ 0 ] ) . resolveSymlink ( fs: localFS) {
82
+ let prospectiveBundlePath = executablePath. dirname. dirname. join ( " share " ) . join ( " pm " ) . join ( " \( nameWhenInstalledInToolchain) . \( resourceBundleExtension) " )
83
+ if let bundle = Bundle ( path: prospectiveBundlePath. str) {
84
+ return bundle
85
+ }
86
+ }
87
+ #endif
88
+ return defaultBundle
89
+ }
72
90
}
Original file line number Diff line number Diff line change @@ -144,6 +144,6 @@ public struct BuiltinSpecsExtension: SpecificationsExtension {
144
144
}
145
145
146
146
public func specificationFiles( ) -> Bundle ? {
147
- . module
147
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBCore " , defaultBundle : Bundle . module)
148
148
}
149
149
}
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ import Foundation
20
20
21
21
struct GenericUnixPlatformSpecsExtension : SpecificationsExtension {
22
22
func specificationFiles( ) -> Bundle ? {
23
- . module
23
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBGenericUnixPlatform " , defaultBundle : Bundle . module)
24
24
}
25
25
26
26
func specificationDomains( ) -> [ String : [ String ] ] {
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import Foundation
25
25
26
26
struct QNXPlatformSpecsExtension : SpecificationsExtension {
27
27
func specificationFiles( ) -> Bundle ? {
28
- . module
28
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBQNXPlatform " , defaultBundle : Bundle . module)
29
29
}
30
30
}
31
31
Original file line number Diff line number Diff line change @@ -36,11 +36,11 @@ struct UniversalPlatformSpecsExtension: SpecificationsExtension {
36
36
}
37
37
38
38
func specificationFiles( ) -> Bundle ? {
39
- . module
39
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBUniversalPlatform " , defaultBundle : Bundle . module)
40
40
}
41
41
42
42
// Allow locating the sole remaining `.xcbuildrules` file.
43
43
func specificationSearchPaths( ) -> [ URL ] {
44
- Bundle . module. resourceURL. map { [ $0] } ?? [ ]
44
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBUniversalPlatform " , defaultBundle : Bundle . module) ? . resourceURL. map { [ $0] } ?? [ ]
45
45
}
46
46
}
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ import Foundation
23
23
24
24
struct WebAssemblyPlatformSpecsExtension : SpecificationsExtension {
25
25
func specificationFiles( ) -> Bundle ? {
26
- . module
26
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBWebAssemblyPlatform " , defaultBundle : Bundle . module)
27
27
}
28
28
}
29
29
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ import Foundation
21
21
22
22
struct WindowsPlatformSpecsExtension : SpecificationsExtension {
23
23
func specificationFiles( ) -> Bundle ? {
24
- . module
24
+ findResourceBundle ( nameWhenInstalledInToolchain : " SwiftBuild_SWBWindowsPlatform " , defaultBundle : Bundle . module)
25
25
}
26
26
}
27
27
You can’t perform that action at this time.
0 commit comments