| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
| 6 import("//build/config/sanitizers/sanitizers.gni") | 6 import("//build/config/sanitizers/sanitizers.gni") |
| 7 import("BUILD.generated.gni") |
| 7 | 8 |
| 8 # Config for us and everybody else depending on BoringSSL. | 9 # Config for us and everybody else depending on BoringSSL. |
| 9 config("external_config") { | 10 config("external_config") { |
| 10 include_dirs = [ "src/include" ] | 11 include_dirs = [ "src/include" ] |
| 11 if (is_component_build) { | 12 if (is_component_build) { |
| 12 defines = [ "BORINGSSL_SHARED_LIBRARY" ] | 13 defines = [ "BORINGSSL_SHARED_LIBRARY" ] |
| 13 } | 14 } |
| 14 } | 15 } |
| 15 | 16 |
| 16 | |
| 17 # Config internal to this build file, shared by boringssl and boringssl_fuzzer. | 17 # Config internal to this build file, shared by boringssl and boringssl_fuzzer. |
| 18 config("internal_config") { | 18 config("internal_config") { |
| 19 visibility = [ ":*" ] # Only targets in this file can depend on this. | 19 visibility = [ ":*" ] # Only targets in this file can depend on this. |
| 20 defines = [ | 20 defines = [ |
| 21 "BORINGSSL_IMPLEMENTATION", | 21 "BORINGSSL_IMPLEMENTATION", |
| 22 "BORINGSSL_NO_STATIC_INITIALIZER", | 22 "BORINGSSL_NO_STATIC_INITIALIZER", |
| 23 "OPENSSL_SMALL_FOOTPRINT", | 23 "OPENSSL_SMALL", |
| 24 ] | 24 ] |
| 25 # configs = [ |
| 26 # # TODO(davidben): Fix size_t truncations in BoringSSL. |
| 27 # # https://crbug.com/429039 |
| 28 # "//build/config/compiler:no_size_t_to_int_warning", |
| 29 # ] |
| 30 if (is_posix) { |
| 31 cflags_c = [ "-std=c99" ] |
| 32 defines += [ "_XOPEN_SOURCE=700" ] |
| 33 } |
| 25 } | 34 } |
| 26 | 35 |
| 27 | |
| 28 config("no_asm_config") { | 36 config("no_asm_config") { |
| 29 visibility = [ ":*" ] # Only targets in this file can depend on this. | 37 visibility = [ ":*" ] # Only targets in this file can depend on this. |
| 30 defines = [ "OPENSSL_NO_ASM" ] | 38 defines = [ "OPENSSL_NO_ASM" ] |
| 31 } | 39 } |
| 32 | 40 |
| 41 all_sources = crypto_sources + ssl_sources |
| 33 | 42 |
| 34 # The list of BoringSSL files is kept in boringssl.gypi. | 43 # Windows' assembly is built with Yasm. The other platforms use the platform |
| 35 gypi_values = | 44 # assembler. |
| 36 exec_script("../../tools/gypi_to_gn.py", | 45 if (is_win && !is_msan) { |
| 37 [ rebase_path("boringssl.gypi") ], | 46 import("//third_party/yasm/yasm_assemble.gni") |
| 38 "scope", | 47 yasm_assemble("boringssl_asm") { |
| 39 [ "boringssl.gypi" ]) | 48 if (current_cpu == "x64") { |
| 40 boringssl_sources = | 49 sources = crypto_sources_win_x86_64 |
| 41 gypi_values.boringssl_crypto_sources + gypi_values.boringssl_ssl_sources | 50 } else if (current_cpu == "x86") { |
| 51 sources = crypto_sources_win_x86 |
| 52 } |
| 53 } |
| 54 } else { |
| 55 # This has no sources on some platforms so must be a source_set. |
| 56 source_set("boringssl_asm") { |
| 57 visibility = [ ":*" ] # Only targets in this file can depend on this. |
| 42 | 58 |
| 59 defines = [] |
| 60 sources = [] |
| 61 include_dirs = [ "src/include" ] |
| 43 | 62 |
| 44 source_set("boringssl_asm") { | 63 if ((current_cpu == "arm" || current_cpu == "arm64") && is_clang) { |
| 45 visibility = [ ":*" ] # Only targets in this file can depend on this. | 64 if (current_cpu == "arm") { |
| 46 sources = [] | 65 # TODO(hans) Enable integrated-as (crbug.com/124610). |
| 47 #asmflags = [] | 66 asmflags += [ "-fno-integrated-as" ] |
| 48 include_dirs = [ | 67 } |
| 49 "src/include", | 68 if (is_android) { |
| 50 # This is for arm_arch.h, which is needed by some asm files. Since the | 69 rebased_android_toolchain_root = |
| 51 # asm files are generated and kept in a different directory, they | 70 rebase_path(android_toolchain_root, root_build_dir) |
| 52 # cannot use relative paths to find this file. | |
| 53 "src/crypto", | |
| 54 ] | |
| 55 | 71 |
| 56 if (current_cpu == "x64") { | 72 # Else /usr/bin/as gets picked up. |
| 57 if (is_ios) { | 73 asmflags += [ "-B${rebased_android_toolchain_root}/bin" ] |
| 58 defines += [ "OPENSSL_NO_ASM" ] | 74 } |
| 59 } else if (is_mac) { | 75 } |
| 60 sources += gypi_values.boringssl_mac_x86_64_sources | 76 |
| 61 } else if (is_linux || is_android) { | 77 if (is_msan) { |
| 62 sources += gypi_values.boringssl_linux_x86_64_sources | 78 public_configs = [ ":no_asm_config" ] |
| 79 } else if (current_cpu == "x64") { |
| 80 if (is_mac) { |
| 81 sources += crypto_sources_mac_x86_64 |
| 82 } else if (is_linux || is_android) { |
| 83 sources += crypto_sources_linux_x86_64 |
| 84 } else { |
| 85 public_configs = [ ":no_asm_config" ] |
| 86 } |
| 87 } else if (current_cpu == "x86") { |
| 88 if (is_mac) { |
| 89 sources += crypto_sources_mac_x86 |
| 90 } else if (is_linux || is_android) { |
| 91 sources += crypto_sources_linux_x86 |
| 92 } else { |
| 93 public_configs = [ ":no_asm_config" ] |
| 94 } |
| 95 } else if (current_cpu == "arm" && (is_linux || is_android)) { |
| 96 sources += crypto_sources_linux_arm |
| 97 } else if (current_cpu == "arm64" && (is_linux || is_android)) { |
| 98 sources += crypto_sources_linux_aarch64 |
| 99 |
| 100 # TODO(davidben): Remove explicit arch flag once https://crbug.com/576858 |
| 101 # is fixed. |
| 102 asmflags += [ "-march=armv8-a+crypto" ] |
| 63 } else { | 103 } else { |
| 64 public_configs = [ ":no_asm_config" ] | 104 public_configs = [ ":no_asm_config" ] |
| 65 } | 105 } |
| 66 } else if (current_cpu == "x86") { | |
| 67 if (is_ios) { | |
| 68 defines += [ "OPENSSL_NO_ASM" ] | |
| 69 } else if (is_mac) { | |
| 70 sources += gypi_values.boringssl_mac_x86_sources | |
| 71 } else if (is_linux || is_android) { | |
| 72 sources += gypi_values.boringssl_linux_x86_sources | |
| 73 } else { | |
| 74 public_configs = [ ":no_asm_config" ] | |
| 75 } | |
| 76 } else if (current_cpu == "arm" && (is_linux || is_android)) { | |
| 77 sources += gypi_values.boringssl_linux_arm_sources | |
| 78 } else if (current_cpu == "arm64" && (is_linux || is_android)) { | |
| 79 sources += gypi_values.boringssl_linux_aarch64_sources | |
| 80 } else { | |
| 81 public_configs = [ ":no_asm_config" ] | |
| 82 } | 106 } |
| 83 } | 107 } |
| 84 | 108 |
| 85 | |
| 86 component("boringssl") { | 109 component("boringssl") { |
| 87 sources = boringssl_sources | 110 sources = all_sources |
| 88 deps = [ | 111 deps = [ |
| 89 ":boringssl_asm", | 112 ":boringssl_asm", |
| 90 ] | 113 ] |
| 114 |
| 91 public_configs = [ ":external_config" ] | 115 public_configs = [ ":external_config" ] |
| 92 configs += [ ":internal_config" ] | 116 configs += [ ":internal_config" ] |
| 117 |
| 93 configs -= [ "//build/config/compiler:chromium_code" ] | 118 configs -= [ "//build/config/compiler:chromium_code" ] |
| 94 configs += [ "//build/config/compiler:no_chromium_code" ] | 119 configs += [ "//build/config/compiler:no_chromium_code" ] |
| 95 } | 120 } |
| OLD | NEW |