Skip to content

Commit

Permalink
Address PR comments and update test
Browse files Browse the repository at this point in the history
  • Loading branch information
AttilaTheFun committed Jan 5, 2025
1 parent 8927163 commit 8afb371
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 29 deletions.
1 change: 1 addition & 0 deletions examples/example_infos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ _macos_single_bazel_version_test_examples = [
"shake_ios_example",
"snapkit_example",
"stripe_example",
"swift_protobuf_example",
"xcmetrics_example",
"tca_example",
"symlink_example",
Expand Down
9 changes: 9 additions & 0 deletions examples/swift_protobuf_example/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# Import Shared settings
import %workspace%/../../shared.bazelrc

# Import CI settings.
import %workspace%/../../ci.bazelrc

# Try to import a local.rc file; typically, written by CI
try-import %workspace%/../../local.bazelrc
11 changes: 11 additions & 0 deletions examples/swift_protobuf_example/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("@rules_swift//swift:swift.bzl", "swift_library")

swift_library(
name = "swift_protobuf_test",
srcs = ["Sources/SwiftProtobufTest.swift"],
module_name = "SwiftProtobufTest",
visibility = ["//visibility:public"],
deps = [
"@swiftpkg_swift_protobuf//:SwiftProtobuf",
],
)
17 changes: 4 additions & 13 deletions examples/swift_protobuf_example/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
Example module for grpc + proto target generation.
"""

# cgrindel_bazel_starlib

bazel_dep(name = "cgrindel_bazel_starlib", version = "0.21.0")

# rules_go

bazel_dep(name = "rules_go", version = "0.50.1")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.host()

# gazelle

bazel_dep(name = "gazelle", version = "0.40.0")
Expand Down Expand Up @@ -40,7 +41,6 @@ local_path_override(
path = "../..",
)

# swift_deps START
swift_deps = use_extension(
"@rules_swift_package_manager//:extensions.bzl",
"swift_deps",
Expand All @@ -56,12 +56,3 @@ use_repo(
"swift_package",
"swiftpkg_swift_protobuf",
)
# swift_deps END

# rules_apple

bazel_dep(name = "rules_apple", version = "3.16.1")

# rules_xcodeproj

bazel_dep(name = "rules_xcodeproj", version = "2.10.0")
4 changes: 0 additions & 4 deletions examples/swift_protobuf_example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ let package = Package(
name: "swift_protobuf_example",
dependencies: [
// These are the versions used by rules_swift
// .package(url: "https://github.com/grpc/grpc-swift-extras", exact: "1.0.0-beta.2"),
// .package(url: "https://github.com/grpc/grpc-swift.git", exact: "2.0.0-beta.2"), // Required by grpc-swift-extras @ 1.0.0-beta.2
// .package(url: "https://github.com/grpc/grpc-swift-protobuf.git", exact: "1.0.0-beta.2"), // Required by grpc-swift @ 2.0.0-beta.2
// .package(url: "https://github.com/grpc/grpc-swift-nio-transport.git", exact: "1.0.0-beta.2"), // Required by grpc-swift @ 2.0.0-beta.2
.package(url: "https://github.com/apple/swift-protobuf.git", exact: "1.28.1"),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import SwiftProtobuf
9 changes: 2 additions & 7 deletions examples/swift_protobuf_example/do_test
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ set -o errexit -o nounset -o pipefail
# to bazel.
bazel="${BIT_BAZEL_BINARY:-bazel}"

# Generate Swift external deps and update build files
"${bazel}" run //:tidy
# Ensure that it builds
"${bazel}" build //...

# Ensure that it builds and tests pass
"${bazel}" test //...

# Ensure that Gazelle doesn't make any changes
"${bazel}" run //:update_build_files -- --mode=diff
19 changes: 14 additions & 5 deletions swiftpkg/tests/swiftpkg_build_files_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,18 @@ _pkg_info = pkginfos.new(
],
),
),
pkginfos.new_build_setting(
kind = build_setting_kinds.language_modes,
values = ["6"],
),
pkginfos.new_build_setting(
kind = build_setting_kinds.experimental_features,
values = ["BuiltinModule"],
),
pkginfos.new_build_setting(
kind = build_setting_kinds.upcoming_features,
values = ["ExistentialAny"],
),
pkginfos.new_build_setting(
kind = build_setting_kinds.unsafe_flags,
values = ["-cross-module-optimization"],
Expand Down Expand Up @@ -552,11 +560,7 @@ load("@build_bazel_rules_swift//swift:swift.bzl", "swift_binary")
swift_binary(
name = "SwiftExecutableTarget.rspm",
copts = [
"-DSWIFT_PACKAGE",
"-enable-experimental-feature",
"BuiltinModule",
] + select({
copts = ["-DSWIFT_PACKAGE"] + select({
"@rules_swift_package_manager//config_settings/spm/platform:ios": ["-DFOOBAR"],
"//conditions:default": [],
}) + select({
Expand All @@ -566,6 +570,11 @@ swift_binary(
"@rules_swift_package_manager//config_settings/spm/configuration:release": ["-cross-module-optimization"],
"//conditions:default": [],
}),
features = [
"swift.enable_v6",
"swift.experimental.BuiltinModule",
"swift.upcoming.ExistentialAny",
],
module_name = "SwiftExecutableTarget",
package_name = "MyPackage",
srcs = ["Source/SwiftExecutableTarget/main.swift"],
Expand Down

0 comments on commit 8afb371

Please sign in to comment.