aboutsummaryrefslogtreecommitdiff
path: root/third_party/boringssl/BUILD.gn
blob: 85cef78d9e7b14ee7927f959c58d976b856924b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Copyright 2021 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

import("//build_overrides/pigweed.gni")
import("$dir_pw_build/target_types.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_third_party/boringssl/boringssl.gni")
import("$dir_pw_unit_test/test.gni")

if (pw_third_party_boringssl_ALIAS != "") {
  assert(dir_pw_third_party_boringssl == "")

  pw_source_set("boringssl") {
    public_deps = [ pw_third_party_boringssl_ALIAS ]
  }
} else if (dir_pw_third_party_boringssl != "") {
  import("$dir_pw_third_party_boringssl/BUILD.generated.gni")

  config("public_config") {
    include_dirs = [
      "$dir_pw_third_party_boringssl/src/include",
      "public",
    ]

    # This can be removed once boringssl threading primitives are implemented,
    # i.e. using pw_sync, and when we have a posix style socket layer.
    defines =
        [ "OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED" ]
  }

  config("internal_config") {
    defines = [
      # Enable virtual desctructor and compile-time check of pure virtual base class
      "BORINGSSL_ALLOW_CXX_RUNTIME",

      # Code size optimiaztion
      "OPENSSL_SMALL",

      # The ARM assembly code is only for cortex-A.
      "OPENSSL_NO_ASM",

      # Disable assert, which may additionally link in unwanted binaries via
      # argument evaluation.
      "NDEBUG",
    ]
    cflags = [
      "-Wno-unused-function",
      "-Wno-conversion",
      "-Wno-unused-parameter",
      "-Wno-char-subscripts",
      "-w",
    ]
    cflags_cc = [
      "-fpermissive",
      "-Wno-error",  # To get through the -Werror=permissive error
    ]
    include_dirs = [ "$dir_pw_third_party_boringssl" ]
  }

  # Remove sources that require file system and posix socket support
  excluded_sources = [
    "src/crypto/bio/connect.c",
    "src/crypto/bio/fd.c",
    "src/crypto/bio/socket.c",
    "src/crypto/bio/socket_helper.c",
  ]

  pw_source_set("boringssl") {
    sources = []
    foreach(source, crypto_sources - excluded_sources + ssl_sources) {
      sources += [ "$dir_pw_third_party_boringssl/$source" ]
    }
    public_configs = [ ":public_config" ]
    configs = [ ":internal_config" ]

    # Contains a faked "sysdeps/sys/socket.h"
    # Can be removed once posix socket layer in Pigweed is supported.
    include_dirs = [ "sysdeps" ]

    public_deps = [
      "$dir_pw_assert",
      "$dir_pw_tls_client:time",
    ]

    # Consume //third_party/boringssl via a Pigweed module only.
    visibility = [
      "$dir_pw_tls_client:*",
      "$dir_pw_tls_client_boringssl:*",
    ]
  }
} else {
  group("boringssl") {
  }
}

pw_doc_group("docs") {
  sources = [ "docs.rst" ]
}