Skip to content

Commit f54a7f1

Browse files
authored
fix: generate repository rule declarations for direct and transitive dependencies (cgrindel#90)
- Fix bug in `ImportRepos` where only direct deps were indexed and repo rule declarations created. - Add initial files for `vapor_example`. Related to cgrindel#50.
1 parent 937a11f commit f54a7f1

33 files changed

+1479
-102
lines changed

.bazelrc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# To update these lines, execute
22
# `bazel run @contrib_rules_bazel_integration_test//tools:update_deleted_packages`
3-
build --deleted_packages=examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party
4-
query --deleted_packages=examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party
3+
build --deleted_packages=examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests
4+
query --deleted_packages=examples/http_archive_ext_deps,examples/http_archive_ext_deps/Sources/MyDequeModule,examples/http_archive_ext_deps/Sources/PrintStuff,examples/http_archive_ext_deps/Tests/MyDequeModuleTests,examples/http_archive_ext_deps/third_party,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests
55

66
# Import Shared settings
77
import %workspace%/shared.bazelrc
+8
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

examples/vapor_example/.bazelrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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
9+
10+
# TODO(cgrindel): Remove host_xcodes if not needed
11+
12+
# # The Vapor tests are very sensitive to the Xcode version being used.
13+
# # This tells Bazel to use the Xcode version specified at //:host_xcodes
14+
# build --xcode_version_config=//:host_xcodes

examples/vapor_example/BUILD.bazel

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
2+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
3+
load("@cgrindel_bazel_starlib//bzltidy:defs.bzl", "tidy")
4+
5+
tidy(
6+
name = "tidy",
7+
targets = [
8+
":swift_update_repos",
9+
":update_build_files",
10+
],
11+
)
12+
13+
# MARK: - Gazelle
14+
15+
# Ignore the Swift build folder
16+
# gazelle:exclude .build
17+
18+
gazelle_binary(
19+
name = "gazelle_bin",
20+
languages = [
21+
"@bazel_skylib//gazelle/bzl",
22+
"@cgrindel_swift_bazel//gazelle",
23+
],
24+
)
25+
26+
gazelle(
27+
name = "update_build_files",
28+
gazelle = ":gazelle_bin",
29+
)
30+
31+
gazelle(
32+
name = "swift_update_repos",
33+
args = [
34+
"-from_file=Package.swift",
35+
"-to_macro=swift_deps.bzl%swift_dependencies",
36+
"-prune",
37+
],
38+
command = "update-repos",
39+
gazelle = ":gazelle_bin",
40+
)
41+
42+
bzl_library(
43+
name = "swift_deps",
44+
srcs = ["swift_deps.bzl"],
45+
visibility = ["//visibility:public"],
46+
deps = ["@cgrindel_swift_bazel//swiftpkg:defs"],
47+
)
48+
49+
# Vapor was not happy building under 13.2.1. Fix the version for now.
50+
# See Keith's article for more details:
51+
# https://www.smileykeith.com/2021/03/08/locking-xcode-in-bazel/
52+
53+
xcode_version(
54+
name = "version14_0_1_14A400",
55+
aliases = [
56+
"14.0",
57+
"14A400",
58+
"14.0.1",
59+
"14.0.1.14A400",
60+
"14",
61+
],
62+
default_ios_sdk_version = "16.0",
63+
default_macos_sdk_version = "12.3",
64+
default_tvos_sdk_version = "16.0",
65+
default_watchos_sdk_version = "9.0",
66+
version = "14.0.1.14A400",
67+
)
68+
69+
xcode_config(
70+
name = "host_xcodes",
71+
default = ":version14_0_1_14A400",
72+
versions = [":version14_0_1_14A400"],
73+
)
+239
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
{
2+
"pins" : [
3+
{
4+
"identity" : "async-http-client",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/swift-server/async-http-client.git",
7+
"state" : {
8+
"revision" : "5bee16a79922e3efcb5cea06ecd27e6f8048b56b",
9+
"version" : "1.13.1"
10+
}
11+
},
12+
{
13+
"identity" : "async-kit",
14+
"kind" : "remoteSourceControl",
15+
"location" : "https://github.com/vapor/async-kit.git",
16+
"state" : {
17+
"revision" : "929808e51fea04f01de0e911ce826ef70c4db4ea",
18+
"version" : "1.15.0"
19+
}
20+
},
21+
{
22+
"identity" : "console-kit",
23+
"kind" : "remoteSourceControl",
24+
"location" : "https://github.com/vapor/console-kit.git",
25+
"state" : {
26+
"revision" : "a7e67a1719933318b5ab7eaaed355cde020465b1",
27+
"version" : "4.5.0"
28+
}
29+
},
30+
{
31+
"identity" : "fluent",
32+
"kind" : "remoteSourceControl",
33+
"location" : "https://github.com/vapor/fluent.git",
34+
"state" : {
35+
"revision" : "2da106f46b093885f77fa03e3c719ab5bb8cfab4",
36+
"version" : "4.6.0"
37+
}
38+
},
39+
{
40+
"identity" : "fluent-kit",
41+
"kind" : "remoteSourceControl",
42+
"location" : "https://github.com/vapor/fluent-kit.git",
43+
"state" : {
44+
"revision" : "be7912ee4991bcc8a5390fac0424d1d08221dcc6",
45+
"version" : "1.36.1"
46+
}
47+
},
48+
{
49+
"identity" : "fluent-sqlite-driver",
50+
"kind" : "remoteSourceControl",
51+
"location" : "https://github.com/vapor/fluent-sqlite-driver.git",
52+
"state" : {
53+
"revision" : "7f2a0b105e9cd22141dee220848d8739da6b7232",
54+
"version" : "4.3.0"
55+
}
56+
},
57+
{
58+
"identity" : "multipart-kit",
59+
"kind" : "remoteSourceControl",
60+
"location" : "https://github.com/vapor/multipart-kit.git",
61+
"state" : {
62+
"revision" : "0d55c35e788451ee27222783c7d363cb88092fab",
63+
"version" : "4.5.2"
64+
}
65+
},
66+
{
67+
"identity" : "routing-kit",
68+
"kind" : "remoteSourceControl",
69+
"location" : "https://github.com/vapor/routing-kit.git",
70+
"state" : {
71+
"revision" : "ffac7b3a127ce1e85fb232f1a6271164628809ad",
72+
"version" : "4.6.0"
73+
}
74+
},
75+
{
76+
"identity" : "sql-kit",
77+
"kind" : "remoteSourceControl",
78+
"location" : "https://github.com/vapor/sql-kit.git",
79+
"state" : {
80+
"revision" : "dcf10a00d7d5df987b7948e6fd5596fb65f6d0c2",
81+
"version" : "3.23.0"
82+
}
83+
},
84+
{
85+
"identity" : "sqlite-kit",
86+
"kind" : "remoteSourceControl",
87+
"location" : "https://github.com/vapor/sqlite-kit.git",
88+
"state" : {
89+
"revision" : "c07d53044727db7edf8550c2e8ccfe1fa40177d2",
90+
"version" : "4.2.0"
91+
}
92+
},
93+
{
94+
"identity" : "sqlite-nio",
95+
"kind" : "remoteSourceControl",
96+
"location" : "https://github.com/vapor/sqlite-nio.git",
97+
"state" : {
98+
"revision" : "3b93e0a58643cc02a8bc42014fe462e1532df62d",
99+
"version" : "1.3.0"
100+
}
101+
},
102+
{
103+
"identity" : "swift-algorithms",
104+
"kind" : "remoteSourceControl",
105+
"location" : "https://github.com/apple/swift-algorithms.git",
106+
"state" : {
107+
"revision" : "b14b7f4c528c942f121c8b860b9410b2bf57825e",
108+
"version" : "1.0.0"
109+
}
110+
},
111+
{
112+
"identity" : "swift-atomics",
113+
"kind" : "remoteSourceControl",
114+
"location" : "https://github.com/apple/swift-atomics.git",
115+
"state" : {
116+
"revision" : "ff3d2212b6b093db7f177d0855adbc4ef9c5f036",
117+
"version" : "1.0.3"
118+
}
119+
},
120+
{
121+
"identity" : "swift-backtrace",
122+
"kind" : "remoteSourceControl",
123+
"location" : "https://github.com/swift-server/swift-backtrace.git",
124+
"state" : {
125+
"revision" : "f25620d5d05e2f1ba27154b40cafea2b67566956",
126+
"version" : "1.3.3"
127+
}
128+
},
129+
{
130+
"identity" : "swift-collections",
131+
"kind" : "remoteSourceControl",
132+
"location" : "https://github.com/apple/swift-collections.git",
133+
"state" : {
134+
"revision" : "937e904258d22af6e447a0b72c0bc67583ef64a2",
135+
"version" : "1.0.4"
136+
}
137+
},
138+
{
139+
"identity" : "swift-crypto",
140+
"kind" : "remoteSourceControl",
141+
"location" : "https://github.com/apple/swift-crypto.git",
142+
"state" : {
143+
"revision" : "92a04c10fc5ce0504f8396aac7392126033e547c",
144+
"version" : "2.2.2"
145+
}
146+
},
147+
{
148+
"identity" : "swift-log",
149+
"kind" : "remoteSourceControl",
150+
"location" : "https://github.com/apple/swift-log.git",
151+
"state" : {
152+
"revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c",
153+
"version" : "1.4.4"
154+
}
155+
},
156+
{
157+
"identity" : "swift-metrics",
158+
"kind" : "remoteSourceControl",
159+
"location" : "https://github.com/apple/swift-metrics.git",
160+
"state" : {
161+
"revision" : "9b39d811a83cf18b79d7d5513b06f8b290198b10",
162+
"version" : "2.3.3"
163+
}
164+
},
165+
{
166+
"identity" : "swift-nio",
167+
"kind" : "remoteSourceControl",
168+
"location" : "https://github.com/apple/swift-nio.git",
169+
"state" : {
170+
"revision" : "7e3b50b38e4e66f31db6cf4a784c6af148bac846",
171+
"version" : "2.46.0"
172+
}
173+
},
174+
{
175+
"identity" : "swift-nio-extras",
176+
"kind" : "remoteSourceControl",
177+
"location" : "https://github.com/apple/swift-nio-extras.git",
178+
"state" : {
179+
"revision" : "91dd2d61fb772e1311bb5f13b59266b579d77e42",
180+
"version" : "1.15.0"
181+
}
182+
},
183+
{
184+
"identity" : "swift-nio-http2",
185+
"kind" : "remoteSourceControl",
186+
"location" : "https://github.com/apple/swift-nio-http2.git",
187+
"state" : {
188+
"revision" : "d6656967f33ed8b368b38e4b198631fc7c484a40",
189+
"version" : "1.23.1"
190+
}
191+
},
192+
{
193+
"identity" : "swift-nio-ssl",
194+
"kind" : "remoteSourceControl",
195+
"location" : "https://github.com/apple/swift-nio-ssl.git",
196+
"state" : {
197+
"revision" : "4fb7ead803e38949eb1d6fabb849206a72c580f3",
198+
"version" : "2.23.0"
199+
}
200+
},
201+
{
202+
"identity" : "swift-nio-transport-services",
203+
"kind" : "remoteSourceControl",
204+
"location" : "https://github.com/apple/swift-nio-transport-services.git",
205+
"state" : {
206+
"revision" : "c0d9a144cfaec8d3d596aadde3039286a266c15c",
207+
"version" : "1.15.0"
208+
}
209+
},
210+
{
211+
"identity" : "swift-numerics",
212+
"kind" : "remoteSourceControl",
213+
"location" : "https://github.com/apple/swift-numerics",
214+
"state" : {
215+
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
216+
"version" : "1.0.2"
217+
}
218+
},
219+
{
220+
"identity" : "vapor",
221+
"kind" : "remoteSourceControl",
222+
"location" : "https://github.com/vapor/vapor.git",
223+
"state" : {
224+
"revision" : "eb2da0d749e185789970c32f7fd9c114a339fa13",
225+
"version" : "4.67.5"
226+
}
227+
},
228+
{
229+
"identity" : "websocket-kit",
230+
"kind" : "remoteSourceControl",
231+
"location" : "https://github.com/vapor/websocket-kit.git",
232+
"state" : {
233+
"revision" : "2d9d2188a08eef4a869d368daab21b3c08510991",
234+
"version" : "2.6.1"
235+
}
236+
}
237+
],
238+
"version" : 2
239+
}

examples/vapor_example/Package.swift

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// swift-tools-version: 5.7
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "vapor_example",
7+
dependencies: [
8+
.package(url: "https://github.com/vapor/vapor.git", exact: "4.67.5"),
9+
.package(url: "https://github.com/vapor/fluent.git", exact: "4.6.0"),
10+
.package(url: "https://github.com/vapor/fluent-sqlite-driver.git", exact: "4.3.0"),
11+
]
12+
)

examples/vapor_example/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Vapor Example for `rules_spm`
2+
3+
[Vapor](https://github.com/vapor/vapor) is a popular web framework for Swift. It is composed of many
4+
Swift and Clang dependencies. Some of their Clang modules
5+
(e.g. [CBcrypt](https://github.com/vapor/vapor/blob/main/Sources/CBcrypt/include/module.modulemap))
6+
have custom module maps. This example exercises the `rules_spm` code that processes custom module
7+
maps and handles novel Clang module linking issues.
8+
9+
10+
## Linux Prequisites
11+
12+
Be sure to install the folllwing to ensure that all of the prerequisites are satisfied.
13+
14+
```sh
15+
sudo apt install sqlite3 libsqlite3-dev
16+
```
17+
18+
## Other Considerations
19+
20+
To get this example to link successfully on Ubuntu, I needed to add a dependency on `@zlib//:zlib`
21+
to `//Tests/AppTests:AppTests` target and the `//Sources/Run:Run` target.

0 commit comments

Comments
 (0)