Add GitHub Actions workflow for the Bazel build Add .github/workflows/bazel.yml to build and test all Bazel targets on Linux with disk and repository caching, add the missing internal source and test files to bazel/ceres.bzl and BUILD so they match internal/ceres/CMakeLists.txt, and gate the Clang-specific benchmark copts (-mllvm -inlinehint-threshold=1000000 and -mno-outline) on @rules_cc//cc/compiler:clang so //... builds under both Clang and GCC. Fixes https://github.com/ceres-solver/ceres-solver/issues/1085 Change-Id: I8376366e38342e853da399af4dbd7fdd1003c954
diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml new file mode 100644 index 0000000..344a704 --- /dev/null +++ b/.github/workflows/bazel.yml
@@ -0,0 +1,36 @@ +name: Bazel + +on: [push, pull_request] + +jobs: + build: + name: ubuntu-26.04-Release + runs-on: ubuntu-26.04 + defaults: + run: + shell: bash -e -o pipefail {0} + env: + BAZEL_CACHE_DIR: ${{github.workspace}}/bazel-cache + + steps: + - uses: actions/checkout@v4 + + - name: Cache Bazel + uses: actions/cache@v4 + with: + path: | + ${{env.BAZEL_CACHE_DIR}} + ~/.cache/bazelisk + key: bazel-${{runner.os}}-${{hashFiles('MODULE.bazel', 'WORKSPACE', 'BUILD', 'examples/BUILD', 'bazel/**')}} + restore-keys: | + bazel-${{runner.os}}- + + - name: Build and Test + run: | + bazelisk test //... \ + --compilation_mode=opt \ + --cxxopt=-std=c++17 \ + --host_cxxopt=-std=c++17 \ + --disk_cache="${BAZEL_CACHE_DIR}/disk" \ + --repository_cache="${BAZEL_CACHE_DIR}/repo" \ + --test_output=errors
diff --git a/BUILD b/BUILD index e82cdfb..b3c5373 100644 --- a/BUILD +++ b/BUILD
@@ -84,10 +84,20 @@ "concurrent_queue", "conditioned_cost_function", "conjugate_gradients_solver", + "coordinate_descent_minimizer", "corrector", "cost_function_to_functor", "covariance", "cubic_interpolation", + "cuda_block_sparse_crs_view", + "cuda_block_structure", + "cuda_dense_cholesky", + "cuda_dense_qr", + "cuda_kernels_vector_ops", + "cuda_partitioned_block_sparse_crs_view", + "cuda_sparse_matrix", + "cuda_streamed_buffer", + "cuda_vector", "dense_cholesky", "dense_linear_solver", "dense_qr", @@ -193,10 +203,18 @@ ])] # Build the benchmarks. +BENCHMARK_COPTS = select({ + "@rules_cc//cc/compiler:clang": [ + "-mllvm -inlinehint-threshold=1000000", + "-mno-outline", + ], + "//conditions:default": [], +}) + [cc_binary( name = benchmark_name, srcs = ["internal/ceres/" + benchmark_name + ".cc"], - copts = ["-mllvm -inlinehint-threshold=1000000"], + copts = BENCHMARK_COPTS, deps = TEST_DEPS + ["@google_benchmark//:benchmark"], ) for benchmark_name in [ "autodiff_manifold_benchmark", @@ -220,6 +238,6 @@ "internal/ceres/benchmark_cost_functions.h", "internal/ceres/cost_function_differentiation_benchmark.cc", ], - copts = ["-mllvm -inlinehint-threshold=1000000"], + copts = BENCHMARK_COPTS, deps = TEST_DEPS + ["@google_benchmark//:benchmark"], )
diff --git a/bazel/ceres.bzl b/bazel/ceres.bzl index f407f88..0dbdf35 100644 --- a/bazel/ceres.bzl +++ b/bazel/ceres.bzl
@@ -57,6 +57,12 @@ "cost_function.cc", "covariance.cc", "covariance_impl.cc", + "cuda_block_sparse_crs_view.cc", + "cuda_block_structure.cc", + "cuda_partitioned_block_sparse_crs_view.cc", + "cuda_sparse_cholesky.cc", + "cuda_sparse_matrix.cc", + "cuda_vector.cc", "dense_cholesky.cc", "dense_normal_cholesky_solver.cc", "dense_qr.cc",