Skip to content

Commit d98729a

Browse files
committed
first commit
0 parents  commit d98729a

24 files changed

Lines changed: 1132 additions & 0 deletions

.bazelproject

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
directories:
2+
.
3+
4+
derive_targets_from_directories: true

.bazelrc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Bazel settings that apply to this repository.
2+
# Take care to document any settings that you expect users to apply.
3+
# Settings that apply only to CI are in .github/workflows/ci.bazelrc
4+
build --nolegacy_external_runfiles
5+
6+
# Load any settings specific to the current user.
7+
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
8+
# This needs to be last statement in this
9+
# config, as the user configuration should be able to overwrite flags from this file.
10+
# See https://docs.bazel.build/versions/master/best-practices.html#bazelrc
11+
# (Note that we use .bazelrc.user so the file appears next to .bazelrc in directory listing,
12+
# rather than user.bazelrc as suggested in the Bazel docs)
13+
try-import %workspace%/.bazelrc.user
14+
15+
# Support symlinks with spaces https://github.com/bazelbuild/bazel/issues/4327
16+
build --experimental_inprocess_symlink_creation

.bazelversion

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
5.1.0
2+
# The first line of this file is used by Bazelisk and Bazel to be sure
3+
# the right version of Bazel is used to build and test this repo.
4+
# This also defines which version is used on CI.
5+
#
6+
# Note that you should also run integration_tests against other Bazel
7+
# versions you support.

.github/workflows/ci.bazelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Bazel settings to apply on CI only
2+
# Included with a --bazelrc option in the call to bazel
3+
build --announce_rc
4+
test --test_output=errors
5+
build --disk_cache=$HOME/.cache/bazel
6+
build --repository_cache=$HOME/.cache/bazel-repo
7+
test --test_env=XDG_CACHE_HOME

.github/workflows/ci.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on push or pull request events but only for the main branch
6+
push:
7+
branches: [main]
8+
pull_request:
9+
branches: [main]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
jobs:
15+
test:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os:
20+
- ubuntu-latest
21+
- macos-latest
22+
bazel: [ 4.2.2, 5.1.0 ]
23+
# The type of runner that the job will run on
24+
runs-on: ${{ matrix.os }}
25+
26+
name: test-on-${{ matrix.os }}-with-bazel-${{ matrix.bazel }}
27+
28+
# Steps represent a sequence of tasks that will be executed as part of the job
29+
steps:
30+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
31+
- uses: actions/checkout@v3
32+
- uses: bazelbuild/setup-bazelisk@v2
33+
- name: Mount bazel action cache
34+
uses: actions/cache@v3
35+
with:
36+
path: "~/.cache/bazel"
37+
key: bazel
38+
- name: Mount bazel repo cache
39+
uses: actions/cache@v3
40+
with:
41+
path: "~/.cache/bazel-repo"
42+
key: bazel-repo
43+
- name: Set Bazelisk Version ${{ matrix.bazel }}
44+
run: echo ${{ matrix.bazel }} > .bazelversion
45+
- name: Build
46+
shell: bash
47+
env:
48+
# Bazelisk will download bazel to here
49+
XDG_CACHE_HOME: ~/.cache/bazel-repo
50+
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc build ...
51+
- name: Test
52+
shell: bash
53+
env:
54+
# Bazelisk will download bazel to here
55+
XDG_CACHE_HOME: ~/.cache/bazel-repo
56+
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test ...

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Cut a release whenever a new tag is pushed to the repo.
2+
# You should use an annotated tag, like `git tag -a v1.2.3`
3+
# and put the release notes into the commit message for the tag.
4+
name: Release
5+
6+
on:
7+
push:
8+
tags:
9+
- "*.*.*"
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- uses: bazelbuild/setup-bazelisk@v2
18+
- name: Check git state is clean
19+
run: git status --porcelain
20+
- name: Export release version
21+
run: 'echo "RELEASE_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV'
22+
- name: Build release archive
23+
env:
24+
# Bazelisk will download bazel to here
25+
XDG_CACHE_HOME: ~/.cache/bazel-repo
26+
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc build //:slamdev_toolchain_chromium
27+
- name: Set versioned archive name
28+
run: cp bazel-bin/slamdev_toolchain_chromium.tar.gz bazel-bin/slamdev_toolchain_chromium-v${{ env.RELEASE_VERSION }}.tar.gz
29+
- name: Export checksum
30+
run: 'echo "RELEASE_CHECKSUM=$(shasum -b -a 256 bazel-bin/slamdev_toolchain_chromium-v${{ env.RELEASE_VERSION }}.tar.gz | cut -d " " -f 1)" >> $GITHUB_ENV'
31+
- name: Upload release
32+
uses: softprops/action-gh-release@v1
33+
with:
34+
files: bazel-bin/slamdev_toolchain_chromium-v${{ env.RELEASE_VERSION }}.tar.gz
35+
fail_on_unmatched_files: true
36+
body: |
37+
```starlark
38+
http_archive(
39+
name = "slamdev_toolchain_chromium",
40+
sha256 = "${{ env.RELEASE_CHECKSUM }}",
41+
url = "https://github.com/slamdev/toolchain_chromium/releases/download/${{ env.RELEASE_VERSION }}/slamdev_toolchain_chromium-v${{ env.RELEASE_VERSION }}.tar.gz",
42+
)
43+
```

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bazel-*
2+
.ijwb

