Skip to content

Commit 7d183c2

Browse files
author
Karim Alweheshy
committed
Pass read and hold libraries path to link for targets
1 parent b636d11 commit 7d183c2

File tree

8 files changed

+36
-2
lines changed

8 files changed

+36
-2
lines changed

tools/generators/pbxnativetargets/src/Generator/Target.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum Target {
3434
let unitTestHost: UnitTestHost?
3535
let dSYMPathsBuildSetting: String?
3636
let librarySearchPaths: Set<BazelPath>
37+
let librariesToLinkPaths: Set<BazelPath>
3738
}
3839

3940
struct UnitTestHost: Equatable {

tools/generators/pbxnativetargets/src/Generator/TargetArguments.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct TargetArguments: Equatable {
3030

3131
let dSYMPathsBuildSetting: String
3232
let librarySearchPaths: [BazelPath]
33+
let librariesToLinkPaths: [BazelPath]
3334
}
3435

3536
extension Dictionary<TargetID, TargetArguments> {
@@ -98,6 +99,11 @@ extension Dictionary<TargetID, TargetArguments> {
9899
as: BazelPath.self,
99100
in: url
100101
)
102+
let librariesToLinkPaths = try rawArgs.consumeArgs(
103+
"libraries_to_link_paths",
104+
as: BazelPath.self,
105+
in: url
106+
)
101107

102108
var buildSettings: [PlatformVariantBuildSetting] = []
103109
if let buildSettingsFile {
@@ -137,7 +143,8 @@ extension Dictionary<TargetID, TargetArguments> {
137143
srcs: srcs,
138144
nonArcSrcs: nonArcSrcs,
139145
dSYMPathsBuildSetting: dSYMPathsBuildSetting,
140-
librarySearchPaths: librarySearchPaths
146+
librarySearchPaths: librarySearchPaths,
147+
librariesToLinkPaths: librariesToLinkPaths
141148
)
142149
)
143150
)

xcodeproj/internal/files/linker_input_files.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,27 @@ def _collect_linker_inputs(
8080
for lib in libraries
8181
])
8282

83+
framework_files = depset([
84+
lib.basename
85+
for lib in libraries
86+
])
87+
8388
return struct(
8489
_cc_linker_inputs = tuple(cc_linker_inputs),
8590
_compilation_providers = compilation_providers,
8691
_objc_libraries = tuple(objc_libraries),
8792
_primary_static_library = primary_static_library,
8893
_top_level_values = top_level_values,
8994
_linker_inputs_for_libs_search_paths = linker_inputs_for_libs_search_paths,
95+
_framework_files = framework_files,
9096
)
9197

9298
def _get_linker_inputs_for_libs_search_paths(linker_inputs):
9399
return linker_inputs._linker_inputs_for_libs_search_paths
94100

101+
def _get_libraries_path_to_link(linker_inputs):
102+
return linker_inputs._framework_files
103+
95104
def _merge_linker_inputs(*, compilation_providers):
96105
return _collect_linker_inputs(
97106
target = None,
@@ -408,4 +417,5 @@ linker_input_files = struct(
408417
),
409418
to_input_files = _to_input_files,
410419
get_linker_inputs_for_libs_search_paths = _get_linker_inputs_for_libs_search_paths,
420+
get_libraries_path_to_link = _get_libraries_path_to_link,
411421
)

xcodeproj/internal/incremental_xcode_targets.bzl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ def _make_incremental_xcode_target(
8484
transitive_dependencies,
8585
unfocus_if_not_test_host = False,
8686
watchkit_extension = None,
87-
linker_inputs_for_libs_search_paths):
87+
linker_inputs_for_libs_search_paths,
88+
libraries_path_to_link):
8889
"""Creates the internal data structure of the `xcode_targets` module.
8990
9091
Args:
@@ -122,6 +123,8 @@ def _make_incremental_xcode_target(
122123
or `None`.
123124
linker_inputs_for_libs_search_paths: Used to generated the
124125
`LIBRARY_SEARCH_PATHS` build setting.
126+
libraries_path_to_link: A depset of libraries paths to link to the
127+
target.
125128
"""
126129
if not is_top_level:
127130
compile_stub_needed = False
@@ -171,6 +174,7 @@ def _make_incremental_xcode_target(
171174
watchkit_extension = watchkit_extension,
172175
transitive_dependencies = transitive_dependencies,
173176
linker_inputs_for_libs_search_paths = linker_inputs_for_libs_search_paths,
177+
libraries_path_to_link = libraries_path_to_link,
174178
)
175179

176180
def _merge_xcode_inputs(*, dest_inputs, mergeable_info):

xcodeproj/internal/pbxproj_partials.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ def _write_consolidation_map_targets(
322322
terminate_with = "",
323323
)
324324

325+
targets_args.add_all(
326+
xcode_target.libraries_path_to_link.to_list(),
327+
omit_if_empty = False,
328+
terminate_with = "",
329+
)
330+
325331
# `outputs.product_path` is only set for top-level targets
326332
if xcode_target.outputs.product_path:
327333
top_level_targets_args.add(xcode_target.id)

xcodeproj/internal/processed_targets/incremental_library_targets.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ def _process_incremental_library_target(
233233
transitive_dependencies = transitive_dependencies,
234234
linker_inputs_for_libs_search_paths = linker_input_files
235235
.get_linker_inputs_for_libs_search_paths(linker_inputs),
236+
libraries_path_to_link = linker_input_files
237+
.get_libraries_path_to_link(linker_inputs),
236238
)
237239
else:
238240
mergeable_infos = depset(

xcodeproj/internal/processed_targets/incremental_top_level_targets.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ def _process_focused_top_level_target(
630630
watchkit_extension = watchkit_extension,
631631
linker_inputs_for_libs_search_paths = linker_input_files
632632
.get_linker_inputs_for_libs_search_paths(linker_inputs),
633+
libraries_path_to_link = linker_input_files
634+
.get_libraries_path_to_link(linker_inputs),
633635
),
634636
)
635637

xcodeproj/internal/processed_targets/mixed_language_library_targets.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ def _process_mixed_language_library_target(
216216
transitive_dependencies = transitive_dependencies,
217217
linker_inputs_for_libs_search_paths = linker_input_files
218218
.get_linker_inputs_for_libs_search_paths(linker_inputs),
219+
libraries_path_to_link = linker_input_files
220+
.get_libraries_path_to_link(linker_inputs),
219221
)
220222
else:
221223
mergeable_infos = depset(

0 commit comments

Comments
 (0)