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 | |
| 8 | configs_to_delete = [ |
| 9 | # Don't enable sanitizers for build tools. They slow down the overall build. |
| 10 | "//build/config/sanitizers:default_sanitizer_flags", |
| 11 | ] |
| 12 | |
| 13 | configs_to_add = [] |
| 14 | if (is_debug) { |
| 15 | configs_to_delete += [ |
| 16 | # Build with full optimizations even on debug configurations, because some |
| 17 | # yasm build steps (highbd_sad4d_sse2.asm) can take ~33 seconds or more in |
| 18 | # debug component builds on Windows. Enabling compiler optimizations saves |
| 19 | # ~5 seconds. |
| 20 | "//build/config/compiler:default_optimization", |
| 21 | |
| 22 | # Don't define _DEBUG. Modest savings, but good for consistency. |
| 23 | "//build/config:debug", |
| 24 | ] |
| 25 | |
| 26 | configs_to_add += [ |
| 27 | "//build/config:release", |
| 28 | "//build/config/compiler:optimize_max", |
| 29 | ] |
| 30 | if (is_win) { |
| 31 | # This switches to using the release CRT. For yasm debug component builds |
| 32 | # of highbd_sad4d_sse2.asm on Windows this saved about 15 s. |
| 33 | configs_to_delete += [ "//build/config/win:default_crt" ] |
| 34 | configs_to_add += [ "//build/config/win:release_crt" ] |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | config("nasm_config") { |
| 39 | include_dirs = [ |
| 40 | ".", |
| 41 | "asm", |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 42 | "disasm", |
| 43 | "include", |
| 44 | "output", |
| 45 | "x86", |
| 46 | ] |
| 47 | |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 48 | defines = [ "HAVE_CONFIG_H" ] |
| 49 | |
| 50 | if (is_clang) { |
| 51 | cflags = [ |
| 52 | # The inline functions in NASM's headers flag this. |
| 53 | "-Wno-unused-function", |
| 54 | |
| 55 | # NASM writes nasm_assert(!"some string literal"). |
| 56 | "-Wno-string-conversion", |
| 57 | |
| 58 | # NASM sometimes redefines macros from its config.h. |
| 59 | "-Wno-macro-redefined", |
Dale Curtis | 20920a8 | 2018-11-01 17:26:45 -0700 | [diff] [blame^] | 60 | |
| 61 | # NASM sometimes compares enums to unsigned integers. |
| 62 | "-Wno-sign-compare", |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 63 | ] |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | if (current_toolchain == host_toolchain) { |
| 68 | executable("nasm") { |
| 69 | sources = nasmlib_sources + nasm_sources |
Dale Curtis | 3dacc5e | 2018-11-01 10:48:41 -0700 | [diff] [blame] | 70 | sources += [ |
| 71 | "config/config.h", |
| 72 | "config/config-mac.h", |
| 73 | "config/config-linux.h", |
| 74 | "config/config-win.h", |
| 75 | ] |
Dale Curtis | 9596cc0 | 2018-10-31 14:25:55 -0700 | [diff] [blame] | 76 | |
| 77 | configs -= configs_to_delete |
| 78 | configs += configs_to_add |
| 79 | configs += [ ":nasm_config" ] |
| 80 | |
| 81 | deps = [ |
| 82 | # Default manifest on Windows (a no-op elsewhere). |
| 83 | "//build/win:default_exe_manifest", |
| 84 | ] |
| 85 | } |
| 86 | } |