Skip to content

Commit 9e03c6b

Browse files
jungleraptorpeddie
andauthored
add testing infra to sysroot creation (#23)
Adds a test harness to help validate sysroot changes before publishing releases. --------- Co-authored-by: Matt Peddie <[email protected]>
1 parent 42031f2 commit 9e03c6b

File tree

13 files changed

+191
-2
lines changed

13 files changed

+191
-2
lines changed

.bazeliskrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
USE_BAZEL_VERSION=6.2.0

.bazelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
build:aarch64_sysroot --incompatible_enable_cc_toolchain_resolution
2+
build:aarch64_sysroot --platforms=@rules_swiftnav//platforms:aarch64_bullseye_graviton2
3+
4+
build:x86_64_sysroot --incompatible_enable_cc_toolchain_resolution
5+
build:x86_64_sysroot --@rules_swiftnav//cc:enable_sysroot=true
6+
7+
try-import %workspace%/.bazelrc.user

.github/workflows/bullseye-aarch64-sysroot.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- .github/workflows/bullseye-aarch64-sysroot.yaml
88
push:
99
tags:
10-
- "bullseye-aarch64-sysroot-*"
10+
- "bullseye-sysroot-*"
1111

1212
jobs:
1313
toolchains:
@@ -21,6 +21,26 @@ jobs:
2121
run: ./sysroot/sysroot-creator.sh build arm64
2222

2323
- name: Upload sysroot
24+
uses: actions/upload-artifact@v3
25+
with:
26+
name: debian_bullseye_aarch64_sysroot.tar.xz
27+
path: sysroot/out/sysroot-build/bullseye/debian_bullseye_arm64_sysroot.tar.xz
28+
29+
- uses: bazelbuild/setup-bazelisk@v2
30+
31+
- name: Mount bazel cache
32+
uses: actions/cache@v1
33+
with:
34+
path: "~/.cache/bazel"
35+
key: bazel
36+
37+
- name: Copy sysroot
38+
run: cp sysroot/out/sysroot-build/bullseye/debian_bullseye_arm64_sysroot.tar.xz debian_bullseye_aarch64_sysroot.tar.xz
39+
40+
- name: Test sysroot
41+
run: bazel build --config=aarch64_sysroot //sysroot/...
42+
43+
- name: Release sysroot
2444
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
2545
uses: svenstaro/upload-release-action@v1-release
2646
with:

.github/workflows/bullseye-x86_64-sysroot.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- .github/workflows/bullseye-x86_64-sysroot.yaml
88
push:
99
tags:
10-
- "bullseye-x86_64-sysroot-*"
10+
- "bullseye-sysroot-*"
1111

1212
jobs:
1313
toolchains:
@@ -21,6 +21,26 @@ jobs:
2121
run: ./sysroot/sysroot-creator.sh build amd64
2222

2323
- name: Upload sysroot
24+
uses: actions/upload-artifact@v3
25+
with:
26+
name: debian_bullseye_x86_64_sysroot.tar.xz
27+
path: sysroot/out/sysroot-build/bullseye/debian_bullseye_amd64_sysroot.tar.xz
28+
29+
- uses: bazelbuild/setup-bazelisk@v2
30+
31+
- name: Mount bazel cache
32+
uses: actions/cache@v1
33+
with:
34+
path: "~/.cache/bazel"
35+
key: bazel
36+
37+
- name: Copy sysroot
38+
run: cp sysroot/out/sysroot-build/bullseye/debian_bullseye_amd64_sysroot.tar.xz debian_bullseye_x86_64_sysroot.tar.xz
39+
40+
- name: Test sysroot
41+
run: bazel build --config=x86_64_sysroot //sysroot/...
42+
43+
- name: Release sysroot
2444
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
2545
uses: svenstaro/upload-release-action@v1-release
2646
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ build-x86/
44
output/
55
llvm-obfuscator-*.txz
66
sysroot/out
7+
/bazel-*
8+
.bazelrc.user

BUILD.bazel

Whitespace-only changes.

WORKSPACE.bazel

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
workspace(name = "swift-toolchains")
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
5+
http_archive(
6+
name = "bazel_skylib",
7+
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
8+
urls = [
9+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
10+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
11+
],
12+
)
13+
14+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
15+
16+
bazel_skylib_workspace()
17+
18+
http_archive(
19+
name = "rules_swiftnav",
20+
sha256 = "91a230cf400921189f1654ebe7ca10305e89f3d8cccc0c7486e6fc8886ac0d1b",
21+
strip_prefix = "rules_swiftnav-3262a9ccd01951aa45576be3db102f03b84047eb",
22+
url = "https://github.com/swift-nav/rules_swiftnav/archive/3262a9ccd01951aa45576be3db102f03b84047eb.tar.gz",
23+
)
24+
25+
load("@rules_swiftnav//cc:repositories.bzl", "register_swift_cc_toolchains", "swift_cc_toolchain")
26+
27+
swift_cc_toolchain()
28+
29+
register_swift_cc_toolchains()
30+
31+
load("@rules_swiftnav//tools:local_archive.bzl", "local_archive")
32+
33+
local_archive(
34+
name = "aarch64-sysroot",
35+
build_file_content = """
36+
filegroup(
37+
name = "aarch64-sysroot",
38+
srcs = glob(["*/**"]),
39+
visibility = ["//visibility:public"],
40+
)
41+
""",
42+
src = "//:debian_bullseye_aarch64_sysroot.tar.xz",
43+
)
44+
45+
local_archive(
46+
name = "x86_64-sysroot",
47+
build_file_content = """
48+
filegroup(
49+
name = "x86_64-sysroot",
50+
srcs = glob(["*/**"]),
51+
visibility = ["//visibility:public"],
52+
)
53+
""",
54+
src = "//:debian_bullseye_x86_64_sysroot.tar.xz",
55+
)

sysroot/BUILD.bazel

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
cc_binary(
2+
name = "uuid",
3+
srcs = ["test/uuid.cc"],
4+
linkopts = [
5+
"-luuid",
6+
],
7+
)
8+
9+
cc_binary(
10+
name = "foo",
11+
srcs = ["test/lapack.cc"],
12+
linkopts = [
13+
"-Lexternal/aarch64-sysroot/usr/lib/aarch64-linux-gnu/blas",
14+
"-Lexternal/aarch64-sysroot/usr/lib/aarch64-linux-gnu/lapack",
15+
"-Lexternal/x86_64-sysroot/usr/lib/x86_64-linux-gnu/blas",
16+
"-Lexternal/x86_64-sysroot/usr/lib/x86_64-linux-gnu/lapack",
17+
"-lm",
18+
"-lpthread",
19+
"-lblas",
20+
"-llapack",
21+
],
22+
)

sysroot/generated_package_lists/bullseye.amd64

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/l
44
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libstdc++6_10.2.1-6_amd64.deb
55
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6_2.31-13+deb11u5_amd64.deb
66
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6-dev_2.31-13+deb11u5_amd64.deb
7+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas3_3.9.0-3_amd64.deb
8+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas-dev_3.9.0-3_amd64.deb
9+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack3_3.9.0-3_amd64.deb
10+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack-dev_3.9.0-3_amd64.deb
711
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/linux/linux-libc-dev_6.1.12-1~bpo11+1_amd64.deb
812
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/u/util-linux/uuid-dev_2.36.1-8+deb11u1_amd64.deb

sysroot/generated_package_lists/bullseye.arm64

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/l
44
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libstdc++6_10.2.1-6_arm64.deb
55
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6_2.31-13+deb11u5_arm64.deb
66
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6-dev_2.31-13+deb11u5_arm64.deb
7+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas3_3.9.0-3_arm64.deb
8+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas-dev_3.9.0-3_arm64.deb
9+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack3_3.9.0-3_arm64.deb
10+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack-dev_3.9.0-3_arm64.deb
711
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/linux/linux-libc-dev_6.1.12-1~bpo11+1_arm64.deb
812
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/u/util-linux/uuid-dev_2.36.1-8+deb11u1_arm64.deb

0 commit comments

Comments
 (0)