# Copyright 2019 The TCMalloc Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

build --cxxopt='-std=c++17'

test --test_output=errors

# Disable noisy warnings from dependencies.
build --per_file_copt=-external/.*@-w
build --host_per_file_copt=-external/.*@-w

# Disable noisy warnings in TCMalloc.
build:clang --copt=-Wno-nullability-completeness
build:gcc --copt=-Wno-sign-compare

# Flip incompatible_disallow_empty_glob to avoid breaking forward compatibility, see
# https://github.com/bazelbuild/bazel/pull/15327 for details.
build --incompatible_disallow_empty_glob

# Flip incompatible_config_setting_private_default_visibility to avoid breaking
# forward compatibility. See https://github.com/bazelbuild/bazel/issues/12933
# for details.
common --incompatible_config_setting_private_default_visibility

# Link Google Test against Abseil and RE2.
build --define='absl=1'

# Use thread-safe death tests in Google Test.
build --copt=-DGTEST_DEFAULT_DEATH_TEST_STYLE='\"threadsafe\"' --host_copt=-DGTEST_DEFAULT_DEATH_TEST_STYLE='\"threadsafe\"'

# AllocationGuard.CooperativeDeathTest checks for "SIGABRT received"
# message printed by this signal handler.
test --test_env="GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1"

# Define the --config=asan-libfuzzer configuration.
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine=@rules_fuzzing//fuzzing/engines:libfuzzer
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer
build:asan-libfuzzer --@rules_fuzzing//fuzzing:cc_engine_sanitizer=asan

# Configure our Docker toolchain setup.
build --extra_toolchains=@docker_toolchain//:all
build:libstdc++ --features=libstdc++
build:gcc --platforms=//ci:linux_gcc
build:clang --platforms=//ci:linux_clang

# Remote build configuration for CI.
build:remote-base --define=EXECUTOR=remote
build:remote-base --remote_cache=grpcs://us-central1-remotebuildexecution.googleapis.com
build:remote-base --remote_executor=grpcs://us-central1-remotebuildexecution.googleapis.com
build:remote-base --remote_instance_name=projects/tcmalloc-94329/instances/ci-central
build:remote-base --remote_timeout=1200 --bes_timeout=600s
build:remote-base --jobs=100
build:remote-base --remote_download_minimal
# Retry up for up to 15 minutes under heavy load (exponential backoff).
build:remote-base --remote_retries=20 --remote_retry_max_delay=60s

build:remote --config=remote-base
build:remote --extra_execution_platforms=//ci:rbe
build:remote --host_platform=//ci:rbe
build:remote --platforms=//ci:rbe
