Skip to content

Commit

Permalink
[hal] Add initial SystemServer support (#7463)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Dec 1, 2024
1 parent 82132c3 commit c51f65b
Show file tree
Hide file tree
Showing 39 changed files with 1,658 additions and 83 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/pregen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def main():
subprocess.run(
[sys.executable, f"{REPO_ROOT}/hal/generate_usage_reporting.py"], check=True
)
subprocess.run(
[
sys.executable,
f"{REPO_ROOT}/hal/generate_nanopb.py",
],
check=True,
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/ntcore/generate_topics.py"], check=True
)
Expand Down
2 changes: 1 addition & 1 deletion cscore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ model {
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib library: 'cscore', linkage: 'shared'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
Expand Down
2 changes: 1 addition & 1 deletion datalogtool/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
Expand Down
93 changes: 31 additions & 62 deletions developerRobot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,74 +64,63 @@ def simProjects = ['halsim_gui']

deploy {
targets {
roborio(RemoteTarget) {
directory = '/home/lvuser'
systemcore(RemoteTarget) {
directory = '/home/systemcore'
maxChannels = 4
locations {
ssh(SshDeployLocation) {
address = "172.22.11.2"
user = 'admin'
password = ''
address = "robot.local"
user = 'systemcore'
password = 'systemcorerules2027'
ipv6 = false
}
}

def remote = it

artifacts.registerFactory(WPIJREArtifact) {
return objects.newInstance(WPIJREArtifact, it, remote)
}

artifacts {
all {
predeploy << { ctx ->
ctx.execute('. /etc/profile.d/natinst-path.sh; /usr/local/frc/bin/frcKillRobot.sh -t 2> /dev/null')
ctx.execute("sed -i -e 's/\"exec /\"/' /usr/local/frc/bin/frcRunRobot.sh")
}
postdeploy << { ctx ->
ctx.execute("sync")
ctx.execute("ldconfig")
}
}

developerRobotCpp(NativeExecutableArtifact) {
libraryDirectory = '/usr/local/frc/third-party/lib'
libraryDirectory = '/home/systemcore/frc/third-party/lib'
def excludes = getLibraryFilter().getExcludes()
excludes.add('**/*.so.debug')
excludes.add('**/*.so.*.debug')
postdeploy << { ctx ->
ctx.execute("echo '/home/lvuser/developerRobotCpp' > /home/lvuser/robotCommand")
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/developerRobotCpp\"")
ctx.execute("echo '/home/systemcore/developerRobotCpp' > /home/systemcore/robotCommand")
ctx.execute("chmod +x /home/systemcore/robotCommand; chown systemcore /home/systemcore/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/systemcore/developerRobotCpp\"")
ctx.execute('chmod +x developerRobotCpp')
}
}

developerRobotCppStatic(NativeExecutableArtifact) {
libraryDirectory = '/usr/local/frc/third-party/lib'
libraryDirectory = '/home/systemcore/frc/third-party/lib'
postdeploy << { ctx ->
ctx.execute("echo '/home/lvuser/developerRobotCppStatic' > /home/lvuser/robotCommand")
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/lvuser/developerRobotCppStatic\"")
ctx.execute("echo '/home/systemcore/developerRobotCppStatic' > /home/systemcore/robotCommand")
ctx.execute("chmod +x /home/systemcore/robotCommand; chown systemcore /home/systemcore/robotCommand")
ctx.execute("setcap cap_sys_nice+eip \"/home/systemcore/developerRobotCppStatic\"")
ctx.execute('chmod +x developerRobotCppStatic')
}
}

developerRobotCppJava(NativeExecutableArtifact) {
libraryDirectory = '/usr/local/frc/third-party/lib'
libraryDirectory = '/home/systemcore/frc/third-party/lib'
def excludes = getLibraryFilter().getExcludes()
excludes.add('**/*.so.debug')
excludes.add('**/*.so.*.debug')
}

jre(WPIJREArtifact) {
}

developerRobotJava(JavaArtifact) {
jarTask = shadowJar
postdeploy << { ctx ->
ctx.execute("echo '/usr/local/frc/JRE/bin/java -XX:+UseSerialGC -Djava.library.path=/usr/local/frc/third-party/lib -Djava.lang.invoke.stringConcat=BC_SB -jar /home/lvuser/developerRobot-all.jar' > /home/lvuser/robotCommand")
ctx.execute("chmod +x /home/lvuser/robotCommand; chown lvuser /home/lvuser/robotCommand")
ctx.execute("echo '/usr/bin/java -XX:+UseG1GC -Djava.library.path=/home/systemcore/frc/third-party/lib -jar /home/systemcore/developerRobot-all.jar' > /home/systemcore/robotCommand")
ctx.execute("chmod +x /home/systemcore/robotCommand; chown systemcore /home/systemcore/robotCommand")
}
}
}
Expand All @@ -141,23 +130,23 @@ deploy {

tasks.register('deployJava') {
try {
dependsOn tasks.named('deployjreroborio')
dependsOn tasks.named('deploydeveloperRobotJavaroborio')
dependsOn tasks.named('deploydeveloperRobotCppJavaroborio') // Deploying shared C++ is how to get the Java shared libraries.
dependsOn tasks.named('deployjresystemcore')
dependsOn tasks.named('deploydeveloperRobotJavasystemcore')
dependsOn tasks.named('deploydeveloperRobotCppJavasystemcore') // Deploying shared C++ is how to get the Java shared libraries.
} catch (ignored) {
}
}

tasks.register('deployShared') {
try {
dependsOn tasks.named('deploydeveloperRobotCpproborio')
dependsOn tasks.named('deploydeveloperRobotCppsystemcore')
} catch (ignored) {
}
}

tasks.register('deployStatic') {
try {
dependsOn tasks.named('deploydeveloperRobotCppStaticroborio')
dependsOn tasks.named('deploydeveloperRobotCppStaticsystemcore')
} catch (ignored) {
}
}
Expand All @@ -179,10 +168,10 @@ model {
}
}
binaries.all { binary ->
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
if (binary.buildType.name == 'debug') {
deploy.targets.roborio.artifacts.developerRobotCpp.binary = binary
deploy.targets.roborio.artifacts.developerRobotCppJava.binary = binary
deploy.targets.systemcore.artifacts.developerRobotCpp.binary = binary
deploy.targets.systemcore.artifacts.developerRobotCppJava.binary = binary
}
}
lib project: ':apriltag', library: 'apriltag', linkage: 'shared'
Expand All @@ -201,14 +190,10 @@ model {
project(':hal').addHalJniDependency(binary)
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries')
} else {
def systemArch = getCurrentArch()
if (binary.targetPlatform.name == systemArch) {
simProjects.each {
lib project: ":simulation:$it", library: it, linkage: 'shared'
}
def systemArch = getCurrentArch()
if (binary.targetPlatform.name == systemArch) {
simProjects.each {
lib project: ":simulation:$it", library: it, linkage: 'shared'
}
}
}
Expand All @@ -229,9 +214,9 @@ model {
}
}
binaries.all { binary ->
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
if (binary.buildType.name == 'debug') {
deploy.targets.roborio.artifacts.developerRobotCppStatic.binary = binary
deploy.targets.systemcore.artifacts.developerRobotCppStatic.binary = binary
}
}
lib project: ':apriltag', library: 'apriltag', linkage: 'static'
Expand All @@ -244,9 +229,6 @@ model {
project(':hal').addHalDependency(binary, 'static')
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
if (binary.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(binary, 'ni_link_libraries', 'ni_runtime_libraries')
}
}
}
}
Expand Down Expand Up @@ -302,20 +284,6 @@ model {
}
}
}
installAthena(Task) {
$.binaries.each {
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'developerRobotCpp') {
dependsOn it.tasks.install
}
}
}
installAthenaStatic(Task) {
$.binaries.each {
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.roborio && it.component.name == 'developerRobotCppStatic') {
dependsOn it.tasks.install
}
}
}

