Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to cpu_features to bazelmod #365

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
###############################################################################
# Common flags that apply to all configurations.
# 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

###############################################################################
# Options for continuous integration.
###############################################################################

# Speedup bazel using a ramdisk.
build:ci --sandbox_base=/dev/shm

# Show as many errors as possible.
build:ci --keep_going

# Show subcommands when building
build:ci --subcommands=true

# Make sure we test for C99 compliance when building the library
build:ci --conlyopt=-std=c99

# Show test errors.
test:ci --test_output=errors

###############################################################################

# The user.bazelrc file is not checked in but available for local mods.
# Always keep this at the end of the file so that user flags override.
try-import %workspace%/user.bazelrc
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ out/

# Bazel artifacts
**/bazel-*
MODULE.bazel.lock

# Per-user bazelrc files
user.bazelrc
19 changes: 9 additions & 10 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ exports_files(["LICENSE"])
INCLUDES = ["include"]

C99_FLAGS = [
"-std=c99",
"-Wall",
"-Wextra",
"-Wmissing-declarations",
Expand Down Expand Up @@ -56,7 +55,7 @@ cc_test(
includes = INCLUDES,
deps = [
":bit_utils",
"@com_google_googletest//:gtest_main",
"@googletest//:gtest_main",
],
)

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

Expand Down Expand Up @@ -148,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 @@ -312,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 @@ -322,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 @@ -369,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")
10 changes: 2 additions & 8 deletions bazel/ci/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ COPY . .

FROM devel AS build
RUN bazel version
RUN bazel build \
-c opt \
--subcommands=true \
...
RUN bazel build --config=ci ...

FROM build AS test
RUN bazel test \
-c opt \
--test_output=errors \
...
RUN bazel test --config=ci ...
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
Loading