From 7a47b77dd40e1e167f66b7323d841aa0ea458980 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Fri, 6 Oct 2023 16:44:07 -0700 Subject: [PATCH] feat: bzlmodify (#68) --- .bazelrc | 13 +-------- .bazelversion | 1 + .github/workflows/bzlmod-archive.yml | 15 ++++++++++ .github/workflows/main.yml | 43 +++++++++++++++++++++++----- MODULE.bazel | 10 +++++++ WORKSPACE.bazel | 29 +------------------ bazel/BUILD.bazel | 4 +++ bazel/common.bazelrc | 20 +++++++++++++ bazel/copts.bzl | 19 ++++++++++-- bazel/platforms/BUILD.bazel | 19 ------------ cog.toml | 10 +++++++ csharp_codegen/BUILD.bazel | 2 +- csharp_codegen/csharp_codegen.cc | 4 +-- renovate.json | 2 +- 14 files changed, 118 insertions(+), 73 deletions(-) create mode 100644 .bazelversion create mode 100644 .github/workflows/bzlmod-archive.yml create mode 100644 MODULE.bazel create mode 100644 bazel/common.bazelrc delete mode 100644 bazel/platforms/BUILD.bazel create mode 100644 cog.toml diff --git a/.bazelrc b/.bazelrc index b1a5004..7cddb69 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,14 +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:windows --platforms=//bazel/platforms:windows - -build:linux --platforms=//bazel/platforms:linux -build:linux --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux - -common:ci --announce_rc -common:ci --disk_cache=~/.cache/bazel-disk-cache +import %workspace%/bazel/common.bazelrc try-import %workspace%/user.bazelrc diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000..91e4a9f --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +6.3.2 diff --git a/.github/workflows/bzlmod-archive.yml b/.github/workflows/bzlmod-archive.yml new file mode 100644 index 0000000..32613e3 --- /dev/null +++ b/.github/workflows/bzlmod-archive.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 354e4bb..1a281a5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,19 +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/clang-format-action@v4.9.0 - with: { clang-format-version: "15" } + with: { clang-format-version: "16" } + + test-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@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 + steps: + - uses: actions/cache@v3 + with: + path: | + ~/.cache/bazelisk + ~/.cache/bazel-disk-cache + key: ${{runner.os}}-bazel-cache + - uses: actions/checkout@v4 + - run: bazelisk build --config=ci //... + - if: ${{ hashfiles('test/MODULE.bazel') != '' }} + run: bazelisk test --config=ci ... + working-directory: test diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..8553dd3 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,10 @@ +module( + name = "ecsact_lang_csharp", + version = "0.1.0", + compatibility_level = 1, +) + +bazel_dep(name = "ecsact_runtime", version = "0.5.4") +bazel_dep(name = "ecsact_codegen", version = "0.1.3") +bazel_dep(name = "rules_cc", version = "0.0.9") +bazel_dep(name = "ecsact_lang_cpp", version = "0.3.1") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 954e539..98b497d 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -2,31 +2,6 @@ workspace(name = "ecsact_lang_csharp") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -http_archive( - name = "ecsact_runtime", - sha256 = "219ce161deeb4865d3c190eac300dd257671e2b2ca0ec8752091506ccfa554a2", - strip_prefix = "ecsact_runtime-5cbf7257d7cbc42762d22e7604bc5bc0efb837fe", - url = "https://github.com/ecsact-dev/ecsact_runtime/archive/5cbf7257d7cbc42762d22e7604bc5bc0efb837fe.zip", -) - -http_archive( - name = "boost", - sha256 = "c41441a6e9f8038ad626e9f937ddc3675ab896b6c3512eefc6840037b3816d03", - strip_prefix = "boost-563e8e0de4eac4b48a02d296581dc2454127608e", - urls = ["https://github.com/bazelboost/boost/archive/563e8e0de4eac4b48a02d296581dc2454127608e.zip"], -) - -load("@boost//:index.bzl", "boost_http_archives") - -boost_http_archives() - -http_archive( - name = "com_google_googletest", - sha256 = "41c14a5a4887125fe329235f00c5f92660f245b91bb8dde7c59f9a2540fdec28", - strip_prefix = "googletest-40412d85124f7c6f3d88454583c4633e5e10fc8c", - url = "https://github.com/google/googletest/archive/40412d85124f7c6f3d88454583c4633e5e10fc8c.zip", -) - http_archive( name = "hedron_compile_commands", sha256 = "ed5aea1dc87856aa2029cb6940a51511557c5cac3dbbcb05a4abd989862c36b4", @@ -53,9 +28,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") diff --git a/bazel/BUILD.bazel b/bazel/BUILD.bazel index e69de29..c9e1c55 100644 --- a/bazel/BUILD.bazel +++ b/bazel/BUILD.bazel @@ -0,0 +1,4 @@ +config_setting( + name = "compiler_emscripten", + flag_values = {"@bazel_tools//tools/cpp:compiler": "emscripten"}, +) diff --git a/bazel/common.bazelrc b/bazel/common.bazelrc new file mode 100644 index 0000000..ebb4c3e --- /dev/null +++ b/bazel/common.bazelrc @@ -0,0 +1,20 @@ +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 diff --git a/bazel/copts.bzl b/bazel/copts.bzl index 8f5e387..b8ebf62 100644 --- a/bazel/copts.bzl +++ b/bazel/copts.bzl @@ -1,4 +1,17 @@ -copts = select({ - "@bazel_tools//tools/cpp:msvc": ["/std:c++latest", "/Zc:preprocessor", "/permissive-"], - "//conditions:default": ["-std=c++20"], +load("@bazel_skylib//lib:selects.bzl", "selects") + +# Ecsact repositories currently only support clang, cl, and emscripten +copts = selects.with_or({ + (Label("//bazel:compiler_emscripten")): [ + "-std=c++20", + ], + ("@rules_cc//cc/compiler:clang"): [ + "-std=c++20", + "-fexperimental-library", + ], + ("@rules_cc//cc/compiler:msvc-cl", "@rules_cc//cc/compiler:clang-cl"): [ + "/std:c++20", + "/permissive-", + "/Zc:preprocessor", + ], }) diff --git a/bazel/platforms/BUILD.bazel b/bazel/platforms/BUILD.bazel deleted file mode 100644 index dae4bb2..0000000 --- a/bazel/platforms/BUILD.bazel +++ /dev/null @@ -1,19 +0,0 @@ -package(default_visibility = ["//:__subpackages__"]) - -platform( - name = "windows", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:windows", - "@bazel_tools//tools/cpp:msvc", - ], -) - -platform( - name = "linux", - constraint_values = [ - "@platforms//cpu:x86_64", - "@platforms//os:linux", - "@bazel_tools//tools/cpp:clang", - ], -) diff --git a/cog.toml b/cog.toml new file mode 100644 index 0000000..9cbba6c --- /dev/null +++ b/cog.toml @@ -0,0 +1,10 @@ +pre_bump_hooks = [ + # Ecsact pre 1.0.0 the 0.X.0 is our 'major' version + "buildozer 'set version {{version}}' '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", +] diff --git a/csharp_codegen/BUILD.bazel b/csharp_codegen/BUILD.bazel index 53a49ce..89e68b9 100644 --- a/csharp_codegen/BUILD.bazel +++ b/csharp_codegen/BUILD.bazel @@ -1,5 +1,5 @@ load("//bazel:copts.bzl", "copts") -load("@ecsact_runtime//:codegen_plugin.bzl", "cc_ecsact_codegen_plugin") +load("@ecsact_lang_cpp//:codegen_plugin.bzl", "cc_ecsact_codegen_plugin") package(default_visibility = ["//visibility:public"]) diff --git a/csharp_codegen/csharp_codegen.cc b/csharp_codegen/csharp_codegen.cc index fc1f1d2..a6d9fa4 100644 --- a/csharp_codegen/csharp_codegen.cc +++ b/csharp_codegen/csharp_codegen.cc @@ -1,8 +1,8 @@ #include #include #include "ecsact/runtime/meta.hh" -#include "ecsact/codegen_plugin.h" -#include "ecsact/codegen_plugin.hh" +#include "ecsact/codegen/plugin.h" +#include "ecsact/codegen/plugin.hh" #include "ecsact/lang-support/lang-csharp.hh" static bool has_parent_system(ecsact_system_id id) { diff --git a/renovate.json b/renovate.json index 25b1be3..fa1abeb 100644 --- a/renovate.json +++ b/renovate.json @@ -3,4 +3,4 @@ "extends": [ "github>ecsact-dev/renovate-config" ] -} +} \ No newline at end of file