Files
allwpilib/toolchains/windows.gradle
Fredric Silberberg 77cf3adf64 This commit updates the gradle files to be cleaner. It also builds for the
current platform by default, and only builds tests when building for the
current platform. Mac builds and VS2015 builds are fixed.

The other big change in this update is the introduction of Debug and
Release builds. Debug builds are built with -O0 and -g. Release builds are
built with -O2 and -g. For GCC-based builds, the resulting shared object
is copied, stripped of debug information, and a debug link is set up to
the copied shared object. This allows the release build to clock in at
around 600 KB. On Windows, the debug info is already stored in a separate
PDB file, so this copy and strip is not necessary.

ntcore is being separated out from the rest of allwpilib. All other
builds will consume a published maven dependency from this project.
There are 4 possible publishing targets now: release, stable, beta, and
development. These are specified on the command line via -Prepo=<repo
name>.

Change-Id: Ie8cb21f910953e09b80a5192317033eb0866cb70
2015-10-31 13:31:01 -04:00

50 lines
2.0 KiB
Groovy

model {
toolChains {
visualCpp(VisualCpp) {
// Workaround for VS2015 adapted from https://github.com/couchbase/couchbase-lite-java-native/issues/23
def VS_2015_INCLUDE_DIR = "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
def VS_2015_LIB_DIR = "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt"
def VS_2015_INSTALL_DIR = 'C:/Program Files (x86)/Microsoft Visual Studio 14.0'
def vsInstallDir = file(VS_2015_INSTALL_DIR)
// If you ever happen to install and uninstall any other version of VS, Gradle will misdetect the compiler
// and linker to run. This fixes that by manually setting the install dir
if (vsInstallDir.exists()) {
installDir = vsInstallDir
}
eachPlatform {
cppCompiler.withArguments { args ->
args << '/EHsc' << '/DNOMINMAX' << '/D_SCL_SECURE_NO_WARNINGS' << '/D_WINSOCK_DEPRECATED_NO_WARNINGS'
if (file(VS_2015_INCLUDE_DIR).exists()) {
args << "/I$VS_2015_INCLUDE_DIR"
}
}
linker.withArguments { args ->
if (file(VS_2015_LIB_DIR).exists()) {
if (platform.architecture.name == 'x86') {
args << "/LIBPATH:$VS_2015_LIB_DIR/x86"
} else {
args << "/LIBPATH:$VS_2015_LIB_DIR/x64"
}
}
}
}
}
}
}
ext.setupReleaseDefines = { cppCompiler, linker ->
cppCompiler.args '/O2', '/Zi', '/FS'
linker.args '/DEF:ntcore.def'
}
ext.setupDebugDefines = { cppCompiler, linker ->
cppCompiler.args '/Zi', '/FS'
linker.args '/DEBUG', '/DEF:ntcore.def'
}
// This is a noop on Windows. On gcc platforms, we strip the release binary and create a separate
// debug library, but Windows already separates debug symbols into a .pdb file.
ext.releaseSetup = {}