Home | History | Annotate | Download | only in util
      1 # Copyright (c) 2016, Google Inc.
      2 #
      3 # Permission to use, copy, modify, and/or distribute this software for any
      4 # purpose with or without fee is hereby granted, provided that the above
      5 # copyright notice and this permission notice appear in all copies.
      6 #
      7 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
      8 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
      9 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     10 # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     11 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
     12 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
     13 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
     14 
     15 licenses(["notice"])
     16 
     17 exports_files(["LICENSE"])
     18 
     19 load(
     20     ":BUILD.generated.bzl",
     21     "crypto_headers",
     22     "crypto_internal_headers",
     23     "crypto_sources",
     24     "crypto_sources_linux_x86_64",
     25     "crypto_sources_mac_x86_64",
     26     "fips_fragments",
     27     "ssl_headers",
     28     "ssl_internal_headers",
     29     "ssl_sources",
     30     "tool_sources",
     31     "tool_headers",
     32 )
     33 
     34 config_setting(
     35     name = "linux_x86_64",
     36     values = {"cpu": "k8"},
     37 )
     38 
     39 config_setting(
     40     name = "mac_x86_64",
     41     values = {"cpu": "darwin"},
     42 )
     43 
     44 config_setting(
     45     name = "windows_x86_64",
     46     values = {"cpu": "x64_windows"},
     47 )
     48 
     49 config_setting(
     50     name = "android",
     51     values = {"crosstool_top": "//external:android/crosstool"}
     52 )
     53 
     54 posix_copts = [
     55     # Assembler option --noexecstack adds .note.GNU-stack to each object to
     56     # ensure that binaries can be built with non-executable stack.
     57     "-Wa,--noexecstack",
     58 
     59     # This is needed on Linux systems (at least) to get rwlock in pthread.
     60     "-D_XOPEN_SOURCE=700",
     61 
     62     # This list of warnings should match those in the top-level CMakeLists.txt.
     63     "-Wall",
     64     "-Werror",
     65     "-Wformat=2",
     66     "-Wsign-compare",
     67     "-Wmissing-field-initializers",
     68     "-Wwrite-strings",
     69     "-Wshadow",
     70     "-fno-common",
     71 
     72     # Modern build environments should be able to set this to use atomic
     73     # operations for reference counting rather than locks. However, it's
     74     # known not to work on some Android builds.
     75     # "-DOPENSSL_C11_ATOMIC",
     76 ]
     77 
     78 boringssl_copts = select({
     79     ":linux_x86_64": posix_copts,
     80     ":mac_x86_64": posix_copts,
     81     ":windows_x86_64": [
     82         "-DWIN32_LEAN_AND_MEAN",
     83         "-DOPENSSL_NO_ASM",
     84     ],
     85     "//conditions:default": ["-DOPENSSL_NO_ASM"],
     86 })
     87 
     88 crypto_sources_asm = select({
     89     ":linux_x86_64": crypto_sources_linux_x86_64,
     90     ":mac_x86_64": crypto_sources_mac_x86_64,
     91     "//conditions:default": [],
     92 })
     93 
     94 # For C targets only (not C++), compile with C11 support.
     95 posix_copts_c11 = [
     96     "-std=c11",
     97     "-Wmissing-prototypes",
     98     "-Wold-style-definition",
     99     "-Wstrict-prototypes",
    100 ]
    101 
    102 boringssl_copts_c11 = boringssl_copts + select({
    103     ":linux_x86_64": posix_copts_c11,
    104     ":mac_x86_64": posix_copts_c11,
    105     "//conditions:default": [],
    106 })
    107 
    108 # For C++ targets only (not C), compile with C++11 support.
    109 posix_copts_cxx = [
    110     "-std=c++11",
    111     "-Wmissing-declarations",
    112 ]
    113 
    114 boringssl_copts_cxx = boringssl_copts + select({
    115     ":linux_x86_64": posix_copts_cxx,
    116     ":mac_x86_64": posix_copts_cxx,
    117     "//conditions:default": [],
    118 })
    119 
    120 cc_library(
    121     name = "crypto",
    122     srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm,
    123     hdrs = crypto_headers + fips_fragments,
    124     copts = boringssl_copts_c11,
    125     includes = ["src/include"],
    126     linkopts = select({
    127         ":mac_x86_64": [],
    128         # Android supports pthreads, but does not provide a libpthread
    129         # to link against.
    130         ":android": [],
    131         "//conditions:default": ["-lpthread"],
    132     }),
    133     visibility = ["//visibility:public"],
    134 )
    135 
    136 cc_library(
    137     name = "ssl",
    138     srcs = ssl_sources + ssl_internal_headers,
    139     hdrs = ssl_headers,
    140     copts = boringssl_copts_cxx,
    141     includes = ["src/include"],
    142     visibility = ["//visibility:public"],
    143     deps = [
    144         ":crypto",
    145     ],
    146 )
    147 
    148 cc_binary(
    149     name = "bssl",
    150     srcs = tool_sources + tool_headers,
    151     copts = boringssl_copts_cxx,
    152     visibility = ["//visibility:public"],
    153     deps = [":ssl"],
    154 )
    155