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