2017-10-17 21:37:58 -07:00
|
|
|
import org.gradle.language.base.internal.ProjectLayout
|
|
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
apply plugin: 'cpp'
|
|
|
|
|
apply plugin: 'visual-studio'
|
|
|
|
|
apply plugin: 'edu.wpi.first.NativeUtils'
|
2018-05-15 21:25:24 -07:00
|
|
|
apply plugin: ExtraTasks
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
apply from: '../shared/config.gradle'
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
ext.examplesMap = [:]
|
|
|
|
|
ext.templatesMap = [:]
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
File examplesTree = file("$projectDir/src/main/cpp/examples")
|
|
|
|
|
examplesTree.list(new FilenameFilter() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean accept(File current, String name) {
|
2017-10-17 21:37:58 -07:00
|
|
|
return new File(current, name).isDirectory();
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
}).each {
|
|
|
|
|
examplesMap.put(it, [])
|
|
|
|
|
}
|
|
|
|
|
File templatesTree = file("$projectDir/src/main/cpp/templates")
|
|
|
|
|
templatesTree.list(new FilenameFilter() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean accept(File current, String name) {
|
2017-10-17 21:37:58 -07:00
|
|
|
return new File(current, name).isDirectory();
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
}).each {
|
|
|
|
|
templatesMap.put(it, [])
|
|
|
|
|
}
|
2017-10-17 21:37:58 -07:00
|
|
|
|
2018-05-15 23:56:03 -07:00
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
ext {
|
2018-05-15 23:56:03 -07:00
|
|
|
sharedCvConfigs = examplesMap + templatesMap + [commands: []]
|
2018-04-29 13:29:07 -07:00
|
|
|
staticCvConfigs = [:]
|
|
|
|
|
useJava = false
|
|
|
|
|
useCpp = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apply from: "${rootDir}/shared/opencv.gradle"
|
|
|
|
|
|
|
|
|
|
model {
|
|
|
|
|
components {
|
2018-05-15 23:56:03 -07:00
|
|
|
commands(NativeLibrarySpec) {
|
|
|
|
|
binaries.all { binary ->
|
|
|
|
|
if (binary in StaticLibraryBinarySpec) {
|
|
|
|
|
binary.buildable = false
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
|
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
|
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
|
|
|
lib project: ':hal', library: 'hal', linkage: 'shared'
|
|
|
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
|
|
|
project(':ni-libraries').addNiLibrariesToLinker(binary)
|
|
|
|
|
}
|
|
|
|
|
sources {
|
|
|
|
|
cpp {
|
|
|
|
|
source {
|
|
|
|
|
srcDirs = ['src/main/cpp/commands']
|
|
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
|
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/main/cpp/commands'
|
|
|
|
|
include '**/*.h'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-29 13:29:07 -07:00
|
|
|
examplesMap.each { key, value ->
|
|
|
|
|
"${key}"(NativeExecutableSpec) {
|
|
|
|
|
binaries.all { binary ->
|
|
|
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
|
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
|
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
|
|
|
lib project: ':hal', library: 'hal', linkage: 'shared'
|
|
|
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
|
|
|
project(':ni-libraries').addNiLibrariesToLinker(binary)
|
|
|
|
|
if (binary.targetPlatform.architecture.name != 'athena') {
|
|
|
|
|
lib project: ':simulation:halsim_lowfi', library: 'halsim_lowfi', linkage: 'shared'
|
|
|
|
|
lib project: ':simulation:halsim_adx_gyro_accelerometer', library: 'halsim_adx_gyro_accelerometer', linkage: 'shared'
|
|
|
|
|
lib project: ':simulation:halsim_print', library: 'halsim_print', linkage: 'shared'
|
|
|
|
|
lib project: ':simulation:halsim_ds_nt', library: 'halsim_ds_nt', linkage: 'shared'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sources {
|
|
|
|
|
cpp {
|
|
|
|
|
source {
|
2018-05-15 21:25:24 -07:00
|
|
|
srcDirs 'src/main/cpp/examples/' + "${key}" + "/cpp"
|
2018-04-29 13:29:07 -07:00
|
|
|
include '**/*.cpp'
|
|
|
|
|
}
|
2018-05-15 21:25:24 -07:00
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/main/cpp/examples/' + "${key}" + "/include"
|
|
|
|
|
include '**/*.h'
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
|
|
|
|
}
|
2017-10-17 21:37:58 -07:00
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
templatesMap.each { key, value ->
|
|
|
|
|
"${key}"(NativeExecutableSpec) {
|
|
|
|
|
binaries.all { binary ->
|
|
|
|
|
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
|
|
|
|
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
|
|
|
|
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
|
|
|
|
lib project: ':hal', library: 'hal', linkage: 'shared'
|
|
|
|
|
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
|
|
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
|
|
|
binary.tasks.withType(CppCompile) {
|
|
|
|
|
if (!(binary.toolChain in VisualCpp)) {
|
|
|
|
|
cppCompiler.args "-Wno-error=deprecated-declarations"
|
2017-10-17 21:37:58 -07:00
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
project(':ni-libraries').addNiLibrariesToLinker(binary)
|
|
|
|
|
if (binary.targetPlatform.architecture.name != 'athena') {
|
|
|
|
|
lib project: ':simulation:halsim_lowfi', library: 'halsim_lowfi', linkage: 'shared'
|
|
|
|
|
lib project: ':simulation:halsim_adx_gyro_accelerometer', library: 'halsim_adx_gyro_accelerometer', linkage: 'shared'
|
|
|
|
|
lib project: ':simulation:halsim_print', library: 'halsim_print', linkage: 'shared'
|
|
|
|
|
lib project: ':simulation:halsim_ds_nt', library: 'halsim_ds_nt', linkage: 'shared'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sources {
|
|
|
|
|
cpp {
|
|
|
|
|
source {
|
2018-05-15 21:25:24 -07:00
|
|
|
srcDirs 'src/main/cpp/templates/' + "${key}" + "/cpp"
|
2018-04-29 13:29:07 -07:00
|
|
|
include '**/*.cpp'
|
2017-10-17 21:37:58 -07:00
|
|
|
}
|
2018-05-15 21:25:24 -07:00
|
|
|
exportedHeaders {
|
|
|
|
|
srcDirs 'src/main/cpp/templates/' + "${key}" + "/include"
|
|
|
|
|
include '**/*.h'
|
|
|
|
|
}
|
2017-10-17 21:37:58 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
tasks {
|
|
|
|
|
def b = $.binaries
|
|
|
|
|
b.each { binary->
|
|
|
|
|
if (binary in NativeExecutableBinarySpec) {
|
|
|
|
|
def installDir = binary.tasks.install.installDirectory.get().toString() + File.separatorChar
|
|
|
|
|
def runFile = binary.tasks.install.runScriptFile.get().asFile.toString()
|
|
|
|
|
|
|
|
|
|
binary.tasks.install.doLast {
|
|
|
|
|
if (binary.targetPlatform.operatingSystem.isWindows()) {
|
|
|
|
|
// Windows batch scripts
|
|
|
|
|
def fileName = binary.component.name + 'LowFi.bat'
|
|
|
|
|
def file = new File(installDir + fileName)
|
|
|
|
|
file.withWriter { out ->
|
|
|
|
|
out.println '@ECHO OFF'
|
|
|
|
|
out.print 'SET HALSIM_EXTENSIONS='
|
|
|
|
|
out.print '"' + new File(installDir + 'lib\\halsim_lowfi.dll').toString() + '";'
|
|
|
|
|
out.println '"' + new File(installDir + 'lib\\halsim_ds_nt.dll').toString() + '"'
|
|
|
|
|
out.println runFile + ' %*'
|
2017-10-17 21:37:58 -07:00
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
|
|
|
|
|
fileName = binary.component.name + 'LowFiRealDS.bat'
|
|
|
|
|
file = new File(installDir + fileName)
|
|
|
|
|
file.withWriter { out ->
|
|
|
|
|
out.println '@ECHO OFF'
|
|
|
|
|
out.print 'SET HALSIM_EXTENSIONS='
|
|
|
|
|
out.print '"' + new File(installDir + 'lib\\halsim_lowfi.dll').toString() + '";'
|
|
|
|
|
out.println '"' + new File(installDir + 'lib\\halsim_ds_socket.dll').toString() + '"'
|
|
|
|
|
out.println runFile + ' %*'
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
def fileName = binary.component.name + 'LowFi.sh'
|
|
|
|
|
def file = new File(installDir + fileName)
|
|
|
|
|
|
|
|
|
|
file.withWriter { out ->
|
|
|
|
|
out.print 'export HALSIM_EXTENSIONS='
|
|
|
|
|
out.print '"' + new File(installDir + '/lib/libhalsim_lowfi.so').toString() + '";'
|
|
|
|
|
out.println '"' + new File(installDir + '/lib/libhalsim_ds_nt.so').toString() + '"'
|
|
|
|
|
out.println runFile + ' "$@"'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileName = binary.component.name + 'LowFiRealDS.sh'
|
|
|
|
|
file = new File(installDir + fileName)
|
|
|
|
|
file.withWriter { out ->
|
|
|
|
|
out.print 'export HALSIM_EXTENSIONS='
|
|
|
|
|
out.print '"' + new File(installDir + '/lib/libhalsim_lowfi.so').toString() + '":'
|
|
|
|
|
out.println '"' + new File(installDir + '/lib/libhalsim_ds_socket.so').toString() + '"'
|
|
|
|
|
out.println runFile + ' "$@"'
|
2017-10-17 21:37:58 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
|
2017-10-17 21:37:58 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-29 13:29:07 -07:00
|
|
|
apply from: 'publish.gradle'
|
2018-05-24 17:08:37 -07:00
|
|
|
|
|
|
|
|
ext {
|
|
|
|
|
templateDirectory = new File("$projectDir/src/main/cpp/templates/")
|
|
|
|
|
templateFile = new File("$projectDir/src/main/cpp/templates/templates.json")
|
|
|
|
|
exampleDirectory = new File("$projectDir/src/main/cpp/examples/")
|
|
|
|
|
exampleFile = new File("$projectDir/src/main/cpp/examples/examples.json")
|
|
|
|
|
commandDirectory = new File("$projectDir/src/main/cpp/commands/")
|
|
|
|
|
commandFile = new File("$projectDir/src/main/cpp/commands/commands.json")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apply from: "${rootDir}/shared/examplecheck.gradle"
|