Skip to content

Commit 9b26969

Browse files
committed
feat Adds a test case for using swift-build
This new test should be able to build the example project added, it cannot right now due to errors in rspm around bundle accessors Signed-off-by: Maxwell Elliott <maxwell@elliott.now>
1 parent 106313f commit 9b26969

File tree

20 files changed

+719
-3
lines changed

20 files changed

+719
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ bazel-*
99
**/.build
1010
**/Packages
1111
**/*.xcodeproj
12+
!examples/swift_build_example/swift-build-app/swift-build-app.xcodeproj
1213
**/xcuserdata/
1314
**/DerivedData/
1415
**/.swiftpm/config/registries.json

examples/example_infos.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ _timeouts = {
116116
"soto_example": "eternal",
117117
"vapor_example": "eternal",
118118
"xcmetrics_example": "eternal",
119+
"swift_build_example": "eternal",
119120
}
120121

121122
_default_enable_bzlmods = [True]
@@ -151,6 +152,7 @@ _macos_single_bazel_version_test_examples = [
151152
"tca_example",
152153
"symlink_example",
153154
"swift_package_registry_example",
155+
"swift_build_example",
154156
]
155157

156158
_linux_single_bazel_version_test_examples = []

examples/swift_build_example/.bazelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Import Shared settings
2+
import %workspace%/../../shared.bazelrc
3+
4+
# Import CI settings.
5+
import %workspace%/../../ci.bazelrc
6+
7+
# Try to import a local.rc file; typically, written by CI
8+
try-import %workspace%/../../local.bazelrc
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
2+
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
3+
4+
tidy(
5+
name = "tidy",
6+
targets = [
7+
":update_build_files",
8+
],
9+
)
10+
11+
# MARK: - Gazelle
12+
13+
# Ignore the Swift build folder
14+
# gazelle:exclude .build
15+
16+
gazelle_binary(
17+
name = "gazelle_bin",
18+
languages = [
19+
"@bazel_skylib_gazelle_plugin//bzl",
20+
"@swift_gazelle_plugin//gazelle",
21+
],
22+
)
23+
24+
gazelle(
25+
name = "update_build_files",
26+
data = [
27+
"@swift_deps_info//:swift_deps_index",
28+
],
29+
extra_args = [
30+
"-swift_dependency_index=$(location @swift_deps_info//:swift_deps_index)",
31+
],
32+
gazelle = ":gazelle_bin",
33+
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
bazel_dep(
2+
name = "rules_swift_package_manager",
3+
version = "0.0.0",
4+
)
5+
local_path_override(
6+
module_name = "rules_swift_package_manager",
7+
path = "../..",
8+
)
9+
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.25.2")
10+
11+
bazel_dep(
12+
name = "rules_swift",
13+
version = "2.7.0",
14+
repo_name = "build_bazel_rules_swift",
15+
)
16+
bazel_dep(name = "rules_apple", version = "3.20.1", repo_name = "build_bazel_rules_apple")
17+
18+
swift_deps = use_extension(
19+
"@rules_swift_package_manager//:extensions.bzl",
20+
"swift_deps",
21+
)
22+
swift_deps.from_package(
23+
declare_swift_deps_info = True,
24+
resolved = "//:Package.resolved",
25+
swift = "//:Package.swift",
26+
)
27+
use_repo(
28+
swift_deps,
29+
"swift_deps_info", # This is generated by the ruleset.`.
30+
"swift_package",
31+
"swiftpkg_swift_build",
32+
)

examples/swift_build_example/Package.resolved

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// swift-tools-version: 6.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "swift_build_example",
7+
dependencies: [
8+
.package(url: "https://github.com/maxwellE/swift-build", branch: "maxwelle/bazel-poc"),
9+
]
10+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Intentionally blank: Using bzlmod
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Intentionally blank: Force bzlmod to strict mode

examples/swift_build_example/do_test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
set -o errexit -o nounset -o pipefail
4+
5+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
6+
7+
# Use the Bazel binary specified by the integration test. Otherise, fall back
8+
# to bazel.
9+
bazel="${BIT_BAZEL_BINARY:-bazel}"
10+
11+
# Generate Swift external deps and update build files
12+
"${bazel}" run //:tidy
13+
14+
# Ensure that it builds and tests pass
15+
"${bazel}" run @swiftpkg_swift_build//:swbuild -- build \
16+
"${script_dir}/swift-build-app/swift-build-app.xcodeproj" \
17+
--target swift-build-app

0 commit comments

Comments
 (0)