summaryrefslogtreecommitdiffstats
path: root/chromium/build/config/win/BUILD.gn
blob: 3fed26abe8cca492da354ea6e3aa509254fef867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/win/visual_studio_version.gni")

# Compiler setup for the Windows SDK. Applied to all targets.
config("sdk") {
  # The include path is the stuff returned by the script.
  #include_dirs = msvc_config[0]  TODO(brettw) make this work.

  defines = [
    "_ATL_NO_OPENGL",
    "_WIN32_WINNT=0x0602",
    "_WINDOWS",
    "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS",
    "NTDDI_VERSION=0x06020000",
    "PSAPI_VERSION=1",
    "WIN32",
    "WINVER=0x0602",
  ]

  # The Windows SDK include directories must be first. They both have a sal.h,
  # and the SDK one is newer and the SDK uses some newer features from it not
  # present in the Visual Studio one.
  include_dirs = [
    "$windows_sdk_path\Include\shared",
    "$windows_sdk_path\Include\um",
    "$windows_sdk_path\Include\winrt",
    "$visual_studio_path\VC\include",
    "$visual_studio_path\VC\atlmfc\include",
  ]

  if (is_visual_studio_express) {
    include_dirs += [
      "$wdk_path/inc/atl71",
      "$wdk_path/inc/mfc42",
    ]

    # https://code.google.com/p/chromium/issues/detail?id=372451#c20
    # Warning 4702 ("Unreachable code") should be re-enabled once Express users
    # are updated to VS2013 Update 2.
    cflags = [ "/wd4702" ]
  } else {
    # Only supported on non-Express versions.
    defines += [ "_SECURE_ATL" ]
  }
}

# Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs.
config("sdk_link") {
  if (cpu_arch == "x64") {
    ldflags = [ "/MACHINE:X64" ]
    lib_dirs = [
      "$windows_sdk_path\Lib\win8\um\x64",
      "$visual_studio_path\VC\lib\amd64",
      "$visual_studio_path\VC\atlmfc\lib\amd64",
    ]
    if (is_visual_studio_express) {
      lib_dirs += [ "$wdk_path/lib/ATL/amd64" ]
    }
  } else {
    ldflags = [
      "/MACHINE:X86",
      "/SAFESEH",  # Not compatible with x64 so use only for x86.
    ]
    lib_dirs = [
      "$windows_sdk_path\Lib\win8\um\x86",
      "$visual_studio_path\VC\lib",
      "$visual_studio_path\VC\atlmfc\lib",
    ]
    if (is_visual_studio_express) {
      lib_dirs += [ "$wdk_path/lib/ATL/i386" ]
    }
    if (!is_asan) {
      ldflags += [ "/largeaddressaware" ]
    }
  }

  if (is_visual_studio_express) {
    # Explicitly required when using the ATL with express.
    libs = [ "atlthunk.lib" ]

    # ATL 8.0 included in WDK 7.1 makes the linker to generate almost eight
    # hundred LNK4254 and LNK4078 warnings:
    #   - warning LNK4254: section 'ATL' (50000040) merged into '.rdata'
    #     (40000040) with different attributes
    #   - warning LNK4078: multiple 'ATL' sections found with different
    #     attributes
    ldflags += [ "/ignore:4254", "/ignore:4078" ]
  }
}

# This default linker setup is provided separately from the SDK setup so
# targets who want different library configurations can remove this and specify
# their own.
config("common_linker_setup") {
  ldflags = [
    "/FIXED:NO",
    "/ignore:4199",
    "/ignore:4221",
    "/NXCOMPAT",
  ]

  # ASLR makes debugging with windbg difficult because Chrome.exe and
  # Chrome.dll share the same base name. As result, windbg will name the
  # Chrome.dll module like chrome_<base address>, where <base address>
  # typically changes with each launch. This in turn means that breakpoints in
  # Chrome.dll don't stick from one launch to the next. For this reason, we
  # turn ASLR off in debug builds.
  if (is_debug) {
    ldflags += [ "/DYNAMICBASE:NO" ]
  } else {
    ldflags += [ "/DYNAMICBASE" ]
  }

  # Delay loaded DLLs.
  ldflags += [
    "/DELAYLOAD:dbghelp.dll",
    "/DELAYLOAD:dwmapi.dll",
    "/DELAYLOAD:shell32.dll",
    "/DELAYLOAD:uxtheme.dll",
  ]
}

# Subsystem --------------------------------------------------------------------

config("console") {
  ldflags = [ "/SUBSYSTEM:CONSOLE" ]
}
config("windowed") {
  ldflags = [ "/SUBSYSTEM:WINDOWS" ]
}

# Incremental linking ----------------------------------------------------------

config("incremental_linking") {
  ldflags = [ "/INCREMENTAL" ]
}
config("no_incremental_linking") {
  ldflags = [ "/INCREMENTAL:NO" ]
}

# Character set ----------------------------------------------------------------

# Not including this config means "ansi" (8-bit system codepage).
config("unicode") {
  defines = [
    "_UNICODE",
    "UNICODE",
  ]
}

# Lean and mean ----------------------------------------------------------------

# Some third party code might not compile with WIN32_LEAN_AND_MEAN so we have
# to have a separate config for it. Remove this config from your target to
# get the "bloaty and accomodating" version of windows.h.
config("lean_and_mean") {
  defines = [
    "WIN32_LEAN_AND_MEAN",
  ]
}

# Nominmax --------------------------------------------------------------------

# Some third party code defines NOMINMAX before including windows.h, which
# then causes warnings when it's been previously defined on the command line.
# For such targets, this config can be removed.

config("nominmax") {
  defines = [
    "NOMINMAX",
  ]
}