Skip to content

Commit 86a22ec

Browse files
committed
Fix issue due to duplicated indexstore bindings in Swift Build and TSC
1 parent a43d0e3 commit 86a22ec

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Sources/SWBCSupport/IndexStore.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,10 @@ typedef struct {
181181
indexstore_string_ref_t
182182
(*unit_dependency_get_name)(indexstore_unit_dependency_t);
183183

184-
bool
185-
(*unit_reader_dependencies_apply)(indexstore_unit_reader_t,
186-
bool(^applier)(indexstore_unit_dependency_t));
187-
188184
bool
189185
(*unit_reader_dependencies_apply_f)(indexstore_unit_reader_t,
190186
void *context,
191187
bool(*applier)(void *context, indexstore_unit_dependency_t));
192-
} indexstore_functions_t;
188+
} swiftbuild_indexstore_functions_t;
193189

194190
#endif

Sources/SWBUtil/Cache.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,21 @@ public final class Cache<Key: Hashable, Value>: NSObject, KeyValueStorage, NSCac
8787
return nil
8888
}
8989
set {
90+
#if os(Linux)
91+
if let newValue = newValue {
92+
cache.value.setObject(ValueWrapper(newValue), forKey: KeyWrapper(key))
93+
} else {
94+
cache.value.removeObject(forKey: KeyWrapper(key))
95+
}
96+
#else
9097
if let newValue, let cacheableValue = newValue as? (any CacheableValue) {
9198
cache.value.setObject(ValueWrapper(newValue), forKey: KeyWrapper(key), cost: cacheableValue.cost)
9299
} else if let newValue = newValue {
93100
cache.value.setObject(ValueWrapper(newValue), forKey: KeyWrapper(key))
94101
} else {
95102
cache.value.removeObject(forKey: KeyWrapper(key))
96103
}
104+
#endif
97105
}
98106
}
99107

@@ -112,12 +120,16 @@ public final class Cache<Key: Hashable, Value>: NSObject, KeyValueStorage, NSCac
112120
}
113121

114122
let value = try body()
123+
#if os(Linux)
124+
cache.value.setObject(ValueWrapper(value), forKey: wrappedKey)
125+
#else
115126
if let cacheableValue = value as? (any CacheableValue) {
116127
cache.value.setObject(ValueWrapper(value), forKey: wrappedKey, cost: cacheableValue.cost)
117128

118129
} else {
119130
cache.value.setObject(ValueWrapper(value), forKey: wrappedKey)
120131
}
132+
#endif
121133
return value
122134
}
123135

Sources/SWBUtil/IndexStore.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private final class IndexStoreAPIImpl {
334334
private let dylib: LibraryHandle
335335

336336
/// The index store API functions.
337-
fileprivate let fn: indexstore_functions_t
337+
fileprivate let fn: swiftbuild_indexstore_functions_t
338338

339339
fileprivate func call<T>(_ fn: (inout indexstore_error_t?) -> T) throws -> T {
340340
var error: indexstore_error_t? = nil
@@ -354,7 +354,7 @@ private final class IndexStoreAPIImpl {
354354
self.path = path
355355
self.dylib = try Library.open(path)
356356

357-
var api = indexstore_functions_t()
357+
var api = swiftbuild_indexstore_functions_t()
358358
api.store_create = Library.lookup(dylib, "indexstore_store_create")
359359
api.store_get_unit_name_from_output_path = Library.lookup(dylib, "indexstore_store_get_unit_name_from_output_path")
360360
api.unit_reader_create = Library.lookup(dylib, "indexstore_unit_reader_create")

0 commit comments

Comments
 (0)