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
This commit is contained in:
Fredric Silberberg
2015-09-24 23:32:55 -04:00
parent dd0e3e4abb
commit 77cf3adf64
14 changed files with 650 additions and 365 deletions

View File

@@ -1,59 +0,0 @@
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: 'cpp'
apply plugin: 'google-test'
apply plugin: 'visual-studio'
model {
toolChains {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
visualCpp(VisualCpp) {
def vs14Dir = file('C:\\Program Files (x86)\\Microsoft Visual Studio 14.0')
// If vs2015 is installed, fall back to vs2013 for now, until Gradle pulls in the right
// includes for the win10 sdk.
if (vs14Dir.exists()) {
def vs12Dir = file('C:\\Program Files (x86)\\Microsoft Visual Studio 12.0')
if (!vs12Dir.exists()) {
throw new GradleException('Compilation with VS 2015 is not currently supported by Gradle. Please install VS 2013, or use the CMake build option.')
}
installDir = vs12Dir
}
}
}
}
components {
tests(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs = ["unit", "../src"]
includes = ["**/*.cpp"]
}
exportedHeaders {
srcDirs = ["../include", "../src", "../gmock/include", "../gmock/gtest/include"]
includes = ["**/*.h"]
}
}
}
binaries.all {
lib project: ':gmock', library: "gmock", linkage: "static"
if (toolChain in Gcc) {
cppCompiler.args '-std=c++1y', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-unused-parameter'
linker.args '-pthread'
}
if (toolChain in VisualCpp) {
cppCompiler.args '/EHsc', '/DNOMINMAX', '/D_SCL_SECURE_NO_WARNINGS', '/D_WINSOCK_DEPRECATED_NO_WARNINGS'
}
}
}
}
}
binaries.withType(GoogleTestTestSuiteBinarySpec) {
lib project: ':gmock', library: "gmock", linkage: "static"
if (targetPlatform.operatingSystem.linux) {
cppCompiler.args '-pthread', '-std=c++1y'
linker.args '-pthread'
} else {
cppCompiler.args '/EHsc', '/DNOMINMAX', '/D_SCL_SECURE_NO_WARNINGS', '/D_WINSOCK_DEPRECATED_NO_WARNINGS'
}
}

45
test/tests.gradle Normal file
View File

@@ -0,0 +1,45 @@
apply plugin: 'google-test'
task check() {}
model {
testSuites {
ntcoreTest {
if (!project.hasProperty('skipJava')) {
setupJniIncludes(binaries)
}
sources {
cpp {
source {
srcDirs = ['test/unit']
includes = ['**/*.cpp']
}
exportedHeaders {
srcDirs = ['include', 'src', 'gmock/include', 'gmock/gtest/include']
includes = ['**/*.h']
}
}
}
binaries.all {
if (project.hasProperty('wpilib')) {
lib project: ':ntcore:gmock', library: "gmock", linkage: "static"
} else {
lib project: ':gmock', library: "gmock", linkage: "static"
}
}
}
}
}
binaries.withType(GoogleTestTestSuiteBinarySpec) {
if (project.hasProperty('wpilib')) {
lib project: ':ntcore:gmock', library: "gmock", linkage: "static"
} else {
lib project: ':gmock', library: "gmock", linkage: "static"
}
if (targetPlatform.operatingSystem.linux) {
cppCompiler.args '-pthread', '-std=c++1y'
linker.args '-pthread'
} else {
cppCompiler.args '/EHsc', '/DNOMINMAX', '/D_SCL_SECURE_NO_WARNINGS', '/D_WINSOCK_DEPRECATED_NO_WARNINGS'
}
}