diff --git a/doc/rules.md b/doc/rules.md index 9c84e03b5..59aa2df7d 100644 --- a/doc/rules.md +++ b/doc/rules.md @@ -429,6 +429,11 @@ swift_interop_hint(name, [!NOTE] +> Bazel 6 users must set the `--experimental_enable_aspect_hints` flag to utilize +> this rule. In addition, downstream consumers of rules that utilize this rule +> must also set the flag. The flag is enabled by default in Bazel 7. + Some build rules, such as `objc_library`, support interoperability with Swift simply by depending on them; a module map is generated automatically. This is for convenience, because the common case is that most `objc_library` targets diff --git a/test/BUILD b/test/BUILD index 9f84436af..3097529be 100644 --- a/test/BUILD +++ b/test/BUILD @@ -1,11 +1,10 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load(":ast_file_tests.bzl", "ast_file_test_suite") load(":bzl_test.bzl", "bzl_test") +load(":cc_library_tests.bzl", "cc_library_test_suite") load(":compiler_arguments_tests.bzl", "compiler_arguments_test_suite") load(":coverage_settings_tests.bzl", "coverage_settings_test_suite") -load(":cc_library_tests.bzl", "cc_library_test_suite") load(":debug_settings_tests.bzl", "debug_settings_test_suite") -load(":explicit_modules_test.bzl", "explicit_modules_test_suite") load(":features_tests.bzl", "features_test_suite") load(":generated_header_tests.bzl", "generated_header_test_suite") load(":imported_framework_tests.bzl", "imported_framework_test_suite") @@ -60,8 +59,6 @@ pch_output_dir_test_suite(name = "pch_output_dir_settings") private_swiftinterface_test_suite(name = "private_swiftinterface") -explicit_modules_test_suite(name = "explicit_modules") - xctest_runner_test_suite(name = "xctest_runner") utils_test_suite(name = "utils") diff --git a/test/explicit_modules_test.bzl b/test/explicit_modules_test.bzl deleted file mode 100644 index 20c079086..000000000 --- a/test/explicit_modules_test.bzl +++ /dev/null @@ -1,105 +0,0 @@ -# Copyright 2022 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Tests for explicit module compilation command line flags""" - -load( - "@build_bazel_rules_swift//test/rules:action_command_line_test.bzl", - "make_action_command_line_test_rule", -) - -explicit_modules_action_command_line_test = make_action_command_line_test_rule( - config_settings = { - "//command_line_option:features": [ - "swift.use_c_modules", - "swift.emit_c_module", - "swift.supports_system_module_flag", - ], - }, -) - -implicit_modules_action_command_line_test = make_action_command_line_test_rule() - -def explicit_modules_test_suite(name): - """Test suite for explicit clang module compilation. - - Args: - name: the base name to be used in things created by this macro - """ - - # Verify that swift libraries compile with the specified module file from deps. - explicit_modules_action_command_line_test( - name = "{}_enabled_swift_side_test".format(name), - expected_argv = [ - # "-fmodule-file=SwiftShims", - "-fno-implicit-module-maps", - "-fno-implicit-modules", - ], - mnemonic = "SwiftCompile", - tags = [name], - target_under_test = "@build_bazel_rules_swift//test/fixtures/explicit_modules:simple", - target_compatible_with = ["@platforms//os:macos"], - ) - - # # Verify that the swift_c_module precompiles. - # explicit_modules_action_command_line_test( - # name = "{}_enabled_c_module_side".format(name), - # expected_argv = [ - # "-fsystem-module", - # "-module-name SwiftShims", - # "-emit-pcm", - # "-fno-implicit-module-maps", - # "-fno-implicit-modules", - # ], - # mnemonic = "SwiftPrecompileCModule", - # tags = [name], - # target_under_test = "@build_bazel_rules_swift//test/fixtures/explicit_modules:shims", - # target_compatible_with = ["@platforms//os:macos"], - # ) - - # # Verify that a swift_c_module with dependencies precompiles. - # explicit_modules_action_command_line_test( - # name = "{}_enabled_c_module_deps".format(name), - # expected_argv = [ - # "-fsystem-module", - # "-fmodule-file=_Builtin_stddef_max_align_t", - # "-fmodule-map-file=__BAZEL_XCODE_DEVELOPER_DIR__/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/module.modulemap", - # "-module-name Darwin", - # "-emit-pcm", - # "-fno-implicit-module-maps", - # "-fno-implicit-modules", - # ], - # mnemonic = "SwiftPrecompileCModule", - # tags = [name], - # target_under_test = "@build_bazel_rules_swift//test/fixtures/explicit_modules:Darwin", - # target_compatible_with = ["@platforms//os:macos"], - # ) - - # Verify that the default behavior isn't impacted. - implicit_modules_action_command_line_test( - name = "{}_disabled_test".format(name), - not_expected_argv = [ - # "-fmodule-file=SwiftShims", - "-fno-implicit-module-maps", - "-fno-implicit-modules", - ], - mnemonic = "SwiftCompile", - tags = [name], - target_under_test = "@build_bazel_rules_swift//test/fixtures/explicit_modules:simple", - ) - - native.test_suite( - name = name, - tags = [name], - ) diff --git a/test/fixtures/explicit_modules/BUILD b/test/fixtures/explicit_modules/BUILD deleted file mode 100644 index 0659437a3..000000000 --- a/test/fixtures/explicit_modules/BUILD +++ /dev/null @@ -1,42 +0,0 @@ -load("//swift:swift.bzl", "swift_library") -load("//test/fixtures:common.bzl", "FIXTURE_TAGS") - -package( - default_visibility = ["//test:__subpackages__"], -) - -licenses(["notice"]) - -############################################################################### -# Fixtures for testing explicit clang module compilation. - -swift_library( - name = "simple", - srcs = ["Empty.swift"], - tags = FIXTURE_TAGS, - # deps = [":shims"], -) - -# swift_c_module( -# name = "shims", -# module_name = "SwiftShims", -# system_module_map = "__BAZEL_XCODE_SDKROOT__/usr/lib/swift/shims/module.modulemap", -# tags = FIXTURE_TAGS, -# ) - -# swift_c_module( -# name = "Darwin", -# module_name = "Darwin", -# system_module_map = "__BAZEL_XCODE_SDKROOT__/usr/include/module.modulemap", -# tags = FIXTURE_TAGS, -# deps = [ -# ":_Builtin_stddef_max_align_t", -# ], -# ) - -# swift_c_module( -# name = "_Builtin_stddef_max_align_t", -# module_name = "_Builtin_stddef_max_align_t", -# system_module_map = "__BAZEL_XCODE_DEVELOPER_DIR__/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/clang/include/module.modulemap", -# tags = FIXTURE_TAGS, -# ) diff --git a/test/fixtures/explicit_modules/Empty.swift b/test/fixtures/explicit_modules/Empty.swift deleted file mode 100644 index bd9ec079d..000000000 --- a/test/fixtures/explicit_modules/Empty.swift +++ /dev/null @@ -1 +0,0 @@ -// Intentionally empty. diff --git a/test/fixtures/interop_hints/BUILD b/test/fixtures/interop_hints/BUILD index d77951c26..0f1bab1fa 100644 --- a/test/fixtures/interop_hints/BUILD +++ b/test/fixtures/interop_hints/BUILD @@ -95,7 +95,7 @@ forward_swift_info_from_swift_clang_module_aspect( objc_library( name = "objc_library_suppressed_lib", hdrs = ["header1.h"], - aspect_hints = [":suppress_hint"], + aspect_hints = ["//swift:no_module"], tags = FIXTURE_TAGS, target_compatible_with = ["@platforms//os:macos"], ) @@ -110,7 +110,7 @@ forward_swift_info_from_swift_clang_module_aspect( objc_library( name = "objc_library_with_swift_dep_suppressed_lib", hdrs = ["header1.h"], - aspect_hints = [":suppress_hint"], + aspect_hints = ["//swift:no_module"], tags = FIXTURE_TAGS, target_compatible_with = ["@platforms//os:macos"], deps = [":empty_lib"], @@ -121,9 +121,3 @@ swift_library( srcs = ["Empty.swift"], tags = FIXTURE_TAGS, ) - -swift_interop_hint( - name = "suppress_hint", - suppressed = True, - tags = FIXTURE_TAGS, -)