blob: c85d2592dc6aa31e0082899eb8f7db9eb95297fd [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
8configs_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
13configs_to_add = []
14if (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
38config("nasm_config") {
39 include_dirs = [
40 ".",
41 "asm",
Dale Curtis9596cc02018-10-31 14:25:55 -070042 "disasm",
43 "include",
44 "output",
45 "x86",
46 ]
47
Dale Curtis9596cc02018-10-31 14:25:55 -070048 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 Curtis20920a82018-11-01 17:26:45 -070060
61 # NASM sometimes compares enums to unsigned integers.
62 "-Wno-sign-compare",
Dale Curtis9596cc02018-10-31 14:25:55 -070063 ]
Yves Gereye701d162018-11-09 18:44:47 +010064 } else if (is_win) {
65 # Please note that's a slightly different set of warnings.
66 cflags = [
67 # NASM sometimes redefines macros from its config.h.
68 "/wd4005", # macro redefinition
69
70 # NASM sometimes compares enums to unsigned integers.
71 "/wd4018", # sign compare
72
73 # NASM comment: Uninitialized -> all zero by C spec
74 # Or sometimes one const struct is forward declared for no reason.
75 "/wd4132", # const object should be initialized
76
77 # NASM uses "(-x) & 0xFF" pattern to negate byte.
78 "/wd4146", # unary minus operator applied to unsigned type
79 ]
Dale Curtis9596cc02018-10-31 14:25:55 -070080 }
81}
82
83if (current_toolchain == host_toolchain) {
84 executable("nasm") {
85 sources = nasmlib_sources + nasm_sources
Dale Curtis3dacc5e2018-11-01 10:48:41 -070086 sources += [
87 "config/config.h",
88 "config/config-mac.h",
89 "config/config-linux.h",
90 "config/config-win.h",
91 ]
Dale Curtis9596cc02018-10-31 14:25:55 -070092
93 configs -= configs_to_delete
94 configs += configs_to_add
95 configs += [ ":nasm_config" ]
96
97 deps = [
98 # Default manifest on Windows (a no-op elsewhere).
99 "//build/win:default_exe_manifest",
100 ]
101 }
102}