Skip to content

Commit 2193acb

Browse files
authored
[workerd-cxx] replacing symlinks with bazel rules (#13)
1 parent f379c3c commit 2193acb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+129
-615
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ build:linux --@rules_rust//:extra_rustc_flags=-Clink-arg=-fuse-ld=lld
1010
build:linux --cxxopt=-std=c++17
1111
build:macos --cxxopt=-std=c++17
1212

13+
build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
14+
build:clippy --output_groups=+clippy_checks
15+
build:clippy --@rules_rust//:clippy_flags=-Dclippy::all,-Dclippy::pedantic
16+
1317
###############################################################################
1418
## Custom user flags
1519
##

.github/workflows/buck2.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 4 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -13,99 +13,6 @@ jobs:
1313
pre_ci:
1414
uses: dtolnay/.github/.github/workflows/pre_ci.yml@master
1515

16-
test:
17-
name: ${{matrix.name || format('Rust {0}', matrix.rust)}}
18-
needs: pre_ci
19-
if: needs.pre_ci.outputs.continue
20-
runs-on: ${{matrix.os}}-latest
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
rust: [nightly, beta, stable, 1.82.0, 1.80.0, 1.77.0, 1.74.0, 1.73.0]
25-
os: [ubuntu]
26-
flags: ['']
27-
include:
28-
- name: Cargo on macOS
29-
rust: nightly
30-
os: macos
31-
- name: Cargo on Windows (msvc)
32-
rust: nightly-x86_64-pc-windows-msvc
33-
os: windows
34-
flags: /EHs
35-
- name: C++14
36-
rust: nightly
37-
os: ubuntu
38-
flags: -std=c++14
39-
- name: C++17
40-
rust: nightly
41-
os: ubuntu
42-
flags: -std=c++17
43-
- name: C++20
44-
rust: nightly
45-
os: ubuntu
46-
flags: -std=c++20
47-
env:
48-
CXXFLAGS: ${{matrix.flags}}
49-
RUSTFLAGS: --cfg deny_warnings -Dwarnings
50-
timeout-minutes: 45
51-
steps:
52-
- name: Enable symlinks (windows)
53-
if: matrix.os == 'windows'
54-
run: git config --global core.symlinks true
55-
- uses: actions/checkout@v4
56-
- uses: dtolnay/rust-toolchain@master
57-
with:
58-
toolchain: ${{matrix.rust}}
59-
components: rust-src
60-
- name: Determine test suite subset
61-
# Our Windows and macOS jobs are the longest running, so exclude the
62-
# relatively slow compiletest from them to speed up end-to-end CI time,
63-
# except during cron builds when no human is presumably waiting on the
64-
# build. The extra coverage is not particularly valuable and we can
65-
# still ensure the test is kept passing on the basis of the scheduled
66-
# builds.
67-
run: |
68-
echo RUSTFLAGS=$RUSTFLAGS >> $GITHUB_ENV
69-
echo exclude=--exclude cxx-test-suite ${{matrix.rust == '1.73.0' && '--exclude cxxbridge-cmd' || ''}} >> $GITHUB_OUTPUT
70-
env:
71-
RUSTFLAGS: ${{env.RUSTFLAGS}} ${{matrix.os != 'ubuntu' && github.event_name != 'schedule' && '--cfg skip_ui_tests' || ''}}
72-
id: testsuite
73-
shell: bash
74-
- name: Ignore macOS linker warning
75-
run: echo RUSTFLAGS=${RUSTFLAGS}\ -Alinker_messages >> $GITHUB_ENV
76-
if: matrix.os == 'macos'
77-
- run: cargo run --manifest-path demo/Cargo.toml
78-
- run: cargo test --workspace ${{steps.testsuite.outputs.exclude}}
79-
if: matrix.rust != '1.74.0' && matrix.rust != '1.73.0'
80-
- run: cargo check --no-default-features --features alloc
81-
env:
82-
RUSTFLAGS: --cfg compile_error_if_std ${{env.RUSTFLAGS}}
83-
- run: cargo check --no-default-features
84-
env:
85-
RUSTFLAGS: --cfg compile_error_if_alloc --cfg cxx_experimental_no_alloc ${{env.RUSTFLAGS}}
86-
- uses: actions/upload-artifact@v4
87-
if: matrix.os == 'ubuntu' && matrix.rust == 'nightly' && always()
88-
with:
89-
name: Cargo.lock
90-
path: Cargo.lock
91-
continue-on-error: true
92-
93-
reindeer:
94-
name: Reindeer
95-
runs-on: ubuntu-latest
96-
if: github.event_name != 'pull_request'
97-
timeout-minutes: 45
98-
steps:
99-
- uses: actions/checkout@v4
100-
- uses: dtolnay/rust-toolchain@stable
101-
with:
102-
components: rust-src
103-
- uses: dtolnay/install@reindeer
104-
- run: reindeer buckify
105-
working-directory: third-party
106-
- name: Check reindeer-generated BUCK file up to date
107-
run: git diff --exit-code
108-
10916
bazel:
11017
name: Bazel on ${{matrix.os == 'ubuntu' && 'Linux' || matrix.os == 'macos' && 'macOS' || matrix.os == 'windows' && 'Windows' || '???'}}
11118
runs-on: ${{matrix.os}}-latest
@@ -129,57 +36,20 @@ jobs:
12936
- name: Check MODULE.bazel.lock up to date
13037
run: git diff --exit-code
13138
- run: bazel run //third-party:vendor
132-
if: matrix.os == 'ubuntu' || matrix.os == 'macos'
39+
if: matrix.os == 'ubuntu'
13340
- name: Check third-party/bazel up to date
13441
run: git diff --exit-code
135-
if: matrix.os == 'ubuntu' || matrix.os == 'macos'
136-
137-
minimal:
138-
name: Minimal versions
139-
needs: pre_ci
140-
if: needs.pre_ci.outputs.continue
141-
runs-on: ubuntu-latest
142-
timeout-minutes: 45
143-
steps:
144-
- uses: actions/checkout@v4
145-
- uses: dtolnay/rust-toolchain@nightly
146-
- run: cargo generate-lockfile -Z minimal-versions
147-
- run: cargo check --locked --workspace
148-
149-
doc:
150-
name: Documentation
151-
needs: pre_ci
152-
if: needs.pre_ci.outputs.continue
153-
runs-on: ubuntu-latest
154-
timeout-minutes: 45
155-
env:
156-
RUSTDOCFLAGS: -Dwarnings
157-
steps:
158-
- uses: actions/checkout@v4
159-
- uses: dtolnay/rust-toolchain@nightly
160-
with:
161-
components: rust-src
162-
- uses: dtolnay/install@cargo-docs-rs
163-
- run: cargo docs-rs
164-
- run: cargo docs-rs -p cxx-build
165-
- run: cargo docs-rs -p cxx-gen
166-
- run: cargo docs-rs -p cxxbridge-flags
167-
- run: cargo docs-rs -p cxxbridge-macro
42+
if: matrix.os == 'ubuntu'
16843

16944
clippy:
17045
name: Clippy
17146
runs-on: ubuntu-latest
17247
if: github.event_name != 'pull_request'
17348
timeout-minutes: 45
174-
env:
175-
RUSTFLAGS: -Dwarnings
17649
steps:
17750
- uses: actions/checkout@v4
178-
- uses: dtolnay/rust-toolchain@nightly
179-
with:
180-
components: clippy, rust-src
181-
- run: cargo clippy --workspace --tests --exclude demo -- -Dclippy::all -Dclippy::pedantic
182-
- run: cargo clippy --manifest-path demo/Cargo.toml -- -Dclippy::all
51+
- run: sudo apt-get install lld
52+
- run: bazel build --config=clippy ... --verbose_failures --noshow_progress
18353

18454
clang-tidy:
18555
name: Clang Tidy
@@ -204,14 +74,3 @@ jobs:
20474
working-directory: book
20575
- run: npx eslint
20676
working-directory: book
207-
208-
outdated:
209-
name: Outdated
210-
runs-on: ubuntu-latest
211-
if: github.event_name != 'pull_request'
212-
timeout-minutes: 45
213-
steps:
214-
- uses: actions/checkout@v4
215-
- uses: dtolnay/rust-toolchain@stable
216-
- uses: dtolnay/install@cargo-outdated
217-
- run: cargo outdated --workspace --exit-code 1

.github/workflows/site._yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/.buckd
2-
/bazel-bin
3-
/bazel-cxx
4-
/bazel-out
5-
/bazel-testlogs
2+
/bazel-*
63
/user.bazelrc
74
/buck-out
85
/expand.cc

BUILD.bazel

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
load("@rules_cc//cc:defs.bzl", "cc_library")
22
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_proc_macro")
3+
load("@bazel_skylib//lib:paths.bzl", "paths")
4+
load(":copy_srcs.bzl", "copy_srcs")
35

46
rust_library(
57
name = "cxx",
@@ -25,10 +27,15 @@ alias(
2527
visibility = ["//visibility:public"],
2628
)
2729

30+
copy_srcs(
31+
name = "cxxbridge-cmd-srcs",
32+
srcs = glob(["gen/cmd/src/*.rs"])
33+
)
34+
2835
rust_binary(
2936
name = "cxxbridge",
30-
srcs = glob(["gen/cmd/src/**/*.rs"]),
31-
compile_data = ["gen/cmd/src/gen/include/cxx.h"],
37+
srcs = [":cxxbridge-cmd-srcs"],
38+
compile_data = ["include/cxx.h"],
3239
edition = "2021",
3340
deps = [
3441
"@crates.io//:clap",
@@ -54,9 +61,14 @@ cc_library(
5461
linkstatic = True,
5562
)
5663

64+
copy_srcs(
65+
name = "cxxbridge-macro-srcs",
66+
srcs = glob(["macro/src/*.rs"])
67+
)
68+
5769
rust_proc_macro(
5870
name = "cxxbridge-macro",
59-
srcs = glob(["macro/src/**/*.rs"]),
71+
srcs = [":cxxbridge-macro-srcs"],
6072
edition = "2021",
6173
proc_macro_deps = [
6274
"@crates.io//:rustversion",
@@ -68,10 +80,17 @@ rust_proc_macro(
6880
],
6981
)
7082

83+
copy_srcs(
84+
name = "cxx-build-srcs",
85+
srcs = glob(["gen/build/src/*.rs"])
86+
)
87+
7188
rust_library(
7289
name = "cxx-build",
73-
srcs = glob(["gen/build/src/**/*.rs"]),
74-
compile_data = ["gen/build/src/gen/include/cxx.h"],
90+
srcs = [":cxx-build-srcs"],
91+
compile_data = [
92+
"include/cxx.h",
93+
],
7594
edition = "2021",
7695
deps = [
7796
"@crates.io//:cc",
@@ -83,10 +102,15 @@ rust_library(
83102
],
84103
)
85104

105+
copy_srcs(
106+
name = "cxx-gen-srcs",
107+
srcs = glob(["gen/lib/src/*.rs"])
108+
)
109+
86110
rust_library(
87111
name = "cxx-gen",
88-
srcs = glob(["gen/lib/src/**/*.rs"]),
89-
compile_data = ["gen/lib/src/gen/include/cxx.h"],
112+
srcs = [":cxx-gen-srcs"],
113+
compile_data = ["include/cxx.h"],
90114
edition = "2021",
91115
visibility = ["//visibility:public"],
92116
deps = [

0 commit comments

Comments
 (0)