Skip to content

Commit

Permalink
feat: bzlmodify (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored Sep 15, 2023
1 parent 65bf277 commit 886cd6e
Show file tree
Hide file tree
Showing 27 changed files with 203 additions and 167 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
external
test
.vsocde
.github
16 changes: 1 addition & 15 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
build --enable_platform_specific_config
build --incompatible_use_platforms_repo_for_constraints
build --incompatible_enable_cc_toolchain_resolution
build --incompatible_strict_action_env
build --enable_runfiles

build:windows --platforms=//bazel/platforms:windows

build:linux --platforms=//bazel/platforms:linux
build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux

build:no-warnings --per_file_copt=//.*@-Werror

common:ci --announce_rc
common:ci --disk_cache=~/.cache/bazel-disk-cache
import %workspace%/bazel/common.bazelrc

try-import %workspace%/user.bazelrc
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6.3.2
15 changes: 15 additions & 0 deletions .github/workflows/bzlmod-archive.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is maintained by ecsact-dev/ecsact_common
# If changes are required please make them there

name: bzlmod archive

on:
release:
types: [published]

jobs:
bzlmod-archive:
uses: ecsact-dev/bazel_registry/.github/workflows/bzlmod-archive.yml@main
secrets: inherit
permissions:
contents: write
53 changes: 18 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,48 @@
name: CI
# This file is maintained by ecsact-dev/ecsact_common
# If changes are required please make them there

name: main

on:
push:
branches:
- "**"

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: jidicula/[email protected]
with: { clang-format-version: "15" }
build-windows:
runs-on: windows-latest
steps:
- uses: actions/cache@v3
with:
path: |
/Users/runneradmin/AppData/Local/bazelisk
/Users/runneradmin/.cache/bazel-disk-cache
key: ${{runner.os}}-bazel-cache
- uses: actions/checkout@v3
- run: bazel build --config=ci //...
with: { clang-format-version: "16" }

test-windows:
runs-on: windows-latest
needs: build-windows
steps:
- uses: actions/cache@v3
with:
path: |
/Users/runneradmin/AppData/Local/bazelisk
/Users/runneradmin/.cache/bazel-disk-cache
key: ${{runner.os}}-bazel-cache
- uses: actions/checkout@v3
- run: bazel test --config=ci //...
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
with:
path: |
~/.cache/bazelisk
~/.cache/bazel-disk-cache
key: ${{runner.os}}-bazel-cache
- uses: actions/checkout@v3
- run: bazel build --config=ci --config=no-warnings //...
- uses: actions/checkout@v4
- run: bazelisk build --config=ci //...
- if: ${{ hashfiles('test/MODULE.bazel') != '' }}
run: bazelisk test --config=ci ...
working-directory: test

test-linux:
runs-on: ubuntu-latest
needs: build-linux
steps:
- uses: actions/cache@v3
with:
path: |
~/.cache/bazelisk
~/.cache/bazel-disk-cache
key: ${{runner.os}}-bazel-cache
- uses: actions/checkout@v3
- run: bazel test --config=ci --config=no-warnings //...
- uses: actions/checkout@v4
- run: bazelisk build --config=ci //...
- if: ${{ hashfiles('test/MODULE.bazel') != '' }}
run: bazelisk test --config=ci ...
working-directory: test
15 changes: 7 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# bazel
/bazel-*
/user.bazelrc
bazel-*/
user.bazelrc

# https://github.com/hedronvision/bazel-compile-commands-extractor
/compile_commands.json
/external

# clangd
/.cache/
# editor stuff
compile_commands.json
external/
.cache/
.helix/
11 changes: 11 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module(
name = "ecsact_interpret",
version = "0.3.0",
compatibility_level = 3,
)

bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "magic_enum", version = "0.9.3")
bazel_dep(name = "ecsact_runtime", version = "0.4.1")
bazel_dep(name = "ecsact_parse", version = "0.2.2")
38 changes: 1 addition & 37 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -1,39 +1,5 @@
workspace(name = "ecsact_interpret")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "magic_enum",
sha256 = "6b948d1680f02542d651fc82154a9e136b341ce55c5bf300736b157e23f9df11",
strip_prefix = "magic_enum-0.8.1",
url = "https://github.com/Neargye/magic_enum/archive/refs/tags/v0.8.1.tar.gz",
)

http_archive(
name = "ecsact_runtime",
sha256 = "35b03aaef0925fda5b5aefb2d6a6e2c9593f31d6414ab157091f9ca26a992da3",
strip_prefix = "ecsact_runtime-0.3.0",
urls = ["https://github.com/ecsact-dev/ecsact_runtime/archive/refs/tags/0.3.0.tar.gz"],
)

http_archive(
name = "ecsact_parse",
sha256 = "3f83ae8af26b08472fceef768d2c719a7ea9bedfc907303b9d80d9a7c9b937e9",
strip_prefix = "ecsact_parse-0.2.0",
urls = ["https://github.com/ecsact-dev/ecsact_parse/archive/refs/tags/0.2.0.tar.gz"],
)

load("@ecsact_parse//:repositories.bzl", "ecsact_parse_dependencies")

ecsact_parse_dependencies()

