• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""absl specific copts.
2
3This file simply selects the correct options from the generated files.  To
4change Abseil copts, edit absl/copts/copts.py
5"""
6
7load(
8    "//absl:copts/GENERATED_copts.bzl",
9    "ABSL_CLANG_CL_FLAGS",
10    "ABSL_CLANG_CL_TEST_FLAGS",
11    "ABSL_GCC_FLAGS",
12    "ABSL_GCC_TEST_FLAGS",
13    "ABSL_LLVM_FLAGS",
14    "ABSL_LLVM_TEST_FLAGS",
15    "ABSL_MSVC_FLAGS",
16    "ABSL_MSVC_LINKOPTS",
17    "ABSL_MSVC_TEST_FLAGS",
18    "ABSL_RANDOM_HWAES_ARM32_FLAGS",
19    "ABSL_RANDOM_HWAES_ARM64_FLAGS",
20    "ABSL_RANDOM_HWAES_MSVC_X64_FLAGS",
21    "ABSL_RANDOM_HWAES_X64_FLAGS",
22)
23
24ABSL_DEFAULT_COPTS = select({
25    "//absl:msvc_compiler": ABSL_MSVC_FLAGS,
26    "//absl:clang-cl_compiler": ABSL_CLANG_CL_FLAGS,
27    "//absl:clang_compiler": ABSL_LLVM_FLAGS,
28    "//conditions:default": ABSL_GCC_FLAGS,
29})
30
31ABSL_TEST_COPTS = ABSL_DEFAULT_COPTS + select({
32    "//absl:msvc_compiler": ABSL_MSVC_TEST_FLAGS,
33    "//absl:clang-cl_compiler": ABSL_CLANG_CL_TEST_FLAGS,
34    "//absl:clang_compiler": ABSL_LLVM_TEST_FLAGS,
35    "//conditions:default": ABSL_GCC_TEST_FLAGS,
36})
37
38ABSL_DEFAULT_LINKOPTS = select({
39    "//absl:msvc_compiler": ABSL_MSVC_LINKOPTS,
40    "//conditions:default": [],
41})
42
43# ABSL_RANDOM_RANDEN_COPTS blaze copts flags which are required by each
44# environment to build an accelerated RandenHwAes library.
45ABSL_RANDOM_RANDEN_COPTS = select({
46    # APPLE
47    ":cpu_darwin_x86_64": ABSL_RANDOM_HWAES_X64_FLAGS,
48    ":cpu_darwin": ABSL_RANDOM_HWAES_X64_FLAGS,
49    ":cpu_x64_windows_msvc": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
50    ":cpu_x64_windows": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
51    ":cpu_k8": ABSL_RANDOM_HWAES_X64_FLAGS,
52    ":cpu_ppc": ["-mcrypto"],
53
54    # Supported by default or unsupported.
55    "//conditions:default": [],
56})
57
58# absl_random_randen_copts_init:
59#  Initialize the config targets based on cpu, os, etc. used to select
60#  the required values for ABSL_RANDOM_RANDEN_COPTS
61def absl_random_randen_copts_init():
62    """Initialize the config_settings used by ABSL_RANDOM_RANDEN_COPTS."""
63
64    # CPU configs.
65    # These configs have consistent flags to enable HWAES intsructions.
66    cpu_configs = [
67        "ppc",
68        "k8",
69        "darwin_x86_64",
70        "darwin",
71        "x64_windows_msvc",
72        "x64_windows",
73    ]
74    for cpu in cpu_configs:
75        native.config_setting(
76            name = "cpu_%s" % cpu,
77            values = {"cpu": cpu},
78        )
79