Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsky authored and brentleyjones committed Apr 5, 2024
1 parent 703297f commit 61d5a1a
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion examples/apple/swift_explicit_modules/BUILD
Original file line number Diff line number Diff line change
@@ -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"],
)
38 changes: 36 additions & 2 deletions test/explicit_modules_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand All @@ -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",
],
Expand Down
33 changes: 25 additions & 8 deletions test/fixtures/explicit_modules/BUILD
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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,
# )
4 changes: 2 additions & 2 deletions test/interop_hints_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
Expand All @@ -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"],
)
Expand Down

0 comments on commit 61d5a1a

Please sign in to comment.