mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
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
165 lines
5.0 KiB
Groovy
165 lines
5.0 KiB
Groovy
import org.gradle.internal.os.OperatingSystem
|
|
|
|
apply plugin: 'cpp'
|
|
apply plugin: 'visual-studio'
|
|
|
|
// Find the target platform. The main wpilib build will set the target platform as a project property. You can also manually build for
|
|
// arm by using ./gradlew build -PbuildPlatform=arm
|
|
allprojects {
|
|
if (!project.hasProperty('armBuild')) {
|
|
ext.buildPlatform = OperatingSystem.current().getFamilyName()
|
|
} else {
|
|
ext.buildPlatform = 'arm'
|
|
}
|
|
}
|
|
|
|
ext.getPlatformPath = { binary ->
|
|
if (binary.targetPlatform.architecture.arm) {
|
|
return 'Linux/arm'
|
|
} else if (binary.targetPlatform.operatingSystem.linux) {
|
|
if (binary.targetPlatform.architecture.amd64) {
|
|
return 'Linux/amd64'
|
|
} else {
|
|
return 'Linux/' + binary.targetPlatform.architecture.name
|
|
}
|
|
} else if (binary.targetPlatform.operatingSystem.windows) {
|
|
if (binary.targetPlatform.architecture.amd64) {
|
|
return 'Windows/amd64'
|
|
} else {
|
|
return 'Windows/' + binary.targetPlatform.architecture.name
|
|
}
|
|
} else {
|
|
return binary.targetPlatform.operatingSystem.name + '/' + binary.targetPlatform.architecture.name
|
|
}
|
|
}
|
|
|
|
// Apply the correct toolchain settings for the target platform
|
|
if (buildPlatform == 'arm') {
|
|
apply from: 'toolchains/arm.gradle'
|
|
} else if (OperatingSystem.current().isLinux()) {
|
|
apply from: 'toolchains/linux.gradle'
|
|
} else if (OperatingSystem.current().isMacOsX()) {
|
|
apply from: 'toolchains/mac.gradle'
|
|
} else if (OperatingSystem.current().isWindows()) {
|
|
apply from: 'toolchains/windows.gradle'
|
|
} else {
|
|
throw new GradleException("ntcore does not support building on ${OperatingSystem.current().getFamilyName()}.")
|
|
}
|
|
|
|
// We only build and run the tests when building for the native platform. If we just build arm, there's not much point.
|
|
if (buildPlatform != 'arm') {
|
|
apply from: 'test/tests.gradle'
|
|
}
|
|
|
|
if (!hasProperty('skipJava')) {
|
|
apply from: 'java/java.gradle'
|
|
}
|
|
|
|
model {
|
|
platforms {
|
|
if (project.buildPlatform == 'arm') {
|
|
arm {
|
|
architecture 'arm'
|
|
operatingSystem 'linux'
|
|
}
|
|
} else {
|
|
x86 {
|
|
architecture 'x86'
|
|
operatingSystem project.buildPlatform
|
|
}
|
|
x64 {
|
|
architecture 'x86_64'
|
|
operatingSystem project.buildPlatform
|
|
}
|
|
}
|
|
}
|
|
|
|
components {
|
|
ntcore(NativeLibrarySpec) {
|
|
if (project.buildPlatform == 'arm') {
|
|
targetPlatform 'arm'
|
|
binaries.all {
|
|
if (project.hasProperty('debug')) {
|
|
setupDebugDefines(cppCompiler, linker)
|
|
} else {
|
|
setupReleaseDefines(cppCompiler, linker)
|
|
}
|
|
}
|
|
} else {
|
|
targetPlatform 'x86'
|
|
targetPlatform 'x64'
|
|
binaries.all {
|
|
if (project.hasProperty('debug')) {
|
|
setupDebugDefines(cppCompiler, linker)
|
|
} else {
|
|
setupReleaseDefines(cppCompiler, linker)
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!project.hasProperty('skipJava')) {
|
|
setupJniIncludes(binaries)
|
|
}
|
|
|
|
sources {
|
|
cpp {
|
|
source {
|
|
srcDirs = ['src']
|
|
if (!project.hasProperty('skipJava')) {
|
|
srcDirs "java/lib"
|
|
}
|
|
includes = ['**/*.cpp']
|
|
}
|
|
exportedHeaders {
|
|
srcDirs = ['include']
|
|
if (!project.hasProperty('skipJava')) {
|
|
jniHeadersNetworkTables.outputs.files.each { file ->
|
|
srcDirs file.getPath()
|
|
}
|
|
}
|
|
includes = ['**/*.h']
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task ntcoreZip(type: Zip) {
|
|
description = 'Creates platform-specific zip of the desktop ntcore libraries.'
|
|
group = 'WPILib'
|
|
destinationDir = project.buildDir
|
|
|
|
from(file('include')) {
|
|
into 'include'
|
|
}
|
|
|
|
binaries.withType(StaticLibraryBinarySpec) { binary ->
|
|
from(binary.staticLibraryFile) {
|
|
into getPlatformPath(binary)
|
|
}
|
|
}
|
|
|
|
binaries.withType(SharedLibraryBinarySpec) { binary ->
|
|
from(binary.sharedLibraryFile) {
|
|
into getPlatformPath(binary)
|
|
}
|
|
}
|
|
}
|
|
|
|
releaseSetup(ntcoreZip)
|
|
|
|
if (!hasProperty('skipJava')) {
|
|
jar.dependsOn ntcoreZip
|
|
}
|
|
|
|
tasks.whenTaskAdded { task ->
|
|
def name = task.name.toLowerCase()
|
|
if (name.contains("ntcoresharedlibrary") || name.contains("ntcorestaticlibrary") ||
|
|
name.contains("ntcoretest")) {
|
|
ntcoreZip.dependsOn task
|
|
}
|
|
}
|
|
|
|
apply from: 'publish.gradle'
|