-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include all framework search paths for all configurations for targets #129
Changes from all commits
f2a05e4
bce67d2
7eadd51
51acff7
e86a97c
d2d2c3d
3cee054
c9a7d4f
a08ec57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,7 @@ def _xcodeproj_aspect_impl(target, ctx): | |
if test_host_target: | ||
test_host_appname = test_host_target[_TargetInfo].direct_targets[0].name | ||
|
||
framework_includes = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "framework_includes")) | ||
info = struct( | ||
name = bundle_info.bundle_name, | ||
bundle_id = bundle_info.bundle_id, | ||
|
@@ -124,7 +125,7 @@ def _xcodeproj_aspect_impl(target, ctx): | |
srcs = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "srcs")), | ||
non_arc_srcs = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "non_arc_srcs")), | ||
asset_srcs = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "asset_srcs")), | ||
framework_includes = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "framework_includes")), | ||
framework_includes = framework_includes, | ||
cc_defines = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "cc_defines")), | ||
swift_defines = depset([], transitive = _get_attr_values_for_name(deps, _SrcsInfo, "swift_defines")), | ||
build_files = depset(_srcs_info_build_files(ctx), transitive = _get_attr_values_for_name(deps, _SrcsInfo, "build_files")), | ||
|
@@ -251,7 +252,22 @@ def _exclude_swift_incompatible_define(define): | |
return token | ||
return None | ||
|
||
def _joined_header_search_paths(hmap_paths): | ||
def _framework_search_paths_for_target(target_name, all_transitive_targets): | ||
# Ensure Xcode will resolve references to the XCTest framework. | ||
framework_search_paths = ["$(PLATFORM_DIR)/Developer/Library/Frameworks"] | ||
|
||
# all_transitive_targets includes all the targets built with their different configurations. | ||
# Some configurations are only applied when the target is reached transitively | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i feel like we should start using subway metaphor, ie: two station can be connected directly or transitively ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol! It has to do with traversal from on target to another through the dependency graph. I hoped this explanation was clear but feel free to suggest a re-wording :) |
||
# (e.g. via an app or test that applies and propagates new build settings). | ||
for at in all_transitive_targets: | ||
if at.name == target_name: | ||
for fi in at.framework_includes.to_list(): | ||
if fi[0] != "/": | ||
fi = "$BAZEL_WORKSPACE_ROOT/%s" % fi | ||
framework_search_paths.append("\"%s\"" % fi) | ||
return " ".join(framework_search_paths) | ||
|
||
def _header_search_paths_for_target(target_name, all_transitive_targets): | ||
"""Helper method transforming valid hmap paths into full absolute paths and concat together | ||
|
||
Args: | ||
|
@@ -261,7 +277,15 @@ def _joined_header_search_paths(hmap_paths): | |
One string joined by absolute hmap paths, each path is quoted and separated by a space | ||
""" | ||
header_search_paths = [] | ||
for hmap in hmap_paths: | ||
all_hmaps = [] | ||
|
||
# all_transitive_targets includes all the targets built with their different configurations. | ||
# Some configurations are only applied when the target is reached transitively | ||
# (e.g. via an app or test that applies and propagates new build settings). | ||
for at in all_transitive_targets: | ||
if at.name == target_name: | ||
all_hmaps.extend(at.hmap_paths.to_list()) | ||
for hmap in all_hmaps: | ||
if len(hmap) == 0: | ||
continue | ||
if hmap != "." and hmap[0] != "/": | ||
|
@@ -397,7 +421,7 @@ env -u RUBYOPT -u RUBY_HOME -u GEM_HOME $BAZEL_BUILD_EXEC {bazel_build_target_na | |
$BAZEL_INSTALLER | ||
""" | ||
|
||
def _populate_xcodeproj_targets_and_schemes(ctx, targets, src_dot_dots): | ||
def _populate_xcodeproj_targets_and_schemes(ctx, targets, src_dot_dots, all_transitive_targets): | ||
"""Helper method to generate dicts for targets and schemes inside Xcode context | ||
|
||
Args: | ||
|
@@ -441,19 +465,9 @@ def _populate_xcodeproj_targets_and_schemes(ctx, targets, src_dot_dots): | |
"CLANG_ENABLE_OBJC_ARC": "YES", | ||
} | ||
|
||
# Just like framework, we need to have absolute path to the hmap files | ||
# so that Objc files can correctly import headers | ||
target_settings["HEADER_SEARCH_PATHS"] = _joined_header_search_paths( | ||
target_info.hmap_paths.to_list(), | ||
) | ||
target_settings["HEADER_SEARCH_PATHS"] = _header_search_paths_for_target(target_name, all_transitive_targets) | ||
|
||
# Ensure Xcode will resolve references to the XCTest framework. | ||
framework_search_paths = ["$(PLATFORM_DIR)/Developer/Library/Frameworks"] | ||
for fi in target_info.framework_includes.to_list(): | ||
if fi[0] != "/": | ||
fi = "$BAZEL_WORKSPACE_ROOT/%s" % fi | ||
framework_search_paths.append("\"%s\"" % fi) | ||
target_settings["FRAMEWORK_SEARCH_PATHS"] = " ".join(framework_search_paths) | ||
target_settings["FRAMEWORK_SEARCH_PATHS"] = _framework_search_paths_for_target(target_name, all_transitive_targets) | ||
|
||
macros = ["\"%s\"" % d for d in target_info.cc_defines.to_list()] | ||
macros.append("$(inherited)") | ||
|
@@ -599,7 +613,7 @@ def _xcodeproj_impl(ctx): | |
for t in _get_attr_values_for_name(ctx.attr.deps, _TargetInfo, "direct_targets"): | ||
targets.extend(t) | ||
|
||
(xcodeproj_targets_by_name, xcodeproj_schemes_by_name) = _populate_xcodeproj_targets_and_schemes(ctx, targets, src_dot_dots) | ||
(xcodeproj_targets_by_name, xcodeproj_schemes_by_name) = _populate_xcodeproj_targets_and_schemes(ctx, targets, src_dot_dots, all_transitive_targets) | ||
|
||
project_file_groups = [ | ||
{"path": paths.join(src_dot_dots, f.short_path), "optional": True} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@import Foundation; | ||
|
||
@interface FW2: NSObject | ||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#import <FW2/FW2.h> | ||
|
||
@implementation FW2 | ||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious if moving here makes any diff. or it's just to make code clenaer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That did not make a difference. I think it does make code slightly cleaner.