1 # Copyright (c) 2013 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/win/visual_studio_version.gni") 6 7 # Compiler setup for the Windows SDK. Applied to all targets. 8 config("sdk") { 9 # The include path is the stuff returned by the script. 10 #include_dirs = msvc_config[0] TODO(brettw) make this work. 11 12 defines = [ 13 "_ATL_NO_OPENGL", 14 "_WIN32_WINNT=0x0602", 15 "_WINDOWS", 16 "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS", 17 "NTDDI_VERSION=0x06020000", 18 "PSAPI_VERSION=1", 19 "WIN32", 20 "WINVER=0x0602", 21 ] 22 23 # The Windows SDK include directories must be first. They both have a sal.h, 24 # and the SDK one is newer and the SDK uses some newer features from it not 25 # present in the Visual Studio one. 26 include_dirs = [ 27 "$windows_sdk_path\Include\shared", 28 "$windows_sdk_path\Include\um", 29 "$windows_sdk_path\Include\winrt", 30 "$visual_studio_path\VC\include", 31 "$visual_studio_path\VC\atlmfc\include", 32 ] 33 34 if (is_visual_studio_express) { 35 include_dirs += [ 36 "$wdk_path/inc/atl71", 37 "$wdk_path/inc/mfc42", 38 ] 39 40 # https://code.google.com/p/chromium/issues/detail?id=372451#c20 41 # Warning 4702 ("Unreachable code") should be re-enabled once Express users 42 # are updated to VS2013 Update 2. 43 cflags = [ "/wd4702" ] 44 } else { 45 # Only supported on non-Express versions. 46 defines += [ "_SECURE_ATL" ] 47 } 48 } 49 50 # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. 51 config("sdk_link") { 52 if (cpu_arch == "x64") { 53 ldflags = [ "/MACHINE:X64" ] 54 lib_dirs = [ 55 "$windows_sdk_path\Lib\win8\um\x64", 56 "$visual_studio_path\VC\lib\amd64", 57 "$visual_studio_path\VC\atlmfc\lib\amd64", 58 ] 59 if (is_visual_studio_express) { 60 lib_dirs += [ "$wdk_path/lib/ATL/amd64" ] 61 } 62 } else { 63 ldflags = [ 64 "/MACHINE:X86", 65 "/SAFESEH", # Not compatible with x64 so use only for x86. 66 ] 67 lib_dirs = [ 68 "$windows_sdk_path\Lib\win8\um\x86", 69 "$visual_studio_path\VC\lib", 70 "$visual_studio_path\VC\atlmfc\lib", 71 ] 72 if (is_visual_studio_express) { 73 lib_dirs += [ "$wdk_path/lib/ATL/i386" ] 74 } 75 if (!is_asan) { 76 ldflags += [ "/largeaddressaware" ] 77 } 78 } 79 80 if (is_visual_studio_express) { 81 # Explicitly required when using the ATL with express. 82 libs = [ "atlthunk.lib" ] 83 84 # ATL 8.0 included in WDK 7.1 makes the linker to generate almost eight 85 # hundred LNK4254 and LNK4078 warnings: 86 # - warning LNK4254: section 'ATL' (50000040) merged into '.rdata' 87 # (40000040) with different attributes 88 # - warning LNK4078: multiple 'ATL' sections found with different 89 # attributes 90 ldflags += [ "/ignore:4254", "/ignore:4078" ] 91 } 92 } 93 94 # This default linker setup is provided separately from the SDK setup so 95 # targets who want different library configurations can remove this and specify 96 # their own. 97 config("common_linker_setup") { 98 ldflags = [ 99 "/FIXED:NO", 100 "/ignore:4199", 101 "/ignore:4221", 102 "/NXCOMPAT", 103 ] 104 105 # ASLR makes debugging with windbg difficult because Chrome.exe and 106 # Chrome.dll share the same base name. As result, windbg will name the 107 # Chrome.dll module like chrome_<base address>, where <base address> 108 # typically changes with each launch. This in turn means that breakpoints in 109 # Chrome.dll don't stick from one launch to the next. For this reason, we 110 # turn ASLR off in debug builds. 111 if (is_debug) { 112 ldflags += [ "/DYNAMICBASE:NO" ] 113 } else { 114 ldflags += [ "/DYNAMICBASE" ] 115 } 116 117 # Delay loaded DLLs. 118 ldflags += [ 119 "/DELAYLOAD:dbghelp.dll", 120 "/DELAYLOAD:dwmapi.dll", 121 "/DELAYLOAD:shell32.dll", 122 "/DELAYLOAD:uxtheme.dll", 123 ] 124 } 125 126 # Subsystem -------------------------------------------------------------------- 127 128 config("console") { 129 ldflags = [ "/SUBSYSTEM:CONSOLE" ] 130 } 131 config("windowed") { 132 ldflags = [ "/SUBSYSTEM:WINDOWS" ] 133 } 134 135 # Incremental linking ---------------------------------------------------------- 136 137 config("incremental_linking") { 138 ldflags = [ "/INCREMENTAL" ] 139 } 140 config("no_incremental_linking") { 141 ldflags = [ "/INCREMENTAL:NO" ] 142 } 143 144 # Character set ---------------------------------------------------------------- 145 146 # Not including this config means "ansi" (8-bit system codepage). 147 config("unicode") { 148 defines = [ 149 "_UNICODE", 150 "UNICODE", 151 ] 152 } 153 154 # Lean and mean ---------------------------------------------------------------- 155 156 # Some third party code might not compile with WIN32_LEAN_AND_MEAN so we have 157 # to have a separate config for it. Remove this config from your target to 158 # get the "bloaty and accomodating" version of windows.h. 159 config("lean_and_mean") { 160 defines = [ 161 "WIN32_LEAN_AND_MEAN", 162 ] 163 } 164 165 # Nominmax -------------------------------------------------------------------- 166 167 # Some third party code defines NOMINMAX before including windows.h, which 168 # then causes warnings when it's been previously defined on the command line. 169 # For such targets, this config can be removed. 170 171 config("nominmax") { 172 defines = [ 173 "NOMINMAX", 174 ] 175 } 176