# 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", # socklen_t is not defined "OPENSSL_NO_SOCK", # 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", "-Wno-cast-qual", "-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_bluetooth_sapphire/*", "$dir_pw_tls_client:*", "$dir_pw_tls_client_boringssl:*", ] } pw_test_group("tests") { tests = [ ":build_test" ] } pw_test("build_test") { sources = [ "build_test.cc" ] deps = [ ":boringssl" ] } } else { group("boringssl") { } } pw_doc_group("docs") { sources = [ "docs.rst" ] }