Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,106 @@
# See absl/copts/copts.py and absl/copts/generate_copts.py
include(GENERATED_AbseilCopts)
set(ABSL_DEFAULT_LINKOPTS "")
if (BUILD_SHARED_LIBS AND (MSVC OR ABSL_BUILD_MONOLITHIC_SHARED_LIBS))
set(ABSL_BUILD_DLL TRUE)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
set(ABSL_BUILD_DLL FALSE)
endif()
if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES [[Clang]])
# Some CMake targets (not known at the moment of processing) could be set to
# compile for multiple architectures as specified by the OSX_ARCHITECTURES
# property, which is target-specific. We should neither inspect nor rely on
# any CMake property or variable to detect an architecture, in particular:
#
# - CMAKE_OSX_ARCHITECTURES
# is just an initial value for OSX_ARCHITECTURES; set too early.
#
# - OSX_ARCHITECTURES
# is a per-target property; targets could be defined later, and their
# properties could be modified any time later.
#
# - CMAKE_SYSTEM_PROCESSOR
# does not reflect multiple architectures at all.
#
# When compiling for multiple architectures, a build system can invoke a
# compiler either
#
# - once: a single command line for multiple architectures (Ninja build)
# - twice: two command lines per each architecture (Xcode build system)
#
# If case of Xcode, it would be possible to set an Xcode-specific attributes
# like XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=arm64] or similar.
#
# In both cases, the viable strategy is to pass all arguments at once, allowing
# the compiler to dispatch arch-specific arguments to a designated backend.
set(ABSL_RANDOM_RANDEN_COPTS "")
foreach(_arch IN ITEMS "x86_64" "arm64")
string(TOUPPER "${_arch}" _arch_uppercase)
string(REPLACE "X86_64" "X64" _arch_uppercase ${_arch_uppercase})
foreach(_flag IN LISTS ABSL_RANDOM_HWAES_${_arch_uppercase}_FLAGS)
list(APPEND ABSL_RANDOM_RANDEN_COPTS "SHELL:-Xarch_${_arch} ${_flag}")
endforeach()
endforeach()
# If a compiler happens to deal with an argument for a currently unused
# architecture, it will warn about an unused command line argument.
option(ABSL_RANDOM_RANDEN_COPTS_WARNING OFF
"Warn if one of ABSL_RANDOM_RANDEN_COPTS is unused")
if(ABSL_RANDOM_RANDEN_COPTS AND NOT ABSL_RANDOM_RANDEN_COPTS_WARNING)
list(APPEND ABSL_RANDOM_RANDEN_COPTS "-Wno-unused-command-line-argument")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|amd64|AMD64")
if (MSVC)
set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_MSVC_X64_FLAGS}")
else()
set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_X64_FLAGS}")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm.*|aarch64")
if (CMAKE_SIZEOF_VOID_P STREQUAL "8")
set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM64_FLAGS}")
elseif(CMAKE_SIZEOF_VOID_P STREQUAL "4")
set(ABSL_RANDOM_RANDEN_COPTS "${ABSL_RANDOM_HWAES_ARM32_FLAGS}")
else()
message(WARNING "Value of CMAKE_SIZEOF_VOID_P (${CMAKE_SIZEOF_VOID_P}) is not supported.")
endif()
else()
set(ABSL_RANDOM_RANDEN_COPTS "")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "QCC")
set(ABSL_DEFAULT_COPTS "${ABSL_GCC_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_GCC_TEST_FLAGS}")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # MATCHES so we get both Clang and AppleClang
if(MSVC)
# clang-cl is half MSVC, half LLVM
set(ABSL_DEFAULT_COPTS "${ABSL_CLANG_CL_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_CLANG_CL_TEST_FLAGS}")
else()
set(ABSL_DEFAULT_COPTS "${ABSL_LLVM_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_LLVM_TEST_FLAGS}")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
# IntelLLVM is similar to Clang, with some additional flags.
if(MSVC)
# clang-cl is half MSVC, half LLVM
set(ABSL_DEFAULT_COPTS "${ABSL_CLANG_CL_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_CLANG_CL_TEST_FLAGS}")
else()
set(ABSL_DEFAULT_COPTS "${ABSL_LLVM_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_LLVM_TEST_FLAGS}")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(ABSL_DEFAULT_COPTS "${ABSL_MSVC_FLAGS}")
set(ABSL_TEST_COPTS "${ABSL_MSVC_TEST_FLAGS}")
set(ABSL_DEFAULT_LINKOPTS "${ABSL_MSVC_LINKOPTS}")
else()
message(WARNING "Unknown compiler: ${CMAKE_CXX_COMPILER}. Building with no default flags")
set(ABSL_DEFAULT_COPTS "")
set(ABSL_TEST_COPTS "")
endif()
set(ABSL_CXX_STANDARD "${CMAKE_CXX_STANDARD}")

