Skip to content

Commit

Permalink
[hal] Initial SystemCore empty HAL (#7454)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Nov 30, 2024
1 parent 847c312 commit 82132c3
Show file tree
Hide file tree
Showing 100 changed files with 20,131 additions and 77 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ jobs:
fail-fast: false
matrix:
include:
- container: wpilib/roborio-cross-ubuntu:2024-22.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
# - container: wpilib/roborio-cross-ubuntu:2025-22.04
# artifact-name: Athena
# build-options: "-Ponlylinuxathena"
- container: wpilib/systemcore-cross-ubuntu:2025-22.04
artifact-name: SystemCore
build-options: "-Ponlylinuxsystemcore"
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
artifact-name: Arm32
build-options: "-Ponlylinuxarm32"
Expand Down
92 changes: 46 additions & 46 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,52 +42,52 @@ jobs:
development
retention-days: 1

Robotbuilder:
name: "Build - RobotBuilder"
needs: [build-artifacts]
runs-on: ubuntu-22.04
env:
DISPLAY: ':10'
steps:
- uses: actions/checkout@v4
with:
repository: wpilibsuite/robotbuilder
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: MavenArtifacts
- name: Patch RobotBuilder to use local development
run: cd src/main/resources/export && echo "wpi.maven.useLocal = false" >> java/build.gradle && echo "wpi.maven.useFrcMavenLocalDevelopment = true" >> java/build.gradle && echo "wpi.versions.wpilibVersion = '$YEAR.424242.+'" >> java/build.gradle && echo "wpi.versions.wpimathVersion = '$YEAR.424242.+'" >> java/build.gradle && echo "wpi.maven.useLocal = false" >> cpp/build.gradle && echo "wpi.maven.useFrcMavenLocalDevelopment = true" >> cpp/build.gradle && echo "wpi.versions.wpilibVersion = '$YEAR.424242.+'" >> cpp/build.gradle && echo "wpi.versions.wpimathVersion = '$YEAR.424242.+'" >> cpp/build.gradle
- name: Install and run xvfb
run: sudo apt-get update && sudo apt-get install -y xvfb && Xvfb $DISPLAY &
- name: Move artifacts
run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Build RobotBuilder with Gradle
run: ./gradlew build test --tests 'robotbuilder.exporters.*' -x htmlSanityCheck -PbuildServer -PreleaseMode ; cat build/test-results/test/TEST-robotbuilder.exporters.*.xml ;
- name: Summarize RobotBuilder Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
build/test-results/test/TEST*.xml
check_run: false
comment_mode: off
- uses: actions/upload-artifact@v4
if: always()
with:
name: RobotBuilderTestResults
path: |
build/reports/
- uses: actions/upload-artifact@v4
with:
name: RobotBuilder Build
path: |
build/libs/
retention-days: 7
# Robotbuilder:
# name: "Build - RobotBuilder"
# needs: [build-artifacts]
# runs-on: ubuntu-22.04
# env:
# DISPLAY: ':10'
# steps:
# - uses: actions/checkout@v4
# with:
# repository: wpilibsuite/robotbuilder
# fetch-depth: 0
# - uses: actions/download-artifact@v4
# with:
# name: MavenArtifacts
# - name: Patch RobotBuilder to use local development
# run: cd src/main/resources/export && echo "wpi.maven.useLocal = false" >> java/build.gradle && echo "wpi.maven.useFrcMavenLocalDevelopment = true" >> java/build.gradle && echo "wpi.versions.wpilibVersion = '$YEAR.424242.+'" >> java/build.gradle && echo "wpi.versions.wpimathVersion = '$YEAR.424242.+'" >> java/build.gradle && echo "wpi.maven.useLocal = false" >> cpp/build.gradle && echo "wpi.maven.useFrcMavenLocalDevelopment = true" >> cpp/build.gradle && echo "wpi.versions.wpilibVersion = '$YEAR.424242.+'" >> cpp/build.gradle && echo "wpi.versions.wpimathVersion = '$YEAR.424242.+'" >> cpp/build.gradle
# - name: Install and run xvfb
# run: sudo apt-get update && sudo apt-get install -y xvfb && Xvfb $DISPLAY &
# - name: Move artifacts
# run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
# - uses: actions/setup-java@v4
# with:
# java-version: 17
# distribution: 'temurin'
# - name: Build RobotBuilder with Gradle
# run: ./gradlew build test --tests 'robotbuilder.exporters.*' -x htmlSanityCheck -PbuildServer -PreleaseMode ; cat build/test-results/test/TEST-robotbuilder.exporters.*.xml ;
# - name: Summarize RobotBuilder Test Results
# uses: EnricoMi/publish-unit-test-result-action@v2
# if: always()
# with:
# files: |
# build/test-results/test/TEST*.xml
# check_run: false
# comment_mode: off
# - uses: actions/upload-artifact@v4
# if: always()
# with:
# name: RobotBuilderTestResults
# path: |
# build/reports/
# - uses: actions/upload-artifact@v4
# with:
# name: RobotBuilder Build
# path: |
# build/libs/
# retention-days: 7

Shuffleboard:
name: "Build - Shuffleboard"
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
plugins {
id 'base'
id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2023.0.1'
id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2020.2'
id 'edu.wpi.first.wpilib.repositories.WPILibRepositoriesPlugin' version '2025.0'
id 'edu.wpi.first.NativeUtils' apply false
id 'edu.wpi.first.GradleJni' version '1.1.0'
id 'edu.wpi.first.GradleVsCode'
Expand All @@ -32,6 +32,7 @@ allprojects {
url = 'https://frcmaven.wpi.edu/artifactory/ex-mvn'
}
}
wpilibRepositories.use2027Repos()
if (project.hasProperty('releaseMode')) {
wpilibRepositories.addAllReleaseRepositories(it)
} else {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ repositories {
}
}
dependencies {
implementation "edu.wpi.first:native-utils:2025.3.0"
implementation "edu.wpi.first:native-utils:2025.7.1"
}
3 changes: 2 additions & 1 deletion cscore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ model {
enableCheckTask true
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.systemcore)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm32)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm64)

