blob: 152f0a761e628b371abe10a51931214f4ec6f1d9 [file] [log] [blame]
Dale Curtis9596cc02018-10-31 14:25:55 -07001# 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
5import("//build/config/compiler/compiler.gni")
6import("nasm_sources.gni")
7
Dale Curtisc74336e2020-04-13 15:37:55 -07008configs_to_delete = [
9 "//build/config/compiler:chromium_code",
10
11 # Don't enable sanitizers for build tools. They slow down the overall build.
12 "//build/config/sanitizers:default_sanitizer_flags",
13]
14
Takuto Ikutaae8e4ca2019-02-19 13:59:42 +090015configs_to_add = [ "//build/config/compiler:no_chromium_code" ]
Dale Curtis9596cc02018-10-31 14:25:55 -070016if (is_debug) {
17 configs_to_delete += [
18 # Build with full optimizations even on debug configurations, because some
19 # yasm build steps (highbd_sad4d_sse2.asm) can take ~33 seconds or more in
20 # debug component builds on Windows. Enabling compiler optimizations saves
21 # ~5 seconds.
22 "//build/config/compiler:default_optimization",
23
24 # Don't define _DEBUG. Modest savings, but good for consistency.
25 "//build/config:debug",
26 ]
27
28 configs_to_add += [
29 "//build/config:release",
30 "//build/config/compiler:optimize_max",
31 ]
32 if (is_win) {
33 # This switches to using the release CRT. For yasm debug component builds
34 # of highbd_sad4d_sse2.asm on Windows this saved about 15 s.
35 configs_to_delete += [ "//build/config/win:default_crt" ]
36 configs_to_add += [ "//build/config/win:release_crt" ]
Tom Anderson076332e2019-03-13 15:11:03 -070037
38 # Without no_default_deps, an implicit dependency on libc++ is added.
39 # libc++ may have been built referencing the debug CRT, but since we're
40 # explicitly using the release CRT, this would result in undefined symbol
41 # errors when linking, so we need to remove the implicit libc++ dependency.
42 no_default_deps = true
Dale Curtis9596cc02018-10-31 14:25:55 -070043 }
44}
45
46config("nasm_config") {
47 include_dirs = [
48 ".",
49 "asm",
Dale Curtis9596cc02018-10-31 14:25:55 -070050 "disasm",
51 "include",
52 "output",
53 "x86",
54 ]
55
Dale Curtis9596cc02018-10-31 14:25:55 -070056 defines = [ "HAVE_CONFIG_H" ]
57
58 if (is_clang) {
59 cflags = [
60 # The inline functions in NASM's headers flag this.
61 "-Wno-unused-function",
62
63 # NASM writes nasm_assert(!"some string literal").
64 "-Wno-string-conversion",
65
66 # NASM sometimes redefines macros from its config.h.
67 "-Wno-macro-redefined",
Dale Curtis20920a82018-11-01 17:26:45 -070068
69 # NASM sometimes compares enums to unsigned integers.
70 "-Wno-sign-compare",
Dale Curtis9596cc02018-10-31 14:25:55 -070071 ]
Yves Gereye701d162018-11-09 18:44:47 +010072 } else if (is_win) {
73 # Please note that's a slightly different set of warnings.
74 cflags = [
75 # NASM sometimes redefines macros from its config.h.
76 "/wd4005", # macro redefinition
77
78 # NASM sometimes compares enums to unsigned integers.
79 "/wd4018", # sign compare
80
Yves Gereya0a69512018-11-09 19:35:11 +010081 # char VS const char mismatch.
82 "/wd4028", # formal parameter 1 different from declaration.
83
Yves Gereye701d162018-11-09 18:44:47 +010084 # NASM comment: Uninitialized -> all zero by C spec
85 # Or sometimes one const struct is forward declared for no reason.
86 "/wd4132", # const object should be initialized
87
88 # NASM uses "(-x) & 0xFF" pattern to negate byte.
89 "/wd4146", # unary minus operator applied to unsigned type
90 ]
Dale Curtis9596cc02018-10-31 14:25:55 -070091 }
92}
93
94if (current_toolchain == host_toolchain) {
95 executable("nasm") {
96 sources = nasmlib_sources + nasm_sources
Dale Curtis3dacc5e2018-11-01 10:48:41 -070097 sources += [
Dale Curtis3dacc5e2018-11-01 10:48:41 -070098 "config/config-linux.h",
Takuto Ikutaae8e4ca2019-02-19 13:59:42 +090099 "config/config-mac.h",
100 "config/config.h",
Takuto Ikuta313e2e82019-02-13 13:52:41 +0900101 "config/msvc.h",
Dale Curtis3dacc5e2018-11-01 10:48:41 -0700102 ]
Dale Curtis9596cc02018-10-31 14:25:55 -0700103
104 configs -= configs_to_delete
105 configs += configs_to_add
106 configs += [ ":nasm_config" ]
107
Dale Curtis9596cc02018-10-31 14:25:55 -0700108 deps = [
109 # Default manifest on Windows (a no-op elsewhere).
110 "//build/win:default_exe_manifest",
111 ]
112 }
113}