mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[build] Make loading sim extensions from MyRobot easier (#2671)
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -222,3 +222,5 @@ compile_commands.json
|
||||
# clang configuration and clangd cache
|
||||
.clang
|
||||
.clangd/
|
||||
|
||||
imgui.ini
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#define DELIM ';'
|
||||
#define HTYPE HMODULE
|
||||
#define DLOPEN(a) LoadLibrary(a)
|
||||
#define DLOPEN(a) LoadLibraryA(a)
|
||||
#define DLSYM GetProcAddress
|
||||
#define DLCLOSE FreeLibrary
|
||||
#else
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import jaci.gradle.toolchains.*
|
||||
import jaci.gradle.nativedeps.*
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
@@ -13,6 +14,12 @@ apply plugin: 'jaci.gradle.EmbeddedTools'
|
||||
|
||||
apply from: '../shared/config.gradle'
|
||||
|
||||
application {
|
||||
if (OperatingSystem.current().isMacOsX()) {
|
||||
applicationDefaultJvmArgs = ['-XstartOnFirstThread']
|
||||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
sharedCvConfigs = [myRobotCpp: []]
|
||||
staticCvConfigs = [myRobotCppStatic: []]
|
||||
@@ -129,6 +136,10 @@ dependencies {
|
||||
implementation project(':wpilibNewCommands')
|
||||
}
|
||||
|
||||
def simProjects = [
|
||||
'halsim_gui'
|
||||
]
|
||||
|
||||
model {
|
||||
components {
|
||||
myRobotCpp(NativeExecutableSpec) {
|
||||
@@ -146,21 +157,28 @@ model {
|
||||
}
|
||||
}
|
||||
binaries.all { binary ->
|
||||
lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared'
|
||||
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
|
||||
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
||||
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
||||
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
||||
lib project: ':ntcore', library: 'ntcoreJNIShared', linkage: 'shared'
|
||||
lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
|
||||
project(':hal').addHalDependency(binary, 'shared')
|
||||
project(':hal').addHalJniDependency(binary)
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
||||
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
||||
nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
||||
lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'shared'
|
||||
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'shared'
|
||||
lib project: ':wpilibc', library: 'wpilibc', linkage: 'shared'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
|
||||
lib project: ':ntcore', library: 'ntcore', linkage: 'shared'
|
||||
lib project: ':cscore', library: 'cscore', linkage: 'shared'
|
||||
lib project: ':ntcore', library: 'ntcoreJNIShared', linkage: 'shared'
|
||||
lib project: ':cscore', library: 'cscoreJNIShared', linkage: 'shared'
|
||||
project(':hal').addHalDependency(binary, 'shared')
|
||||
project(':hal').addHalJniDependency(binary)
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
lib project: ':cameraserver', library: 'cameraserver', linkage: 'shared'
|
||||
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
||||
nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
||||
} else {
|
||||
def systemArch = getCurrentArch()
|
||||
if (binary.targetPlatform.name == systemArch) {
|
||||
simProjects.each {
|
||||
lib project: ":simulation:$it", library: it, linkage: 'shared'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
myRobotCppStatic(NativeExecutableSpec) {
|
||||
@@ -179,18 +197,18 @@ model {
|
||||
}
|
||||
}
|
||||
binaries.all { binary ->
|
||||
lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'static'
|
||||
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'static'
|
||||
lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
|
||||
lib project: ':ntcore', library: 'ntcore', linkage: 'static'
|
||||
lib project: ':cscore', library: 'cscore', linkage: 'static'
|
||||
project(':hal').addHalDependency(binary, 'static')
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
lib project: ':cameraserver', library: 'cameraserver', linkage: 'static'
|
||||
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
||||
nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
||||
}
|
||||
lib project: ':wpilibOldCommands', library: 'wpilibOldCommands', linkage: 'static'
|
||||
lib project: ':wpilibNewCommands', library: 'wpilibNewCommands', linkage: 'static'
|
||||
lib project: ':wpilibc', library: 'wpilibc', linkage: 'static'
|
||||
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
|
||||
lib project: ':ntcore', library: 'ntcore', linkage: 'static'
|
||||
lib project: ':cscore', library: 'cscore', linkage: 'static'
|
||||
project(':hal').addHalDependency(binary, 'static')
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
|
||||
lib project: ':cameraserver', library: 'cameraserver', linkage: 'static'
|
||||
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
|
||||
nativeUtils.useRequiredLibrary(binary, 'netcomm_shared', 'chipobject_shared', 'visa_shared', 'ni_runtime_shared')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,6 +219,7 @@ model {
|
||||
description = "Run the myRobotCpp executable"
|
||||
def found = false
|
||||
def systemArch = getCurrentArch()
|
||||
def runTask = it
|
||||
c.each {
|
||||
if (it in NativeExecutableSpec && it.name == "myRobotCpp") {
|
||||
it.binaries.each {
|
||||
@@ -213,6 +232,32 @@ model {
|
||||
run.dependsOn it.tasks.install
|
||||
run.systemProperty 'java.library.path', filePath
|
||||
run.environment 'LD_LIBRARY_PATH', filePath
|
||||
|
||||
def installTask = it.tasks.install
|
||||
|
||||
def doFirstTask = {
|
||||
def extensions = '';
|
||||
installTask.installDirectory.get().getAsFile().eachFileRecurse {
|
||||
def name = it.name
|
||||
if (!(name.endsWith('.dll') || name.endsWith('.so') || name.endsWith('.dylib'))) {
|
||||
return
|
||||
}
|
||||
def file = it
|
||||
simProjects.each {
|
||||
if (name.startsWith(it) || name.startsWith("lib$it".toString())) {
|
||||
extensions += file.absolutePath + File.pathSeparator
|
||||
}
|
||||
}
|
||||
}
|
||||
if (extensions != '') {
|
||||
run.environment 'HALSIM_EXTENSIONS', extensions
|
||||
runTask.environment 'HALSIM_EXTENSIONS', extensions
|
||||
}
|
||||
}
|
||||
|
||||
runTask.doFirst doFirstTask
|
||||
run.doFirst doFirstTask
|
||||
|
||||
run.workingDir filePath
|
||||
|
||||
found = true
|
||||
|
||||
@@ -419,6 +419,6 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
runRobot(robotSupplier);
|
||||
}
|
||||
|
||||
System.exit(1);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user