###############################
# Linux
###############################

# Start with configuring the autodetected toolchain.
# The target toolchain should be captured already in its toolchain.
common:linux --repo_env=BAZEL_COPTS="-Wall:-Wextra:-Werror:-gz=zlib"

# C++ only
common:linux --repo_env=BAZEL_CXXOPTS="-std=c++23:-Wformat=2:-pedantic:-Wno-psabi:-Wno-unused-parameter:-fPIC:-pthread:-Wno-deprecated-enum-enum-conversion"

# C Only
common:linux --repo_env=BAZEL_CONLYOPTS="-Wformat=2:-pedantic:-Wno-psabi:-Wno-unused-parameter:-fPIC:-pthread"

# Linker
common:linux --repo_env=BAZEL_LINKOPTS="-rdynamic:-pthread:-ldl:-latomic:-Wl,-rpath,'$ORIGIN':-gz=zlib"

# Cleanup build output for tools
build:linux --host_cxxopt=-Wno-missing-field-initializers
build:linux --host_cxxopt=-Wno-deprecated-enum-enum-conversion
build:linux --host_cxxopt=-Wno-sign-compare
build:linux --host_cxxopt=-Wno-unknown-pragmas
build:linux --host_cxxopt=-Wno-attributes

# Ignore potential issues in third party code on the host
build:linux --host_cxxopt=-Wno-pedantic
build:linux --host_cxxopt=-Wno-format-nonliteral
build:linux --host_cxxopt=-Wno-missing-requires
build:linux --host_cxxopt=-Wno-implicit-fallthrough

build:linux --host_per_file_copt=external/zlib/.*\.c@-Wno-deprecated-non-prototype
build:linux --host_per_file_copt=external/.*@-Wno-pedantic,-Wno-implicit-fallthrough,-Wno-format-nonliteral,-Wno-sign-compare,-Wno-sign-compare,-Wno-type-limits,-Wno-maybe-uninitialized,-Wno-missing-field-initializers,-Wno-trigraphs,-Wno-attributes,-Wno-return-type,-Wno-unused-function,-Wno-format-y2k,-Wno-deprecated-declarations
build:linux --host_per_file_copt=external/.*\.cpp$,external/.*\.cc$@-Wno-missing-requires,-Wno-volatile,-Wno-redundant-move,-Wno-class-memaccess,-Wno-ignored-qualifiers,-Wno-stringop-overflow,-Wno-extra

# Set soname. Needed for robotpy
build:linux --features=set_soname
build:linux --host_features=set_soname

build:linux --host_platform=//shared/bazel:linux_x86_64
build:linux --platforms=//shared/bazel:linux_x86_64