View File

@ -0,0 +1,217 @@
# GENERATED! DO NOT MANUALLY EDIT THIS FILE.
#
# (1) Edit absl/copts/copts.py.
# (2) Run `python <path_to_absl>/copts/generate_copts.py`.
list(APPEND ABSL_CLANG_CL_FLAGS
"/W3"
"/DNOMINMAX"
"/DWIN32_LEAN_AND_MEAN"
"/D_CRT_SECURE_NO_WARNINGS"
"/D_SCL_SECURE_NO_WARNINGS"
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
)
list(APPEND ABSL_CLANG_CL_TEST_FLAGS
"/W3"
"/DNOMINMAX"
"/DWIN32_LEAN_AND_MEAN"
"/D_CRT_SECURE_NO_WARNINGS"
"/D_SCL_SECURE_NO_WARNINGS"
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
"-Wno-deprecated-declarations"
"-Wno-implicit-int-conversion"
"-Wno-missing-prototypes"
"-Wno-missing-variable-declarations"
"-Wno-shadow"
"-Wno-shorten-64-to-32"
"-Wno-sign-compare"
"-Wno-sign-conversion"
"-Wno-unreachable-code-loop-increment"
"-Wno-unused-function"
"-Wno-unused-member-function"
"-Wno-unused-parameter"
"-Wno-unused-private-field"
"-Wno-unused-template"
"-Wno-used-but-marked-unused"
"-Wno-gnu-zero-variadic-macro-arguments"
)
list(APPEND ABSL_GCC_FLAGS
"-Wall"
"-Wextra"
"-Wcast-qual"
"-Wconversion-null"
"-Wformat-security"
"-Wmissing-declarations"
"-Wnon-virtual-dtor"
"-Woverlength-strings"
"-Wpointer-arith"
"-Wundef"
"-Wunused-local-typedefs"
"-Wunused-result"
"-Wvarargs"
"-Wvla"
"-Wwrite-strings"
"-DNOMINMAX"
)
list(APPEND ABSL_GCC_TEST_FLAGS
"-Wall"
"-Wextra"
"-Wcast-qual"
"-Wconversion-null"
"-Wformat-security"
"-Wnon-virtual-dtor"
"-Woverlength-strings"
"-Wpointer-arith"
"-Wundef"
"-Wunused-local-typedefs"
"-Wunused-result"
"-Wvarargs"
"-Wvla"
"-Wwrite-strings"
"-DNOMINMAX"
"-Wno-deprecated-declarations"
"-Wno-missing-declarations"
"-Wno-self-move"
"-Wno-sign-compare"
"-Wno-unused-function"
"-Wno-unused-parameter"
"-Wno-unused-private-field"
)
list(APPEND ABSL_LLVM_FLAGS
"-Wall"
"-Wextra"
"-Wc++98-compat-extra-semi"
"-Wcast-qual"
"-Wconversion"
"-Wdeprecated-pragma"
"-Wfloat-overflow-conversion"
"-Wfloat-zero-conversion"
"-Wfor-loop-analysis"
"-Wformat-security"
"-Wgnu-redeclared-enum"
"-Winfinite-recursion"
"-Winvalid-constexpr"
"-Wliteral-conversion"
"-Wmissing-declarations"
"-Woverlength-strings"
"-Wpointer-arith"
"-Wself-assign"
"-Wshadow-all"
"-Wshorten-64-to-32"
"-Wsign-conversion"
"-Wstring-conversion"
"-Wtautological-overlap-compare"
"-Wtautological-unsigned-zero-compare"
"-Wundef"
"-Wuninitialized"
"-Wunreachable-code"
"-Wunused-comparison"
"-Wunused-local-typedefs"
"-Wunused-result"
"-Wvla"
"-Wwrite-strings"
"-Wno-float-conversion"
"-Wno-implicit-float-conversion"
"-Wno-implicit-int-float-conversion"
"-Wno-unknown-warning-option"
"-DNOMINMAX"
)
list(APPEND ABSL_LLVM_TEST_FLAGS
"-Wall"
"-Wextra"
"-Wc++98-compat-extra-semi"
"-Wcast-qual"
"-Wconversion"
"-Wdeprecated-pragma"
"-Wfloat-overflow-conversion"
"-Wfloat-zero-conversion"
"-Wfor-loop-analysis"
"-Wformat-security"
"-Wgnu-redeclared-enum"
"-Winfinite-recursion"
"-Winvalid-constexpr"
"-Wliteral-conversion"
"-Wmissing-declarations"
"-Woverlength-strings"
"-Wpointer-arith"
"-Wself-assign"
"-Wshadow-all"
"-Wstring-conversion"
"-Wtautological-overlap-compare"
"-Wtautological-unsigned-zero-compare"
"-Wundef"
"-Wuninitialized"
"-Wunreachable-code"
"-Wunused-comparison"
"-Wunused-local-typedefs"
"-Wunused-result"
"-Wvla"
"-Wwrite-strings"
"-Wno-float-conversion"
"-Wno-implicit-float-conversion"
"-Wno-implicit-int-float-conversion"
"-Wno-unknown-warning-option"
"-DNOMINMAX"
"-Wno-deprecated-declarations"
"-Wno-implicit-int-conversion"
"-Wno-missing-prototypes"
"-Wno-missing-variable-declarations"
"-Wno-shadow"
"-Wno-shorten-64-to-32"
"-Wno-sign-compare"
"-Wno-sign-conversion"
"-Wno-unreachable-code-loop-increment"
"-Wno-unused-function"
"-Wno-unused-member-function"
"-Wno-unused-parameter"
"-Wno-unused-private-field"
"-Wno-unused-template"
"-Wno-used-but-marked-unused"
"-Wno-gnu-zero-variadic-macro-arguments"
)
list(APPEND ABSL_MSVC_FLAGS
"/W3"
"/bigobj"
"/wd4005"
"/wd4068"
"/wd4180"
"/wd4503"
"/wd4800"
"/DNOMINMAX"
"/DWIN32_LEAN_AND_MEAN"
"/D_CRT_SECURE_NO_WARNINGS"
"/D_SCL_SECURE_NO_WARNINGS"
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
)
list(APPEND ABSL_MSVC_LINKOPTS
"-ignore:4221"
)
list(APPEND ABSL_MSVC_TEST_FLAGS
"/W3"
"/bigobj"
"/wd4005"
"/wd4068"
"/wd4180"
"/wd4503"
"/wd4800"
"/DNOMINMAX"
"/DWIN32_LEAN_AND_MEAN"
"/D_CRT_SECURE_NO_WARNINGS"
"/D_SCL_SECURE_NO_WARNINGS"
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE"
"/wd4018"
"/wd4101"
"/wd4244"
"/wd4267"
"/wd4503"
"/wd4996"
"/DNOMINMAX"
)

