mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Using MrcLib on the robot is going to be the plan for the future, to make things easier. MrcLib is how sim is supported going forward. The desktop version of mrclib can act as a robot server. This is set up where the mrclib interface is in shared code. On robot, that is the only backend used. On desktop, a default sim backend is used. However, the sim plugin can switch that to the real robot backend, so the robot code will exactly look like a real robot.
135 lines
3.8 KiB
Groovy
135 lines
3.8 KiB
Groovy
ext {
|
|
nativeName = 'hal'
|
|
setBaseName = 'wpiHal'
|
|
devMain = 'org.wpilib.hardware.hal.DevMain'
|
|
generatedHeaders = "src/generated/main/native/include"
|
|
splitSetup = {
|
|
if (it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
|
|
it.sources {
|
|
systemCoreCpp(CppSourceSet) {
|
|
source {
|
|
srcDirs = ['src/main/native/systemcore']
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDir 'src/main/native/include'
|
|
srcDir generatedHeaders
|
|
srcDir 'src/mrc/include'
|
|
srcDir 'src/generated/main/native/cpp/mrc/protobuf'
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
it.sources {
|
|
simCpp(CppSourceSet) {
|
|
source {
|
|
srcDirs 'src/main/native/sim'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDir 'src/main/native/include'
|
|
srcDir generatedHeaders
|
|
srcDir 'src/mrc/include'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
it.sources {
|
|
nanopbCpp(CppSourceSet) {
|
|
source {
|
|
srcDirs 'src/generated/main/native/cpp'
|
|
include '**/*.cpp'
|
|
}
|
|
exportedHeaders {
|
|
srcDirs 'src/generated/main/native/cpp'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
exeSplitSetup = {
|
|
}
|
|
}
|
|
|
|
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
|
|
|
|
apply from: "${rootDir}/shared/libmrclib.gradle"
|
|
|
|
ext {
|
|
addHalDependency = { binary, shared->
|
|
nativeUtils.useRequiredLibrary(binary, 'mrclib')
|
|
binary.lib project: ':hal', library: 'hal', linkage: shared
|
|
}
|
|
|
|
addHalJniDependency = { binary->
|
|
nativeUtils.useRequiredLibrary(binary, 'mrclib')
|
|
binary.lib project: ':hal', library: 'halJNIShared', linkage: 'shared'
|
|
}
|
|
}
|
|
|
|
sourceSets.main.java.srcDir "${projectDir}/src/generated/main/java"
|
|
|
|
cppSourcesZip {
|
|
from('src/main/native/athena') {
|
|
into '/athena'
|
|
}
|
|
|
|
from('src/main/native/systemcore') {
|
|
into '/systemcore'
|
|
}
|
|
|
|
from('src/main/native/sim') {
|
|
into '/sim'
|
|
}
|
|
}
|
|
|
|
cppHeadersZip {
|
|
from(generatedHeaders) {
|
|
into '/'
|
|
}
|
|
from('src/mrc/include') {
|
|
into '/'
|
|
}
|
|
}
|
|
|
|
Action<List<String>> symbolFilter = { symbols ->
|
|
symbols.removeIf({ !it.startsWith('HAL_') && !it.startsWith('HALSIM_') })
|
|
} as Action<List<String>>;
|
|
|
|
nativeUtils.exportsConfigs {
|
|
hal {
|
|
}
|
|
halJNI {
|
|
x64SymbolFilter = symbolFilter
|
|
}
|
|
}
|
|
|
|
model {
|
|
components {
|
|
all {
|
|
it.sources.each {
|
|
it.exportedHeaders {
|
|
srcDirs 'src/mrc/include',
|
|
'src/generated/main/native/cpp/mrc/protobuf'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
binaries {
|
|
all {
|
|
if (!it.buildable || !(it instanceof NativeBinarySpec)) {
|
|
return
|
|
}
|
|
nativeUtils.useRequiredLibrary(it, 'mrclib')
|
|
if (it.component.name == "${nativeName}JNI") {
|
|
project(':ntcore').addNtcoreDependency(it, 'static')
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
|
} else {
|
|
project(':ntcore').addNtcoreDependency(it, 'shared')
|
|
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
|
|
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
|
}
|
|
}
|
|
}
|
|
}
|