From 61d5a1a71bff44dcf1f965302f5a1f4cf3f9e9c6 Mon Sep 17 00:00:00 2001 From: Aaron Sky Date: Wed, 3 Apr 2024 15:14:20 -0400 Subject: [PATCH] Address feedback --- .bazelci/presubmit.yml | 2 ++ .bazelrc | 3 -- examples/apple/swift_explicit_modules/BUILD | 12 ++++++- test/explicit_modules_test.bzl | 38 +++++++++++++++++++-- test/fixtures/explicit_modules/BUILD | 33 +++++++++++++----- test/interop_hints_tests.bzl | 4 +-- 6 files changed, 76 insertions(+), 16 deletions(-) diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 51f5d884f..4699f5305 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -47,9 +47,11 @@ tasks: build_flags: # Bazel 6.x has dependencies that produce warnings now - "--features=-treat_warnings_as_errors" + - "--experimental_enable_aspect_hints" test_flags: # Bazel 6.x has dependencies that produce warnings now - "--features=-treat_warnings_as_errors" + - "--experimental_enable_aspect_hints" macos_latest: name: "Current LTS" diff --git a/.bazelrc b/.bazelrc index 9e67fd192..ab04f51f7 100644 --- a/.bazelrc +++ b/.bazelrc @@ -11,9 +11,6 @@ build --macos_minimum_os=13.0 # dependencies cause us to use a newer version build --check_direct_dependencies=off -# https://github.com/bazelbuild/bazel/issues/14327 -build --experimental_enable_aspect_hints - # Make sure no warnings slip into the C++ tools we vendor build --features treat_warnings_as_errors diff --git a/examples/apple/swift_explicit_modules/BUILD b/examples/apple/swift_explicit_modules/BUILD index 28297cb08..73574c54d 100644 --- a/examples/apple/swift_explicit_modules/BUILD +++ b/examples/apple/swift_explicit_modules/BUILD @@ -1,8 +1,18 @@ load("//swift:swift.bzl", "swift_binary") -# This package is meant to demonstrate the use of explicit clang module compilation. +# # This package is meant to demonstrate the use of explicit clang module compilation. + +# # In order to build with features "swift.use_c_modules" and "swift.emit_c_module", it is necessary +# # to add all of the framework dependencies explicitly. SwiftShims is the only one required for +# # compiling a swift binary with no imports. +# swift_c_module( +# name = "shims", +# module_name = "SwiftShims", +# system_module_map = "__BAZEL_XCODE_SDKROOT__/usr/lib/swift/shims/module.modulemap", +# ) swift_binary( name = "hello_world", srcs = ["main.swift"], + # deps = [":shims"], ) diff --git a/test/explicit_modules_test.bzl b/test/explicit_modules_test.bzl index 6015c6829..20c079086 100644 --- a/test/explicit_modules_test.bzl +++ b/test/explicit_modules_test.bzl @@ -42,7 +42,7 @@ def explicit_modules_test_suite(name): explicit_modules_action_command_line_test( name = "{}_enabled_swift_side_test".format(name), expected_argv = [ - "-fmodule-file=SwiftShims", + # "-fmodule-file=SwiftShims", "-fno-implicit-module-maps", "-fno-implicit-modules", ], @@ -52,11 +52,45 @@ def explicit_modules_test_suite(name): 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", + # "-fmodule-file=SwiftShims", "-fno-implicit-module-maps", "-fno-implicit-modules", ], diff --git a/test/fixtures/explicit_modules/BUILD b/test/fixtures/explicit_modules/BUILD index bb42f1f00..0659437a3 100644 --- a/test/fixtures/explicit_modules/BUILD +++ b/test/fixtures/explicit_modules/BUILD @@ -1,4 +1,4 @@ -load("//swift:swift.bzl", "swift_interop_hint", "swift_library") +load("//swift:swift.bzl", "swift_library") load("//test/fixtures:common.bzl", "FIXTURE_TAGS") package( @@ -14,12 +14,29 @@ swift_library( name = "simple", srcs = ["Empty.swift"], tags = FIXTURE_TAGS, - deps = [":shims"], + # deps = [":shims"], ) -swift_interop_hint( - name = "shims", - module_map = "__BAZEL_XCODE_SDKROOT__/usr/lib/swift/shims/module.modulemap", - module_name = "SwiftShims", - tags = FIXTURE_TAGS, -) +# 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/interop_hints_tests.bzl b/test/interop_hints_tests.bzl index b33cb9d80..cf8f31dc4 100644 --- a/test/interop_hints_tests.bzl +++ b/test/interop_hints_tests.bzl @@ -71,7 +71,7 @@ def interop_hints_test_suite(name = "interop_hints"): provider_test( name = "{}_objc_library_module_suppressed".format(name), does_not_propagate_provider = "SwiftInfo", - tags = [name, "manual"], # TODO: Enable once https://github.com/bazelbuild/bazel/issues/12897 is fixed + tags = [name], target_under_test = "@build_bazel_rules_swift//test/fixtures/interop_hints:objc_library_suppressed", target_compatible_with = ["@platforms//os:macos"], ) @@ -81,7 +81,7 @@ def interop_hints_test_suite(name = "interop_hints"): provider_test( name = "{}_objc_library_module_with_swift_dep_suppressed".format(name), does_not_propagate_provider = "SwiftInfo", - tags = [name, "manual"], # TODO: Enable once https://github.com/bazelbuild/bazel/issues/12897 is fixed + tags = [name], target_under_test = "@build_bazel_rules_swift//test/fixtures/interop_hints:objc_library_with_swift_dep_suppressed", target_compatible_with = ["@platforms//os:macos"], )