View File

@ -0,0 +1,218 @@
"""GENERATED! DO NOT MANUALLY EDIT THIS FILE.
(1) Edit absl/copts/copts.py.
(2) Run `python <path_to_absl>/copts/generate_copts.py`.
"""
ABSL_CLANG_CL_FLAGS = [
"/W3",
"/DNOMINMAX",
"/DWIN32_LEAN_AND_MEAN",
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
]
ABSL_CLANG_CL_TEST_FLAGS = [
"/W3",
"/DNOMINMAX",
"/DWIN32_LEAN_AND_MEAN",
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
"-Wno-deprecated-declarations",
"-Wno-implicit-int-conversion",
"-Wno-missing-prototypes",
"-Wno-missing-variable-declarations",
"-Wno-shadow",
"-Wno-shorten-64-to-32",
"-Wno-sign-compare",
"-Wno-sign-conversion",
"-Wno-unreachable-code-loop-increment",
"-Wno-unused-function",
"-Wno-unused-member-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
"-Wno-unused-template",
"-Wno-used-but-marked-unused",
"-Wno-gnu-zero-variadic-macro-arguments",
]
ABSL_GCC_FLAGS = [
"-Wall",
"-Wextra",
"-Wcast-qual",
"-Wconversion-null",
"-Wformat-security",
"-Wmissing-declarations",
"-Wnon-virtual-dtor",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wundef",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvarargs",
"-Wvla",
"-Wwrite-strings",
"-DNOMINMAX",
]
ABSL_GCC_TEST_FLAGS = [
"-Wall",
"-Wextra",
"-Wcast-qual",
"-Wconversion-null",
"-Wformat-security",
"-Wnon-virtual-dtor",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wundef",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvarargs",
"-Wvla",
"-Wwrite-strings",
"-DNOMINMAX",
"-Wno-deprecated-declarations",
"-Wno-missing-declarations",
"-Wno-self-move",
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
]
ABSL_LLVM_FLAGS = [
"-Wall",
"-Wextra",
"-Wc++98-compat-extra-semi",
"-Wcast-qual",
"-Wconversion",
"-Wdeprecated-pragma",
"-Wfloat-overflow-conversion",
"-Wfloat-zero-conversion",
"-Wfor-loop-analysis",
"-Wformat-security",
"-Wgnu-redeclared-enum",
"-Winfinite-recursion",
"-Winvalid-constexpr",
"-Wliteral-conversion",
"-Wmissing-declarations",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wself-assign",
"-Wshadow-all",
"-Wshorten-64-to-32",
"-Wsign-conversion",
"-Wstring-conversion",
"-Wtautological-overlap-compare",
"-Wtautological-unsigned-zero-compare",
"-Wundef",
"-Wuninitialized",
"-Wunreachable-code",
"-Wunused-comparison",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvla",
"-Wwrite-strings",
"-Wno-float-conversion",
"-Wno-implicit-float-conversion",
"-Wno-implicit-int-float-conversion",
"-Wno-unknown-warning-option",
"-DNOMINMAX",
]
ABSL_LLVM_TEST_FLAGS = [
"-Wall",
"-Wextra",
"-Wc++98-compat-extra-semi",
"-Wcast-qual",
"-Wconversion",
"-Wdeprecated-pragma",
"-Wfloat-overflow-conversion",
"-Wfloat-zero-conversion",
"-Wfor-loop-analysis",
"-Wformat-security",
"-Wgnu-redeclared-enum",
"-Winfinite-recursion",
"-Winvalid-constexpr",
"-Wliteral-conversion",
"-Wmissing-declarations",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wself-assign",
"-Wshadow-all",
"-Wstring-conversion",
"-Wtautological-overlap-compare",
"-Wtautological-unsigned-zero-compare",
"-Wundef",
"-Wuninitialized",
"-Wunreachable-code",
"-Wunused-comparison",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvla",
"-Wwrite-strings",
"-Wno-float-conversion",
"-Wno-implicit-float-conversion",
"-Wno-implicit-int-float-conversion",
"-Wno-unknown-warning-option",
"-DNOMINMAX",
"-Wno-deprecated-declarations",
"-Wno-implicit-int-conversion",
"-Wno-missing-prototypes",
"-Wno-missing-variable-declarations",
"-Wno-shadow",
"-Wno-shorten-64-to-32",
"-Wno-sign-compare",
"-Wno-sign-conversion",
"-Wno-unreachable-code-loop-increment",
"-Wno-unused-function",
"-Wno-unused-member-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
"-Wno-unused-template",
"-Wno-used-but-marked-unused",
"-Wno-gnu-zero-variadic-macro-arguments",
]
ABSL_MSVC_FLAGS = [
"/W3",
"/bigobj",
"/wd4005",
"/wd4068",
"/wd4180",
"/wd4503",
"/wd4800",
"/DNOMINMAX",
"/DWIN32_LEAN_AND_MEAN",
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
]
ABSL_MSVC_LINKOPTS = [
"-ignore:4221",
]
ABSL_MSVC_TEST_FLAGS = [
"/W3",
"/bigobj",
"/wd4005",
"/wd4068",
"/wd4180",
"/wd4503",
"/wd4800",
"/DNOMINMAX",
"/DWIN32_LEAN_AND_MEAN",
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
"/wd4018",
"/wd4101",
"/wd4244",
"/wd4267",
"/wd4503",
"/wd4996",
"/DNOMINMAX",
]

