|
| 1 | +# Copyright (c) 2013-2022 GitHub Inc. |
| 2 | +# Copyright 2022 the V8 project authors. All rights reserved. |
| 3 | +# Copyright 2023 Microsoft Inc. |
| 4 | +# Use of this source code is governed by a BSD-style license that can be |
| 5 | +# found in the LICENSE file. |
| 6 | + |
| 7 | +# This file is used by GN for building, which is NOT the build system used for |
| 8 | +# building official binaries. |
| 9 | +# Please edit the gyp files if you are making changes to build system. |
| 10 | + |
| 11 | +# The actual configurations are put inside a template in unofficial.gni to |
| 12 | +# prevent accidental edits from contributors. |
| 13 | +template("base64_gn_build") { |
| 14 | + config("base64_external_config") { |
| 15 | + include_dirs = [ "base64/include" ] |
| 16 | + if (!is_component_build) { |
| 17 | + defines = [ "BASE64_STATIC_DEFINE" ] |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + config("base64_internal_config") { |
| 22 | + include_dirs = [ "base64/lib" ] |
| 23 | + if (is_component_build) { |
| 24 | + defines = [ "BASE64_EXPORTS" ] |
| 25 | + } else { |
| 26 | + defines = [] |
| 27 | + } |
| 28 | + if (target_cpu == "x86" || target_cpu == "x64") { |
| 29 | + defines += [ |
| 30 | + "HAVE_SSSE3=1", |
| 31 | + "HAVE_SSE41=1", |
| 32 | + "HAVE_SSE42=1", |
| 33 | + "HAVE_AVX=1", |
| 34 | + "HAVE_AVX2=1", |
| 35 | + ] |
| 36 | + } |
| 37 | + if (target_cpu == "arm") { |
| 38 | + defines += [ "HAVE_NEON32=1" ] |
| 39 | + } |
| 40 | + if (target_cpu == "arm64") { |
| 41 | + defines += [ "HAVE_NEON64=1" ] |
| 42 | + } |
| 43 | + if (is_clang || !is_win) { |
| 44 | + cflags_c = [ |
| 45 | + "-Wno-implicit-fallthrough", |
| 46 | + "-Wno-shadow", |
| 47 | + "-Wno-unused-but-set-variable", |
| 48 | + ] |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + gypi_values = exec_script("../../tools/gypi_to_gn.py", |
| 53 | + [ rebase_path("base64.gyp") ], |
| 54 | + "scope", |
| 55 | + [ "base64.gyp" ]) |
| 56 | + |
| 57 | + component(target_name) { |
| 58 | + forward_variables_from(invoker, "*") |
| 59 | + configs += [ ":base64_internal_config" ] |
| 60 | + public_configs = [ ":base64_external_config" ] |
| 61 | + sources = gypi_values.base64_sources_common |
| 62 | + deps = [ |
| 63 | + ":base64_ssse3", |
| 64 | + ":base64_sse41", |
| 65 | + ":base64_sse42", |
| 66 | + ":base64_avx", |
| 67 | + ":base64_avx2", |
| 68 | + ":base64_neon32", |
| 69 | + ":base64_neon64", |
| 70 | + ] |
| 71 | + } |
| 72 | + |
| 73 | + source_set("base64_ssse3") { |
| 74 | + configs += [ ":base64_internal_config" ] |
| 75 | + sources = [ "base64/lib/arch/ssse3/codec.c" ] |
| 76 | + if (target_cpu == "x86" || target_cpu == "x64") { |
| 77 | + if (is_clang || !is_win) { |
| 78 | + cflags_c = [ "-mssse3" ] |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + source_set("base64_sse41") { |
| 84 | + configs += [ ":base64_internal_config" ] |
| 85 | + sources = [ "base64/lib/arch/sse41/codec.c" ] |
| 86 | + if (target_cpu == "x86" || target_cpu == "x64") { |
| 87 | + if (is_clang || !is_win) { |
| 88 | + cflags_c = [ "-msse4.1" ] |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + source_set("base64_sse42") { |
| 94 | + configs += [ ":base64_internal_config" ] |
| 95 | + sources = [ "base64/lib/arch/sse42/codec.c" ] |
| 96 | + if (target_cpu == "x86" || target_cpu == "x64") { |
| 97 | + if (is_clang || !is_win) { |
| 98 | + cflags_c = [ "-msse4.2" ] |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + source_set("base64_avx") { |
| 104 | + configs += [ ":base64_internal_config" ] |
| 105 | + sources = [ "base64/lib/arch/avx/codec.c" ] |
| 106 | + if (target_cpu == "x86" || target_cpu == "x64") { |
| 107 | + if (is_clang || !is_win) { |
| 108 | + cflags_c = [ "-mavx" ] |
| 109 | + } else if (is_win) { |
| 110 | + cflags_c = [ "/arch:AVX" ] |
| 111 | + } |
| 112 | + } |
| 113 | + } |
| 114 | + source_set("base64_avx2") { |
| 115 | + configs += [ ":base64_internal_config" ] |
| 116 | + sources = [ "base64/lib/arch/avx2/codec.c" ] |
| 117 | + if (target_cpu == "x86" || target_cpu == "x64") { |
| 118 | + if (is_clang || !is_win) { |
| 119 | + cflags_c = [ "-mavx2" ] |
| 120 | + } else if (is_win) { |
| 121 | + cflags_c = [ "/arch:AVX2" ] |
| 122 | + } |
| 123 | + } |
| 124 | + } |
| 125 | + |
| 126 | + source_set("base64_neon32") { |
| 127 | + configs += [ ":base64_internal_config" ] |
| 128 | + sources = [ "base64/lib/arch/neon32/codec.c" ] |
| 129 | + if (target_cpu == "arm") { |
| 130 | + if (is_clang || !is_win) { |
| 131 | + cflags_c = [ "-mfpu=neon" ] |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + |
| 136 | + source_set("base64_neon64") { |
| 137 | + configs += [ ":base64_internal_config" ] |
| 138 | + sources = [ "base64/lib/arch/neon64/codec.c" ] |
| 139 | + # NEON is required in arm64, so no -mfpu flag is needed |
| 140 | + } |
| 141 | +} |
0 commit comments