Skip to content

Commit

Permalink
Merge branch 'wpilibsuite:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel1464 authored Oct 5, 2024
2 parents 148fd34 + f856c05 commit c971a81
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/comment-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
distribution: 'temurin'
java-version: 17
- name: Install wpiformat
run: pip3 install wpiformat==2024.41
run: pip3 install wpiformat==2024.42
- name: Run wpiformat
run: wpiformat
- name: Run spotlessApply
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
python-version: '3.10'
- name: Install wpiformat
run: pip3 install wpiformat==2024.41
run: pip3 install wpiformat==2024.42
- name: Run
run: wpiformat
- name: Check output
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
with:
python-version: '3.10'
- name: Install wpiformat
run: pip3 install wpiformat==2024.41
run: pip3 install wpiformat==2024.42
- name: Create compile_commands.json
run: |
./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
Expand Down
161 changes: 161 additions & 0 deletions .github/workflows/sentinel-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Sentinel Build (No Cache)

on:
workflow_dispatch:
schedule:
- cron: "15 3 * * Sat" # 11:15PM EST every Friday

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
build-docker:
if: (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main') || github.event_name != 'schedule'
strategy:
fail-fast: false
matrix:
include:
- container: wpilib/roborio-cross-ubuntu:2024-22.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
artifact-name: Arm32
build-options: "-Ponlylinuxarm32"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/ubuntu-base:22.04
artifact-name: Linux
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ubuntu-22.04
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build with Gradle
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/work -w /work -e GITHUB_REF -e CI
run: df . && rm -f semicolon_delimited_script && echo $GITHUB_REF && ./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
- name: Check free disk space
run: df .
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: build/allOutputs

build-host:
if: (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main') || github.event_name != 'schedule'
env:
MACOSX_DEPLOYMENT_TARGET: 13.3
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
artifact-name: Win64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win64Release
architecture: x64
build-options: "-PciReleaseOnly"
task: "copyAllOutputs"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: WinArm64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly -Pbuildwinarm64 -Ponlywindowsarm64"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: WinArm64Release
architecture: x64
build-options: "-PciReleaseOnly -Pbuildwinarm64 -Ponlywindowsarm64"
task: "copyAllOutputs"
outputs: "build/allOutputs"
- os: macOS-14
artifact-name: macOS
architecture: aarch64
task: "build"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win32
architecture: x86
task: ":ntcoreffi:build"
outputs: "ntcoreffi/build/outputs"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
architecture: ${{ matrix.architecture }}
- name: Import Developer ID Certificate
uses: wpilibsuite/import-signing-certificate@v2
with:
certificate-data: ${{ secrets.APPLE_CERTIFICATE_DATA }}
certificate-passphrase: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
keychain-password: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Set Keychain Lock Timeout
run: security set-keychain-settings -lut 3600
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Set Java Heap Size
run: sed -i 's/-Xmx2g/-Xmx1g/g' gradle.properties
if: matrix.artifact-name == 'Win32'
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Check disk free space pre-cleanup (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- name: Cleanup disk space
# CodeQL: 5G
# go: 748M
# Android: 12G
run: |
rm -rf /Users/runner/hostedtoolcache/CodeQL
rm -rf /Users/runner/hostedtoolcache/go
rm -rf /Users/runner/Library/Android
if: matrix.os == 'macOS-14'
- name: Check disk free space post-cleanup (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- name: Build with Gradle
run: ./gradlew ${{ matrix.task }} -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
- name: Sign Libraries with Developer ID
run: ./gradlew copyAllOutputs -PbuildServer -PskipJavaFormat -PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} ${{ matrix.build-options }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Check disk free space (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.outputs }}
5 changes: 2 additions & 3 deletions wpilibc/src/main/native/include/frc/Alert.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ class Alert {
Alert(std::string_view group, std::string_view text, AlertType type);

/**
* Sets whether the alert should currently be displayed. When activated, the
* alert text will also be sent to the console. This method can be safely
* called periodically.
* Sets whether the alert should currently be displayed. This method can be
* safely called periodically.
*
* @param active Whether to display the alert.
*/
Expand Down
8 changes: 7 additions & 1 deletion wpilibc/src/main/native/include/frc/RobotController.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ struct CANStatus {
int transmitErrorCount;
};

enum RadioLEDState { kOff = 0, kGreen = 1, kRed = 2, kOrange = 3 };
/** State for the radio led. */
enum RadioLEDState {
kOff = 0, ///< Off.
kGreen = 1, ///< Green.
kRed = 2, ///< Red.
kOrange = 3 ///< Orange.
};

class RobotController {
public:
Expand Down
4 changes: 2 additions & 2 deletions wpilibj/src/main/java/edu/wpi/first/wpilibj/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public Alert(String group, String text, AlertType type) {
}

/**
* Sets whether the alert should currently be displayed. When activated, the alert text will also
* be sent to the console. This method can be safely called periodically.
* Sets whether the alert should currently be displayed. This method can be safely called
* periodically.
*
* @param active Whether to display the alert.
*/
Expand Down
23 changes: 22 additions & 1 deletion wpiunits/generate_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,18 @@ def output(outPath, outfn, contents):
"Velocity": {
"base_unit": "unit()",
"generics": {"D": {"extends": "Unit"}},
"multiply": {},
"multiply": {
"Time": {
"implementation": inspect.cleandoc(
"""
@Override
default Measure<D> times(Time multiplier) {
return (Measure<D>) unit().numerator().ofBaseUnits(baseUnitMagnitude() * multiplier.baseUnitMagnitude());
}
"""
)
}
},
"divide": {},
},
"Voltage": {"base_unit": "Volts", "multiply": {"Current": "Power"}, "divide": {}},
Expand Down Expand Up @@ -310,6 +321,15 @@ def mtou(measure_name):
return re.sub(regex, "\\1Unit\\2", measure_name)


def indent(multiline_string, indentation):
"""
Indents a multiline string by `indentation` number of spaces
"""
return "\n".join(
list(map(lambda line: " " * indentation + line, multiline_string.split("\n")))
)


def main():

dirname, _ = os.path.split(os.path.abspath(__file__))
Expand All @@ -331,6 +351,7 @@ def main():
"generics_list": generics_list,
"generics_usage": generics_usage,
"mtou": mtou,
"indent": indent,
}

for unit_name in UNIT_CONFIGURATIONS:
Expand Down
4 changes: 4 additions & 0 deletions wpiunits/src/generate/main/java/Measure-interface.java.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ public interface {{ helpers['type_decl'](name) }} extends Measure<{{ helpers['mt
}
{% else %}
{% if unit in config[name]['multiply'] %}
{%- if 'implementation' in config[name]['multiply'][unit] -%}
{{ helpers['indent'](config[name]['multiply'][unit]['implementation'], 2) }}
{%- else %}
@Override
default {{ config[name]['multiply'][unit] }} times({{ unit }} multiplier) {
return {{ config[config[name]['multiply'][unit]]['base_unit'] }}.of(baseUnitMagnitude() * multiplier.baseUnitMagnitude());
}
{%- endif %}
{% else %}
@Override
default Mult<{{ helpers['mtou'](name) }}, {{ helpers['mtou'](unit) }}> times({{ unit }} multiplier) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.

package edu.wpi.first.units.measure;

import static edu.wpi.first.units.Units.Milliseconds;
import static edu.wpi.first.units.Units.Seconds;
import static edu.wpi.first.units.Units.Volts;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;

import edu.wpi.first.units.Measure;
import edu.wpi.first.units.VelocityUnit;
import edu.wpi.first.units.VoltageUnit;
import org.junit.jupiter.api.Test;

class VelocityTest {
@Test
void velocityTimesTimeReturnsDivisor() {
var velocity = VelocityUnit.combine(Volts, Seconds).of(123);
var time = Milliseconds.of(100);
Measure<VoltageUnit> result = velocity.times(time);
// Compile-time test - would fail to compile if the return type was Mult or Measure<?>

assertInstanceOf(Voltage.class, result);
}
}

0 comments on commit c971a81

Please sign in to comment.