View File

@ -0,0 +1,39 @@
"""absl specific copts.
This file simply selects the correct options from the generated files. To
change Abseil copts, edit absl/copts/copts.py
"""
load(
"//absl:copts/GENERATED_copts.bzl",
"ABSL_CLANG_CL_FLAGS",
"ABSL_CLANG_CL_TEST_FLAGS",
"ABSL_GCC_FLAGS",
"ABSL_GCC_TEST_FLAGS",
"ABSL_LLVM_FLAGS",
"ABSL_LLVM_TEST_FLAGS",
"ABSL_MSVC_FLAGS",
"ABSL_MSVC_LINKOPTS",
"ABSL_MSVC_TEST_FLAGS",
)
ABSL_DEFAULT_COPTS = select({
"@rules_cc//cc/compiler:msvc-cl": ABSL_MSVC_FLAGS,
"@rules_cc//cc/compiler:clang-cl": ABSL_CLANG_CL_FLAGS,
"@rules_cc//cc/compiler:clang": ABSL_LLVM_FLAGS,
"@rules_cc//cc/compiler:gcc": ABSL_GCC_FLAGS,
"//conditions:default": [],
})
ABSL_TEST_COPTS = select({
"@rules_cc//cc/compiler:msvc-cl": ABSL_MSVC_TEST_FLAGS,
"@rules_cc//cc/compiler:clang-cl": ABSL_CLANG_CL_TEST_FLAGS,
"@rules_cc//cc/compiler:clang": ABSL_LLVM_TEST_FLAGS,
"@rules_cc//cc/compiler:gcc": ABSL_GCC_TEST_FLAGS,
"//conditions:default": [],
})
ABSL_DEFAULT_LINKOPTS = select({
"@rules_cc//cc/compiler:msvc-cl": ABSL_MSVC_LINKOPTS,
"//conditions:default": [],
})

