Files
allwpilib/shared/plugins/setupBuild.gradle

111 lines
4.9 KiB
Groovy
Raw Normal View History

2018-04-29 13:29:07 -07:00
apply plugin: 'cpp'
apply plugin: 'edu.wpi.first.NativeUtils'
apply plugin: ExtraTasks
2018-04-29 13:29:07 -07:00
if (!project.hasProperty('onlylinuxathena')) {
ext.skiplinuxathena = true
2018-04-29 13:29:07 -07:00
apply from: "${rootDir}/shared/config.gradle"
model {
components {
"${pluginName}"(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs = ['src/main/native/cpp']
includes = ["**/*.cpp"]
}
exportedHeaders {
srcDirs = ["src/main/native/include"]
}
}
}
binaries.all {
// Define a custom entry point if we are building statically to avoid symbol collision.
2018-04-29 13:29:07 -07:00
if (it instanceof StaticLibraryBinarySpec) {
// These scenario is seldom used, except in sysid to build a fully static exe
// with simulation modules. When building static, it is important that no two
// modules have the same entry point symbolically.
def name = project.name.replace("halsim_", "").toUpperCase()
it.cppCompiler.define("HALSIM_InitExtension", "HALSIM_InitExtension_$name")
2018-04-29 13:29:07 -07:00
}
project(':hal').addHalDependency(it, 'shared')
2018-04-29 13:29:07 -07:00
if (project.hasProperty('includeNtCore')) {
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
}
if (project.hasProperty('includeWpiutil')) {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
}
appendDebugPathToBinaries(binaries)
2018-04-29 13:29:07 -07:00
}
"${pluginName}Dev"(NativeExecutableSpec) {
targetBuildTypes 'debug'
2018-04-29 13:29:07 -07:00
sources {
cpp {
source {
srcDirs = ['src/dev/native/cpp']
includes = ["**/*.cpp"]
}
exportedHeaders {
srcDirs = ["src/dev/native/include"]
}
}
}
binaries.all {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
project(':hal').addHalDependency(it, 'shared')
lib library: pluginName
if (project.hasProperty('includeNtCore')) {
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
}
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
2019-11-13 21:35:52 -08:00
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(it, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
2019-11-13 21:35:52 -08:00
}
} else {
it.buildable = false
2018-04-29 13:29:07 -07:00
}
}
}
}
}
apply from: "${rootDir}/shared/plugins/publish.gradle"
}
model {
tasks {
def c = $.components
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
2018-04-29 13:29:07 -07:00
project.tasks.create('runCpp', Exec) {
group = 'WPILib'
description = "Run the ${pluginName}Dev executable"
def found = false
def systemArch = getCurrentArch()
c.each {
if (it in NativeExecutableSpec && it.name == "${pluginName}Dev") {
it.binaries.each {
if (!found) {
def arch = it.targetPlatform.name
2018-04-29 13:29:07 -07:00
if (arch == systemArch) {
dependsOn it.tasks.install
commandLine it.tasks.install.runScriptFile.get().asFile.toString()
// it.tasks.install.libs.each { lib ->
// if (lib.name.contains(pluginName)) {
// def filePath = it.tasks.install.installDirectory.get().toString() + File.separatorChar + 'lib' + File.separatorChar + lib.name
// environment('HALSIM_EXTENSIONS', filePath)
// }
// }
found = true
}
}
}
}
}
}
}
}
}