http_archive(
name = "com_google_googletest",
sha256 = "d4cb2430eb82495a49a24310a609b99726726bf126c2fbfa92fd04c14f6a3b31",
strip_prefix = "googletest-d1a0039b97291dd1dc14f123b906bb7622ffe07c",
url = "https://github.com/google/googletest/archive/d1a0039b97291dd1dc14f123b906bb7622ffe07c.zip",
)

http_archive(
name = "hedron_compile_commands",
sha256 = "ed5aea1dc87856aa2029cb6940a51511557c5cac3dbbcb05a4abd989862c36b4",
Expand All @@ -60,9 +26,7 @@ load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")

llvm_toolchain(
name = "llvm_toolchain",
cxx_standard = {"linux": "c++20"},
distribution = "clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04.tar.xz",
llvm_version = "15.0.6",
llvm_version = "16.0.4",
)

load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
Expand Down
23 changes: 23 additions & 0 deletions bazel/common.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is maintained by ecsact-dev/ecsact_common
# If changes are required please make them there

startup --windows_enable_symlinks
common --enable_bzlmod
common --registry=https://raw.githubusercontent.com/ecsact-dev/bazel_registry/main
common --registry=https://raw.githubusercontent.com/bazelboost/registry/main
common --registry=https://bcr.bazel.build
build --enable_platform_specific_config
build --incompatible_use_platforms_repo_for_constraints
build --incompatible_enable_cc_toolchain_resolution
build --incompatible_strict_action_env
build --enable_runfiles
build --noincompatible_remove_rule_name_parameter
query --noincompatible_remove_rule_name_parameter

# Temporary until https://github.com/grailbio/bazel-toolchain/pull/198 is merged
build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux

common:ci --announce_rc
common:ci --verbose_failures
common:ci --keep_going
common:ci --disk_cache=~/.cache/bazel-disk-cache
16 changes: 13 additions & 3 deletions bazel/copts.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
copts = select({
"@bazel_tools//tools/cpp:msvc": ["/std:c++latest"],
"//conditions:default": ["-std=c++20", "-Werror"],
load("@bazel_skylib//lib:selects.bzl", "selects")

# Ecsact repositories currently only support clang and cl
copts = selects.with_or({
("@rules_cc//cc/compiler:clang"): [
"-std=c++2b",
"-fexperimental-library",
],
("@rules_cc//cc/compiler:msvc-cl", "@rules_cc//cc/compiler:clang-cl"): [
"/std:c++latest",
"/permissive-",
"/Zc:preprocessor",
],
})
19 changes: 0 additions & 19 deletions bazel/platforms/BUILD.bazel

This file was deleted.

16 changes: 11 additions & 5 deletions cog.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
post_bump_hooks = [
"git push",
"git push origin {{version}}",
"gh release create {{version}} --generate-notes --latest -t {{version}} --verify-tag",
]
pre_bump_hooks = [
"buildozer 'set version {{version}}' //MODULE.bazel:%module",
# Ecsact pre 1.0.0 the 0.X.0 is our 'major' version
"buildozer 'set compatibility_level {{version.minor}}' //MODULE.bazel:%module",
]

post_bump_hooks = [
"git push",
"git push origin {{version}}",
"gh release create {{version}} --generate-notes --latest -t {{version}} --verify-tag",
]
2 changes: 1 addition & 1 deletion renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"extends": [
"github>ecsact-dev/renovate-config"
]
}
}
3 changes: 3 additions & 0 deletions test/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import %workspace%/../bazel/common.bazelrc

try-import %workspace%/user.bazelrc
26 changes: 13 additions & 13 deletions test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bazel:copts.bzl", "copts")
load("@ecsact_interpret//bazel:copts.bzl", "copts")

cc_library(
name = "test_lib",
hdrs = ["test_lib.hh"],
visibility = ["//test:__subpackages__"],
visibility = ["//:__subpackages__"],
deps = [
"//:ecsact_interpret",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@googletest//:gtest",
],
)

Expand All @@ -18,10 +18,10 @@ cc_test(
copts = copts,
data = ["test.ecsact"],
deps = [
"//:ecsact_interpret",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

Expand All @@ -32,10 +32,10 @@ cc_test(
data = ["comment_before_package.ecsact"],
deps = [
":test_lib",
"//:ecsact_interpret",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)

Expand All @@ -51,9 +51,9 @@ cc_test(
],
deps = [
":test_lib",
"//:ecsact_interpret",
"@ecsact_interpret",
"@bazel_sundry//bazel_sundry:runfiles",
"@com_google_googletest//:gtest",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest",
"@googletest//:gtest_main",
],
)
18 changes: 18 additions & 0 deletions test/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module(name = "ecsact_interpret_test")

bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "bazel_skylib", version = "1.4.2")
bazel_dep(name = "googletest", version = "1.14.0")
bazel_dep(name = "bazel_sundry")
bazel_dep(name = "ecsact_interpret")

git_override(
module_name = "bazel_sundry",
commit = "a999751b4992fab12a06f1bede2414708c6db540",
remote = "https://github.com/seaube/bazel_sundry",
)

local_path_override(
module_name = "ecsact_interpret",
path = "..",
)
Loading

0 comments on commit 886cd6e

Please sign in to comment.