installSystemCore(Task) {
$.binaries.each {
Expand All @@ -324,6 +292,7 @@ model {
}
}
}

installSystemCoreStatic(Task) {
$.binaries.each {
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore && it.component.name == 'developerRobotCppStatic') {
Expand Down
6 changes: 3 additions & 3 deletions glass/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
Expand All @@ -112,7 +112,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
Expand Down Expand Up @@ -153,7 +153,7 @@ model {
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore) {
it.buildable = false
return
}
Expand Down
1 change: 1 addition & 0 deletions hal/.styleguide
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ generatedFileExclude {
hal/src/main/native/systemcore/ctre/
hal/src/main/native/systemcore/rev/
UsageReporting\.h$
src/generated/main/native/cpp
}

modifiableFileExclude {
Expand Down
23 changes: 22 additions & 1 deletion hal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ cc_library(
visibility = ["//hal:__subpackages__"],
)

cc_library(
name = "mrc_cc_headers",
hdrs = glob(["src/mrc/include/**"]),
includes = ["src/mrc/include"],
strip_include_prefix = "src/mrc/include",
visibility = ["//hal:__subpackages__"],
)

cc_library(
name = "generated_mrc_cc_headers",
hdrs = glob(["src/generated/main/native/cpp/mrc/protobuf/**"]),
includes = ["src/generated/main/native/cpp/mrc/protobuf"],
strip_include_prefix = "src/generated/main/native/cpp/mrc/protobuf",
visibility = ["//hal:__subpackages__"],
)

filegroup(
name = "generated_java",
srcs = glob(["src/generated/main/java/**/*.java"]),
Expand Down Expand Up @@ -39,7 +55,10 @@ filegroup(
cc_library(
name = "wpiHal.static",
srcs = [":platform-srcs"] + glob(
["src/main/native/cpp/**"],
[
"src/main/native/cpp/**",
"src/generated/main/native/cpp/**",
],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
Expand All @@ -48,6 +67,8 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":generated_cc_headers",
":mrc_cc_headers",
":generated_mrc_cc_headers",
"//wpiutil:wpiutil.static",
] + HAL_DEPS,
)
Expand Down
44 changes: 43 additions & 1 deletion hal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ ext {
exportedHeaders {
srcDir 'src/main/native/include'
srcDir generatedHeaders
srcDir 'src/mrc/include'
}
}
}
} else {
} else {
it.sources {
simCpp(CppSourceSet) {
source {
Expand All @@ -49,10 +50,22 @@ ext {
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 = {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
Expand Down Expand Up @@ -107,3 +120,32 @@ model {
}
}
}

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
}
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'
}
}
}
}
Loading

0 comments on commit c51f65b

Please sign in to comment.