blob: dd52d884b846a85b9f0c537a3afd7c9292b67ff2 [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
David Benjaminf5648742019-06-19 17:59:05 -04008configs_to_delete = [ "//build/config/compiler:chromium_code" ]
Takuto Ikutaae8e4ca2019-02-19 13:59:42 +09009configs_to_add = [ "//build/config/compiler:no_chromium_code" ]
Dale Curtis9596cc02018-10-31 14:25:55 -070010if (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",
20 ]
21
22 configs_to_add += [
23 "//build/config:release",
24 "//build/config/compiler:optimize_max",
25 ]
26 if (is_win) {
27 # This switches to using the release CRT. For yasm debug component builds
28 # of highbd_sad4d_sse2.asm on Windows this saved about 15 s.
29 configs_to_delete += [ "//build/config/win:default_crt" ]
30 configs_to_add += [ "//build/config/win:release_crt" ]
Tom Anderson076332e2019-03-13 15:11:03 -070031
32 # Without no_default_deps, an implicit dependency on libc++ is added.
33 # libc++ may have been built referencing the debug CRT, but since we're
34 # explicitly using the release CRT, this would result in undefined symbol
35 # errors when linking, so we need to remove the implicit libc++ dependency.
36 no_default_deps = true
Dale Curtis9596cc02018-10-31 14:25:55 -070037 }
38}
39
40config("nasm_config") {
41 include_dirs = [
42 ".",
43 "asm",
Dale Curtis9596cc02018-10-31 14:25:55 -070044 "disasm",
45 "include",
46 "output",
47 "x86",
48 ]
49
Dale Curtis9596cc02018-10-31 14:25:55 -070050 defines = [ "HAVE_CONFIG_H" ]
51
52 if (is_clang) {
53 cflags = [
54 # The inline functions in NASM's headers flag this.
55 "-Wno-unused-function",
56
57 # NASM writes nasm_assert(!"some string literal").
58 "-Wno-string-conversion",
59
60 # NASM sometimes redefines macros from its config.h.
61 "-Wno-macro-redefined",
Dale Curtis20920a82018-11-01 17:26:45 -070062
63 # NASM sometimes compares enums to unsigned integers.
64 "-Wno-sign-compare",
Dale Curtis9596cc02018-10-31 14:25:55 -070065 ]
Yves Gereye701d162018-11-09 18:44:47 +010066 } else if (is_win) {
67 # Please note that's a slightly different set of warnings.
68 cflags = [
69 # NASM sometimes redefines macros from its config.h.
70 "/wd4005", # macro redefinition
71
72 # NASM sometimes compares enums to unsigned integers.
73 "/wd4018", # sign compare
74
Yves Gereya0a69512018-11-09 19:35:11 +010075 # char VS const char mismatch.
76 "/wd4028", # formal parameter 1 different from declaration.
77
Yves Gereye701d162018-11-09 18:44:47 +010078 # NASM comment: Uninitialized -> all zero by C spec
79 # Or sometimes one const struct is forward declared for no reason.
80 "/wd4132", # const object should be initialized
81
82 # NASM uses "(-x) & 0xFF" pattern to negate byte.
83 "/wd4146", # unary minus operator applied to unsigned type
84 ]
Dale Curtis9596cc02018-10-31 14:25:55 -070085 }
86}
87
88if (current_toolchain == host_toolchain) {
89 executable("nasm") {
90 sources = nasmlib_sources + nasm_sources
Dale Curtis3dacc5e2018-11-01 10:48:41 -070091 sources += [
Dale Curtis3dacc5e2018-11-01 10:48:41 -070092 "config/config-linux.h",
Takuto Ikutaae8e4ca2019-02-19 13:59:42 +090093 "config/config-mac.h",
94 "config/config.h",
Takuto Ikuta313e2e82019-02-13 13:52:41 +090095 "config/msvc.h",
Dale Curtis3dacc5e2018-11-01 10:48:41 -070096 ]
Dale Curtis9596cc02018-10-31 14:25:55 -070097
98 configs -= configs_to_delete
99 configs += configs_to_add
100 configs += [ ":nasm_config" ]
101
Dale Curtis9596cc02018-10-31 14:25:55 -0700102 deps = [
103 # Default manifest on Windows (a no-op elsewhere).
104 "//build/win:default_exe_manifest",
105 ]
106 }
107}