Skip to content

Commit

Permalink
Fix derive files with bitcode (bazelbuild#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
keith authored Oct 21, 2020
1 parent af9eb15 commit af736a8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
2 changes: 0 additions & 2 deletions swift/internal/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ def _all_action_configs(
swift_toolchain_config.action_config(
actions = [
swift_action_names.COMPILE,
swift_action_names.DERIVE_FILES,
swift_action_names.PRECOMPILE_C_MODULE,
],
configurators = [swift_toolchain_config.add_arg("-embed-bitcode")],
Expand All @@ -328,7 +327,6 @@ def _all_action_configs(
swift_toolchain_config.action_config(
actions = [
swift_action_names.COMPILE,
swift_action_names.DERIVE_FILES,
swift_action_names.PRECOMPILE_C_MODULE,
],
configurators = [
Expand Down
8 changes: 8 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ bzl_library(
"//test/rules:starlark_tests_bzls",
],
)

# TODO: Remove once https://github.com/bazelbuild/bazel/pull/10945 lands
config_setting(
name = "linux",
constraint_values = [
"@bazel_tools//platforms:linux",
],
)
62 changes: 62 additions & 0 deletions test/split_derived_files_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ split_swiftmodule_indexing_test = make_action_command_line_test_rule(
],
},
)
split_swiftmodule_bitcode_test = make_action_command_line_test_rule(
config_settings = {
"//command_line_option:apple_bitcode": "embedded",
"//command_line_option:features": [
"swift.split_derived_files_generation",
],
},
)
split_swiftmodule_bitcode_markers_test = make_action_command_line_test_rule(
config_settings = {
"//command_line_option:apple_bitcode": "embedded_markers",
"//command_line_option:features": [
"swift.split_derived_files_generation",
],
},
)

def split_derived_files_test_suite(name = "split_derived_files"):
"""Test suite for split derived files options.
Expand Down Expand Up @@ -256,6 +272,52 @@ def split_derived_files_test_suite(name = "split_derived_files"):
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

split_swiftmodule_bitcode_test(
name = "{}_bitcode_compile".format(name),
expected_argv = select({
"//test:linux": [],
"//conditions:default": [
"-embed-bitcode",
],
}),
mnemonic = "SwiftCompile",
tags = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

split_swiftmodule_bitcode_test(
name = "{}_bitcode_derive_files".format(name),
not_expected_argv = [
"-embed-bitcode",
],
mnemonic = "SwiftDeriveFiles",
tags = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

split_swiftmodule_bitcode_markers_test(
name = "{}_bitcode_markers_compile".format(name),
expected_argv = select({
"//test:linux": [],
"//conditions:default": [
"-embed-bitcode-marker",
],
}),
mnemonic = "SwiftCompile",
tags = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

split_swiftmodule_bitcode_markers_test(
name = "{}_bitcode_markers_derive_files".format(name),
not_expected_argv = [
"-embed-bitcode-marker",
],
mnemonic = "SwiftDeriveFiles",
tags = [name],
target_under_test = "@build_bazel_rules_swift//test/fixtures/debug_settings:simple",
)

native.test_suite(
name = name,
tags = [name],
Expand Down

0 comments on commit af736a8

Please sign in to comment.