View File

@ -0,0 +1,188 @@
"""Abseil compiler options.
This is the source of truth for Abseil compiler options. To modify Abseil
compilation options:
(1) Edit the appropriate list in this file based on the platform the flag is
needed on.
(2) Run `<path_to_absl>/copts/generate_copts.py`.
The generated copts are consumed by configure_copts.bzl and
AbseilConfigureCopts.cmake.
"""
ABSL_GCC_FLAGS = [
"-Wall",
"-Wextra",
"-Wcast-qual",
"-Wconversion-null",
"-Wformat-security",
"-Wmissing-declarations",
"-Wnon-virtual-dtor",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wundef",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvarargs",
"-Wvla", # variable-length array
"-Wwrite-strings",
# Don't define min and max macros (Build on Windows using gcc)
"-DNOMINMAX",
]
ABSL_GCC_TEST_ADDITIONAL_FLAGS = [
"-Wno-deprecated-declarations",
"-Wno-missing-declarations",
"-Wno-self-move",
"-Wno-sign-compare",
"-Wno-unused-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
]
ABSL_LLVM_FLAGS = [
"-Wall",
"-Wextra",
"-Wc++98-compat-extra-semi",
"-Wcast-qual",
"-Wconversion",
"-Wdeprecated-pragma",
"-Wfloat-overflow-conversion",
"-Wfloat-zero-conversion",
"-Wfor-loop-analysis",
"-Wformat-security",
"-Wgnu-redeclared-enum",
"-Winfinite-recursion",
"-Winvalid-constexpr",
"-Wliteral-conversion",
"-Wmissing-declarations",
"-Woverlength-strings",
"-Wpointer-arith",
"-Wself-assign",
"-Wshadow-all",
"-Wshorten-64-to-32",
"-Wsign-conversion",
"-Wstring-conversion",
"-Wtautological-overlap-compare",
"-Wtautological-unsigned-zero-compare",
"-Wundef",
"-Wuninitialized",
"-Wunreachable-code",
"-Wunused-comparison",
"-Wunused-local-typedefs",
"-Wunused-result",
"-Wvla",
"-Wwrite-strings",
# Warnings that are enabled by group warning flags like -Wall that we
# explicitly disable.
"-Wno-float-conversion",
"-Wno-implicit-float-conversion",
"-Wno-implicit-int-float-conversion",
# Disable warnings on unknown warning flags (when warning flags are
# unknown on older compiler versions)
"-Wno-unknown-warning-option",
# Don't define min and max macros (Build on Windows using clang)
"-DNOMINMAX",
]
ABSL_LLVM_TEST_ADDITIONAL_FLAGS = [
"-Wno-deprecated-declarations",
"-Wno-implicit-int-conversion",
"-Wno-missing-prototypes",
"-Wno-missing-variable-declarations",
"-Wno-shadow",
"-Wno-shorten-64-to-32",
"-Wno-sign-compare",
"-Wno-sign-conversion",
"-Wno-unreachable-code-loop-increment",
"-Wno-unused-function",
"-Wno-unused-member-function",
"-Wno-unused-parameter",
"-Wno-unused-private-field",
"-Wno-unused-template",
"-Wno-used-but-marked-unused",
# gtest depends on this GNU extension being offered.
"-Wno-gnu-zero-variadic-macro-arguments",
]
# /Wall with msvc includes unhelpful warnings such as C4711, C4710, ...
MSVC_BIG_WARNING_FLAGS = [
"/W3",
]
MSVC_WARNING_FLAGS = [
# Increase the number of sections available in object files
"/bigobj",
"/wd4005", # macro-redefinition
"/wd4068", # unknown pragma
# qualifier applied to function type has no meaning; ignored
"/wd4180",
# The decorated name was longer than the compiler limit
"/wd4503",
# forcing value to bool 'true' or 'false' (performance warning)
"/wd4800",
]
MSVC_DEFINES = [
"/DNOMINMAX", # Don't define min and max macros (windows.h)
# Don't bloat namespace with incompatible winsock versions.
"/DWIN32_LEAN_AND_MEAN",
# Don't warn about usage of insecure C functions.
"/D_CRT_SECURE_NO_WARNINGS",
"/D_SCL_SECURE_NO_WARNINGS",
# Introduced in VS 2017 15.8, allow overaligned types in aligned_storage
"/D_ENABLE_EXTENDED_ALIGNED_STORAGE",
]
def GccStyleFilterAndCombine(default_flags, test_flags):
"""Merges default_flags and test_flags for GCC and LLVM.
Args:
default_flags: A list of default compiler flags
test_flags: A list of flags that are only used in tests
Returns:
A combined list of default_flags and test_flags, but with all flags of the
form '-Wwarning' removed if test_flags contains a flag of the form
'-Wno-warning'
"""
remove = set(["-W" + f[5:] for f in test_flags if f[:5] == "-Wno-"])
return [f for f in default_flags if f not in remove] + test_flags
COPT_VARS = {
"ABSL_GCC_FLAGS": ABSL_GCC_FLAGS,
"ABSL_GCC_TEST_FLAGS": GccStyleFilterAndCombine(
ABSL_GCC_FLAGS, ABSL_GCC_TEST_ADDITIONAL_FLAGS
),
"ABSL_LLVM_FLAGS": ABSL_LLVM_FLAGS,
"ABSL_LLVM_TEST_FLAGS": GccStyleFilterAndCombine(
ABSL_LLVM_FLAGS, ABSL_LLVM_TEST_ADDITIONAL_FLAGS
),
"ABSL_CLANG_CL_FLAGS": MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES,
"ABSL_CLANG_CL_TEST_FLAGS": (
MSVC_BIG_WARNING_FLAGS + MSVC_DEFINES + ABSL_LLVM_TEST_ADDITIONAL_FLAGS
),
"ABSL_MSVC_FLAGS": (
MSVC_BIG_WARNING_FLAGS + MSVC_WARNING_FLAGS + MSVC_DEFINES
),
"ABSL_MSVC_TEST_FLAGS": (
MSVC_BIG_WARNING_FLAGS
+ MSVC_WARNING_FLAGS
+ MSVC_DEFINES
+ [
"/wd4018", # signed/unsigned mismatch
"/wd4101", # unreferenced local variable
"/wd4244", # shortening conversion
"/wd4267", # shortening conversion
"/wd4503", # decorated name length exceeded, name was truncated
"/wd4996", # use of deprecated symbol
"/DNOMINMAX", # disable the min() and max() macros from <windows.h>
]
),
"ABSL_MSVC_LINKOPTS": [
# Object file doesn't export any previously undefined symbols
"-ignore:4221",
],
}

