Skip to content
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

Add full support for mixed_language_library #3069

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add full support for mixed_language_library
Signed-off-by: Brentley Jones <github@brentleyjones.com>
brentleyjones committed Aug 12, 2024
commit 530e7d0eae6b6365c8873cd884cc4262ccc375bf
9 changes: 6 additions & 3 deletions docs/bazel.md
Original file line number Diff line number Diff line change
@@ -933,8 +933,9 @@ rules, then you will use these providers to communicate between them.
XcodeProjAutomaticTargetProcessingInfo(<a href="#XcodeProjAutomaticTargetProcessingInfo-alternate_icons">alternate_icons</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-app_icons">app_icons</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-args">args</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-bundle_id">bundle_id</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-codesign_inputs">codesign_inputs</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-codesignopts">codesignopts</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-collect_uncategorized_files">collect_uncategorized_files</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-deps">deps</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-entitlements">entitlements</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-env">env</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-exported_symbols_lists">exported_symbols_lists</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-extra_files">extra_files</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-hdrs">hdrs</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-implementation_deps">implementation_deps</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-infoplists">infoplists</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-is_supported">is_supported</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-is_top_level">is_top_level</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-label">label</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-launchdplists">launchdplists</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-link_mnemonics">link_mnemonics</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-non_arc_srcs">non_arc_srcs</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-pch">pch</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-implementation_deps">implementation_deps</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-infoplists">infoplists</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-is_header_only_library">is_header_only_library</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-is_mixed_language">is_mixed_language</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-is_supported">is_supported</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-is_top_level">is_top_level</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-label">label</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-launchdplists">launchdplists</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-link_mnemonics">link_mnemonics</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-non_arc_srcs">non_arc_srcs</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-pch">pch</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-provisioning_profile">provisioning_profile</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-should_generate">should_generate</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-srcs">srcs</a>, <a href="#XcodeProjAutomaticTargetProcessingInfo-target_type">target_type</a>,
<a href="#XcodeProjAutomaticTargetProcessingInfo-xcode_targets">xcode_targets</a>)
</pre>
@@ -970,6 +971,8 @@ return an `XcodeProjInfo` provider instance instead.
| <a id="XcodeProjAutomaticTargetProcessingInfo-hdrs"></a>hdrs | A sequence of attribute names to collect `File`s from for `hdrs`-like attributes.<br><br>This is only used when `xcodeproj.generation_mode = "legacy"` is set. |
| <a id="XcodeProjAutomaticTargetProcessingInfo-implementation_deps"></a>implementation_deps | A sequence of attribute names to collect `Target`s from for `implementation_deps`-like attributes. |
| <a id="XcodeProjAutomaticTargetProcessingInfo-infoplists"></a>infoplists | A sequence of attribute names to collect `File`s from for the `infoplists`-like attributes.<br><br>This is only used when `xcodeproj.generation_mode = "legacy"` is set. |
| <a id="XcodeProjAutomaticTargetProcessingInfo-is_header_only_library"></a>is_header_only_library | Whether this target doesn't contain src files.<br><br>This is only used when `xcodeproj.generation_mode = "incremental"` is set. |
| <a id="XcodeProjAutomaticTargetProcessingInfo-is_mixed_language"></a>is_mixed_language | Whether this target is a mixed-language target.<br><br>This is only used when `xcodeproj.generation_mode = "incremental"` is set. |
| <a id="XcodeProjAutomaticTargetProcessingInfo-is_supported"></a>is_supported | Whether an Xcode target can be generated for this target. Even if this value is `False`, setting values for the other attributes can cause inputs to be collected and shown in the Xcode project. |
| <a id="XcodeProjAutomaticTargetProcessingInfo-is_top_level"></a>is_top_level | Whether this target is a "top-level" (e.g. bundled or executable) target. |
| <a id="XcodeProjAutomaticTargetProcessingInfo-label"></a>label | The effective `Label` to use for the target. This should generally be `target.label`, but in the case of skipped wrapper rules (e.g. `*_unit_test` targets), you might want to rename the target to the skipped target's label.<br><br>This is only used when `xcodeproj.generation_mode = "incremental"` is set. |
@@ -1020,7 +1023,7 @@ Provides information needed to generate an Xcode project.
| <a id="XcodeProjInfo-framework_product_mappings"></a>framework_product_mappings | A `depset` of `(linker_path, product_path)` `tuple`s. `linker_path` is the `.framework/Executable` path used when linking to a framework. `product_path` is the path to a built `.framework` product. In particular, `product_path` can have a fully fleshed out framework, including resources, while `linker_path` will most likely only have a symlink to a `.dylib` in it.<br><br>This is only set and used when `xcodeproj.generation_mode = "incremental"` is set. |
| <a id="XcodeProjInfo-hosted_targets"></a>hosted_targets | A `depset` of `struct`s with `host` and `hosted` fields. The `host` field is the target ID (see `xcode_target.id`) of the hosting target. The `hosted` field is the target ID of the hosted target. |
| <a id="XcodeProjInfo-inputs"></a>inputs | A value from `input_files.collect`/`inputs_files.merge`, that contains information related to all of the input `File`s for the project collected so far. It also includes information related to "extra files" that should be added to the Xcode project, but are not associated with any targets. |
| <a id="XcodeProjInfo-label"></a>label | The `Label` of the target.<br><br>This is only set and used when `xcodeproj.generation_mode = "legacy"` is set. |
| <a id="XcodeProjInfo-label"></a>label | The `Label` of the target. |
| <a id="XcodeProjInfo-labels"></a>labels | A `depset` of `Labels` for the target and its transitive dependencies.<br><br>This is only set and used when `xcodeproj.generation_mode = "legacy"` is set. |
| <a id="XcodeProjInfo-lldb_context"></a>lldb_context | A value from `lldb_context.collect`. |
| <a id="XcodeProjInfo-mergable_xcode_library_targets"></a>mergable_xcode_library_targets | A `depset` of target IDs (see `xcode_target.id`). Each represents a target that can potentially merge into a top-level target (to be decided by the top-level target).<br><br>This is only set and used when `xcodeproj.generation_mode = "legacy"` is set. |
Original file line number Diff line number Diff line change
@@ -82,11 +82,11 @@ def _write_target_build_settings_test_impl(ctx):
entitlements = ctx.attr.entitlements,
extension_safe = ctx.attr.extension_safe,
generate_build_settings = ctx.attr.generate_build_settings,
generate_swift_debug_settings = ctx.attr.generate_swift_debug_settings,
include_self_swift_debug_settings = (
ctx.attr.include_self_swift_debug_settings
),
infoplist = ctx.attr.infoplist,
is_top_level_target = ctx.attr.is_top_level_target,
name = "a_target_name",
previews_dynamic_frameworks = [
(mock_actions.mock_file(f), True)
@@ -176,9 +176,9 @@ write_target_build_settings_test = unittest.make(
"entitlements": attr.string(),
"extension_safe": attr.bool(mandatory = True),
"generate_build_settings": attr.bool(mandatory = True),
"generate_swift_debug_settings": attr.bool(mandatory = True),
"include_self_swift_debug_settings": attr.bool(mandatory = True),
"infoplist": attr.string(),
"is_top_level_target": attr.bool(mandatory = True),
"previews_dynamic_frameworks": attr.string_list(mandatory = True),
"previews_include_path": attr.string(mandatory = True),
"provisioning_profile_is_xcode_managed": attr.bool(mandatory = True),
@@ -219,9 +219,9 @@ def write_target_build_settings_test_suite(name):
entitlements = None,
extension_safe = False,
generate_build_settings,
generate_swift_debug_settings,
include_self_swift_debug_settings = True,
infoplist = None,
is_top_level_target = False,
previews_dynamic_frameworks = [],
previews_include_path = "",
provisioning_profile_is_xcode_managed = False,
@@ -250,9 +250,9 @@ def write_target_build_settings_test_suite(name):
entitlements = entitlements,
extension_safe = extension_safe,
generate_build_settings = generate_build_settings,
generate_swift_debug_settings = generate_swift_debug_settings,
include_self_swift_debug_settings = include_self_swift_debug_settings,
infoplist = infoplist,
is_top_level_target = is_top_level_target,
previews_dynamic_frameworks = previews_dynamic_frameworks,
previews_include_path = previews_include_path,
provisioning_profile_is_xcode_managed = provisioning_profile_is_xcode_managed,
@@ -278,6 +278,7 @@ def write_target_build_settings_test_suite(name):
conly_args = [],
cxx_args = [],
generate_build_settings = False,
generate_swift_debug_settings = False,
swift_args = [],

# Expected
@@ -297,6 +298,7 @@ def write_target_build_settings_test_suite(name):
conly_args = [],
cxx_args = [],
generate_build_settings = True,
generate_swift_debug_settings = False,
swift_args = [],

# Expected
@@ -344,6 +346,7 @@ def write_target_build_settings_test_suite(name):
conly_args = ["a", "c", "b"],
cxx_args = [],
generate_build_settings = True,
generate_swift_debug_settings = False,
swift_args = [],

# Expected
@@ -389,6 +392,7 @@ def write_target_build_settings_test_suite(name):
conly_args = [],
cxx_args = ["a", "c", "b"],
generate_build_settings = True,
generate_swift_debug_settings = False,
swift_args = [],

# Expected
@@ -434,6 +438,7 @@ def write_target_build_settings_test_suite(name):
conly_args = ["a1", "c2", "b1"],
cxx_args = ["a2", "c1", "b2"],
generate_build_settings = True,
generate_swift_debug_settings = False,
swift_args = [],

# Expected
@@ -481,6 +486,7 @@ def write_target_build_settings_test_suite(name):
conly_args = ["a1", "c2", "b1"],
cxx_args = ["a2", "c1", "b2"],
generate_build_settings = True,
generate_swift_debug_settings = True,
include_self_swift_debug_settings = False,
swift_args = ["a", "c", "b"],

@@ -535,6 +541,7 @@ def write_target_build_settings_test_suite(name):
certificate_name = "best certificate",
entitlements = "some/app.entitlements",
generate_build_settings = True,
generate_swift_debug_settings = False,
provisioning_profile_is_xcode_managed = True,
provisioning_profile_name = "a profile",
swift_args = [],
@@ -585,6 +592,7 @@ def write_target_build_settings_test_suite(name):
conly_args = [],
cxx_args = [],
generate_build_settings = True,
generate_swift_debug_settings = True,
swift_args = ["-v", "a"],

# Expected
@@ -634,6 +642,7 @@ def write_target_build_settings_test_suite(name):
conly_args = [],
cxx_args = [],
generate_build_settings = True,
generate_swift_debug_settings = True,
swift_args = ["-v", "a"],
swift_debug_settings_to_merge = [
"transitive_debug_settings/2",
@@ -693,9 +702,9 @@ def write_target_build_settings_test_suite(name):
device_family = "1,2",
extension_safe = True,
generate_build_settings = False,
generate_swift_debug_settings = True,
include_self_swift_debug_settings = False,
infoplist = "some/Info.plist",
is_top_level_target = True,
previews_dynamic_frameworks = [
"bazel-out/generated.framework",
"/absolute/f.framework",
24 changes: 18 additions & 6 deletions xcodeproj/internal/automatic_target_info.bzl
Original file line number Diff line number Diff line change
@@ -144,6 +144,16 @@ A sequence of attribute names to collect `File`s from for the `infoplists`-like
attributes.

This is only used when `xcodeproj.generation_mode = "legacy"` is set.
""",
"is_header_only_library": """\
Whether this target doesn't contain src files.

This is only used when `xcodeproj.generation_mode = "incremental"` is set.
""",
"is_mixed_language": """\
Whether this target is a mixed-language target.

This is only used when `xcodeproj.generation_mode = "incremental"` is set.
""",
"is_supported": """\
Whether an Xcode target can be generated for this target. Even if this value is
@@ -313,10 +323,6 @@ _BUNDLE_XCODE_TARGETS = {
"private_deps": _XCODE_TARGET_TYPES_COMPILE,
"transitive_deps": _XCODE_TARGET_TYPES_COMPILE,
}
_MIXED_LANGUAGE_XCODE_TARGETS = {
"clang_target": _XCODE_TARGET_TYPES_COMPILE,
"swift_target": _XCODE_TARGET_TYPES_COMPILE,
}
_OBJC_LIBRARY_XCODE_TARGETS = {
"deps": _XCODE_TARGET_TYPES_COMPILE_AND_NONE,
# Issues like https://github.com/bazelbuild/bazel/issues/17646 made some Bazel users
@@ -393,6 +399,8 @@ def calculate_automatic_target_info(
hdrs = EMPTY_LIST
implementation_deps = EMPTY_LIST
infoplists = EMPTY_LIST
is_header_only_library = False
is_mixed_language = False
is_supported = True
is_top_level = False
label = target.label
@@ -411,6 +419,7 @@ def calculate_automatic_target_info(
bool(target.files) and
_has_values_in(_SRCS_ATTRS, attr = rule_attr)
)
is_header_only_library = not is_supported
elif rule_kind == "cc_import":
extra_files = _CC_IMPORT_EXTRA_FILES_ATTRS
is_supported = False
@@ -428,6 +437,7 @@ def calculate_automatic_target_info(
_has_values_in(_NON_ARC_SRCS_ATTRS, attr = rule_attr)
)
)
is_header_only_library = not is_supported
elif rule_kind == "objc_import":
extra_files = _OBJC_IMPORT_EXTRA_FILES_ATTRS
is_supported = False
@@ -441,8 +451,8 @@ def calculate_automatic_target_info(
elif rule_kind == "swift_proto_library":
xcode_targets = _DEPS_XCODE_TARGETS
elif rule_kind == "mixed_language_library":
is_supported = False
xcode_targets = _MIXED_LANGUAGE_XCODE_TARGETS
is_mixed_language = True
xcode_targets = _DEPS_XCODE_TARGETS
elif (AppleResourceBundleInfo in target and
rule_kind != "apple_bundle_import"):
is_supported = False
@@ -564,6 +574,8 @@ def calculate_automatic_target_info(
exported_symbols_lists = exported_symbols_lists,
hdrs = hdrs,
infoplists = infoplists,
is_header_only_library = is_header_only_library,
is_mixed_language = is_mixed_language,
is_supported = is_supported,
is_top_level = is_top_level,
implementation_deps = implementation_deps,
Loading