1# Copyright 2019 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import("//build_overrides/build.gni")
6import("BUILD.generated.gni")
7import("BUILD.generated_tests.gni")
8
9if (build_with_chromium) {
10  group("boringssl") {
11    public_configs = [ "//build/config/compiler:default_include_dirs" ]
12    public_deps = [
13      "//third_party/boringssl",
14    ]
15  }
16} else {
17  # Config for us and everybody else depending on BoringSSL.
18  config("external_config") {
19    include_dirs = [ "src/include" ]
20    cflags = []
21    if (is_clang) {
22      cflags += [ "-Wno-extra-semi" ]
23    }
24  }
25
26  # Config internal to this build file, shared by boringssl and boringssl_fuzzer.
27  config("internal_config") {
28    visibility = [ ":*" ]  # Only targets in this file can depend on this.
29    defines = [
30      "BORINGSSL_ALLOW_CXX_RUNTIME",
31      "BORINGSSL_IMPLEMENTATION",
32      "BORINGSSL_NO_STATIC_INITIALIZER",
33      "OPENSSL_SMALL",
34    ]
35    cflags = [ "-w" ]  # Disable all warnings.
36    cflags_c = [ "-std=c99" ]
37
38    defines += [ "_XOPEN_SOURCE=700" ]
39  }
40
41  config("no_asm_config") {
42    visibility = [ ":*" ]  # Only targets in this file can depend on this.
43    defines = [ "OPENSSL_NO_ASM" ]
44  }
45
46  all_sources = crypto_sources + ssl_sources
47  all_headers = crypto_headers + ssl_headers
48
49  # This has no sources on some platforms so must be a source_set.
50  source_set("boringssl_asm") {
51    visibility = [ ":*" ]  # Only targets in this file can depend on this.
52
53    sources = []
54    asmflags = []
55
56    if (is_linux) {
57      if (current_cpu == "x64") {
58        sources += crypto_sources_linux_x86_64
59      } else if (current_cpu == "x86") {
60        sources += crypto_sources_linux_x86
61      } else {
62        public_configs = [ ":no_asm_config" ]
63      }
64    } else if (is_mac) {
65      if (current_cpu == "x64") {
66        sources += crypto_sources_mac_x86_64
67      } else if (current_cpu == "x86") {
68        sources += crypto_sources_mac_x86
69      } else {
70        public_configs = [ ":no_asm_config" ]
71      }
72    } else {
73      public_configs = [ ":no_asm_config" ]
74    }
75  }
76
77  source_set("boringssl") {
78    sources = all_sources
79    public = all_headers
80    deps = [
81      ":boringssl_asm",
82      "src/third_party/fiat:fiat_license",
83    ]
84
85    public_configs = [ ":external_config" ]
86    configs += [ ":internal_config" ]
87  }
88}
89