Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit ee335c1

Browse files
author
Raphael Kubo da Costa
committed
[Backport][Windows] Pass "/MD" and variants outside the "runtime_library" target
This patch is required for the .NET extension bridge to be built. BUG=XWALK-7336 > Create separate configurations for passing "/MD", "/MT" and their debug > variants: "dynamic_crt" passes "/MD" and "/MDd", whereas "static_crt" > passes "/MT" and "/MTd". BUILDCONFIG then depends on "default_crt", > which has some logic to choose whether to use either dynamic_crt or > static_crt. > > The main reason behind this is to allow users to config -= the > "default_crt" config: in gyp, it was possible to configure what was > going to be passed to the compiler via the > "win_{release,debug}_RuntimeLibrary" variable, which was useful when > building code that needs to pass "/CLR", as it requires "/MD" and does > not work with "/MT". > > [email protected],[email protected],[email protected] > > Review-Url: https://codereview.chromium.org/2379573003
1 parent 64345ff commit ee335c1

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

build/config/BUILDCONFIG.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ _native_compiler_configs = [
472472
]
473473
if (is_win) {
474474
_native_compiler_configs += [
475+
"//build/config/win:default_crt",
475476
"//build/config/win:lean_and_mean",
476477
"//build/config/win:nominmax",
477478
"//build/config/win:unicode",

build/config/win/BUILD.gn

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -183,33 +183,6 @@ config("runtime_library") {
183183
# However it is prohibited when using /analyze
184184
defines += [ "_USING_V110_SDK71_" ]
185185
}
186-
187-
if (is_component_build) {
188-
# Component mode: dynamic CRT. Since the library is shared, it requires
189-
# exceptions or will give errors about things not matching, so keep
190-
# exceptions on.
191-
if (is_debug) {
192-
cflags += [ "/MDd" ]
193-
} else {
194-
cflags += [ "/MD" ]
195-
}
196-
} else {
197-
if (current_os != "win") {
198-
# WindowsRT: use the dynamic CRT.
199-
if (is_debug) {
200-
cflags += [ "/MDd" ]
201-
} else {
202-
cflags += [ "/MD" ]
203-
}
204-
} else {
205-
# Desktop Windows: static CRT.
206-
if (is_debug) {
207-
cflags += [ "/MTd" ]
208-
} else {
209-
cflags += [ "/MT" ]
210-
}
211-
}
212-
}
213186
}
214187

215188
# Sets the default Windows build version. This is separated because some
@@ -278,6 +251,44 @@ config("common_linker_setup") {
278251
}
279252
}
280253

254+
# CRT --------------------------------------------------------------------------
255+
256+
# Configures how the runtime library (CRT) is going to be used.
257+
# See https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx for a reference of
258+
# what each value does.
259+
config("default_crt") {
260+
if (is_component_build) {
261+
# Component mode: dynamic CRT. Since the library is shared, it requires
262+
# exceptions or will give errors about things not matching, so keep
263+
# exceptions on.
264+
configs = [ ":dynamic_crt" ]
265+
} else {
266+
if (current_os != "win") {
267+
# WindowsRT: use the dynamic CRT.
268+
configs = [ ":dynamic_crt" ]
269+
} else {
270+
# Desktop Windows: static CRT.
271+
configs = [ ":static_crt" ]
272+
}
273+
}
274+
}
275+
276+
config("dynamic_crt") {
277+
if (is_debug) {
278+
cflags = [ "/MDd" ]
279+
} else {
280+
cflags = [ "/MD" ]
281+
}
282+
}
283+
284+
config("static_crt") {
285+
if (is_debug) {
286+
cflags = [ "/MTd" ]
287+
} else {
288+
cflags = [ "/MT" ]
289+
}
290+
}
291+
281292
# Subsystem --------------------------------------------------------------------
282293

283294
# This is appended to the subsystem to specify a minimum version.

0 commit comments

Comments
 (0)