forked from elide-dev/capnproto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This changeset adds support for Bzlmod, both in the sense that Cap'n'Proto now uses Bzlmod for development dependencies, and also in the sense that this codebase now defines a module which can be published for Cap'n'Proto C++. Nearly all dependencies for capnp are available on Bzlmod; the sole exception being Brotli, which will still need to be added by downstream projects. New macros have been added so that Cap'n'Proto can be used in projects downstream, either via `WORKSPACE.bazel` or Bzlmod. - feat: add `capnp_repositories` in `defs/repositories.bzl` - feat: add `capnp_workspace` in `defs/workspace.bzl` - feat: add `MODULE.bazel` with dev and API dependencies - feat: add support for `.bazelci` via presubmit config - test: add integration test for `workspace` via bazel - test: add integration test for bzlmod support - feat: add bcr publishing flow (occurs on release) - feat: add public target for runtime capnproto dependency - docs: add doc page with instructions for use from bazel - fix: make all capnproto sources private to this codebase - chore: generate initial bzlmod dependency lockfile - chore: move root `WORKSPACE` logic to `defs` calls - chore: split `.bazelrc` into `base.bazelrc` to reuse settings - chore: move `cc_capnp_library` to `internal` Signed-off-by: Sam Gammon <[email protected]>
- Loading branch information
Showing
46 changed files
with
4,517 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
matrix: | ||
bazel_version: ["7.0.0"] | ||
platform: ["centos7", "debian10", "macos", "ubuntu2004"] | ||
|
||
validate_config: 1 | ||
buildifier: latest | ||
|
||
tasks: | ||
build: | ||
working_directory: c++ | ||
include_json_profile: | ||
- build | ||
- test | ||
build_targets: | ||
- "//..." | ||
test_targets: | ||
- "//..." | ||
|
||
bcr_test_module: | ||
module_path: "integration_tests/bzlmod" | ||
matrix: | ||
platform: ["debian10", "macos", "ubuntu2004", "centos7"] | ||
tasks: | ||
build_bzlmod_test: | ||
name: "Build test module" | ||
platform: ${{ platform }} | ||
build_targets: | ||
- "//:sample-bin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
moduleRoots: ["./c++"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"homepage": "https://github.com/capnproto/capnproto", | ||
"maintainers": [ | ||
{ | ||
"github": "kentonv", | ||
"name": "Kenton Varda" | ||
} | ||
], | ||
"repository": ["github:capnproto/capnproto"], | ||
"versions": [], | ||
"yanked_versions": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
bcr_test_module: | ||
module_path: "integration_tests/bzlmod" | ||
matrix: | ||
platform: ["debian10", "macos", "ubuntu2004"] | ||
tasks: | ||
build_bzlmod_test: | ||
name: "Build test module" | ||
platform: ${{ platform }} | ||
build_targets: | ||
- "//:sample-bin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"integrity": "", | ||
"strip_prefix": "{REPO}-{VERSION}/c++", | ||
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/capnproto-cpp-{VERSION}.tar.gz" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("@buildifier_prebuilt//:rules.bzl", "buildifier") | ||
|
||
buildifier( | ||
name = "buildifier.check", | ||
exclude_patterns = ["./.git/*"], | ||
lint_mode = "warn", | ||
mode = "diff", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This file contains Bazel settings to apply on CI only. | ||
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml | ||
|
||
# Debug where options came from | ||
build --announce_rc | ||
|
||
# Apply CI configurations | ||
build --config=ci | ||
|
||
# This directory is configured in GitHub actions to be persisted between runs. | ||
# We do not enable the repository cache to cache downloaded external artifacts | ||
# as these are generally faster to download again than to fetch them from the | ||
# GitHub actions cache. | ||
build --disk_cache=~/.cache/bazel | ||
|
||
# Don't rely on test logs being easily accessible from the test runner, | ||
# though it makes the log noisier. | ||
test --test_output=errors | ||
|
||
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used | ||
test --test_env=XDG_CACHE_HOME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: Bazel CI | ||
|
||
# Controls when the action will run. | ||
"on": | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: read | ||
|
||
concurrency: | ||
# Cancel previous actions from the same revision | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@29e53247c6366e30acbedfc767f58f79fc05836c | ||
with: | ||
folders: | | ||
[ | ||
"./c++", | ||
] | ||
exclude_windows: false | ||
exclude: | | ||
[ | ||
{"bazelversion": "7.0.0", "bzlmodEnabled": true}, | ||
{"bazelversion": "7.0.0", "bzlmodEnabled": false} | ||
] |
7 changes: 4 additions & 3 deletions
7
.github/workflows/quick-test.yml → .github/workflows/module.quick-test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
name: Release | ||
|
||
"on": | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
|
||
workflow_dispatch: | ||
inputs: | ||
prerelease: | ||
description: Pre-release | ||
type: boolean | ||
default: false | ||
artifact: | ||
description: Artifact | ||
type: string | ||
default: "capnp-cpp" | ||
dry: | ||
description: Dry-run | ||
type: boolean | ||
default: false | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
release: | ||
name: "Release: BCR" | ||
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v2 | ||
with: | ||
release_files: capnp-cpp-*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
# Set by GH actions, see | ||
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables | ||
TAG=${GITHUB_REF_NAME} | ||
# The prefix is chosen to match what GitHub generates for source archives | ||
PREFIX="capnp-cpp-${TAG:1}" | ||
ARCHIVE="capnp-cpp-$TAG.tar.gz" | ||
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE | ||
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') | ||
|
||
cat << EOF | ||
1. Enable with \`common --enable_bzlmod\` in \`.bazelrc\`. | ||
2. Add to your \`MODULE.bazel\` file: | ||
\`\`\`starlark | ||
bazel_dep(name = "capnp-cpp", version = "${TAG:1}") | ||
\`\`\` | ||
## Using WORKSPACE | ||
Paste this snippet into your `WORKSPACE.bazel` file: | ||
\`\`\`starlark | ||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
http_archive( | ||
name = "capnp-cpp", | ||
sha256 = "${SHA}", | ||
strip_prefix = "${PREFIX}", | ||
url = "https://github.com/capnproto/capnp-cpp/releases/download/${TAG}/${ARCHIVE}", | ||
) | ||
EOF | ||
|
||
awk 'f;/--SNIP--/{f=1}' integration_tests/workspace/WORKSPACE.bazel | ||
echo "\`\`\`" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"Cap'n'Proto for C++" | ||
|
||
module( | ||
name = "capnp-cpp", | ||
version = "1.0.2", # keep in sync with current version | ||
) | ||
|
||
|
||
## | ||
## Dependencies: API | ||
## | ||
|
||
bazel_dep( | ||
name = "platforms", | ||
version = "0.0.7", | ||
) | ||
bazel_dep( | ||
name = "bazel_skylib", | ||
version = "1.4.2", | ||
) | ||
bazel_dep( | ||
name = "zlib", | ||
version = "1.3", | ||
) | ||
bazel_dep( | ||
name = "boringssl", | ||
version = "0.0.0-20230215-5c22014", | ||
repo_name = "ssl", | ||
) | ||
|
||
## | ||
## Dependencies: Development | ||
## | ||
|
||
bazel_dep( | ||
name = "rules_license", | ||
version = "0.0.7", | ||
dev_dependency = True, | ||
) | ||
bazel_dep( | ||
name = "rules_testing", | ||
version = "0.4.0", | ||
dev_dependency = True, | ||
) | ||
bazel_dep( | ||
name = "aspect_bazel_lib", | ||
version = "1.34.1", | ||
dev_dependency = True, | ||
) | ||
bazel_dep( | ||
name = "stardoc", | ||
version = "0.6.2", | ||
dev_dependency = True, | ||
repo_name = "io_bazel_stardoc", | ||
) | ||
bazel_dep( | ||
name = "buildifier_prebuilt", | ||
version = "6.3.3", | ||
dev_dependency = True, | ||
) |
Oops, something went wrong.