Expand Down Expand Up @@ -177,7 +178,7 @@ model {
components {
examplesMap.each { key, value ->
if (key == "usbviewer") {
if (!project.hasProperty('onlylinuxathena')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxsystemcore')) {
"${key}"(NativeExecutableSpec) {
targetBuildTypes 'debug'
binaries.all {
Expand Down
2 changes: 1 addition & 1 deletion datalogtool/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.internal.os.OperatingSystem

if (project.hasProperty('onlylinuxathena')) {
if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxsystemcore')) {
return;
}

Expand Down
15 changes: 15 additions & 0 deletions developerRobot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -316,5 +316,20 @@ model {
}
}
}

installSystemCore(Task) {
$.binaries.each {
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore && it.component.name == 'developerRobotCpp') {
dependsOn it.tasks.install
}
}
}
installSystemCoreStatic(Task) {
$.binaries.each {
if (it in NativeExecutableBinarySpec && it.targetPlatform.name == nativeUtils.wpi.platforms.systemcore && it.component.name == 'developerRobotCppStatic') {
dependsOn it.tasks.install
}
}
}
}
}
2 changes: 1 addition & 1 deletion fieldImages/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.internal.os.OperatingSystem

if (project.hasProperty('onlylinuxathena')) {
if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxsystemcore')) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion glass/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import org.gradle.internal.os.OperatingSystem

if (project.hasProperty('onlylinuxathena')) {
if (project.hasProperty('onlylinuxathena') || project.hasProperty('onlylinuxsystemcore')) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions hal/.styleguide
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ generatedFileExclude {
hal/src/main/native/athena/frccansae/
hal/src/main/native/athena/visa/
hal/src/main/native/include/ctre/
hal/src/main/native/systemcore/ctre/
hal/src/main/native/systemcore/rev/
UsageReporting\.h$
}

Expand Down
19 changes: 18 additions & 1 deletion hal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@ ext {
}
}
}
} else {
} else 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
}
}
}
} else {
it.sources {
simCpp(CppSourceSet) {
source {
Expand Down Expand Up @@ -57,6 +70,10 @@ cppSourcesZip {
into '/athena'
}

from('src/main/native/systemcore') {
into '/systemcore'
}

from('src/main/native/sim') {
into '/sim'
}
Expand Down
4 changes: 3 additions & 1 deletion hal/src/main/native/include/hal/HALBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ HAL_ENUM(HAL_RuntimeType) {
/** roboRIO 2.0 */
HAL_Runtime_RoboRIO2,
/** Simulation runtime */
HAL_Runtime_Simulation
HAL_Runtime_Simulation,
/** SystemCore */
HAL_Runtime_SystemCore,
};

#ifdef __cplusplus
Expand Down
58 changes: 58 additions & 0 deletions hal/src/main/native/systemcore/Accelerometer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

#include "hal/Accelerometer.h"

#include <stdint.h>

#include <cassert>
#include <cstdio>
#include <memory>

#include "HALInitializer.h"
#include "hal/HAL.h"

using namespace hal;

namespace hal::init {
void InitializeAccelerometer() {}
} // namespace hal::init

namespace hal {

/**
* Initialize the accelerometer.
*/
static void initializeAccelerometer() {
hal::init::CheckInit();
}

} // namespace hal

extern "C" {

void HAL_SetAccelerometerActive(HAL_Bool active) {
initializeAccelerometer();
}

void HAL_SetAccelerometerRange(HAL_AccelerometerRange range) {
initializeAccelerometer();
}

double HAL_GetAccelerometerX(void) {
initializeAccelerometer();
return 0.0;
}

double HAL_GetAccelerometerY(void) {
initializeAccelerometer();
return 0.0;
}

double HAL_GetAccelerometerZ(void) {
initializeAccelerometer();
return 0.0;
}

} // extern "C"
84 changes: 84 additions & 0 deletions hal/src/main/native/systemcore/AddressableLED.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

#include "hal/AddressableLED.h"

#include <cstring>
#include <memory>

#include <fmt/format.h>

#include "HALInitializer.h"
#include "hal/Errors.h"

using namespace hal;

namespace hal::init {
void InitializeAddressableLED() {}
} // namespace hal::init

extern "C" {

HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
HAL_DigitalHandle outputPort, int32_t* status) {
hal::init::CheckInit();

*status = HAL_HANDLE_ERROR;
return HAL_kInvalidHandle;
}

void HAL_FreeAddressableLED(HAL_AddressableLEDHandle handle) {}

void HAL_SetAddressableLEDOutputPort(HAL_AddressableLEDHandle handle,
HAL_DigitalHandle outputPort,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}

void HAL_SetAddressableLEDLength(HAL_AddressableLEDHandle handle,
int32_t length, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}

static_assert(sizeof(HAL_AddressableLEDData) == sizeof(uint32_t),
"LED Data must be 32 bit");

void HAL_WriteAddressableLEDData(HAL_AddressableLEDHandle handle,
const struct HAL_AddressableLEDData* data,
int32_t length, int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}

void HAL_SetAddressableLEDBitTiming(HAL_AddressableLEDHandle handle,
int32_t highTime0NanoSeconds,
int32_t lowTime0NanoSeconds,
int32_t highTime1NanoSeconds,
int32_t lowTime1NanoSeconds,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}

void HAL_SetAddressableLEDSyncTime(HAL_AddressableLEDHandle handle,
int32_t syncTimeMicroSeconds,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}

void HAL_StartAddressableLEDOutput(HAL_AddressableLEDHandle handle,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}

void HAL_StopAddressableLEDOutput(HAL_AddressableLEDHandle handle,
int32_t* status) {
*status = HAL_HANDLE_ERROR;
return;
}
} // extern "C"
Loading

0 comments on commit 82132c3

Please sign in to comment.