Parcourir la source

chore: cleanup bazel files + sync bzlmod version (#1147)

Ezekiel Warren il y a 1 an
Parent
commit
154b91e835
6 fichiers modifiés avec 40 ajouts et 13 suppressions
  1. 6 7
      .bazelrc
  2. 3 0
      .github/workflows/bazel-release-archive.yml
  3. 1 0
      .gitignore
  4. 1 5
      MODULE.bazel
  5. 28 0
      scripts/sync_bzlmod_version.sh
  6. 1 1
      test/.bazelrc

+ 6 - 7
.bazelrc

@@ -1,17 +1,16 @@
 common --enable_bzlmod
 build --enable_platform_specific_config
-build --incompatible_use_platforms_repo_for_constraints
 build --incompatible_enable_cc_toolchain_resolution
 build --enable_runfiles
 build --incompatible_strict_action_env
 
-# required for googletest 
+# required for googletest
 build:linux --cxxopt=-std=c++17
 build:macos --cxxopt=-std=c++17
 
-common:ci --announce_rc
-common:ci --verbose_failures
+common:ci --announce_rc
+common:ci --verbose_failures
 common:ci --keep_going
-test:ci --test_output=errors
-
-try-import %workspace%/user.bazelrc
+test:ci --test_output=errors
+
+try-import %workspace%/user.bazelrc

+ 3 - 0
.github/workflows/bazel-release-archive.yml

@@ -13,7 +13,10 @@ jobs:
     permissions:
       contents: write
     steps:
+      - uses: actions/setup-go@v5
+      - run: go install github.com/bazelbuild/buildtools/buildozer@latest
       - uses: actions/checkout@v4
+      - run: ./scripts/sync_bzlmod_version.sh
       - run: git archive $GITHUB_REF -o "entt-${GITHUB_REF:10}.tar.gz"
       - run: gh release upload ${GITHUB_REF:10} "entt-${GITHUB_REF:10}.tar.gz"
         env:

+ 1 - 0
.gitignore

@@ -13,3 +13,4 @@ cpp.hint
 /bazel-*
 /test/bazel-*
 /user.bazelrc
+*.bazel.lock

+ 1 - 5
MODULE.bazel

@@ -1,8 +1,4 @@
-module(
-    name = "entt",
-    version = "3.12.2",
-    compatibility_level = 3012,
-)
+module(name = "entt")
 
 bazel_dep(name = "rules_cc", version = "0.0.8")
 bazel_dep(name = "bazel_skylib", version = "1.4.2")

+ 28 - 0
scripts/sync_bzlmod_version.sh

@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+set -e
+
+SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
+VERSION_HEADER=$(realpath "$SCRIPT_DIR/../src/entt/config/version.h" --relative-to=$(pwd))
+BAZEL_MODULE=$(realpath "$SCRIPT_DIR/../MODULE.bazel" --relative-to=$(pwd))
+
+if [[ -z "${VERSION_HEADER}" ]]; then
+	echo "Cannot find version header"
+	exit 1
+fi
+
+echo "Getting version from $VERSION_HEADER ..."
+
+ENTT_MAJOR_VERSION=$(sed -nr 's/#define ENTT_VERSION_MAJOR ([0-9]+)/\1/p' $VERSION_HEADER)
+ENTT_MINOR_VERSION=$(sed -nr 's/#define ENTT_VERSION_MINOR ([0-9]+)/\1/p' $VERSION_HEADER)
+ENTT_PATCH_VERSION=$(sed -nr 's/#define ENTT_VERSION_PATCH ([0-9]+)/\1/p' $VERSION_HEADER)
+
+VERSION="$ENTT_MAJOR_VERSION.$ENTT_MINOR_VERSION.$ENTT_PATCH_VERSION"
+
+echo "Found $VERSION"
+
+buildozer "set version $VERSION" //MODULE.bazel:%module
+
+# a commit is needed for 'git archive'
+git add $BAZEL_MODULE
+git commit -m "chore: update MODULE.bazel version to $VERSION"

+ 1 - 1
test/.bazelrc

@@ -1 +1 @@
-import "%workspace%/../.bazelrc"
+import "%workspace%/../.bazelrc"