Skip to content

Commit

Permalink
Switch to cpu_features to bazelmod (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
gchatelet authored Sep 13, 2024
1 parent c6a22fc commit 7a8174a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# Use sparingly for things common to all compilers and platforms.
###############################################################################

# Enable Bzlmod for every Bazel command
common --enable_bzlmod

# Prevent invalid caching if input files are modified during a build.
build --experimental_guard_against_concurrent_changes

Expand Down
18 changes: 9 additions & 9 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cc_test(
includes = INCLUDES,
deps = [
":bit_utils",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)

Expand Down Expand Up @@ -89,7 +89,7 @@ cc_test(
includes = INCLUDES,
deps = [
":string_view",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)

Expand Down Expand Up @@ -147,7 +147,7 @@ cc_test(
":cpu_features_macros",
":filesystem_for_testing",
":string_view",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)

Expand Down Expand Up @@ -311,7 +311,7 @@ cc_library(
PLATFORM_CPU_ARM: ["include/cpuinfo_arm.h"],
PLATFORM_CPU_ARM64: [
"include/cpuinfo_aarch64.h",
"include/internal/cpuid_aarch64.h"
"include/internal/cpuid_aarch64.h",
],
PLATFORM_CPU_MIPS: ["include/cpuinfo_mips.h"],
PLATFORM_CPU_PPC: ["include/cpuinfo_ppc.h"],
Expand All @@ -321,10 +321,10 @@ cc_library(
copts = C99_FLAGS,
defines = selects.with_or({
PLATFORM_CPU_X86_64: ["CPU_FEATURES_MOCK_CPUID_X86"],
PLATFORM_CPU_ARM64: [
"CPU_FEATURES_MOCK_CPUID_AARCH64",
"CPU_FEATURES_MOCK_SYSCTL_AARCH64",
],
PLATFORM_CPU_ARM64: [
"CPU_FEATURES_MOCK_CPUID_AARCH64",
"CPU_FEATURES_MOCK_SYSCTL_AARCH64",
],
"//conditions:default": [],
}) + selects.with_or({
PLATFORM_OS_MACOS: ["HAVE_SYSCTLBYNAME"],
Expand Down Expand Up @@ -368,7 +368,7 @@ cc_test(
":filesystem_for_testing",
":hwcaps_for_testing",
":string_view",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)

Expand Down
17 changes: 17 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################

CPU_FEATURES_VERSION = "0.9.0"

module(
name = "cpu_features",
repo_name = "com_google_cpufeatures",
version = CPU_FEATURES_VERSION,
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "googletest", version = "1.15.2")
21 changes: 3 additions & 18 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
workspace(name = "com_google_cpufeatures")

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
name = "com_google_googletest",
tag = "release-1.11.0",
remote = "https://github.com/google/googletest.git",
)
# This file marks the root of the Bazel workspace.
# See MODULE.bazel for external dependencies setup.

git_repository(
name = "bazel_skylib",
tag = "1.2.0",
remote = "https://github.com/bazelbuild/bazel-skylib.git",
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()
workspace(name = "com_google_cpufeatures")
3 changes: 3 additions & 0 deletions scripts/make_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ fi
echo -e "${ACTION}Modifying CMakeLists.txt${NOCOLOR}"
sed -i "s/CpuFeatures VERSION ${LATEST_VERSION}/CpuFeatures VERSION ${VERSION}/g" CMakeLists.txt

echo -e "${ACTION}Modifying MODULE.bazel${NOCOLOR}"
sed -i "s/CPU_FEATURES_VERSION = \"${LATEST_VERSION}\"/CPU_FEATURES_VERSION = \"${VERSION}\"/g" MODULE.bazel

echo -e "${ACTION}Commit new revision${NOCOLOR}"
git add CMakeLists.txt
git commit -m"Release ${GIT_TAG}"
Expand Down

0 comments on commit 7a8174a

Please sign in to comment.