View File

@ -0,0 +1,109 @@
#!/usr/bin/env python3
"""Generate Abseil compile compile option configs.
Usage: <path_to_absl>/copts/generate_copts.py
The configs are generated from copts.py.
"""
from os import path
import sys
from copts import COPT_VARS
# Helper functions
def file_header_lines():
return [
"GENERATED! DO NOT MANUALLY EDIT THIS FILE.", "",
"(1) Edit absl/copts/copts.py.",
"(2) Run `python <path_to_absl>/copts/generate_copts.py`."
]
def flatten(*lists):
return [item for sublist in lists for item in sublist]
def relative_filename(filename):
return path.join(path.dirname(__file__), filename)
# Style classes. These contain all the syntactic styling needed to generate a
# copt file for different build tools.
class CMakeStyle(object):
"""Style object for CMake copts file."""
def separator(self):
return ""
def list_introducer(self, name):
return "list(APPEND " + name
def list_closer(self):
return ")\n"
def docstring(self):
return "\n".join((("# " + line).strip() for line in file_header_lines()))
def filename(self):
return "GENERATED_AbseilCopts.cmake"
class StarlarkStyle(object):
"""Style object for Starlark copts file."""
def separator(self):
return ","
def list_introducer(self, name):
return name + " = ["
def list_closer(self):
return "]\n"
def docstring(self):
docstring_quotes = "\"\"\""
return docstring_quotes + "\n".join(
flatten(file_header_lines(), [docstring_quotes]))
def filename(self):
return "GENERATED_copts.bzl"
def copt_list(name, arg_list, style):
"""Copt file generation."""
make_line = lambda s: " \"" + s + "\"" + style.separator()
external_str_list = [make_line(s) for s in arg_list]
return "\n".join(
flatten(
[style.list_introducer(name)],
external_str_list,
[style.list_closer()]))
def generate_copt_file(style):
"""Creates a generated copt file using the given style object.
Args:
style: either StarlarkStyle() or CMakeStyle()
"""
with open(relative_filename(style.filename()), "w") as f:
f.write(style.docstring())
f.write("\n")
for var_name, arg_list in sorted(COPT_VARS.items()):
f.write("\n")
f.write(copt_list(var_name, arg_list, style))
def main(argv):
if len(argv) > 1:
raise RuntimeError("generate_copts needs no command line args")
generate_copt_file(StarlarkStyle())
generate_copt_file(CMakeStyle())
if __name__ == "__main__":
main(sys.argv)