Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 1 | # Copyright 2018 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import("//build/config/compiler/compiler.gni") |
| 6 | import("nasm_sources.gni") |
| 7 | |
David Benjamin | f564874 | 2019-06-19 17:59:05 -0400 | [diff] [blame] | 8 | configs_to_delete = [ "//build/config/compiler:chromium_code" ] |
Takuto Ikuta | ae8e4ca | 2019-02-19 13:59:42 +0900 | [diff] [blame] | 9 | configs_to_add = [ "//build/config/compiler:no_chromium_code" ] |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 10 | if (is_debug) { |
| 11 | configs_to_delete += [ |
| 12 | # Build with full optimizations even on debug configurations, because some |
| 13 | # yasm build steps (highbd_sad4d_sse2.asm) can take ~33 seconds or more in |
| 14 | # debug component builds on Windows. Enabling compiler optimizations saves |
| 15 | # ~5 seconds. |
| 16 | "//build/config/compiler:default_optimization", |
| 17 | |
| 18 | # Don't define _DEBUG. Modest savings, but good for consistency. |
| 19 | "//build/config:debug", |
Dale Curtis | 946b404 | 2020-04-13 12:32:03 -0700 | [diff] [blame] | 20 | |
| 21 | # Don't enable sanitizers for build tools. They slow down the overall build. |
| 22 | "//build/config/sanitizers:default_sanitizer_flags", |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 23 | ] |
| 24 | |
| 25 | configs_to_add += [ |
| 26 | "//build/config:release", |
| 27 | "//build/config/compiler:optimize_max", |
| 28 | ] |
| 29 | if (is_win) { |
| 30 | # This switches to using the release CRT. For yasm debug component builds |
| 31 | # of highbd_sad4d_sse2.asm on Windows this saved about 15 s. |
| 32 | configs_to_delete += [ "//build/config/win:default_crt" ] |
| 33 | configs_to_add += [ "//build/config/win:release_crt" ] |
Tom Anderson | 076332e | 2019-03-13 15:11:03 -0700 | [diff] [blame] | 34 | |
| 35 | # Without no_default_deps, an implicit dependency on libc++ is added. |
| 36 | # libc++ may have been built referencing the debug CRT, but since we're |
| 37 | # explicitly using the release CRT, this would result in undefined symbol |
| 38 | # errors when linking, so we need to remove the implicit libc++ dependency. |
| 39 | no_default_deps = true |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 40 | } |
| 41 | } |
| 42 | |
| 43 | config("nasm_config") { |
| 44 | include_dirs = [ |
| 45 | ".", |
| 46 | "asm", |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 47 | "disasm", |
| 48 | "include", |
| 49 | "output", |
| 50 | "x86", |
| 51 | ] |
| 52 | |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 53 | defines = [ "HAVE_CONFIG_H" ] |
| 54 | |
| 55 | if (is_clang) { |
| 56 | cflags = [ |
| 57 | # The inline functions in NASM's headers flag this. |
| 58 | "-Wno-unused-function", |
| 59 | |
| 60 | # NASM writes nasm_assert(!"some string literal"). |
| 61 | "-Wno-string-conversion", |
| 62 | |
| 63 | # NASM sometimes redefines macros from its config.h. |
| 64 | "-Wno-macro-redefined", |
Dale Curtis | 20920a8 | 2018-11-01 17:26:45 -0700 | [diff] [blame] | 65 | |
| 66 | # NASM sometimes compares enums to unsigned integers. |
| 67 | "-Wno-sign-compare", |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 68 | ] |
Yves Gerey | e701d16 | 2018-11-09 18:44:47 +0100 | [diff] [blame] | 69 | } else if (is_win) { |
| 70 | # Please note that's a slightly different set of warnings. |
| 71 | cflags = [ |
| 72 | # NASM sometimes redefines macros from its config.h. |
| 73 | "/wd4005", # macro redefinition |
| 74 | |
| 75 | # NASM sometimes compares enums to unsigned integers. |
| 76 | "/wd4018", # sign compare |
| 77 | |
Yves Gerey | a0a6951 | 2018-11-09 19:35:11 +0100 | [diff] [blame] | 78 | # char VS const char mismatch. |
| 79 | "/wd4028", # formal parameter 1 different from declaration. |
| 80 | |
Yves Gerey | e701d16 | 2018-11-09 18:44:47 +0100 | [diff] [blame] | 81 | # NASM comment: Uninitialized -> all zero by C spec |
| 82 | # Or sometimes one const struct is forward declared for no reason. |
| 83 | "/wd4132", # const object should be initialized |
| 84 | |
| 85 | # NASM uses "(-x) & 0xFF" pattern to negate byte. |
| 86 | "/wd4146", # unary minus operator applied to unsigned type |
| 87 | ] |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 88 | } |
| 89 | } |
| 90 | |
| 91 | if (current_toolchain == host_toolchain) { |
| 92 | executable("nasm") { |
| 93 | sources = nasmlib_sources + nasm_sources |
Dale Curtis | 3dacc5e | 2018-11-01 10:48:41 -0700 | [diff] [blame] | 94 | sources += [ |
Dale Curtis | 3dacc5e | 2018-11-01 10:48:41 -0700 | [diff] [blame] | 95 | "config/config-linux.h", |
Takuto Ikuta | ae8e4ca | 2019-02-19 13:59:42 +0900 | [diff] [blame] | 96 | "config/config-mac.h", |
| 97 | "config/config.h", |
Takuto Ikuta | 313e2e8 | 2019-02-13 13:52:41 +0900 | [diff] [blame] | 98 | "config/msvc.h", |
Dale Curtis | 3dacc5e | 2018-11-01 10:48:41 -0700 | [diff] [blame] | 99 | ] |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 100 | |
| 101 | configs -= configs_to_delete |
| 102 | configs += configs_to_add |
| 103 | configs += [ ":nasm_config" ] |
| 104 | |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 105 | deps = [ |
| 106 | # Default manifest on Windows (a no-op elsewhere). |
| 107 | "//build/win:default_exe_manifest", |
| 108 | ] |
| 109 | } |
| 110 | } |