blob: 37e60e7bdd46ddbc842d1cf6bfd55ce98f5aba37 [file] [log] [blame]
# Copyright 2021 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/config/win/visual_studio_version.gni")
config("platform_configuration") {
# TODO(b/206809341): Migrate Detect64BitPortabilityProblems
configs = [ "//starboard/build/config/sabi" ]
cflags_cc = [ "/TP" ]
cflags = []
ldflags = [
"/NXCOMPAT",
"/MANIFEST:NO",
]
libs = []
include_dirs = []
arflags = []
defines = [
"_UNICODE",
"UNICODE",
]
if (!cobalt_fastbuild) {
# Containers cannot use PDBs, so we conditionally disable them.
# We want to keep them for non-docker builds as they make compilation
# significantly faster.
if (is_docker_build) {
cflags += [ "/Z7" ]
} else {
cflags += [
"/Zi",
"/FS",
]
}
ldflags += [ "/DEBUG:FULL" ]
}
# msvs_base
# OutputDirectory and IntermediateDirectory, maybe CharacterSet
include_dirs += [
"$wdk_include_path/shared",
"$wdk_include_path/ucrt",
"$wdk_include_path/um",
"$wdk_include_path/winrt",
"$msvc_path/include",
]
cflags += [
"/EHsc",
"/std:c++14",
]
# msvs_debug/_devel/etc
ldflags += [ "/INCREMENTAL:NO" ]
if (is_debug) {
cflags += [
"/Od",
# Check stack frame validity and check for uninitialized variables at run time.
"/RTC1",
]
} else {
cflags += [ "/O2" ]
}
if (!is_gold) {
libs += [ "dbghelp.lib" ]
}
if (is_debug || is_devel) {
cflags += [
# Use debug multithreaded library.
"/MDd",
"/GS",
# Unit tests can have huge object files.
"/bigobj",
]
} else {
cflags += [
# Use release multithreaded library.
"/MD",
# Unreferenced variable.
# Often variables are only referenced in DCHECKs.
"/wd4189",
]
ldflags += [
"/OPT:REF",
"/OPT:ICF",
]
}
# target defaults
if (current_toolchain == default_toolchain) {
defines += [
# Disable warnings. These options were inherited from Chromium.
"_CRT_SECURE_NO_DEPRECATE",
"_CRT_NONSTDC_NO_WARNINGS",
"_CRT_NONSTDC_NO_DEPRECATE",
"_SCL_SECURE_NO_DEPRECATE",
# Disable suggestions to switch to Microsoft-specific secure CRT.
"_CRT_SECURE_NO_WARNINGS",
"__STDC_FORMAT_MACROS", # so that we get PRI*
# By defining this, M_PI will get #defined.
"_USE_MATH_DEFINES",
# min and max collide with std::min and std::max
"NOMINMAX",
# Conform with C99 spec.
"_CRT_STDIO_ISO_WIDE_SPECIFIERS",
]
}
cflags += [
# Check for buffer overruns.
"/GS",
# "for" loop's initializer go out of scope after the for loop.
"/Zc:forScope",
# wchar_t is treated as a built-in type.
"/Zc:wchar_t",
# Don't send error reports to MS.
"/errorReport:none",
]
arflags += [
# Linking statically with C++/CX library is not recommended.
# TODO: Remove after removing ComponentExtensions
"/ignore:4264",
]
cflags += [
# Allow unused function input parameter.
"/wd4100",
# Conditional expression is constant.
# Triggers in many legitimate cases, like branching on a constant declared
# in type traits.
"/wd4127",
# Disable anonymous union warnings.
"/wd4201",
# 4244 (Level 2) - Implicit conversion from float to int
# 4244 (Level 3) - Implicit conversion from int to something smaller
# than int.
# 4244 (Level 4) - Implicit conversion of types, which may result in
# data loss.
"/wd4244",
# Class has virtual functions, but destructor is not virtual.
# Far less useful than in GCC because doesn't take into account the fact
# that destructor is not public.
"/wd4265",
# Inconsistent DLL linkage
"/wd4273",
# Matching delete operator for `new`. 4291 is also ignored by Chromium.
"/wd4291",
# Double -> float truncation. Not enabled on other compilers.
"/wd4305",
# cast truncates constant value.
# We do not care.
"/wd4309",
# casting constant number.
"/wd4310",
# An rvalue cannot be bound to a non-const reference.
# In previous versions of Visual C++, it was possible to bind an rvalue
# to a non-const reference in a direct initialization. This warning
# is useless as it simply describes proper C++ behavior.
"/wd4350",
# layout of class may have changed from a previous version of
# the compiler due to better packing of member. We don't care about
# binary compatibility with other compiler versions.
"/wd4371",
# relative include path contains '..'.
# This occurs in a lot third party libraries and we don't care.
"/wd4464",
# decorated name length exceeded, name was truncated.
"/wd4503",
# assignment operator could not be generated.
# This is expected for structs with const members.
"/wd4512",
# Unreferenced inline function has been removed.
# While detection of dead code is good, this warning triggers in
# third-party libraries which renders it useless.
"/wd4514",
# Expression before comma has no effect.
# Cannot be used because Microsoft uses _ASSERTE(("message", 0)) trick
# in malloc.h which is included pretty much everywhere.
"/wd4548",
# Use of noexcept in targets compiled without /EHsc triggers a warning
# "termination on exception is not guaranteed" which we consider benign
# because we don't expect exceptions to cross the boundary of modules
# compiled with /EHsc.
"/wd4577",
# Copy constructor could not be generated because a base class copy
# constructor is inaccessible.
# This is an expected consequence of using DISALLOW_COPY_AND_ASSIGN().
"/wd4625",
# Assignment operator could not be generated because a base class
# assignment operator is inaccessible.
# This is an expected consequence of using DISALLOW_COPY_AND_ASSIGN().
"/wd4626",
# Digraphs not supported.
"/wd4628",
# Sometimes template definitions and declarations are separate and MSVC
# complains when it fails to find the definition on seeing the template.
"/wd4661",
# Symbol is not defined as a preprocessor macro, replacing with '0'.
# Seems like common practice, used in Windows SDK and gtest.
"/wd4668",
# Function not inlined.
# It's up to the compiler to decide what to inline.
"/wd4710",
# Function selected for inline expansion.
# It's up to the compiler to decide what to inline.
"/wd4711",
# The type and order of elements caused the compiler to add padding
# to the end of a struct.
# Unsurprisingly, most of the structs become larger because of padding
# but it's a universally acceptable price for better performance.
"/wd4820",
# Disable static analyzer warning for std::min and std::max with
# objects.
# https://connect.microsoft.com/VisualStudio/feedback/details/783808/static-analyzer-warning-c28285-for-std-min-and-std-max
"/wd28285",
]
}
config("no_pedantic_warnings") {
cflags = [
# Enable some warnings, even those that are disabled by default.
# See https://msdn.microsoft.com/en-us/library/23k5d385.aspx
"/W2",
]
}
config("pedantic_warnings") {
cflags = [
# Enable some warnings, even those that are disabled by default.
# See https://msdn.microsoft.com/en-us/library/23k5d385.aspx
"/W4",
# Warn if an enumeration value is unhandled in switch (C4062).
# This warning is off by default, so it must be turned on explicitly.
"/w44062",
]
}