• 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    "//absl:gcc_compiler": ABSL_GCC_FLAGS,
29    "//conditions:default": ABSL_GCC_FLAGS,
30})
31
32ABSL_TEST_COPTS = ABSL_DEFAULT_COPTS + select({
33    "//absl:msvc_compiler": ABSL_MSVC_TEST_FLAGS,
34    "//absl:clang-cl_compiler": ABSL_CLANG_CL_TEST_FLAGS,
35    "//absl:clang_compiler": ABSL_LLVM_TEST_FLAGS,
36    "//absl:gcc_compiler": ABSL_GCC_TEST_FLAGS,
37    "//conditions:default": ABSL_GCC_TEST_FLAGS,
38})
39
40ABSL_DEFAULT_LINKOPTS = select({
41    "//absl:msvc_compiler": ABSL_MSVC_LINKOPTS,
42    "//conditions:default": [],
43})
44
45# ABSL_RANDOM_RANDEN_COPTS blaze copts flags which are required by each
46# environment to build an accelerated RandenHwAes library.
47ABSL_RANDOM_RANDEN_COPTS = select({
48    # APPLE
49    ":cpu_darwin_x86_64": ABSL_RANDOM_HWAES_X64_FLAGS,
50    ":cpu_darwin": ABSL_RANDOM_HWAES_X64_FLAGS,
51    ":cpu_x64_windows_msvc": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
52    ":cpu_x64_windows": ABSL_RANDOM_HWAES_MSVC_X64_FLAGS,
53    ":cpu_k8": ABSL_RANDOM_HWAES_X64_FLAGS,
54    ":cpu_ppc": ["-mcrypto"],
55    ":cpu_aarch64": ABSL_RANDOM_HWAES_ARM64_FLAGS,
56
57    # Supported by default or unsupported.
58    "//conditions:default": [],
59})
60
61# absl_random_randen_copts_init:
62#  Initialize the config targets based on cpu, os, etc. used to select
63#  the required values for ABSL_RANDOM_RANDEN_COPTS
64def absl_random_randen_copts_init():
65    """Initialize the config_settings used by ABSL_RANDOM_RANDEN_COPTS."""
66
67    # CPU configs.
68    # These configs have consistent flags to enable HWAES intsructions.
69    cpu_configs = [
70        "ppc",
71        "k8",
72        "darwin_x86_64",
73        "darwin",
74        "x64_windows_msvc",
75        "x64_windows",
76        "aarch64",
77    ]
78    for cpu in cpu_configs:
79        native.config_setting(
80            name = "cpu_%s" % cpu,
81            values = {"cpu": cpu},
82        )
83