1# Copyright 2021 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15import("//build_overrides/pigweed.gni") 16import("$dir_pw_build/target_types.gni") 17import("$dir_pw_docgen/docs.gni") 18import("$dir_pw_third_party/boringssl/boringssl.gni") 19import("$dir_pw_unit_test/test.gni") 20 21if (pw_third_party_boringssl_ALIAS != "") { 22 assert(dir_pw_third_party_boringssl == "") 23 24 pw_source_set("boringssl") { 25 public_deps = [ pw_third_party_boringssl_ALIAS ] 26 } 27} else if (dir_pw_third_party_boringssl != "") { 28 import("$dir_pw_third_party_boringssl/BUILD.generated.gni") 29 30 config("public_config") { 31 include_dirs = [ 32 "$dir_pw_third_party_boringssl/src/include", 33 "public", 34 ] 35 36 # This can be removed once boringssl threading primitives are implemented, 37 # i.e. using pw_sync, and when we have a posix style socket layer. 38 defines = 39 [ "OPENSSL_NO_THREADS_CORRUPT_MEMORY_AND_LEAK_SECRETS_IF_THREADED" ] 40 } 41 42 config("internal_config") { 43 defines = [ 44 # Enable virtual desctructor and compile-time check of pure virtual base class 45 "BORINGSSL_ALLOW_CXX_RUNTIME", 46 47 # Code size optimiaztion 48 "OPENSSL_SMALL", 49 50 # The ARM assembly code is only for cortex-A. 51 "OPENSSL_NO_ASM", 52 53 # Disable assert, which may additionally link in unwanted binaries via 54 # argument evaluation. 55 "NDEBUG", 56 ] 57 cflags = [ 58 "-Wno-unused-function", 59 "-Wno-conversion", 60 "-Wno-unused-parameter", 61 "-Wno-char-subscripts", 62 "-w", 63 ] 64 cflags_cc = [ 65 "-fpermissive", 66 "-Wno-error", # To get through the -Werror=permissive error 67 ] 68 include_dirs = [ "$dir_pw_third_party_boringssl" ] 69 } 70 71 # Remove sources that require file system and posix socket support 72 excluded_sources = [ 73 "src/crypto/bio/connect.c", 74 "src/crypto/bio/fd.c", 75 "src/crypto/bio/socket.c", 76 "src/crypto/bio/socket_helper.c", 77 ] 78 79 pw_source_set("boringssl") { 80 sources = [ "crypto_sysrand.cc" ] 81 foreach(source, crypto_sources - excluded_sources + ssl_sources) { 82 sources += [ "$dir_pw_third_party_boringssl/$source" ] 83 } 84 public_configs = [ ":public_config" ] 85 configs = [ ":internal_config" ] 86 87 # Contains a faked "sysdeps/sys/socket.h" 88 # Can be removed once posix socket layer in Pigweed is supported. 89 include_dirs = [ "sysdeps" ] 90 91 public_deps = [ "$dir_pw_tls_client:time" ] 92 } 93} else { 94 group("boringssl") { 95 } 96} 97 98pw_doc_group("docs") { 99 sources = [ "docs.rst" ] 100} 101