From 008c7ec1f548755f2e97d5c0ed7e163a42ad32dd Mon Sep 17 00:00:00 2001 From: Stefan Bucur <281483+stefanbucur@users.noreply.github.com> Date: Fri, 2 Apr 2021 23:01:49 -0400 Subject: [PATCH] Switch the cel-cpp project to the new Bazel build script. This reduces the build.sh file to a single line. (#5549) --- .../base-builder/bazel_build_fuzz_tests | 2 +- projects/bazel-rules-fuzzing-test/build.sh | 9 +++++++-- projects/cel-cpp/build.sh | 16 +--------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/infra/base-images/base-builder/bazel_build_fuzz_tests b/infra/base-images/base-builder/bazel_build_fuzz_tests index 86740ee01..d843d75f6 100755 --- a/infra/base-images/base-builder/bazel_build_fuzz_tests +++ b/infra/base-images/base-builder/bazel_build_fuzz_tests @@ -42,7 +42,7 @@ done declare -r BAZEL_BUILD_FLAGS=( "-c" "opt" - "--//fuzzing:cc_engine=@rules_fuzzing_oss_fuzz//:oss_fuzz_engine" \ + "--@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing_oss_fuzz//:oss_fuzz_engine" \ "--@rules_fuzzing//fuzzing:cc_engine_instrumentation=oss-fuzz" \ "--@rules_fuzzing//fuzzing:cc_engine_sanitizer=none" \ "--linkopt=-lc++" \ diff --git a/projects/bazel-rules-fuzzing-test/build.sh b/projects/bazel-rules-fuzzing-test/build.sh index 056e16b3d..4698ebd92 100644 --- a/projects/bazel-rules-fuzzing-test/build.sh +++ b/projects/bazel-rules-fuzzing-test/build.sh @@ -16,7 +16,12 @@ # ################################################################################ -# This is an example build script for projects using the rules_fuzzing library -# for Bazel. +# Due to https://github.com/bazelbuild/bazel/issues/11128, affecting Bazel 4.0 +# or earlier, we cannot use the "@rules_fuzzing//" prefix for the label-typed +# cc_engine configuration flag when fuzzing directly the rules_fuzzing workspace. +# +# This is NOT needed for any other Bazel repository that depends on +# rules_fuzzing. +export BAZEL_EXTRA_BUILD_FLAGS="--//fuzzing:cc_engine=@rules_fuzzing_oss_fuzz//:oss_fuzz_engine" bazel_build_fuzz_tests diff --git a/projects/cel-cpp/build.sh b/projects/cel-cpp/build.sh index 5a6315a35..b204d1cb6 100755 --- a/projects/cel-cpp/build.sh +++ b/projects/cel-cpp/build.sh @@ -15,18 +15,4 @@ # ################################################################################ -declare -r QUERY=' - let all_fuzz_tests = attr(tags, "fuzz-test", "//...") in - $all_fuzz_tests - attr(tags, "no-oss-fuzz", $all_fuzz_tests) -' - -declare -r PACKAGE_SUFFIX="_oss_fuzz" -declare -r OSS_FUZZ_TESTS="$(bazel query "${QUERY}" | sed "s/$/${PACKAGE_SUFFIX}/")" - -bazel build -c opt --config=oss-fuzz --linkopt=-lc++ \ - --action_env=CC="${CC}" --action_env=CXX="${CXX}" \ - ${OSS_FUZZ_TESTS[*]} - -for oss_fuzz_archive in $(find bazel-bin/ -name "*${PACKAGE_SUFFIX}.tar"); do - tar -xvf "${oss_fuzz_archive}" -C "${OUT}" -done +bazel_build_fuzz_tests