.pre-commit-config.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# See CONTRIBUTING.md for instructions.
2+
# See https://pre-commit.com for more information
3+
# See https://pre-commit.com/hooks.html for more hooks
4+
5+
# Commitizen runs in commit-msg stage
6+
# but we don't want to run the other hooks on commit messages
7+
default_stages: [commit]
8+
9+
repos:
10+
# Check formatting and lint for starlark code
11+
- repo: https://github.com/keith/pre-commit-buildifier
12+
rev: 4.0.1.1
13+
hooks:
14+
- id: buildifier
15+
- id: buildifier-lint
16+
# Enforce that commit messages allow for later changelog generation
17+
- repo: https://github.com/commitizen-tools/commitizen
18+
rev: v2.18.0
19+
hooks:
20+
# Requires that commitizen is already installed
21+
- id: commitizen
22+
stages: [commit-msg]
23+
- repo: https://github.com/pre-commit/mirrors-prettier
24+
rev: "v2.4.0"
25+
hooks:
26+
- id: prettier

BUILD.bazel

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
load("@rules_pkg//:pkg.bzl", "pkg_tar")
3+
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")
4+
5+
gazelle_binary(
6+
name = "gazelle_bin",
7+
languages = ["@bazel_skylib//gazelle/bzl"],
8+
)
9+
10+
gazelle(
11+
name = "gazelle",
12+
gazelle = "gazelle_bin",
13+
)
14+
15+
# This declares the release artifact users
16+
pkg_tar(
17+
name = "slamdev_toolchain_chromium",
18+
srcs = [
19+
"LICENSE",
20+
"README.md",
21+
"//chromium:package_content",
22+
],
23+
extension = "tar.gz",
24+
# It is all source code, so make it read-only.
25+
mode = "0444",
26+
# Make it owned by root so it does not have the uid of the CI robot.
27+
owner = "0.0",
28+
strip_prefix = ".",
29+
)
30+
31+
bzl_library(
32+
name = "internal_deps",
33+
srcs = ["internal_deps.bzl"],
34+
visibility = ["//visibility:public"],
35+
deps = [
36+
"@bazel_tools//tools/build_defs/repo:http.bzl",
37+
"@bazel_tools//tools/build_defs/repo:utils.bzl",
38+
],
39+
)

CONTRIBUTING.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# How to Contribute
2+
3+
## Formatting
4+
5+
Starlark files should be formatted by buildifier.
6+
We suggest using a pre-commit hook to automate this.
7+
First [install pre-commit](https://pre-commit.com/#installation),
8+
then run
9+
10+
```shell
11+
pre-commit install
12+
```
13+
14+
Otherwise later tooling on CI may yell at you about formatting/linting violations.
15+
16+
## Updating BUILD files
17+
18+
Some targets are generated from sources.
19+
Currently this is just the `bzl_library` targets.
20+
Run `bazel run //:gazelle` to keep them up-to-date.
21+
22+
## Using this as a development dependency of other rules
23+
24+
You'll commonly find that you develop in another WORKSPACE, such as
25+
some other ruleset that depends on toolchain_chromium, or in a nested
26+
WORKSPACE in the integration_tests folder.
27+
28+
To always tell Bazel to use this directory rather than some release
29+
artifact or a version fetched from the internet, run this from this
30+
directory:
31+
32+
```sh
33+
OVERRIDE="--override_repository=toolchain_chromium=$(pwd)/toolchain_chromium"
34+
echo "build $OVERRIDE" >> ~/.bazelrc
35+
echo "query $OVERRIDE" >> ~/.bazelrc
36+
```
37+
38+
This means that any usage of `@toolchain_chromium` on your system will point to this folder.

0 commit comments

Comments
 (0)