Compare commits

...

63 Commits

Author SHA1 Message Date
Jade
638d265b33 [commands] Add a warning to schedule docs (NFC) (#7073)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-09 23:31:40 -08:00
Elliot Scher
6125227836 [wpical] Add JSON Combiner (#7640)
This new feature allows users to combine multiple Apriltag layouts. This can be useful for fields where the apriltags are split into two or more sections: (red/blue side, grouped together by task, etc.)
2025-01-09 23:30:17 -08:00
HarryXChen
e37c35746a [wpimath] Implement Translation3d.RotateAround (#7661) 2025-01-09 20:31:34 -08:00
oh-yes-0-fps
995bc98ccf [epilogue] Revert "Add a measure's symbol to its name when logged by Epilogue (#7535)" (#7652)
This reverts commit 469bb3290d.

The approach used has issues due to the fact unit symbols often have a literal / in them,
which causes issues with NT topic visualization.

A better approach would be to use topic metadata.
2025-01-07 12:35:10 -07:00
Matt
2de03c9601 [cscore] Use frame time in Linux UsbCameraImpl (#7609) 2025-01-07 09:33:20 -07:00
Ryan Heuer
8e459a4f2a [glass] Field2d: Fix custom image padding to maintain aspect ratio (#7648) 2025-01-06 21:16:14 -08:00
Peter Johnson
58d7c07343 [fieldImages] Use rendered image (#7650)
Source: https://www.chiefdelphi.com/t/4k-field-image-2025-reefscape/478797
2025-01-06 21:15:39 -08:00
Peter Johnson
9b08f0244c [wpiutil] SignalObject: Fix move operator= (#7649) 2025-01-06 20:11:34 -08:00
sciencewhiz
7032de3d5d [glass] Field2D: Change field picker to show JSONs first (#7643)
Too many people don't realize that glass/simgui field2d can load
pathweaver JSON field files since it's hidden.
2025-01-05 22:36:14 -08:00
Kevin-OConnor
159e18ce05 [fieldImages] Flip 2025 Field Image (#7638)
Original image was flipped when it should have been rotated.
2025-01-04 11:37:44 -08:00
Peter Johnson
257d0e0824 [fieldImages] Add 2025 Reefscape to Fields, make default (#7635) 2025-01-04 11:14:27 -08:00
Kevin-OConnor
b65f159c3f Add 2025 field and apriltags (#7634)
Column in Field Drawings is labeled X-Rotation, but I believe it should be Y-Rotation so have reflected that here. We'll fix in a TU if this is correct.
2025-01-04 10:14:34 -08:00
Tyler Veness
11a0c36737 [wpimath] Make Rotation2d member initialization order match declaration order (#7632) 2025-01-03 22:44:17 -08:00
Wispy
17a03514ba [glass, simgui] Fix minimum widths of windows (#7604) 2025-01-01 15:20:35 -08:00
Jade
9ebc4b32ae [commands] Undeprecate deferredProxy (#7417)
This changes the way deferred proxy is implemented to not use the
deprecated ProxyCommand constructor.

This function serves a good purpose that should be kept IMO. The
constructor was confusing but this is just good syntactic sugar over
`defer(() -> supplier.get().asProxy())`.

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-01 15:11:39 -08:00
Elliot Scher
ce60bd5035 [wpical] Add support for new Apriltags (ID 16-22) (#7619) 2025-01-01 14:53:58 -08:00
Jade
468a3c6d95 [apriltag] Add kDefaultField to C++ (#7618)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-01 14:34:51 -08:00
Peter Johnson
4350ea769c [build] Bump ni-libraries to 2025.2.0 (#7617) 2024-12-31 20:50:50 -08:00
sciencewhiz
83397392f4 [hal] Update Usage Reporting to match 2025v2 image numbers (#7616) 2024-12-31 20:24:26 -08:00
Tyler Veness
786d22049b [wpilibc] Rename DCMotorSim getters (#7614) 2024-12-31 16:48:45 -08:00
Dustin Spicuzza
86137c49f5 [wpilibc] DCMotorSim: Add setAngle/setAngularVelocity (parity with Java) (#7613) 2024-12-31 14:30:16 -08:00
Tyler Veness
4edf52d3b6 [wpilibc] Clean up Joystick::GetDirection() (#7612) 2024-12-31 13:31:05 -08:00
Gold856
a41fb460a9 Update ThirdPartyNotices.txt (#7608) 2024-12-30 20:16:10 -06:00
sciencewhiz
d4985b8ba0 [ci] Build RobotPy in tools workflow (#6800) 2024-12-29 23:47:45 -06:00
sciencewhiz
1538370034 Update license year to 2025 (#7607) 2024-12-29 23:46:38 -06:00
Carl Hauser
eef1bf33de [wpilib] Fix SmartDashboard.setDefault* docs (NFC) (#6490)
Fix incorrect comments related to NT SetDefault* methods across multiple components
2024-12-29 18:41:29 -06:00
ハイドラント
78b6d61e88 [commands] Use factories and decorators in Command tests (#7006) 2024-12-29 10:45:17 -06:00
David Vo
e7dd5dca82 [wpilibj] TimedRobot: Squash ErrorProne warnings (#7605) 2024-12-28 21:01:43 -08:00
Matt
a27df8ec24 [cscore] Sink: add ability to get most recent frame instead of waiting (#7572)
This allows more control over frame dropping.
2024-12-28 20:44:48 -08:00
Elliot Scher
85507a6c65 [wpical] Add WPIcal: Field Calibration Tool (#6915)
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
Co-authored-by: Jade <spacey-sooty@proton.me>
Co-authored-by: Matthew Morley <matthew.morley.ca@gmail.com>
2024-12-28 20:24:32 -08:00
Peter Johnson
b74f84f876 [upstream_utils] Add imgui_demo.cpp (#7602)
This has useful debugging functions; it was left out of the change
from the separate thirdparty repo.
2024-12-28 19:33:55 -08:00
Joseph Eng
54e9c76e03 [wpilibc] Fully qualify names in error macros (#7601) 2024-12-28 16:59:19 -06:00
sciencewhiz
203487a6aa [wpimath] improve LTVUnicycleController docs (NFC) (#7599)
Document the states and inputs so it isn't necessary to look at the code
Fix max velocity throws doc
2024-12-28 16:03:47 -06:00
Tyler Veness
57344ef3b2 [wpimath] Use ct_matrix instead of Eigen/LU for determinant in headers (#7600)
This caught a bug in ct_matrix's 3x3 determinant.
2024-12-28 16:03:29 -06:00
sciencewhiz
46d401553e [wpilib] Add Koors40 motor controller (#7469) 2024-12-27 15:04:43 -06:00
Tyler Veness
9e63dcfb16 [ci] Install wpiformat into venv (#7596) 2024-12-26 21:59:48 -06:00
Gold856
934bf7bf05 [build] CMake: Make NO_WERROR also work on MSVC (#7594) 2024-12-26 21:33:20 -06:00
Nicholas Armstrong
fe49cbe429 [wpimath] Remove Units class from Elevator and Arm Feedforwards (#7570) 2024-12-26 20:21:19 -06:00
Tyler Veness
0470e51569 [upstream_utils] Upgrade to fmt 11.1.0 (#7593)
Usage of FMT_STRING() was removed since it caused compilation failures,
and https://fmt.dev/11.1/api/#compile-time-checks says it's no longer
necessary for compile-time format strings.

Fixes #7592.
2024-12-26 19:14:02 -06:00
Tyler Veness
72fdca3507 [examples] Fix C-style cast warning from cpplint (#7591) 2024-12-25 23:33:41 -06:00
sciencewhiz
dee50bf500 [ci] Validate gradle wrapper inline (#7582)
Updates to v4 of the gradle wrapper validation action
2024-12-24 17:42:07 -08:00
Tyler Veness
939a9ceee1 [upstream_utils] Upgrade to LLVM 19.1.6 (#7101) 2024-12-24 17:40:31 -08:00
Gold856
b670a59b5b [build] Fix imgui libraries not being published (#7575) 2024-12-23 19:05:06 -08:00
Brendan Raykoff
9b12ddb595 [upstream_utils] Patch protobuf to remove deprecated ATOMIC_VAR_INIT (#7585) 2024-12-23 16:14:15 -06:00
Peter Johnson
76625fa0f9 [build] cmake: Build wpiutil dev executable (#7578) 2024-12-22 15:03:33 -08:00
Peter Johnson
bb130b67b8 [wpiutil] DataLogWriter: Don't crash on file open error (#7579) 2024-12-22 15:03:12 -08:00
Wispy
469bb3290d [epilogue] Add a measure's symbol to its name when logged by Epilogue (#7535) 2024-12-22 13:35:31 -08:00
Tyler Veness
02a0adc653 [wpimath] Add Rotation3d rotation vector getter (#7564)
The code churn in Java is just making the function order consistent
between languages.
2024-12-22 13:34:51 -08:00
Ryan Blue
0c99073b94 Use std::bit_cast (#7567)
Backport #7492

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-12-22 13:34:16 -08:00
Tyler Veness
d631fa8e4b [wpimath] Fix algorithm link (NFC) (#7569)
Fixes #7568.
2024-12-22 13:33:07 -08:00
Tyler Veness
19d385d149 [ci] Upgrade to wpiformat 2024.51 (#7573) 2024-12-22 13:44:40 -06:00
Ryan Blue
d0cc7e4eca [ci] Disable cleaner cron job (#7574) 2024-12-21 19:08:48 -08:00
Kaya
807dffed35 [commands] Fix C++ iterator invalidation bug (#7554)
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
Co-authored-by: Ryan Blue <13878527+rzblue@users.noreply.github.com>
2024-12-20 00:32:24 -06:00
Ryan Blue
f46c81cfe3 [ci] Delete comment command (#7566) 2024-12-19 20:53:17 -06:00
PJ Reiniger
9ccd73108b [bazel] MVP for building wpilibc + commands framework (#7231) 2024-12-18 22:00:40 -08:00
Gold856
38d8929f48 [ci] Move pregen steps into a composite action (#7474)
This ensures that complete uniformity in how the generation scripts are run. All dependencies and scripts are set up in the exact same way, each time. The old pregen_all script has been removed and moved into the composite action to ensure failed scripts will always fail the job.
2024-12-18 21:59:47 -08:00
Jan-Felix Abellera
cc73236a06 [hal] Add CAN device type for servo controllers (#7556) 2024-12-18 21:57:34 -08:00
Jade
f8720a628c [commands] Fix proxy command deprecation docs (#7396)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
2024-12-18 21:57:11 -08:00
Jade
156bd71fef [developerRobot] Workaround Eclipse annotation processor issues (#7537)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-12-18 09:46:31 -07:00
Ryan Blue
6e44187ff6 [build] cmake: Add wpilibNewCommands and apriltag to developerRobot (#7557) 2024-12-18 09:35:23 -07:00
Jan-Felix Abellera
e2cbdf9718 [hal] Add usage reporting for REV Servo Hub (#7555) 2024-12-18 09:34:45 -07:00
Jade
66cce1835c [ci] Add Buildifier to /format comment command (#7480)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-12-18 09:31:02 -07:00
sciencewhiz
6fe5da7289 [examples] Fix example json for SimpleDifferentialDriveSimulation (NFC) (#7561)
Uses LTVUnicycleController now instead of RAMSETE.
2024-12-18 09:20:31 -07:00
366 changed files with 48307 additions and 6251 deletions

65
.github/actions/pregen/action.yml vendored Normal file
View File

@@ -0,0 +1,65 @@
name: 'Setup and run pregeneration'
description: 'Sets up the dependencies needed to generate generated files and runs all generation scripts'
runs:
using: "composite"
steps:
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install jinja and protobuf
run: python -m pip install jinja2 protobuf grpcio-tools
shell: bash
- name: Install protobuf and perl dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler liblist-moreutils-perl
wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.3/protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
chmod +x protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
shell: bash
- name: Regenerate hal
run: ./hal/generate_usage_reporting.py
shell: bash
- name: Regenerate ntcore
run: ./ntcore/generate_topics.py
shell: bash
- name: Regenerate imgui
run: |
./thirdparty/imgui_suite/generate_fonts.sh
./thirdparty/imgui_suite/generate_gl3w.py
shell: bash
- name: Regenerate HIDs
run: |
./wpilibc/generate_hids.py
./wpilibj/generate_hids.py
./wpilibNewCommands/generate_hids.py
shell: bash
- name: Regenerate PWM motor controllers
run: |
./wpilibc/generate_pwm_motor_controllers.py
./wpilibj/generate_pwm_motor_controllers.py
shell: bash
- name: Regenerate mrcal minimath
run: ./wpical/generate_mrcal.py
shell: bash
- name: Regenerate wpimath
run: |
./wpimath/generate_nanopb.py
./wpimath/generate_numbers.py
./wpimath/generate_quickbuf.py --quickbuf_plugin protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
shell: bash
- name: Regenerate wpiunits
run: ./wpiunits/generate_units.py
shell: bash
- name: Regenerate wpiutil nanopb
run: ./wpiutil/generate_nanopb.py
shell: bash

View File

@@ -2,8 +2,6 @@ name: Artifactory Nightly Cleanup
on:
workflow_dispatch:
schedule:
- cron: '15 2 * * *'
jobs:
wpilib-mvn-development_unused_cleanup:

View File

@@ -1,101 +0,0 @@
name: Comment Commands
on:
issue_comment:
types: [ created ]
jobs:
format:
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/format')
runs-on: ubuntu-22.04
steps:
- name: React Rocket
uses: actions/github-script@v7
with:
script: |
const {owner, repo} = context.issue
github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
content: "rocket",
});
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}
- name: Fetch all history and metadata
run: |
git checkout -b pr
git branch -f main origin/main
- name: Checkout PR
run: |
gh pr checkout $NUMBER
env:
GITHUB_TOKEN: "${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}"
NUMBER: ${{ github.event.issue.number }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Install wpiformat
run: pip3 install wpiformat==2024.50
- name: Run wpiformat
run: wpiformat
- name: Run spotlessApply
run: ./gradlew spotlessApply
- name: Commit
run: |
# Set credentials
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Commit
git commit -am "Formatting fixes"
git push
pregen:
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/pregen')
runs-on: ubuntu-22.04
steps:
- name: React Rocket
uses: actions/github-script@v7
with:
script: |
const {owner, repo} = context.issue
github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
content: "rocket",
});
- uses: actions/checkout@v4
with:
token: ${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}
- name: Checkout PR
run: |
gh pr checkout $NUMBER
env:
GITHUB_TOKEN: "${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}"
NUMBER: ${{ github.event.issue.number }}
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install jinja
run: python -m pip install jinja2
- name: Install protobuf dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler && wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.3/protoc-gen-quickbuf-1.3.3-linux-x86_64.exe && chmod +x protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
- name: Regenerate all
run: ./.github/workflows/pregen_all.py --quickbuf_plugin=protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
- name: Commit
run: |
# Set credentials
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Commit
git commit -am "Regenerate pregenerated files"
git push

View File

@@ -20,6 +20,7 @@ jobs:
with:
fetch-depth: 0
persist-credentials: false
- uses: gradle/actions/wrapper-validation@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'

View File

@@ -18,9 +18,9 @@ def main():
for obj in data:
out_args = []
# Filter out -isystem flags that cause false positives
iter_args = iter(obj["arguments"])
for arg in iter_args:
# Filter out -isystem flags that cause false positives
if arg == "-isystem":
next_arg = next(iter_args)
@@ -28,6 +28,9 @@ def main():
# error: conflicting types for '_mm_prefetch' [clang-diagnostic-error]
if not next_arg.startswith("/usr/lib/gcc/"):
out_args += ["-isystem", next_arg]
# Replace GCC warning argument with one Clang recognizes
elif arg == "-Wno-maybe-uninitialized":
out_args.append("-Wno-uninitialized")
else:
out_args.append(arg)

View File

@@ -1,14 +0,0 @@
name: "Validate Gradle Wrapper"
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v3

View File

@@ -7,6 +7,13 @@ concurrency:
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
build-docker:
strategy:
fail-fast: false
@@ -26,6 +33,7 @@ jobs:
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ubuntu-22.04
needs: [validation]
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
@@ -109,6 +117,7 @@ jobs:
outputs: "ntcoreffi/build/outputs"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
needs: [validation]
steps:
- uses: actions/checkout@v4
with:
@@ -181,6 +190,7 @@ jobs:
build-documentation:
name: "Build - Documentation"
runs-on: ubuntu-22.04
needs: [validation]
steps:
- uses: actions/checkout@v4
with:

View File

@@ -11,6 +11,13 @@ concurrency:
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
wpiformat:
name: "wpiformat"
runs-on: ubuntu-22.04
@@ -27,9 +34,11 @@ jobs:
with:
python-version: '3.12'
- name: Install wpiformat
run: pip3 install wpiformat==2024.50
run: |
python -m venv ${{ runner.temp }}/wpiformat
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2024.51
- name: Run
run: wpiformat
run: ${{ runner.temp }}/wpiformat/bin/wpiformat
- name: Check output
run: git --no-pager diff --exit-code HEAD
- name: Generate diff
@@ -51,6 +60,7 @@ jobs:
tidy:
name: "clang-tidy"
runs-on: ubuntu-22.04
needs: [validation]
container: wpilib/ubuntu-base:22.04
steps:
- uses: actions/checkout@v4
@@ -66,21 +76,24 @@ jobs:
with:
python-version: '3.12'
- name: Install wpiformat
run: pip3 install wpiformat==2024.50
run: |
python -m venv ${{ runner.temp }}/wpiformat
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2024.51
- name: Create compile_commands.json
run: |
./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
./.github/workflows/fix_compile_commands.py build/TargetedCompileCommands/linuxx86-64release/compile_commands.json
./.github/workflows/fix_compile_commands.py build/TargetedCompileCommands/linuxx86-64debug/compile_commands.json
- name: List changed files
run: wpiformat -list-changed-files
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -list-changed-files
- name: Run clang-tidy release
run: wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64release -vv
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64release -vv
- name: Run clang-tidy debug
run: wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64debug -vv
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64debug -vv
javaformat:
name: "Java format"
runs-on: ubuntu-22.04
needs: [validation]
container: wpilib/ubuntu-base:22.04
steps:
- uses: actions/checkout@v4
@@ -114,6 +127,7 @@ jobs:
documentation:
name: "Documentation"
runs-on: ubuntu-22.04
needs: [validation]
steps:
- uses: actions/checkout@v4
with:

View File

@@ -1,78 +0,0 @@
#!/usr/bin/env python3
import argparse
import subprocess
import sys
from pathlib import Path
def main():
script_path = Path(__file__).resolve()
REPO_ROOT = script_path.parent.parent.parent
parser = argparse.ArgumentParser()
parser.add_argument(
"--quickbuf_plugin",
help="Path to the quickbuf protoc plugin",
required=True,
)
args = parser.parse_args()
subprocess.run(
[sys.executable, f"{REPO_ROOT}/hal/generate_usage_reporting.py"], check=True
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/ntcore/generate_topics.py"], check=True
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/wpimath/generate_numbers.py"], check=True
)
subprocess.run(
[
sys.executable,
f"{REPO_ROOT}/wpimath/generate_quickbuf.py",
f"--quickbuf_plugin={args.quickbuf_plugin}",
],
check=True,
)
subprocess.run(
[
sys.executable,
f"{REPO_ROOT}/wpimath/generate_nanopb.py",
],
check=True,
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/wpiunits/generate_units.py"], check=True
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/wpilibc/generate_hids.py"], check=True
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/wpilibj/generate_hids.py"], check=True
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/wpilibNewCommands/generate_hids.py"], check=True
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/wpilibc/generate_pwm_motor_controllers.py"],
check=True,
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/wpilibj/generate_pwm_motor_controllers.py"],
check=True,
)
subprocess.run(
[
sys.executable,
f"{REPO_ROOT}/wpiutil/generate_nanopb.py",
],
check=True,
)
subprocess.run(
[sys.executable, f"{REPO_ROOT}/thirdparty/imgui_suite/generate_gl3w.py"],
check=True,
)
subprocess.run(f"{REPO_ROOT}/thirdparty/imgui_suite/generate_fonts.sh", check=True)
if __name__ == "__main__":
main()

View File

@@ -18,16 +18,8 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install jinja and protobuf
run: python -m pip install jinja2 protobuf grpcio-tools
- name: Install protobuf dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler && wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.3/protoc-gen-quickbuf-1.3.3-linux-x86_64.exe && chmod +x protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
- name: Regenerate all
run: python ./.github/workflows/pregen_all.py --quickbuf_plugin protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
- name: Run pregen
uses: ./.github/actions/pregen
- name: Add untracked files to index so they count as changes
run: git add -A
- name: Check output

View File

@@ -10,6 +10,13 @@ concurrency:
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
build-docker:
if: (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main') || github.event_name != 'schedule'
strategy:
@@ -30,6 +37,7 @@ jobs:
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ubuntu-22.04
needs: [validation]
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
@@ -101,6 +109,7 @@ jobs:
outputs: "ntcoreffi/build/outputs"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
needs: [validation]
steps:
- uses: actions/checkout@v4
with:

View File

@@ -29,12 +29,13 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/actions/wrapper-validation@v4
- name: Build WPILib with Gradle
uses: addnab/docker-run-action@v3
with:
image: wpilib/roborio-cross-ubuntu:2025-22.04
options: -v ${{ github.workspace }}:/work -w /work -e GITHUB_REF -e CI -e DISPLAY
run: df . && rm -f semicolon_delimited_script && ./gradlew :wpilibc:publish :wpilibj:publish :wpilibNewCommands:publish :hal:publish :cameraserver:publish :ntcore:publish :cscore:publish :wpimath:publish :wpinet:publish :wpiutil:publish :apriltag:publish :wpiunits:publish :simulation:halsim_gui:publish :simulation:halsim_ds_socket:publish :fieldImages:publish :epilogue-processor:publish :epilogue-runtime:publish :thirdparty:googletest:publish -x test -x Javadoc -x doxygen --build-cache && cp -r /root/releases/maven/development /work
run: df . && rm -f semicolon_delimited_script && ./gradlew :wpilibc:publish :wpilibj:publish :wpilibNewCommands:publish :hal:publish :cameraserver:publish :ntcore:publish :cscore:publish :wpimath:publish :wpinet:publish :wpiutil:publish :apriltag:publish :wpiunits:publish :simulation:halsim_gui:publish :simulation:halsim_ds_socket:publish :simulation:halsim_ws_server:publish :simulation:halsim_ws_client:publish :simulation:halsim_xrp:publish :fieldImages:publish :romiVendordep:publish :xrpVendordep:publish :epilogue-processor:publish :epilogue-runtime:publish :thirdparty:googletest:publish -x test -x Javadoc -x doxygen --build-cache && cp -r /root/releases/maven/development /work
- uses: actions/upload-artifact@v4
with:
name: MavenArtifacts
@@ -148,3 +149,58 @@ jobs:
path: |
build/allOutputs/
retention-days: 7
Robotpy:
name: "Build - Robotpy"
needs: [build-artifacts]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: robotpy/mostrobotpy
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: MavenArtifacts
- name: Move artifacts
run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
- uses: actions/setup-python@v5
with:
python-version: 3.13
#
# Setup build caching
#
- name: Set ccache size
shell: bash
id: ccache
run: echo "MAX_SIZE=500M" >> $GITHUB_OUTPUT
- name: Setup ccache
# uses: hendrikmuhs/ccache-action@v1.2.10
uses: robotpy/ccache-action@fork
with:
key: ubuntu-22.04-3.13
variant: ccache
max-size: ${{ steps.ccache.outputs.max_size }}
- name: Install deps
shell: bash
run: |
python -m pip --disable-pip-version-check install -r rdev_requirements.txt
- name: Install numpy (needed for stubgen but broken in raspbian CI)
shell: bash
run: |
python -m pip --disable-pip-version-check install numpy
- name: Patch RobotPy rdev to use local development
run: git config user.name github-actions && git config user.email github-actions@github.com && set -- ~/releases/maven/development/edu/wpi/first/wpiutil/wpiutil-cpp/*/ ; wpilibversion=$(basename $1) && echo $wpilibversion && sed --regexp-extended -i 's@(wpilib_bin_url =).*@\1 \"file:\/\/'"$HOME"'\/releases\/maven\/development"@' rdev.toml && sed --regexp-extended -i 's/(wpilib_bin_version =).*/\1 \"'"$wpilibversion"'\"/' rdev.toml && ./rdev.sh update-pyproject --commit
- name: Build + test wheels
shell: bash
run: |
./rdev.sh ci run
env:
RPYBUILD_STRIP_LIBPYTHON: "1"
RPYBUILD_CC_LAUNCHER: ccache

View File

@@ -76,6 +76,7 @@ cmake_dependent_option(
)
option(WITH_CSCORE "Build cscore (needs OpenCV)" ON)
option(WITH_NTCORE "Build ntcore" ON)
option(WITH_WPICAL "Build wpical" OFF)
option(WITH_WPIMATH "Build wpimath" ON)
cmake_dependent_option(
WITH_WPIUNITS
@@ -142,6 +143,11 @@ if(WITH_DOCS)
include(AddDoxygenDocs)
add_doxygen_docs()
endif()
if(WITH_WPICAL)
find_package(Ceres CONFIG REQUIRED)
endif()
find_package(LIBSSH CONFIG 0.7.1)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
@@ -314,6 +320,9 @@ if(WITH_GUI)
add_subdirectory(glass)
add_subdirectory(outlineviewer)
add_subdirectory(sysid)
if(WITH_WPICAL)
add_subdirectory(wpical)
endif()
if(LIBSSH_FOUND)
add_subdirectory(roborioteamnumbersetter)
add_subdirectory(datalogtool)

View File

@@ -1,4 +1,4 @@
Copyright (c) 2009-2024 FIRST and other WPILib contributors
Copyright (c) 2009-2025 FIRST and other WPILib contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -59,6 +59,8 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen
On macOS ARM, run `softwareupdate --install-rosetta`. This is necessary to be able to use the macOS x86 roboRIO toolchain on ARM.
On linux, run `sudo apt install gfortran`. This is necessary to be able to build WPIcal on linux platforms.
## Setup
Clone the WPILib repository and follow the instructions above for installing any required tooling. The build process uses versioning information from git. Downloading the source is not sufficient to run the build.

View File

@@ -15,7 +15,8 @@ licenses, and/or restrictions:
Program Locations
------- ---------
Google Test gtest
Google Test thirdparty/googletest/include
thirdparty/googletest/src
LLVM wpiutil/src/main/native/thirdparty/llvm
wpiutil/src/test/native/cpp/llvm/
JSON for Modern C++ wpiutil/src/main/native/thirdparty/json
@@ -33,17 +34,28 @@ popper.js wpinet/src/main/native/resources/popper-*
units wpimath/src/main/native/include/units/
Eigen wpimath/src/main/native/thirdparty/eigen/include/
StackWalker wpiutil/src/main/native/windows/StackWalker.*
GHC filesystem wpiutil/src/main/native/thirdparty/include/wpi/ghc/
Team 254 Library wpilibj/src/main/java/edu/wpi/first/wpilibj/spline/SplineParameterizer.java
wpilibj/src/main/java/edu/wpi/first/wpilibj/trajectory/TrajectoryParameterizer.java
wpilibc/src/main/native/include/spline/SplineParameterizer.h
wpilibc/src/main/native/include/trajectory/TrajectoryParameterizer.h
wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp
Team 254 Library wpimath/src/main/java/edu/wpi/first/math/spline/SplineParameterizer.java
wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryParameterizer.java
wpimath/src/main/native/include/frc/spline/SplineParameterizer.h
wpimath/src/main/native/include/frc/trajectory/TrajectoryParameterizer.h
wpimath/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp
Portable File Dialogs wpigui/src/main/native/include/portable-file-dialogs.h
V8 export-template wpiutil/src/main/native/include/wpi/SymbolExports.h
GCEM wpimath/src/main/native/thirdparty/gcem/include/
Sleipnir wpimath/src/main/native/thirdparty/sleipnir
Debugging wpiutil/src/main/native/thirdparty/debugging
argparse wpiutil/src/main/native/thirdparty/argparse/include/wpi/argparse.h
apriltag apriltag/src/main/native/thirdparty/apriltag
glfw thirdparty/imgui_suite/glfw
Dear ImGui thirdparty/imgui_suite/imgui
implot thirdparty/imgui_suite/implot
memory wpiutil/src/main/native/thirdparty/memory
nanopb wpiutil/src/main/native/thirdparty/nanopb
protobuf wpiutil/src/main/native/thirdparty/protobuf
mrcal wpical/src/main/native/thirdparty/mrcal
libdogleg wpical/src/main/native/thirdparty/libdogleg
Additionally, glfw, memory, and nanopb were all modified for use in WPILib.
==============================================================================
Google Test License
@@ -462,7 +474,7 @@ limitations under the License.
==============================================================================
MPacks License
MPack License
==============================================================================
The MIT License (MIT)
@@ -1078,33 +1090,6 @@ and/or modify it under the terms of the Do What the **** You Want
to Public License, Version 2, as published by the WTFPL Task Force.
See http://www.wtfpl.net/ for more details.
======================
Boost Software License
======================
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
======
fmtlib
======
@@ -1136,29 +1121,6 @@ of this Software are embedded into a machine-executable object form of such
source code, you may redistribute such embedded portions in such object form
without including the above copyright and permission notices.
==============
GHC filesystem
==============
Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==================
V8 export-template
==================
@@ -1251,3 +1213,492 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================
argparse License
================
Copyright (c) 2018 Pranav Srinivas Kumar <pranav.srinivas.kumar@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================
apriltag License
================
BSD 2-Clause License
Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
============
gl3w License
============
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
============
glfw License
============
Copyright (c) 2002-2006 Marcus Geelnard
Copyright (c) 2006-2019 Camilla Löwy
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would
be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
==================
Dear ImGui License
==================
The MIT License (MIT)
Copyright (c) 2014-2024 Omar Cornut
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============
implot License
==============
MIT License
Copyright (c) 2020 Evan Pezent
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============
memory License
==============
Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but
is not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any
source distribution.
==============
nanopb License
==============
Copyright (c) 2011 Petteri Aimonen <jpa at nanopb.mail.kapsi.fi>
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held liable
for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
================
protobuf License
================
Copyright 2008 Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Code generated by the Protocol Buffer compiler is owned by the owner
of the input file used when generating it. This code is not
standalone and requires a support library to be linked with it. This
support library is itself covered by the above license.
===========
stb License
===========
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=============
mrcal License
=============
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright (c) 2017-2023 California Institute of Technology ("Caltech"). U.S.
Government sponsorship acknowledged. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=================
libdogleg License
=================
Copyright 2011 Oblong Industries 2017 Dima Kogan <dima@secretsauce.net>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
The full text of the license is available at http://www.gnu.org/licenses

View File

@@ -35,8 +35,8 @@ maven_install(
# Download toolchains
http_archive(
name = "rules_bzlmodrio_toolchains",
sha256 = "2ef1cafce7f4fd4e909bb5de8b0dc771a934646afd55d5f100ff31f6b500df98",
url = "https://github.com/wpilibsuite/rules_bzlmodRio_toolchains/releases/download/2024-1.bcr1/rules_bzlmodRio_toolchains-2024-1.bcr1.tar.gz",
sha256 = "fe267e2af53c1def1e962700a9aeda9e8fdfa9fb46b72167c615ec0e25447dd6",
url = "https://github.com/wpilibsuite/rules_bzlmodRio_toolchains/releases/download/2025-1/rules_bzlmodRio_toolchains-2025-1.tar.gz",
)
load("@rules_bzlmodrio_toolchains//:maven_deps.bzl", "setup_legacy_setup_toolchains_dependencies")
@@ -71,6 +71,12 @@ register_toolchains(
"@local_bullseye_64//:macos",
"@local_bullseye_64//:linux",
"@local_bullseye_64//:windows",
"@local_bookworm_32//:macos",
"@local_bookworm_32//:linux",
"@local_bookworm_32//:windows",
"@local_bookworm_64//:macos",
"@local_bookworm_64//:linux",
"@local_bookworm_64//:windows",
)
setup_legacy_setup_jdk_dependencies()
@@ -87,8 +93,8 @@ setup_legacy_bzlmodrio_ni_cpp_dependencies()
http_archive(
name = "bzlmodrio-opencv",
sha256 = "5314cce05b49451a46bf3e3140fc401342e53d5f3357612ed4473e59bb616cba",
url = "https://github.com/wpilibsuite/bzlmodRio-opencv/releases/download/2024.4.8.0-4.bcr1/bzlmodRio-opencv-2024.4.8.0-4.bcr1.tar.gz",
sha256 = "4f4a607956ca8555618736c3058dd96e09d02df19e95088c1e352d2319fd70c7",
url = "https://github.com/wpilibsuite/bzlmodRio-opencv/releases/download/2025.4.10.0-2/bzlmodRio-opencv-2025.4.10.0-2.tar.gz",
)
load("@bzlmodrio-opencv//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_opencv_cpp_dependencies")
@@ -98,3 +104,16 @@ setup_legacy_bzlmodrio_opencv_cpp_dependencies()
load("@bzlmodrio-opencv//:maven_java_deps.bzl", "setup_legacy_bzlmodrio_opencv_java_dependencies")
setup_legacy_bzlmodrio_opencv_java_dependencies()
http_archive(
name = "build_bazel_apple_support",
sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80",
url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz",
)
load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)
apple_support_dependencies()

112
apriltag/BUILD.bazel Normal file
View File

@@ -0,0 +1,112 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("@rules_python//python:defs.bzl", "py_binary")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")
cc_library(
name = "thirdparty-apriltag",
srcs = glob(["src/main/native/thirdparty/apriltag/src/**"]),
hdrs = glob(["src/main/native/thirdparty/apriltag/include/**"]),
copts = select({
"@bazel_tools//src/conditions:darwin": [
"-Wno-format-nonliteral",
"-Wno-gnu-zero-variadic-macro-arguments",
"-Wno-uninitialized",
"-Wno-sign-compare",
"-Wno-type-limits",
],
"@bazel_tools//src/conditions:windows": [
"/wd4005",
"/wd4018",
"/wd4244",
"/wd4267",
"/wd4996",
],
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": [
"-Wno-format-nonliteral",
"-Wno-maybe-uninitialized",
"-Wno-sign-compare",
"-Wno-type-limits",
],
}),
includes = ["src/main/native/thirdparty/apriltag/include/common"],
strip_include_prefix = "src/main/native/thirdparty/apriltag/include",
visibility = ["//visibility:public"],
)
generate_resources(
name = "generate-resources",
namespace = "frc",
prefix = "APRILTAG",
resource_files = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
)
cc_library(
name = "apriltag.static",
srcs = [":generate-resources"] + glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
defines = ["WPILIB_EXPORTS"],
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
":thirdparty-apriltag",
"//wpimath:wpimath.static",
"//wpiutil:wpiutil.static",
],
)
java_library(
name = "apriltag-java",
srcs = glob(["src/main/java/**/*.java"]),
resource_strip_prefix = "apriltag/src/main/native/resources",
resources = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
deps = [
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",
"@bzlmodrio-opencv//libraries/java/opencv",
"@maven//:com_fasterxml_jackson_core_jackson_annotations",
"@maven//:com_fasterxml_jackson_core_jackson_core",
"@maven//:com_fasterxml_jackson_core_jackson_databind",
],
)
cc_test(
name = "apriltag-cpp-test",
size = "small",
srcs = glob(["src/test/native/cpp/**"]),
tags = [
"no-asan",
],
deps = [
":apriltag.static",
"//thirdparty/googletest:googletest.static",
],
)
cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":apriltag.static",
],
)
java_binary(
name = "DevMain-Java",
srcs = ["src/dev/java/edu/wpi/first/apriltag/DevMain.java"],
main_class = "edu.wpi.first.apriltag.DevMain",
deps = [
":apriltag-java",
],
)
py_binary(
name = "convert_apriltag_layouts",
srcs = ["convert_apriltag_layouts.py"],
tags = ["manual"],
)

View File

@@ -7,10 +7,11 @@ AprilTagFields expects.
The input CSV has the following format:
* Columns: ID, X, Y, Z, Rotation
* Columns: ID, X, Y, Z, Z Rotation, Y Rotation
* ID is a positive integer
* X, Y, and Z are decimal inches
* Rotation is yaw in degrees
* Z Rotation is yaw in degrees
* Y Rotation is pitch in degrees
The values come from a table in the layout marking diagram (e.g.,
https://firstfrc.blob.core.windows.net/frc2024/FieldAssets/2024LayoutMarkingDiagram.pdf).
@@ -48,13 +49,14 @@ def main():
x = float(row[1])
y = float(row[2])
z = float(row[3])
rotation = float(row[4])
zRotation = float(row[4])
yRotation = float(row[5])
# Turn yaw into quaternion
q = geometry.Rotation3d(
units.radians(0.0),
units.radians(0.0),
units.degreesToRadians(rotation),
units.radians(0),
units.degreesToRadians(yRotation),
units.degreesToRadians(zRotation),
).getQuaternion()
json_data["tags"].append(

View File

@@ -13,13 +13,15 @@ public enum AprilTagFields {
/** 2023 Charged Up. */
k2023ChargedUp("2023-chargedup.json"),
/** 2024 Crescendo. */
k2024Crescendo("2024-crescendo.json");
k2024Crescendo("2024-crescendo.json"),
/** 2025 Reefscape. */
k2025Reefscape("2025-reefscape.json");
/** Base resource directory. */
public static final String kBaseResourceDir = "/edu/wpi/first/apriltag/";
/** Alias to the current game. */
public static final AprilTagFields kDefaultField = k2024Crescendo;
public static final AprilTagFields kDefaultField = k2025Reefscape;
/** Resource filename. */
public final String m_resourceFile;

View File

@@ -133,6 +133,7 @@ namespace frc {
std::string_view GetResource_2022_rapidreact_json();
std::string_view GetResource_2023_chargedup_json();
std::string_view GetResource_2024_crescendo_json();
std::string_view GetResource_2025_reefscape_json();
} // namespace frc
@@ -148,6 +149,9 @@ AprilTagFieldLayout AprilTagFieldLayout::LoadField(AprilTagField field) {
case AprilTagField::k2024Crescendo:
fieldString = GetResource_2024_crescendo_json();
break;
case AprilTagField::k2025Reefscape:
fieldString = GetResource_2025_reefscape_json();
break;
case AprilTagField::kNumFields:
throw std::invalid_argument("Invalid Field");
}

View File

@@ -20,6 +20,10 @@ enum class AprilTagField {
k2023ChargedUp,
/// 2024 Crescendo.
k2024Crescendo,
/// 2025 Reefscape.
k2025Reefscape,
/// Alias to the current game.
kDefaultField = k2025Reefscape,
// This is a placeholder for denoting the last supported field. This should
// always be the last entry in the enum and should not be used by users

View File

@@ -1,17 +0,0 @@
ID,X,Y,Z,Rotation
1,593.68,9.68,53.38,120
2,637.21,34.79,53.38,120
3,652.73,196.17,57.13,180
4,652.73,218.42,57.13,180
5,578.77,323.00,53.38,270
6,72.5,323.00,53.38,270
7,-1.50,218.42,57.13,0
8,-1.50,196.17,57.13,0
9,14.02,34.79,53.38,60
10,57.54,9.68,53.38,60
11,468.69,146.19,52.00,300
12,468.69,177.10,52.00,60
13,441.74,161.62,52.00,180
14,209.48,161.62,52.00,0
15,182.73,177.10,52.00,120
16,182.73,146.19,52.00,240
1 ID X Y Z Rotation
2 1 593.68 9.68 53.38 120
3 2 637.21 34.79 53.38 120
4 3 652.73 196.17 57.13 180
5 4 652.73 218.42 57.13 180
6 5 578.77 323.00 53.38 270
7 6 72.5 323.00 53.38 270
8 7 -1.50 218.42 57.13 0
9 8 -1.50 196.17 57.13 0
10 9 14.02 34.79 53.38 60
11 10 57.54 9.68 53.38 60
12 11 468.69 146.19 52.00 300
13 12 468.69 177.10 52.00 60
14 13 441.74 161.62 52.00 180
15 14 209.48 161.62 52.00 0
16 15 182.73 177.10 52.00 120
17 16 182.73 146.19 52.00 240

View File

@@ -0,0 +1,23 @@
ID,X,Y,Z,Z-Rotation,X-Rotation
1,657.37,25.8,58.5,126,0
2,657.37,291.2,58.5,234,0
3,455.15,317.15,51.25,270,0
4,365.2,241.64,73.54,0,30
5,365.2,75.39,73.54,0,30
6,530.49,130.17,12.13,300,0
7,546.87,158.5,12.13,0,0
8,530.49,186.83,12.13,60,0
9,497.77,186.83,12.13,120,0
10,481.39,158.5,12.13,180,0
11,497.77,130.17,12.13,240,0
12,33.51,25.8,58.5,54,0
13,33.51,291.2,58.5,306,0
14,325.68,241.64,73.54,180,30
15,325.68,75.39,73.54,180,30
16,235.73,-0.15,51.25,90,0
17,160.39,130.17,12.13,240,0
18,144,158.5,12.13,180,0
19,160.39,186.83,12.13,120,0
20,193.1,186.83,12.13,60,0
21,209.49,158.5,12.13,0,0
22,193.1,130.17,12.13,300,0
1 ID X Y Z Z-Rotation X-Rotation
2 1 657.37 25.8 58.5 126 0
3 2 657.37 291.2 58.5 234 0
4 3 455.15 317.15 51.25 270 0
5 4 365.2 241.64 73.54 0 30
6 5 365.2 75.39 73.54 0 30
7 6 530.49 130.17 12.13 300 0
8 7 546.87 158.5 12.13 0 0
9 8 530.49 186.83 12.13 60 0
10 9 497.77 186.83 12.13 120 0
11 10 481.39 158.5 12.13 180 0
12 11 497.77 130.17 12.13 240 0
13 12 33.51 25.8 58.5 54 0
14 13 33.51 291.2 58.5 306 0
15 14 325.68 241.64 73.54 180 30
16 15 325.68 75.39 73.54 180 30
17 16 235.73 -0.15 51.25 90 0
18 17 160.39 130.17 12.13 240 0
19 18 144 158.5 12.13 180 0
20 19 160.39 186.83 12.13 120 0
21 20 193.1 186.83 12.13 60 0
22 21 209.49 158.5 12.13 0 0
23 22 193.1 130.17 12.13 300 0

View File

@@ -0,0 +1,404 @@
{
"tags": [
{
"ID": 1,
"pose": {
"translation": {
"x": 16.697198,
"y": 0.65532,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": 0.4539904997395468,
"X": 0.0,
"Y": 0.0,
"Z": 0.8910065241883678
}
}
}
},
{
"ID": 2,
"pose": {
"translation": {
"x": 16.697198,
"y": 7.3964799999999995,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": -0.45399049973954675,
"X": -0.0,
"Y": 0.0,
"Z": 0.8910065241883679
}
}
}
},
{
"ID": 3,
"pose": {
"translation": {
"x": 11.560809999999998,
"y": 8.05561,
"z": 1.30175
},
"rotation": {
"quaternion": {
"W": -0.7071067811865475,
"X": -0.0,
"Y": 0.0,
"Z": 0.7071067811865476
}
}
}
},
{
"ID": 4,
"pose": {
"translation": {
"x": 9.276079999999999,
"y": 6.137656,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 0.9659258262890683,
"X": 0.0,
"Y": 0.25881904510252074,
"Z": 0.0
}
}
}
},
{
"ID": 5,
"pose": {
"translation": {
"x": 9.276079999999999,
"y": 1.914906,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 0.9659258262890683,
"X": 0.0,
"Y": 0.25881904510252074,
"Z": 0.0
}
}
}
},
{
"ID": 6,
"pose": {
"translation": {
"x": 13.474446,
"y": 3.3063179999999996,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.8660254037844387,
"X": -0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 7,
"pose": {
"translation": {
"x": 13.890498,
"y": 4.0259,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 8,
"pose": {
"translation": {
"x": 13.474446,
"y": 4.745482,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 9,
"pose": {
"translation": {
"x": 12.643358,
"y": 4.745482,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 10,
"pose": {
"translation": {
"x": 12.227305999999999,
"y": 4.0259,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 11,
"pose": {
"translation": {
"x": 12.643358,
"y": 3.3063179999999996,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.4999999999999998,
"X": -0.0,
"Y": 0.0,
"Z": 0.8660254037844387
}
}
}
},
{
"ID": 12,
"pose": {
"translation": {
"x": 0.851154,
"y": 0.65532,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": 0.8910065241883679,
"X": 0.0,
"Y": 0.0,
"Z": 0.45399049973954675
}
}
}
},
{
"ID": 13,
"pose": {
"translation": {
"x": 0.851154,
"y": 7.3964799999999995,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": -0.8910065241883678,
"X": -0.0,
"Y": 0.0,
"Z": 0.45399049973954686
}
}
}
},
{
"ID": 14,
"pose": {
"translation": {
"x": 8.272272,
"y": 6.137656,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 5.914589856893349e-17,
"X": -0.25881904510252074,
"Y": 1.5848095757158825e-17,
"Z": 0.9659258262890683
}
}
}
},
{
"ID": 15,
"pose": {
"translation": {
"x": 8.272272,
"y": 1.914906,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 5.914589856893349e-17,
"X": -0.25881904510252074,
"Y": 1.5848095757158825e-17,
"Z": 0.9659258262890683
}
}
}
},
{
"ID": 16,
"pose": {
"translation": {
"x": 5.9875419999999995,
"y": -0.0038099999999999996,
"z": 1.30175
},
"rotation": {
"quaternion": {
"W": 0.7071067811865476,
"X": 0.0,
"Y": 0.0,
"Z": 0.7071067811865476
}
}
}
},
{
"ID": 17,
"pose": {
"translation": {
"x": 4.073905999999999,
"y": 3.3063179999999996,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.4999999999999998,
"X": -0.0,
"Y": 0.0,
"Z": 0.8660254037844387
}
}
}
},
{
"ID": 18,
"pose": {
"translation": {
"x": 3.6576,
"y": 4.0259,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 19,
"pose": {
"translation": {
"x": 4.073905999999999,
"y": 4.745482,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 20,
"pose": {
"translation": {
"x": 4.904739999999999,
"y": 4.745482,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 21,
"pose": {
"translation": {
"x": 5.321046,
"y": 4.0259,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 22,
"pose": {
"translation": {
"x": 4.904739999999999,
"y": 3.3063179999999996,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.8660254037844387,
"X": -0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
}
],
"field": {
"length": 17.548,
"width": 8.052
}
}

View File

@@ -1,6 +1,22 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
cc_library(
name = "cameraserver.static",
srcs = glob(["src/main/native/cpp/**"]),
hdrs = glob(["src/main/native/include/**/*"]),
includes = [
"cpp",
"src/main/native/include",
],
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//cscore:cscore.static",
"//ntcore:ntcore.static",
],
)
java_library(
name = "cameraserver-java",
srcs = glob(["src/main/java/**/*.java"]),
@@ -16,10 +32,21 @@ java_library(
],
)
cc_test(
name = "cameraserver-cpp-test",
size = "small",
srcs = glob(["src/test/native/**"]),
deps = [
":cameraserver.static",
"//thirdparty/googletest:googletest.static",
],
)
cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":cameraserver.static",
],
)

View File

@@ -14,18 +14,20 @@ macro(wpilib_target_warnings target)
target_compile_options(${target} PRIVATE ${WARNING_FLAGS})
else()
target_compile_options(
${target}
PRIVATE
/wd4146
/wd4244
/wd4251
/wd4267
/wd4324
/WX
/D_CRT_SECURE_NO_WARNINGS
${WPILIB_TARGET_WARNINGS}
set(WARNING_FLAGS
/wd4146
/wd4244
/wd4251
/wd4267
/wd4324
/D_CRT_SECURE_NO_WARNINGS
${WPILIB_TARGET_WARNINGS}
)
if(NOT NO_WERROR)
set(WARNING_FLAGS ${WARNING_FLAGS} /WX)
endif()
target_compile_options(${target} PRIVATE ${WARNING_FLAGS})
endif()
# Suppress C++-specific OpenCV warning; C compiler rejects it with an error

View File

@@ -1,5 +1,76 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
WIN_SRCS = glob([
"src/main/native/windows/**/*.cpp",
"src/main/native/windows/**/*.h",
])
LINUX_SRCS = glob([
"src/main/native/linux/**/*.cpp",
"src/main/native/linux/**/*.h",
])
MAC_SRCS = glob(["src/main/native/osx/**/*.cpp"])
filegroup(
name = "native-srcs",
srcs = select({
"@bazel_tools//src/conditions:darwin": MAC_SRCS,
"@bazel_tools//src/conditions:windows": WIN_SRCS,
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": LINUX_SRCS,
}),
)
objc_library(
name = "cscore-mac",
srcs = glob([
"src/main/native/objcpp/**/*.mm",
"src/main/native/cpp/*.h",
]),
hdrs = glob([
"src/main/native/include/**/*",
"src/main/native/objcpp/**/*.h",
]),
copts = [
"-std=c++20",
],
includes = [
"src/main/native/cpp",
"src/main/native/include",
"src/main/native/objcpp",
],
tags = ["manual"],
deps = [
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"@bzlmodrio-opencv//libraries/cpp/opencv",
],
)
cc_library(
name = "cscore.static",
srcs = [":native-srcs"] + glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
includes = [
"src/main/native/cpp",
"src/main/native/include",
],
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//wpinet:wpinet.static",
"//wpiutil:wpiutil.static",
"@bzlmodrio-opencv//libraries/cpp/opencv",
] + select({
"@bazel_tools//src/conditions:darwin": [":cscore-mac"],
"//conditions:default": [],
}),
)
java_library(
name = "cscore-java",
srcs = glob(["src/main/java/**/*.java"]),
@@ -10,6 +81,24 @@ java_library(
],
)
cc_test(
name = "cscore-cpp-test",
size = "small",
srcs = glob(["src/test/native/**"]),
deps = [
":cscore.static",
"//thirdparty/googletest:googletest.static",
],
)
cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":cscore.static",
],
)
java_binary(
name = "DevMain-Java",
srcs = ["src/dev/java/edu/wpi/first/cscore/DevMain.java"],

View File

@@ -185,7 +185,7 @@ model {
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib library: 'cscore', linkage: 'shared'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return

View File

@@ -6,6 +6,7 @@ package edu.wpi.first.cscore;
import edu.wpi.first.util.PixelFormat;
import edu.wpi.first.util.RawFrame;
import edu.wpi.first.util.TimestampSource;
import java.nio.ByteBuffer;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
@@ -44,7 +45,7 @@ public class CvSink extends ImageSink {
* Create a sink for accepting OpenCV images. grabFrame() must be called on the created sink to
* get each new image.
*
* @param name Source name (arbitrary unique identifier)
* @param name Sink name (arbitrary unique identifier)
* @param pixelFormat Source pixel format
*/
public CvSink(String name, PixelFormat pixelFormat) {
@@ -220,4 +221,22 @@ public class CvSink extends ImageSink {
}
return rv;
}
/**
* Get the last time a frame was grabbed. This uses the same time base as wpi::Now().
*
* @return Time in 1 us increments.
*/
public long getLastFrameTime() {
return m_frame.getTimestamp();
}
/**
* Get the time source for the timestamp the last frame was grabbed at.
*
* @return Time source
*/
public TimestampSource getLastFrameTimeSource() {
return m_frame.getTimestampSource();
}
}

View File

@@ -16,18 +16,22 @@
using namespace cs;
Frame::Frame(SourceImpl& source, std::string_view error, Time time)
Frame::Frame(SourceImpl& source, std::string_view error, Time time,
WPI_TimestampSource timeSrc)
: m_impl{source.AllocFrameImpl().release()} {
m_impl->refcount = 1;
m_impl->error = error;
m_impl->time = time;
m_impl->timeSource = timeSrc;
}
Frame::Frame(SourceImpl& source, std::unique_ptr<Image> image, Time time)
Frame::Frame(SourceImpl& source, std::unique_ptr<Image> image, Time time,
WPI_TimestampSource timeSrc)
: m_impl{source.AllocFrameImpl().release()} {
m_impl->refcount = 1;
m_impl->error.resize(0);
m_impl->time = time;
m_impl->timeSource = timeSrc;
m_impl->images.push_back(image.release());
}

View File

@@ -39,6 +39,7 @@ class Frame {
wpi::recursive_mutex mutex;
std::atomic_int refcount{0};
Time time{0};
WPI_TimestampSource timeSource{WPI_TIMESRC_UNKNOWN};
SourceImpl& source;
std::string error;
wpi::SmallVector<Image*, 4> images;
@@ -48,9 +49,11 @@ class Frame {
public:
Frame() noexcept = default;
Frame(SourceImpl& source, std::string_view error, Time time);
Frame(SourceImpl& source, std::string_view error, Time time,
WPI_TimestampSource timeSrc);
Frame(SourceImpl& source, std::unique_ptr<Image> image, Time time);
Frame(SourceImpl& source, std::unique_ptr<Image> image, Time time,
WPI_TimestampSource timeSrc);
Frame(const Frame& frame) noexcept : m_impl{frame.m_impl} {
if (m_impl) {
@@ -75,6 +78,9 @@ class Frame {
}
Time GetTime() const { return m_impl ? m_impl->time : 0; }
WPI_TimestampSource GetTimeSource() const {
return m_impl ? m_impl->timeSource : WPI_TIMESRC_UNKNOWN;
}
std::string_view GetError() const {
if (!m_impl) {

View File

@@ -50,7 +50,7 @@ inline void NamedLog(wpi::Logger& logger, unsigned int level, const char* file,
#define SLOG(level, format, ...) \
NamedLog(m_logger, level, __FILE__, __LINE__, GetName(), \
FMT_STRING(format) __VA_OPT__(, ) __VA_ARGS__)
format __VA_OPT__(, ) __VA_ARGS__)
#define SERROR(format, ...) \
SLOG(::wpi::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)

View File

@@ -63,6 +63,11 @@ uint64_t RawSinkImpl::GrabFrame(WPI_RawFrame& image) {
}
uint64_t RawSinkImpl::GrabFrame(WPI_RawFrame& image, double timeout) {
return GrabFrame(image, timeout, 0);
}
uint64_t RawSinkImpl::GrabFrame(WPI_RawFrame& image, double timeout,
uint64_t lastFrameTime) {
SetEnabled(true);
auto source = GetSource();
@@ -72,7 +77,7 @@ uint64_t RawSinkImpl::GrabFrame(WPI_RawFrame& image, double timeout) {
return 0;
}
auto frame = source->GetNextFrame(timeout); // blocks
auto frame = source->GetNextFrame(timeout, lastFrameTime); // blocks
if (!frame) {
// Bad frame; sleep for 20 ms so we don't consume all processor time.
std::this_thread::sleep_for(std::chrono::milliseconds(20));
@@ -115,6 +120,8 @@ uint64_t RawSinkImpl::GrabFrameImpl(WPI_RawFrame& rawFrame,
rawFrame.pixelFormat = newImage->pixelFormat;
rawFrame.size = newImage->size();
std::copy(newImage->data(), newImage->data() + rawFrame.size, rawFrame.data);
rawFrame.timestamp = incomingFrame.GetTime();
rawFrame.timestampSrc = incomingFrame.GetTimeSource();
return incomingFrame.GetTime();
}
@@ -183,6 +190,18 @@ uint64_t GrabSinkFrameTimeout(CS_Sink sink, WPI_RawFrame& image, double timeout,
return static_cast<RawSinkImpl&>(*data->sink).GrabFrame(image, timeout);
}
uint64_t GrabSinkFrameTimeoutLastTime(CS_Sink sink, WPI_RawFrame& image,
double timeout, uint64_t lastFrameTime,
CS_Status* status) {
auto data = Instance::GetInstance().GetSink(sink);
if (!data || (data->kind & SinkMask) == 0) {
*status = CS_INVALID_HANDLE;
return 0;
}
return static_cast<RawSinkImpl&>(*data->sink)
.GrabFrame(image, timeout, lastFrameTime);
}
} // namespace cs
extern "C" {
@@ -209,4 +228,13 @@ uint64_t CS_GrabRawSinkFrameTimeout(CS_Sink sink, struct WPI_RawFrame* image,
return cs::GrabSinkFrameTimeout(sink, *image, timeout, status);
}
uint64_t CS_GrabRawSinkFrameTimeoutWithFrameTime(CS_Sink sink,
struct WPI_RawFrame* image,
double timeout,
uint64_t lastFrameTime,
CS_Status* status) {
return cs::GrabSinkFrameTimeoutLastTime(sink, *image, timeout, lastFrameTime,
status);
}
} // extern "C"

View File

@@ -34,10 +34,15 @@ class RawSinkImpl : public SinkImpl {
uint64_t GrabFrame(WPI_RawFrame& frame);
uint64_t GrabFrame(WPI_RawFrame& frame, double timeout);
// Wait for a frame with a time other than lastFrameTime
uint64_t GrabFrame(WPI_RawFrame& frame, double timeout,
uint64_t lastFrameTime);
private:
void ThreadMain();
// Copies the image from incomingFrame into rawFrame, converting where
// necessary to the resolution of rawFrame
uint64_t GrabFrameImpl(WPI_RawFrame& rawFrame, Frame& incomingFrame);
std::atomic_bool m_active; // set to false to terminate threads

View File

@@ -29,7 +29,7 @@ SourceImpl::SourceImpl(std::string_view name, wpi::Logger& logger,
m_notifier(notifier),
m_telemetry(telemetry),
m_name{name} {
m_frame = Frame{*this, std::string_view{}, 0};
m_frame = Frame{*this, std::string_view{}, 0, WPI_TIMESRC_UNKNOWN};
}
SourceImpl::~SourceImpl() {
@@ -84,13 +84,19 @@ Frame SourceImpl::GetNextFrame() {
return m_frame;
}
Frame SourceImpl::GetNextFrame(double timeout) {
Frame SourceImpl::GetNextFrame(double timeout, Frame::Time lastFrameTime) {
std::unique_lock lock{m_frameMutex};
auto oldTime = m_frame.GetTime();
if (lastFrameTime == 0) {
lastFrameTime = m_frame.GetTime();
}
// Wait unitl m_frame has a timestamp other than lastFrameTime
if (!m_frameCv.wait_for(
lock, std::chrono::milliseconds(static_cast<int>(timeout * 1000)),
[=, this] { return m_frame.GetTime() != oldTime; })) {
m_frame = Frame{*this, "timed out getting frame", wpi::Now()};
[=, this] { return m_frame.GetTime() != lastFrameTime; })) {
m_frame = Frame{*this, "timed out getting frame", wpi::Now(),
WPI_TIMESRC_UNKNOWN};
}
return m_frame;
}
@@ -98,7 +104,7 @@ Frame SourceImpl::GetNextFrame(double timeout) {
void SourceImpl::Wakeup() {
{
std::scoped_lock lock{m_frameMutex};
m_frame = Frame{*this, std::string_view{}, 0};
m_frame = Frame{*this, std::string_view{}, 0, WPI_TIMESRC_UNKNOWN};
}
m_frameCv.notify_all();
}
@@ -458,7 +464,8 @@ std::unique_ptr<Image> SourceImpl::AllocImage(
}
void SourceImpl::PutFrame(VideoMode::PixelFormat pixelFormat, int width,
int height, std::string_view data, Frame::Time time) {
int height, std::string_view data, Frame::Time time,
WPI_TimestampSource timeSrc) {
if (pixelFormat == VideoMode::PixelFormat::kBGRA) {
// Write BGRA as BGR to save a copy
auto image =
@@ -475,10 +482,11 @@ void SourceImpl::PutFrame(VideoMode::PixelFormat pixelFormat, int width,
fmt::ptr(data.data()), data.size());
std::memcpy(image->data(), data.data(), data.size());
PutFrame(std::move(image), time);
PutFrame(std::move(image), time, timeSrc);
}
void SourceImpl::PutFrame(std::unique_ptr<Image> image, Frame::Time time) {
void SourceImpl::PutFrame(std::unique_ptr<Image> image, Frame::Time time,
WPI_TimestampSource timeSrc) {
// Update telemetry
m_telemetry.RecordSourceFrames(*this, 1);
m_telemetry.RecordSourceBytes(*this, static_cast<int>(image->size()));
@@ -486,7 +494,7 @@ void SourceImpl::PutFrame(std::unique_ptr<Image> image, Frame::Time time) {
// Update frame
{
std::scoped_lock lock{m_frameMutex};
m_frame = Frame{*this, std::move(image), time};
m_frame = Frame{*this, std::move(image), time, timeSrc};
}
// Signal listeners
@@ -497,7 +505,7 @@ void SourceImpl::PutError(std::string_view msg, Frame::Time time) {
// Update frame
{
std::scoped_lock lock{m_frameMutex};
m_frame = Frame{*this, msg, time};
m_frame = Frame{*this, msg, time, WPI_TIMESRC_UNKNOWN};
}
// Signal listeners

View File

@@ -13,6 +13,7 @@
#include <vector>
#include <wpi/Logger.h>
#include <wpi/RawFrame.h>
#include <wpi/condition_variable.h>
#include <wpi/json_fwd.h>
#include <wpi/mutex.h>
@@ -98,7 +99,8 @@ class SourceImpl : public PropertyContainer {
// Blocking function that waits for the next frame and returns it (with
// timeout in seconds). If timeout expires, returns empty frame.
Frame GetNextFrame(double timeout);
// If lastFrameTime==0, uses m_frame.GetTime() for lastFrameTime
Frame GetNextFrame(double timeout, Frame::Time lastFrameTime = 0);
// Force a wakeup of all GetNextFrame() callers by sending an empty frame.
void Wakeup();
@@ -140,8 +142,10 @@ class SourceImpl : public PropertyContainer {
std::string_view valueStr) override;
void PutFrame(VideoMode::PixelFormat pixelFormat, int width, int height,
std::string_view data, Frame::Time time);
void PutFrame(std::unique_ptr<Image> image, Frame::Time time);
std::string_view data, Frame::Time time,
WPI_TimestampSource timeSrc = WPI_TIMESRC_FRAME_DEQUEUE);
void PutFrame(std::unique_ptr<Image> image, Frame::Time time,
WPI_TimestampSource timeSrc = WPI_TIMESRC_FRAME_DEQUEUE);
void PutError(std::string_view msg, Frame::Time time);
// Notification functions for corresponding atomics

View File

@@ -8,6 +8,7 @@
#include <functional>
#include <opencv2/core/mat.hpp>
#include <wpi/RawFrame.h>
#include "cscore_oo.h"
#include "cscore_raw.h"
@@ -151,6 +152,44 @@ class CvSink : public ImageSink {
[[nodiscard]]
uint64_t GrabFrameNoTimeoutDirect(cv::Mat& image);
/**
* Wait for the next frame and get the image.
* Times out (returning 0) after timeout seconds.
* The provided image will have the pixelFormat this class was constructed
* with. The data is backed by data in the CvSink. It will be invalidated by
* any grabFrame*() call on the sink.
*
* <p>If lastFrameTime is provided and non-zero, the sink will fill image with
* the first frame from the source that is not equal to lastFrameTime. If
* lastFrameTime is zero, the time of the current frame owned by the CvSource
* is used, and this function will block until the connected CvSource provides
* a new frame.
*
* @return Frame time, or 0 on error (call GetError() to obtain the error
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]]
uint64_t GrabFrameDirectLastTime(cv::Mat& image, uint64_t lastFrameTime,
double timeout = 0.225);
/**
* Get the last time a frame was grabbed. This uses the same time base as
* wpi::Now().
*
* @return Time in 1 us increments.
*/
[[nodiscard]]
uint64_t LastFrameTime();
/**
* Get the time source for the timestamp the last frame was grabbed at.
*
* @return Time source
*/
[[nodiscard]]
WPI_TimestampSource LastFrameTimeSource();
private:
constexpr int GetCvFormat(WPI_PixelFormat pixelFormat);
@@ -365,6 +404,33 @@ inline uint64_t CvSink::GrabFrameNoTimeoutDirect(cv::Mat& image) {
return timestamp;
}
inline uint64_t CvSink::GrabFrameDirectLastTime(cv::Mat& image,
uint64_t lastFrameTime,
double timeout) {
rawFrame.height = 0;
rawFrame.width = 0;
rawFrame.stride = 0;
rawFrame.pixelFormat = pixelFormat;
auto timestamp = GrabSinkFrameTimeoutLastTime(m_handle, rawFrame, timeout,
lastFrameTime, &m_status);
if (m_status != CS_OK) {
return 0;
}
image =
cv::Mat{rawFrame.height, rawFrame.width,
GetCvFormat(static_cast<WPI_PixelFormat>(rawFrame.pixelFormat)),
rawFrame.data, static_cast<size_t>(rawFrame.stride)};
return timestamp;
}
inline uint64_t CvSink::LastFrameTime() {
return rawFrame.timestamp;
}
inline WPI_TimestampSource CvSink::LastFrameTimeSource() {
return static_cast<WPI_TimestampSource>(rawFrame.timestampSrc);
}
} // namespace cs
#endif // CSCORE_CSCORE_CV_H_

View File

@@ -27,6 +27,11 @@ uint64_t CS_GrabRawSinkFrame(CS_Sink sink, struct WPI_RawFrame* rawImage,
CS_Status* status);
uint64_t CS_GrabRawSinkFrameTimeout(CS_Sink sink, struct WPI_RawFrame* rawImage,
double timeout, CS_Status* status);
uint64_t CS_GrabRawSinkFrameTimeoutWithFrameTime(CS_Sink sink,
struct WPI_RawFrame* rawImage,
double timeout,
uint64_t lastFrameTime,
CS_Status* status);
CS_Sink CS_CreateRawSink(const struct WPI_String* name, CS_Bool isCv,
CS_Status* status);
@@ -67,6 +72,9 @@ void PutSourceFrame(CS_Source source, const WPI_RawFrame& image,
uint64_t GrabSinkFrame(CS_Sink sink, WPI_RawFrame& image, CS_Status* status);
uint64_t GrabSinkFrameTimeout(CS_Sink sink, WPI_RawFrame& image, double timeout,
CS_Status* status);
uint64_t GrabSinkFrameTimeoutLastTime(CS_Sink sink, WPI_RawFrame& image,
double timeout, uint64_t lastFrameTime,
CS_Status* status);
/**
* A source for user code to provide video frames as raw bytes.
@@ -163,6 +171,24 @@ class RawSink : public ImageSink {
*/
[[nodiscard]]
uint64_t GrabFrameNoTimeout(wpi::RawFrame& image) const;
/**
* Wait for the next frame and get the image. May block forever.
* The provided image will have three 8-bit channels stored in BGR order.
*
* <p>If lastFrameTime is provided and non-zero, the sink will fill image with
* the first frame from the source that is not equal to lastFrameTime. If
* lastFrameTime is zero, the time of the current frame owned by the CvSource
* is used, and this function will block until the connected CvSource provides
* a new frame.
*
* @return Frame time, or 0 on error (call GetError() to obtain the error
* message); the frame time is in the same time base as wpi::Now(),
* and is in 1 us increments.
*/
[[nodiscard]]
uint64_t GrabFrameLastTime(wpi::RawFrame& image, uint64_t lastFrameTime,
double timeout = 0.225) const;
};
inline RawSource::RawSource(std::string_view name, const VideoMode& mode) {
@@ -199,6 +225,14 @@ inline uint64_t RawSink::GrabFrameNoTimeout(wpi::RawFrame& image) const {
m_status = 0;
return GrabSinkFrame(m_handle, image, &m_status);
}
inline uint64_t RawSink::GrabFrameLastTime(wpi::RawFrame& image,
uint64_t lastFrameTime,
double timeout) const {
m_status = 0;
return GrabSinkFrameTimeoutLastTime(m_handle, image, timeout, lastFrameTime,
&m_status);
}
/** @} */
} // namespace cs

View File

@@ -555,8 +555,51 @@ void UsbCameraImpl::CameraThreadMain() {
good = false;
}
if (good) {
Frame::Time frameTime{wpi::Now()};
WPI_TimestampSource timeSource{WPI_TIMESRC_FRAME_DEQUEUE};
// check the timestamp time
auto tsFlags = buf.flags & V4L2_BUF_FLAG_TIMESTAMP_MASK;
SDEBUG4("Flags {}", tsFlags);
if (tsFlags == V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN) {
SDEBUG4("Got unknown time for frame - default to wpi::Now");
} else if (tsFlags == V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC) {
SDEBUG4("Got valid monotonic time for frame");
// we can't go directly to frametime, since the rest of cscore
// expects us to use wpi::Now, which is in an arbitrary timebase
// (see timestamp.cpp). Best I can do is (approximately) translate
// between timebases
// grab current time in the same timebase as buf.timestamp
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
int64_t nowTime = {ts.tv_sec * 1'000'000 + ts.tv_nsec / 1000};
int64_t bufTime = {buf.timestamp.tv_sec * 1'000'000 +
buf.timestamp.tv_usec};
// And offset frameTime by the latency
int64_t offset{nowTime - bufTime};
frameTime -= offset;
// Figure out the timestamp's source
int tsrcFlags = buf.flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
if (tsrcFlags == V4L2_BUF_FLAG_TSTAMP_SRC_EOF) {
timeSource = WPI_TIMESRC_V4L_EOF;
} else if (tsrcFlags == V4L2_BUF_FLAG_TSTAMP_SRC_SOE) {
timeSource = WPI_TIMESRC_V4L_SOE;
} else {
timeSource = WPI_TIMESRC_UNKNOWN;
}
SDEBUG4("Frame was {} uS old, flags {}, source {}", offset,
tsrcFlags, static_cast<int>(timeSource));
} else {
// Can't do anything if we can't access the clock, leave default
}
} else if (tsFlags == V4L2_BUF_FLAG_TIMESTAMP_COPY) {
SDEBUG4("Got valid copy time for frame - default to wpi::Now");
}
PutFrame(static_cast<VideoMode::PixelFormat>(m_mode.pixelFormat),
width, height, image, wpi::Now()); // TODO: time
width, height, image, frameTime, timeSource);
}
}

View File

@@ -29,7 +29,7 @@ inline void NamedLog(UsbCameraImplObjc* objc, unsigned int level,
#define OBJCLOG(level, format, ...) \
NamedLog(self, level, __FILE__, __LINE__, \
FMT_STRING(format) __VA_OPT__(, ) __VA_ARGS__)
format __VA_OPT__(, ) __VA_ARGS__)
#define OBJCERROR(format, ...) \
OBJCLOG(::wpi::WPI_LOG_ERROR, format __VA_OPT__(, ) __VA_ARGS__)

View File

@@ -101,7 +101,7 @@ model {
lib project: ':glass', library: 'glass', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'libssh')
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'

View File

@@ -5,4 +5,4 @@ include(CompileWarnings)
file(GLOB developerRobotCpp_src src/main/native/cpp/*.cpp)
add_executable(developerRobotCpp ${developerRobotCpp_src})
target_link_libraries(developerRobotCpp wpilibc)
target_link_libraries(developerRobotCpp wpilibc wpilibNewCommands apriltag)

View File

@@ -142,6 +142,19 @@ deploy {
}
}
// Prevent the eclipse compiler (used by the VS Code extension for intellisense and debugging)
// from generating bad class files from annotation processors like Epilogue
eclipse {
classpath {
containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
file.whenMerged { cp ->
def entries = cp.entries;
def src = new org.gradle.plugins.ide.eclipse.model.SourceFolder('build/generated/sources/annotationProcessor/java/main/', null)
entries.add(src)
}
}
}
tasks.register('deployJava') {
try {
dependsOn tasks.named('deployjreroborio')

View File

@@ -0,0 +1,22 @@
load("@rules_java//java:defs.bzl", "java_library", "java_plugin")
java_library(
name = "processor",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
runtime_deps = [
"//wpilibNewCommands:wpilibNewCommands-java",
],
deps = [
"//epilogue-runtime:epilogue",
],
)
java_plugin(
name = "plugin",
processor_class = "edu.wpi.first.epilogue.processor.AnnotationProcessor",
visibility = ["//visibility:public"],
deps = [
":processor",
],
)

View File

@@ -43,6 +43,8 @@ public class LoggerGenerator {
LoggerGenerator::isBuiltInJavaMethod;
private final ProcessingEnvironment m_processingEnv;
private final List<ElementHandler> m_handlers;
@SuppressWarnings("BadAnnotationImplementation")
private final Logged m_defaultConfig =
new Logged() {
@Override

View File

@@ -0,0 +1,12 @@
load("@rules_java//java:defs.bzl", "java_library")
java_library(
name = "epilogue",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//ntcore:networktables-java",
"//wpiunits",
"//wpiutil:wpiutil-java",
],
)

31
fieldImages/BUILD.bazel Normal file
View File

@@ -0,0 +1,31 @@
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_java//java:defs.bzl", "java_library")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")
generate_resources(
name = "generate-resources",
namespace = "fields",
prefix = "FIELDS",
resource_files = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
)
cc_library(
name = "fieldImages",
srcs = [":generate-resources"] + glob(["src/main/native/cpp/**"]),
hdrs = glob(["src/main/native/include/**/*"]),
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
)
java_library(
name = "fieldImages-java",
srcs = glob(["src/main/java/**/*.java"]),
resource_strip_prefix = "fieldImages/src/main/native/resources",
resources = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
deps = [
"@maven//:com_fasterxml_jackson_core_jackson_annotations",
"@maven//:com_fasterxml_jackson_core_jackson_databind",
],
)

View File

@@ -16,12 +16,13 @@ public enum Fields {
k2021Slalom("2021-slalompath.json"),
k2022RapidReact("2022-rapidreact.json"),
k2023ChargedUp("2023-chargedup.json"),
k2024Crescendo("2024-crescendo.json");
k2024Crescendo("2024-crescendo.json"),
k2025Reefscape("2025-reefscape.json");
public static final String kBaseResourceDir = "/edu/wpi/first/fields/";
/** Alias to the current game. */
public static final Fields kDefaultField = k2024Crescendo;
public static final Fields kDefaultField = k2025Reefscape;
public final String m_resourceFile;

View File

@@ -16,10 +16,13 @@
#include "fields/2022-rapidreact.h"
#include "fields/2023-chargedup.h"
#include "fields/2024-crescendo.h"
#include "fields/2025-reefscape.h"
using namespace fields;
static const Field kFields[] = {
{"2025 Reefscape", GetResource_2025_reefscape_json,
GetResource_2025_field_png},
{"2024 Crescendo", GetResource_2024_crescendo_json,
GetResource_2024_field_png},
{"2023 Charged Up", GetResource_2023_chargedup_json,

View File

@@ -0,0 +1,12 @@
// 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.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2025_reefscape_json();
std::string_view GetResource_2025_field_png();
} // namespace fields

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 KiB

View File

@@ -0,0 +1,19 @@
{
"game": "Reefscape",
"field-image": "2025-field.png",
"field-corners": {
"top-left": [
534,
291
],
"bottom-right": [
3466,
1638
]
},
"field-size": [
57.573,
26.417
],
"field-unit": "foot"
}

View File

@@ -97,7 +97,7 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
}
appendDebugPathToBinaries(binaries)
}
@@ -127,7 +127,7 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
}
appendDebugPathToBinaries(binaries)
}
@@ -167,7 +167,7 @@ model {
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'opencv_static')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'

View File

@@ -57,12 +57,22 @@ void Window::Display() {
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, m_padding);
}
std::string label;
std::string* name = &m_name;
if (m_name.empty()) {
label = fmt::format("{}###{}", m_defaultName, m_id);
} else {
label = fmt::format("{}###{}", m_name, m_id);
name = &m_defaultName;
}
std::string label = fmt::format("{}###{}", *name, m_id);
// Accounts for size of title, collapse button, and close button
float minWidth =
ImGui::CalcTextSize(name->c_str()).x + ImGui::GetFontSize() * 2 +
ImGui::GetStyle().ItemInnerSpacing.x * 3 +
ImGui::GetStyle().FramePadding.x * 2 + ImGui::GetStyle().WindowBorderSize;
// Accounts for size of hamburger button
if (m_renamePopupEnabled || m_view->HasSettings()) {
minWidth += ImGui::GetFontSize() + ImGui::GetStyle().FramePadding.x;
}
ImGui::SetNextWindowSizeConstraints({minWidth, 0}, ImVec2{FLT_MAX, FLT_MAX});
if (Begin(label.c_str(), &m_visible, m_flags)) {
if (m_renamePopupEnabled || m_view->HasSettings()) {

View File

@@ -33,7 +33,7 @@ void glass::DisplayLEDDisplay(LEDDisplayModel* model, int index) {
int& order = storage.GetInt("order", LEDConfig::RowMajor);
int& start = storage.GetInt("start", LEDConfig::UpperLeft);
ImGui::PushItemWidth(ImGui::GetFontSize() * 6);
ImGui::PushItemWidth(ImGui::GetFontSize() * 7);
ImGui::LabelText("Length", "%d", length);
ImGui::LabelText("Running", "%s", running ? "Yes" : "No");
ImGui::InputInt("Columns", &numColumns);

View File

@@ -373,13 +373,12 @@ void FieldInfo::DisplaySettings() {
}
ImGui::EndCombo();
}
if (m_builtin.empty() && ImGui::Button("Load image...")) {
if (m_builtin.empty() && ImGui::Button("Load JSON/image...")) {
m_fileOpener = std::make_unique<pfd::open_file>(
"Choose field image", "",
std::vector<std::string>{"Image File",
"Choose field JSON/image", "",
std::vector<std::string>{"PathWeaver JSON File", "*.json", "Image File",
"*.jpg *.jpeg *.png *.bmp *.psd *.tga *.gif "
"*.hdr *.pic *.ppm *.pgm",
"PathWeaver JSON File", "*.json"});
"*.hdr *.pic *.ppm *.pgm"});
}
if (ImGui::Button("Reset image")) {
Reset();
@@ -586,17 +585,29 @@ FieldFrameData FieldInfo::GetFrameData(ImVec2 min, ImVec2 max) const {
max.x -= (m_imageWidth - m_right) * scale;
max.y -= (m_imageHeight - m_bottom) * scale;
} else if ((max.x - min.x) > 40 && (max.y - min.y > 40)) {
// scale padding to be proportional to aspect ratio
float width = max.x - min.x;
float height = max.y - min.y;
float padX, padY;
if (width > height) {
padX = 20 * width / height;
padY = 20;
} else {
padX = 20;
padY = 20 * height / width;
}
// ensure there's some padding
min.x += 20;
max.x -= 20;
min.y += 20;
max.y -= 20;
min.x += padX;
max.x -= padX;
min.y += padY;
max.y -= padY;
// also pad the image so it's the same size as the box
ffd.imageMin.x += 20;
ffd.imageMax.x -= 20;
ffd.imageMin.y += 20;
ffd.imageMax.y -= 20;
ffd.imageMin.x += padX;
ffd.imageMax.x -= padX;
ffd.imageMin.y += padY;
ffd.imageMax.y -= padY;
}
ffd.min = min;

View File

@@ -122,5 +122,6 @@ kResourceType_ChoreoTrigger = 120
kResourceType_PathWeaverTrajectory = 121
kResourceType_Koors40 = 122
kResourceType_ThriftyNova = 123
kResourceType_PWFSEN36005 = 124
kResourceType_LaserShark = 125
kResourceType_RevServoHub = 124
kResourceType_PWFSEN36005 = 125
kResourceType_LaserShark = 126

View File

@@ -267,10 +267,12 @@ public final class FRCNetComm {
public static final int kResourceType_Koors40 = 122;
/** kResourceType_ThriftyNova = 123. */
public static final int kResourceType_ThriftyNova = 123;
/** kResourceType_PWFSEN36005 = 124. */
public static final int kResourceType_PWFSEN36005 = 124;
/** kResourceType_LaserShark = 125. */
public static final int kResourceType_LaserShark = 125;
/** kResourceType_RevServoHub = 124. */
public static final int kResourceType_RevServoHub = 124;
/** kResourceType_PWFSEN36005 = 125. */
public static final int kResourceType_PWFSEN36005 = 125;
/** kResourceType_LaserShark = 126. */
public static final int kResourceType_LaserShark = 126;
}
/**

View File

@@ -175,8 +175,9 @@ namespace HALUsageReporting {
kResourceType_PathWeaverTrajectory = 121,
kResourceType_Koors40 = 122,
kResourceType_ThriftyNova = 123,
kResourceType_PWFSEN36005 = 124,
kResourceType_LaserShark = 125,
kResourceType_RevServoHub = 124,
kResourceType_PWFSEN36005 = 125,
kResourceType_LaserShark = 126,
};
enum tInstances : int32_t {
kLanguage_LabVIEW = 1,

View File

@@ -144,8 +144,9 @@ typedef enum
kResourceType_PathWeaverTrajectory = 121,
kResourceType_Koors40 = 122,
kResourceType_ThriftyNova = 123,
kResourceType_PWFSEN36005 = 124,
kResourceType_LaserShark = 125,
kResourceType_RevServoHub = 124,
kResourceType_PWFSEN36005 = 125,
kResourceType_LaserShark = 126,
// kResourceType_MaximumID = 255,
} tResourceType;

View File

@@ -47,6 +47,8 @@ public final class CANAPITypes {
kMiscellaneous(10),
/** IO breakout. */
kIOBreakout(11),
/** Servo Controller. */
kServoController(12),
/** Firmware update. */
kFirmwareUpdate(31);

View File

@@ -44,6 +44,8 @@ HAL_ENUM(HAL_CANDeviceType) {
HAL_CAN_Dev_kMiscellaneous = 10,
/// IO breakout.
HAL_CAN_Dev_kIOBreakout = 11,
// Servo controller.
HAL_CAN_Dev_kServoController = 12,
/// Firmware update.
HAL_CAN_Dev_kFirmwareUpdate = 31
};

View File

@@ -5,11 +5,11 @@
#include "WireDecoder3.h"
#include <algorithm>
#include <bit>
#include <string>
#include <utility>
#include <fmt/format.h>
#include <wpi/MathExtras.h>
#include <wpi/SpanExtras.h>
#include "Message3.h"
@@ -74,7 +74,7 @@ std::optional<uint64_t> WireDecoder3::SimpleValueReader::Read64(
std::optional<double> WireDecoder3::SimpleValueReader::ReadDouble(
std::span<const uint8_t>* in) {
if (auto val = Read64(in)) {
return wpi::bit_cast<double>(val.value());
return std::bit_cast<double>(val.value());
} else {
return std::nullopt;
}

View File

@@ -4,8 +4,9 @@
#include "WireEncoder3.h"
#include <bit>
#include <wpi/Endian.h>
#include <wpi/MathExtras.h>
#include <wpi/SmallVector.h>
#include <wpi/leb128.h>
#include <wpi/raw_ostream.h>
@@ -33,7 +34,7 @@ static void Write32(wpi::raw_ostream& os, uint32_t val) {
static void WriteDouble(wpi::raw_ostream& os, double val) {
uint8_t buf[8];
wpi::support::endian::write64be(buf, wpi::bit_cast<uint64_t>(val));
wpi::support::endian::write64be(buf, std::bit_cast<uint64_t>(val));
os << buf;
}

View File

@@ -387,7 +387,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultBoolean(bool defaultValue) {
return nt::SetDefaultBoolean(m_pubHandle, defaultValue);
@@ -397,7 +397,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultInteger(int64_t defaultValue) {
return nt::SetDefaultInteger(m_pubHandle, defaultValue);
@@ -407,7 +407,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultFloat(float defaultValue) {
return nt::SetDefaultFloat(m_pubHandle, defaultValue);
@@ -417,7 +417,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultDouble(double defaultValue) {
return nt::SetDefaultDouble(m_pubHandle, defaultValue);
@@ -427,7 +427,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultString(std::string_view defaultValue) {
return nt::SetDefaultString(m_pubHandle, defaultValue);
@@ -437,7 +437,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultRaw(std::span<const uint8_t> defaultValue) {
return nt::SetDefaultRaw(m_pubHandle, defaultValue);
@@ -447,7 +447,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultBooleanArray(std::span<const int> defaultValue) {
return nt::SetDefaultBooleanArray(m_pubHandle, defaultValue);
@@ -457,7 +457,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultIntegerArray(std::span<const int64_t> defaultValue) {
return nt::SetDefaultIntegerArray(m_pubHandle, defaultValue);
@@ -467,7 +467,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultFloatArray(std::span<const float> defaultValue) {
return nt::SetDefaultFloatArray(m_pubHandle, defaultValue);
@@ -477,7 +477,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultDoubleArray(std::span<const double> defaultValue) {
return nt::SetDefaultDoubleArray(m_pubHandle, defaultValue);
@@ -487,7 +487,7 @@ class GenericPublisher : public Publisher {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultStringArray(std::span<const std::string> defaultValue) {
return nt::SetDefaultStringArray(m_pubHandle, defaultValue);

View File

@@ -361,11 +361,11 @@ class NetworkTable final {
bool PutNumber(std::string_view key, double value);
/**
* Gets the current value in the table, setting it if it does not exist.
* Set Default Entry Value
*
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
* @returns True if the table key did not already exist, otherwise False
*/
bool SetDefaultNumber(std::string_view key, double defaultValue);
@@ -389,11 +389,11 @@ class NetworkTable final {
bool PutString(std::string_view key, std::string_view value);
/**
* Gets the current value in the table, setting it if it does not exist.
* Set Default Entry Value
*
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
* @returns True if the table key did not already exist, otherwise False
*/
bool SetDefaultString(std::string_view key, std::string_view defaultValue);
@@ -419,11 +419,11 @@ class NetworkTable final {
bool PutBoolean(std::string_view key, bool value);
/**
* Gets the current value in the table, setting it if it does not exist.
* Set Default Entry Value
*
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
* @returns True if the table key did not already exist, otherwise False
*/
bool SetDefaultBoolean(std::string_view key, bool defaultValue);
@@ -452,11 +452,11 @@ class NetworkTable final {
bool PutBooleanArray(std::string_view key, std::span<const int> value);
/**
* Gets the current value in the table, setting it if it does not exist.
* Set Default Entry Value
*
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @return False if the table key exists with a different type
* @return True if the table key did not already exist, otherwise False
*/
bool SetDefaultBooleanArray(std::string_view key,
std::span<const int> defaultValue);
@@ -490,11 +490,11 @@ class NetworkTable final {
bool PutNumberArray(std::string_view key, std::span<const double> value);
/**
* Gets the current value in the table, setting it if it does not exist.
* Set Default Entry Value
*
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
* @returns True if the table key did not already exist, otherwise False
*/
bool SetDefaultNumberArray(std::string_view key,
std::span<const double> defaultValue);
@@ -524,11 +524,11 @@ class NetworkTable final {
bool PutStringArray(std::string_view key, std::span<const std::string> value);
/**
* Gets the current value in the table, setting it if it does not exist.
* Set Default Entry Value
*
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @returns False if the table key exists with a different type
* @returns True if the table key did not already exist, otherwise False
*/
bool SetDefaultStringArray(std::string_view key,
std::span<const std::string> defaultValue);
@@ -558,11 +558,11 @@ class NetworkTable final {
bool PutRaw(std::string_view key, std::span<const uint8_t> value);
/**
* Gets the current value in the table, setting it if it does not exist.
* Set Default Entry Value
*
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @return False if the table key exists with a different type
* @return True if the table key did not already exist, otherwise False
*/
bool SetDefaultRaw(std::string_view key,
std::span<const uint8_t> defaultValue);
@@ -592,11 +592,11 @@ class NetworkTable final {
bool PutValue(std::string_view key, const Value& value);
/**
* Gets the current value in the table, setting it if it does not exist.
* Set Default Entry Value.
*
* @param key the key
* @param defaultValue the default value to set if key doesn't exist.
* @return False if the table key exists with a different type
* @return True if the table key did not already exist, otherwise False
*/
bool SetDefaultValue(std::string_view key, const Value& defaultValue);

View File

@@ -260,7 +260,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultValue(const Value& defaultValue) {
return SetDefaultEntryValue(m_handle, defaultValue);
@@ -270,7 +270,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultBoolean(bool defaultValue) {
return nt::SetDefaultBoolean(m_handle, defaultValue);
@@ -280,7 +280,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultInteger(int64_t defaultValue) {
return nt::SetDefaultInteger(m_handle, defaultValue);
@@ -290,7 +290,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultFloat(float defaultValue) {
return nt::SetDefaultFloat(m_handle, defaultValue);
@@ -300,7 +300,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultDouble(double defaultValue) {
return nt::SetDefaultDouble(m_handle, defaultValue);
@@ -310,7 +310,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultString(std::string_view defaultValue) {
return nt::SetDefaultString(m_handle, defaultValue);
@@ -320,7 +320,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultRaw(std::span<const uint8_t> defaultValue) {
return nt::SetDefaultRaw(m_handle, defaultValue);
@@ -330,7 +330,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultBooleanArray(std::span<const int> defaultValue) {
return nt::SetDefaultBooleanArray(m_handle, defaultValue);
@@ -340,7 +340,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultIntegerArray(std::span<const int64_t> defaultValue) {
return nt::SetDefaultIntegerArray(m_handle, defaultValue);
@@ -350,7 +350,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultFloatArray(std::span<const float> defaultValue) {
return nt::SetDefaultFloatArray(m_handle, defaultValue);
@@ -360,7 +360,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultDoubleArray(std::span<const double> defaultValue) {
return nt::SetDefaultDoubleArray(m_handle, defaultValue);
@@ -370,7 +370,7 @@ class NetworkTableEntry final {
* Sets the entry's value if it does not exist.
*
* @param defaultValue the default value to set
* @return False if the entry exists with a different type
* @return True if the entry did not already have a value, otherwise False
*/
bool SetDefaultStringArray(std::span<const std::string> defaultValue) {
return nt::SetDefaultStringArray(m_handle, defaultValue);

View File

@@ -476,8 +476,8 @@ void NT_GetEntryValueType(NT_Entry entry, unsigned int types,
/**
* Set Default Entry Value.
*
* Returns copy of current entry value if it exists.
* Otherwise, sets passed in value, and returns set value.
* Returns 0 if name exists.
* Otherwise, sets passed in value, and returns 1.
* Note that one of the type options is "unassigned".
*
* @param entry entry handle

View File

@@ -488,8 +488,8 @@ Value GetEntryValue(NT_Handle subentry);
/**
* Set Default Entry Value
*
* Returns copy of current entry value if it exists.
* Otherwise, sets passed in value, and returns set value.
* Returns False if name exists.
* Otherwise, sets passed in value, and returns True.
* Note that one of the type options is "unassigned".
*
* @param entry entry handle

View File

@@ -60,12 +60,12 @@ inline void ReportError(int32_t status, const char* fileName, int lineNumber,
}
} // namespace frc
#define FRC_ReportError(status, format, ...) \
do { \
if ((status) != 0) { \
::frc::ReportError(status, __FILE__, __LINE__, __FUNCTION__, \
FMT_STRING(format) __VA_OPT__(, ) __VA_ARGS__); \
} \
#define FRC_ReportError(status, format, ...) \
do { \
if ((status) != 0) { \
::frc::ReportError(status, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__); \
} \
} while (0)
namespace RobotController {

View File

@@ -102,7 +102,7 @@ model {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {

View File

@@ -103,7 +103,7 @@ model {
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'libssh')
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << 'ws2_32.lib' << 'advapi32.lib' << 'crypt32.lib' << 'user32.lib'

53
romiVendordep/BUILD.bazel Normal file
View File

@@ -0,0 +1,53 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
cc_library(
name = "romi-cpp.static",
srcs = glob([
"src/main/native/cpp/**",
]),
hdrs = glob(["src/main/native/include/**"]),
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
"//wpilibc:wpilibc.static",
],
)
java_library(
name = "romi-java",
srcs = glob(["src/main/java/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//hal:hal-java",
"//wpilibj",
],
)
cc_test(
name = "romi-test",
size = "small",
srcs = glob(["src/test/native/cpp/**"]),
deps = [
"//thirdparty/googletest:googletest.static",
],
)
cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":romi-cpp.static",
],
)
java_binary(
name = "DevMain-Java",
srcs = ["src/dev/java/edu/wpi/first/wpilibj/romi/DevMain.java"],
main_class = "edu.wpi.first.wpilibj.romi.DevMain",
deps = [
"//hal:hal-java",
"//ntcore:networktables-java",
"//wpiutil:wpiutil-java",
],
)

View File

@@ -62,6 +62,7 @@ include 'epilogue-processor'
include 'epilogue-runtime'
include 'thirdparty:googletest'
include 'thirdparty:imgui_suite'
include 'wpical'
buildCache {
def cred = {

View File

@@ -42,3 +42,6 @@ build:macos --linkopt=-Wl,-rpath,'@loader_path'"
# Things not in nativetools
build:macos --copt=-Wno-shorten-64-to-32
build:macos --host_per_file_copt=external/zlib/.*\.c@-Wno-deprecated-non-prototype
build:macos --host_per_file_copt=external/com_google_protobuf/.*\.cc@-Wno-unused-function

View File

@@ -14,3 +14,5 @@ build:roborio --cxxopt=-Wno-error=deprecated-declarations
# Extra 11
build:roborio --cxxopt=-Wno-error=deprecated-enum-enum-conversion
build:roborio --host_per_file_copt=external/zlib/.*\.c@-Wno-deprecated-non-prototype

13
shared/ceres.gradle Normal file
View File

@@ -0,0 +1,13 @@
nativeUtils {
nativeDependencyContainer {
ceres(getNativeDependencyTypeClass('WPIStaticMavenDependency')) {
groupId = "edu.wpi.first.thirdparty.frc2024.ceres"
artifactId = "ceres-cpp"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = '2.2-3'
targetPlatforms.addAll(nativeUtils.wpi.platforms.desktopPlatforms)
}
}
}

View File

@@ -14,7 +14,7 @@ nativeUtils {
wpi {
configureDependencies {
opencvYear = "frc2025"
niLibVersion = "2025.0.0"
niLibVersion = "2025.2.0"
opencvVersion = "4.10.0-3"
}
}

View File

@@ -67,9 +67,9 @@ def tagList = [
"SmartDashboard", "Shuffleboard", "Sendable", "DataLog",
/* --- Controls --- */
"Exponential Profile", "PID", "State-Space", "Ramsete", "Path Following", "Trajectory",
"SysId", "Simulation", "Trapezoid Profile", "Profiled PID", "Odometry", "LQR",
"Pose Estimator",
"Exponential Profile", "PID", "State-Space", "LTVUnicycleController", "Path Following",
"Trajectory", "SysId", "Simulation", "Trapezoid Profile", "Profiled PID", "Odometry",
"LQR", "Pose Estimator",
/* --- Hardware --- */
"Analog", "Ultrasonic", "Gyro", "Pneumatics", "I2C", "Duty Cycle", "PDP", "DMA", "Relay",

View File

@@ -31,7 +31,7 @@ model {
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return

View File

@@ -1104,7 +1104,15 @@ static void DriverStationExecute() {
}
ImGui::SetNextWindowPos(ImVec2{5, 20}, ImGuiCond_FirstUseEver);
ImGui::Begin("Robot State", nullptr, ImGuiWindowFlags_AlwaysAutoResize);
const char* title = "Robot State";
// Accounts for size of title and collapse button
float minWidth = ImGui::CalcTextSize(title).x + ImGui::GetFontSize() +
ImGui::GetStyle().ItemInnerSpacing.x * 2 +
ImGui::GetStyle().FramePadding.x * 2 +
ImGui::GetStyle().WindowBorderSize;
ImGui::SetNextWindowSizeConstraints(ImVec2{minWidth, 0},
ImVec2{FLT_MAX, FLT_MAX});
ImGui::Begin(title, nullptr, ImGuiWindowFlags_AlwaysAutoResize);
if (ImGui::Selectable("Disconnected", !isAttached)) {
HALSIM_SetDriverStationEnabled(false);
HALSIM_SetDriverStationDsAttached(false);

View File

@@ -4,11 +4,11 @@
#include "XRP.h"
#include <bit>
#include <string>
#include <fmt/format.h>
#include <wpi/Endian.h>
#include <wpi/MathExtras.h>
#include <wpi/json.h>
using namespace wpilibxrp;
@@ -245,7 +245,7 @@ void XRP::SetupMotorTag(wpi::raw_uv_ostream& buf) {
// Convert the value
wpi::support::endian::write32be(value,
wpi::bit_cast<uint32_t>(motor.second));
std::bit_cast<uint32_t>(motor.second));
buf << value[0] << value[1] << value[2] << value[3];
}
}
@@ -261,7 +261,7 @@ void XRP::SetupServoTag(wpi::raw_uv_ostream& buf) {
// Convert the value
wpi::support::endian::write32be(value,
wpi::bit_cast<uint32_t>(servo.second));
std::bit_cast<uint32_t>(servo.second));
buf << value[0] << value[1] << value[2] << value[3];
}
}
@@ -283,17 +283,17 @@ void XRP::ReadGyroTag(std::span<const uint8_t> packet) {
packet = packet.subspan(2); // Skip past the size and tag
float rate_x =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[0]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[0]));
float rate_y =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[4]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[4]));
float rate_z =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[8]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[8]));
float angle_x =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[12]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[12]));
float angle_y =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[16]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[16]));
float angle_z =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[20]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[20]));
// Make the json object
wpi::json gyroJson;
@@ -314,11 +314,11 @@ void XRP::ReadAccelTag(std::span<const uint8_t> packet) {
packet = packet.subspan(2); // Skip past the size and tag
float accel_x =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[0]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[0]));
float accel_y =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[4]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[4]));
float accel_z =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[8]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[8]));
wpi::json accelJson;
accelJson["type"] = "Accel";
@@ -409,7 +409,7 @@ void XRP::ReadAnalogTag(std::span<const uint8_t> packet) {
packet = packet.subspan(3);
float voltage =
wpi::bit_cast<float>(wpi::support::endian::read32be(&packet[0]));
std::bit_cast<float>(wpi::support::endian::read32be(&packet[0]));
wpi::json analogJson;
analogJson["type"] = "AI";

View File

@@ -100,7 +100,7 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'
@@ -139,7 +139,7 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imgui', linkage: 'static'
lib project: ':thirdparty:imgui_suite', library: 'imguiSuite', linkage: 'static'
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'

View File

@@ -25,7 +25,7 @@ nativeUtils.platformConfigs.named('osxuniversal') {
model {
components {
imgui(NativeLibrarySpec) {
imguiSuite(NativeLibrarySpec) {
sources {
cpp {
source {

File diff suppressed because it is too large Load Diff

View File

@@ -34,7 +34,7 @@ def copy_upstream_src(wpilib_root):
def main():
name = "fmt"
url = "https://github.com/fmtlib/fmt"
tag = "11.0.2"
tag = "11.1.0"
fmt = Lib(name, url, tag, copy_upstream_src)
fmt.main()

View File

@@ -1,28 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Tyler Veness <calcmogul@gmail.com>
Date: Tue, 16 May 2023 13:49:18 -0700
Subject: [PATCH] Suppress warnings we can't fix
---
include/fmt/format.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/fmt/format.h b/include/fmt/format.h
index 67f0ab739b0de55d03ab3e71424f1eb9e9c9bdfc..cf5ad9820683130ce9895f5d216d9b9efd0185ac 100644
--- a/include/fmt/format.h
+++ b/include/fmt/format.h
@@ -1276,7 +1276,14 @@ inline auto equal2(const char* lhs, const char* rhs) -> bool {
template <typename Char>
FMT_CONSTEXPR20 FMT_INLINE void copy2(Char* dst, const char* src) {
if (!is_constant_evaluated() && sizeof(Char) == sizeof(char)) {
+#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1000
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
memcpy(dst, src, 2);
+#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 1000
+# pragma GCC diagnostic pop
+#endif
return;
}
*dst++ = static_cast<Char>(*src++);

View File

@@ -48,6 +48,7 @@ def copy_upstream_src(wpilib_root):
"./backends/imgui_impl_opengl2.cpp",
"./backends/imgui_impl_opengl3.cpp",
"./imgui.cpp",
"./imgui_demo.cpp",
"./imgui_draw.cpp",
"./imgui_tables.cpp",
"./imgui_widgets.cpp",

58
upstream_utils/libdogleg.py Executable file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env python3
import os
import shutil
from upstream_utils import Lib, walk_cwd_and_copy_if
def copy_upstream_src(wpilib_root):
wpical = os.path.join(wpilib_root, "wpical")
# Delete old install
for d in [
"src/main/native/thirdparty/libdogleg/src",
"src/main/native/thirdparty/libdogleg/include",
]:
shutil.rmtree(os.path.join(wpical, d), ignore_errors=True)
files = walk_cwd_and_copy_if(
lambda dp, f: f.endswith("dogleg.h"),
os.path.join(wpical, "src/main/native/thirdparty/libdogleg/include"),
)
for f in files:
with open(f) as file:
content = file.read()
content = content.replace(
"#include <cholmod.h>", "#include <suitesparse/cholmod.h>"
)
with open(f, "w") as file:
file.write(content)
files = walk_cwd_and_copy_if(
lambda dp, f: f.endswith("dogleg.cpp"),
os.path.join(wpical, "src/main/native/thirdparty/libdogleg/src"),
)
for f in files:
with open(f) as file:
content = file.read()
content = content.replace("#warning", "// #warning")
content = content.replace("__attribute__((unused))", "")
content = content.replace(
"#include <cholmod_function.h>", "#include <suitesparse/cholmod_function.h>"
)
with open(f, "w") as file:
file.write(content)
def main():
name = "libdogleg"
url = "https://github.com/dkogan/libdogleg"
tag = "c971ea43088d286a3683c1039b9a85f761f7df15"
libdogleg = Lib(name, url, tag, copy_upstream_src)
libdogleg.main()
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,38 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gold856 <117957790+Gold856@users.noreply.github.com>
Date: Fri, 29 Nov 2024 19:52:22 -0500
Subject: [PATCH 1/3] Convert to C++
---
dogleg.c => dogleg.cpp | 0
dogleg.h | 8 +++++++-
2 files changed, 7 insertions(+), 1 deletion(-)
rename dogleg.c => dogleg.cpp (100%)
diff --git a/dogleg.c b/dogleg.cpp
similarity index 100%
rename from dogleg.c
rename to dogleg.cpp
diff --git a/dogleg.h b/dogleg.h
index 74337263a89d3448f55e125db6702ebfa7588b97..4a23b669a30642d290549bb94a1c787f079d0647 100644
--- a/dogleg.h
+++ b/dogleg.h
@@ -126,7 +126,9 @@ typedef struct
} dogleg_solverContext_t;
-
+#ifdef __cplusplus
+extern "C" {
+#endif
// Fills in the given structure with the default parameter set
void dogleg_getDefaultParameters(dogleg_parameters2_t* parameters);
@@ -293,3 +295,7 @@ double dogleg_getOutliernessTrace_newFeature_sparse(const double* Jqu
int NoutlierFeatures,
dogleg_operatingPoint_t* point,
dogleg_solverContext_t* ctx);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif

View File

@@ -0,0 +1,79 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gold856 <117957790+Gold856@users.noreply.github.com>
Date: Fri, 29 Nov 2024 19:54:54 -0500
Subject: [PATCH 2/3] Replace VLAs with vectors
---
dogleg.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/dogleg.cpp b/dogleg.cpp
index 7e4259c303e21a9f4c63ba16f1bf5df131935057..9ed95f64b232f41a51fe23d72885ecadd86dc065 100644
--- a/dogleg.cpp
+++ b/dogleg.cpp
@@ -6,6 +6,7 @@
// Apparently I need this in MSVC to get constants
#define _USE_MATH_DEFINES
+#include <vector>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
@@ -1907,7 +1908,7 @@ static bool getOutliernessFactors_dense( // output
// where A = Jo inv(JtJ) Jot
//
// A is symmetric. I store the upper triangle
- double A[featureSize*(featureSize+1)/2];
+ std::vector<double> A(featureSize*(featureSize+1)/2);
int iA=0;
for(int i=0; i<featureSize; i++)
for(int j=i; j<featureSize; j++, iA++)
@@ -1921,7 +1922,7 @@ static bool getOutliernessFactors_dense( // output
}
accum_outlierness_factor(&factors[i_feature],
&point->x[i_measurement],
- A, featureSize, *scale);
+ A.data(), featureSize, *scale);
}
result = true;
@@ -2008,7 +2009,7 @@ static bool getOutliernessFactors_sparse( // output
// where A = Jo inv(JtJ) Jot
//
// A is symmetric. I store the upper triangle
- double A[featureSize*(featureSize+1)/2];
+ std::vector<double> A(featureSize*(featureSize+1)/2);
int iA=0;
for(int i=0; i<featureSize; i++)
for(int j=i; j<featureSize; j++, iA++)
@@ -2027,7 +2028,7 @@ static bool getOutliernessFactors_sparse( // output
}
accum_outlierness_factor(&factors[i_feature],
&point->x[i_measurement],
- A, featureSize, *scale);
+ A.data(), featureSize, *scale);
}
result = true;
@@ -2212,8 +2213,8 @@ double dogleg_getOutliernessTrace_newFeature_sparse(const double* Jqu
// This is Jt because cholmod thinks in terms of col-first instead of
// row-first
- int Jt_p[featureSize+1];
- int Jt_i[NstateActive*featureSize];
+ std::vector<int> Jt_p(featureSize+1);
+ std::vector<int> Jt_i(NstateActive*featureSize);
for(int i=0; i<=featureSize; i++)
{
Jt_p[i] = i*NstateActive;
@@ -2224,8 +2225,8 @@ double dogleg_getOutliernessTrace_newFeature_sparse(const double* Jqu
cholmod_sparse Jt_query_sparse = {.nrow = ctx->Nstate,
.ncol = featureSize,
.nzmax = NstateActive*featureSize,
- .p = (void*)Jt_p,
- .i = (void*)Jt_i,
+ .p = (void*)Jt_p.data(),
+ .i = (void*)Jt_i.data(),
.x = (double*)JqueryFeature,
.sorted = 1,
.packed = 1,

View File

@@ -0,0 +1,324 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Gold856 <117957790+Gold856@users.noreply.github.com>
Date: Sun, 1 Dec 2024 00:28:14 -0500
Subject: [PATCH 3/3] Fix C++ build errors
---
dogleg.cpp | 110 +++++++++++++++++++++++++++++++----------------------
1 file changed, 65 insertions(+), 45 deletions(-)
diff --git a/dogleg.cpp b/dogleg.cpp
index 9ed95f64b232f41a51fe23d72885ecadd86dc065..c93f696a9427f0644b047308d2d99302cd246462 100644
--- a/dogleg.cpp
+++ b/dogleg.cpp
@@ -327,9 +327,9 @@ void _dogleg_testGradient(unsigned int var, const double* p0,
{
int is_sparse = NJnnz > 0;
- double* x0 = malloc(Nmeas * sizeof(double));
- double* x = malloc(Nmeas * sizeof(double));
- double* p = malloc(Nstate * sizeof(double));
+ double* x0 = static_cast<double*>(malloc(Nmeas * sizeof(double)));
+ double* x = static_cast<double*>(malloc(Nmeas * sizeof(double)));
+ double* p = static_cast<double*>(malloc(Nstate * sizeof(double)));
ASSERT(x0);
ASSERT(x);
ASSERT(p);
@@ -376,8 +376,8 @@ void _dogleg_testGradient(unsigned int var, const double* p0,
}
else
{
- J_dense = malloc( Nmeas * Nstate * sizeof(J_dense[0]) );
- J_dense0 = malloc( Nmeas * Nstate * sizeof(J_dense[0]) );
+ J_dense = static_cast<double*>(malloc( Nmeas * Nstate * sizeof(J_dense[0]) ));
+ J_dense0 = static_cast<double*>(malloc( Nmeas * Nstate * sizeof(J_dense[0]) ));
dogleg_callback_dense_t* f_dense = (dogleg_callback_dense_t*)f;
p[var] -= GRADTEST_DELTA/2.0;
@@ -487,11 +487,13 @@ static void computeCauchyUpdate(dogleg_operatingPoint_t* point,
// LAPACK prototypes for a packed cholesky factorization and a linear solve
// using that factorization, respectively
+extern "C" {
int dpptrf_(char* uplo, int* n, double* ap,
int* info, int uplo_len);
int dpptrs_(char* uplo, int* n, int* nrhs,
double* ap, double* b, int* ldb, int* info,
int uplo_len);
+}
void dogleg_computeJtJfactorization(dogleg_operatingPoint_t* point, dogleg_solverContext_t* ctx)
@@ -538,8 +540,8 @@ void dogleg_computeJtJfactorization(dogleg_operatingPoint_t* point, dogleg_solve
if(ctx->factorization_dense == NULL)
{
// Need to store symmetric JtJ, so I only need one triangle of it
- ctx->factorization_dense = malloc( ctx->Nstate * (ctx->Nstate+1) / 2 *
- sizeof( ctx->factorization_dense[0]));
+ ctx->factorization_dense = static_cast<double*>(malloc( ctx->Nstate * (ctx->Nstate+1) / 2 *
+ sizeof( ctx->factorization_dense[0])));
ASSERT(ctx->factorization_dense);
}
@@ -582,7 +584,9 @@ void dogleg_computeJtJfactorization(dogleg_operatingPoint_t* point, dogleg_solve
int info;
- dpptrf_(&(char){'L'}, &(int){ctx->Nstate}, ctx->factorization_dense,
+ char uplo = 'L';
+ int Nstate_copy = ctx->Nstate;
+ dpptrf_(&uplo, &Nstate_copy, ctx->factorization_dense,
&info, 1);
ASSERT(info >= 0); // we MUST either succeed or see complain of singular
// JtJ
@@ -611,10 +615,10 @@ static void computeGaussNewtonUpdate(dogleg_operatingPoint_t* point, dogleg_solv
if( ctx->is_sparse )
{
// solve JtJ*updateGN = Jt*x. Gauss-Newton step is then -updateGN
- cholmod_dense Jt_x_dense = {.nrow = ctx->Nstate,
+ cholmod_dense Jt_x_dense = {.nrow = static_cast<size_t>(ctx->Nstate),
.ncol = 1,
- .nzmax = ctx->Nstate,
- .d = ctx->Nstate,
+ .nzmax = static_cast<size_t>(ctx->Nstate),
+ .d = static_cast<size_t>(ctx->Nstate),
.x = point->Jt_x,
.xtype = CHOLMOD_REAL,
.dtype = CHOLMOD_DOUBLE};
@@ -626,18 +630,22 @@ static void computeGaussNewtonUpdate(dogleg_operatingPoint_t* point, dogleg_solv
ctx->factorization,
&Jt_x_dense,
&ctx->common);
- vec_negate(point->updateGN_cholmoddense->x,
+ vec_negate(static_cast<double*>(point->updateGN_cholmoddense->x),
ctx->Nstate); // should be more efficient than this later
- point->updateGN_lensq = norm2(point->updateGN_cholmoddense->x, ctx->Nstate);
+ point->updateGN_lensq = norm2(static_cast<double*>(point->updateGN_cholmoddense->x), ctx->Nstate);
}
else
{
memcpy( point->updateGN_dense, point->Jt_x, ctx->Nstate * sizeof(point->updateGN_dense[0]));
int info;
- dpptrs_(&(char){'L'}, &(int){ctx->Nstate}, &(int){1},
+ char uplo = 'L';
+ int nhrs = 1;
+ int Nstate_copy = ctx->Nstate;
+ int Nstate_copy2 = ctx->Nstate;
+ dpptrs_(&uplo, &Nstate_copy, &nhrs,
ctx->factorization_dense,
- point->updateGN_dense, &(int){ctx->Nstate}, &info, 1);
+ point->updateGN_dense, &Nstate_copy2, &info, 1);
vec_negate(point->updateGN_dense,
ctx->Nstate); // should be more efficient than this later
@@ -677,7 +685,7 @@ static void computeInterpolatedUpdate(double* update_dogleg,
double dsq = trustregion*trustregion;
double norm2a = point->updateCauchy_lensq;
const double* a = point->updateCauchy;
- const double* b = ctx->is_sparse ? point->updateGN_cholmoddense->x : point->updateGN_dense;
+ const double* b = ctx->is_sparse ? static_cast<double*>(point->updateGN_cholmoddense->x) : point->updateGN_dense;
double l2 = 0.0;
double neg_c = 0.0;
@@ -1029,7 +1037,7 @@ dogleg_operatingPoint_t* allocOperatingPoint(int Nstate, int numMeasurements,
{
int is_sparse = NJnnz > 0;
- dogleg_operatingPoint_t* point = malloc(sizeof(dogleg_operatingPoint_t));
+ dogleg_operatingPoint_t* point = static_cast<dogleg_operatingPoint_t*>(malloc(sizeof(dogleg_operatingPoint_t)));
ASSERT(point != NULL);
@@ -1042,7 +1050,7 @@ dogleg_operatingPoint_t* allocOperatingPoint(int Nstate, int numMeasurements,
if(!is_sparse)
Npool += numMeasurements*Nstate + Nstate;
- double* pool = malloc( Npool * sizeof(double) );
+ double* pool = static_cast<double*>(malloc( Npool * sizeof(double) ));
ASSERT( pool != NULL );
point->p = &pool[0];
@@ -1170,7 +1178,7 @@ static double _dogleg_optimize(double* p, unsigned int Nstate,
int is_sparse = NJnnz > 0;
- dogleg_solverContext_t* ctx = malloc(sizeof(dogleg_solverContext_t));
+ dogleg_solverContext_t* ctx = static_cast<dogleg_solverContext_t*>(malloc(sizeof(dogleg_solverContext_t)));
ctx->f = f;
ctx->cookie = cookie;
ctx->factorization = NULL;
@@ -1294,10 +1302,13 @@ static bool pseudoinverse_J_dense(// output
memcpy(out,
&point->J_dense[i_meas0*ctx->Nstate],
NmeasInChunk*ctx->Nstate*sizeof(double));
- dpptrs_(&(char){'L'}, &(int){ctx->Nstate}, &NmeasInChunk,
+ char uplo = 'L';
+ int Nstate_copy = ctx->Nstate;
+ int Nstate_copy2 = ctx->Nstate;
+ dpptrs_(&uplo, &Nstate_copy, &NmeasInChunk,
ctx->factorization_dense,
out,
- &(int){ctx->Nstate}, &info, 1);
+ &Nstate_copy2, &info, 1);
return info==0;
}
@@ -1873,11 +1884,12 @@ static bool getOutliernessFactors_dense( // output
int Nmeasurements = ctx->Nmeasurements;
bool result = false;
- double* invJtJ_Jt = malloc(Nstate*chunk_size*sizeof(double));
+ double* invJtJ_Jt = static_cast<double*>(malloc(Nstate*chunk_size*sizeof(double)));
if(invJtJ_Jt == NULL)
{
SAY("Couldn't allocate invJtJ_Jt!");
- goto done;
+ free(invJtJ_Jt);
+ return result;
}
getOutliernessScale(scale,
@@ -1895,7 +1907,8 @@ static bool getOutliernessFactors_dense( // output
if(!pinvresult)
{
SAY("Couldn't compute pinv!");
- goto done;
+ free(invJtJ_Jt);
+ return result;
}
i_measurement_valid_chunk_start = i_measurement;
i_measurement_valid_chunk_last = i_measurement+chunk_size-1;
@@ -1926,7 +1939,6 @@ static bool getOutliernessFactors_dense( // output
}
result = true;
- done:
free(invJtJ_Jt);
return result;
}
@@ -1975,7 +1987,9 @@ static bool getOutliernessFactors_sparse( // output
if(!Jt_chunk)
{
SAY("Couldn't allocate Jt_chunk!");
- goto done;
+ if(Jt_chunk) cholmod_free_dense(&Jt_chunk, &ctx->common);
+ if(invJtJ_Jt) cholmod_free_dense(&invJtJ_Jt, &ctx->common);
+ return result;
}
getOutliernessScale(scale,
@@ -1995,7 +2009,9 @@ static bool getOutliernessFactors_sparse( // output
if(invJtJ_Jt == NULL)
{
SAY("Couldn't compute pinv!");
- goto done;
+ if(Jt_chunk) cholmod_free_dense(&Jt_chunk, &ctx->common);
+ if(invJtJ_Jt) cholmod_free_dense(&invJtJ_Jt, &ctx->common);
+ return result;
}
i_measurement_valid_chunk_start = i_measurement;
@@ -2032,7 +2048,6 @@ static bool getOutliernessFactors_sparse( // output
}
result = true;
- done:
if(Jt_chunk) cholmod_free_dense(&Jt_chunk, &ctx->common);
if(invJtJ_Jt) cholmod_free_dense(&invJtJ_Jt, &ctx->common);
return result;
@@ -2222,18 +2237,18 @@ double dogleg_getOutliernessTrace_newFeature_sparse(const double* Jqu
for(int j=0; j<NstateActive; j++)
Jt_i[j + i*NstateActive] = istateActive + j;
}
- cholmod_sparse Jt_query_sparse = {.nrow = ctx->Nstate,
- .ncol = featureSize,
- .nzmax = NstateActive*featureSize,
- .p = (void*)Jt_p.data(),
- .i = (void*)Jt_i.data(),
- .x = (double*)JqueryFeature,
- .sorted = 1,
- .packed = 1,
+ cholmod_sparse Jt_query_sparse = {.nrow = static_cast<size_t>(ctx->Nstate),
+ .ncol = static_cast<size_t>(featureSize),
+ .nzmax = static_cast<size_t>(NstateActive*featureSize),
+ .p = Jt_p.data(),
+ .i = Jt_i.data(),
+ .x = const_cast<double*>(JqueryFeature),
.stype = 0, // NOT symmetric
.itype = CHOLMOD_INT,
.xtype = CHOLMOD_REAL,
- .dtype = CHOLMOD_DOUBLE};
+ .dtype = CHOLMOD_DOUBLE,
+ .sorted = 1,
+ .packed = 1};
// Really shouldn't need to do this every time. In fact I probably don't need
// to do it at all, since this will have been done by the solver during the
@@ -2408,18 +2423,22 @@ bool dogleg_markOutliers(// output, input
bool markedAny = false;
- double* factors = malloc(Nfeatures * sizeof(double));
+ double* factors = static_cast<double*>(malloc(Nfeatures * sizeof(double)));
if(factors == NULL)
{
SAY("Error allocating factors");
- goto done;
+ free(factors);
+ return markedAny;
}
if(!dogleg_getOutliernessFactors(factors, scale,
featureSize, Nfeatures,
*Noutliers,
point, ctx))
- goto done;
+ {
+ free(factors);
+ return markedAny;
+ }
// I have my list of POTENTIAL outliers (any that have factor > 1.0). I
// check to see how much confidence I would lose if I were to throw out any
@@ -2427,7 +2446,10 @@ bool dogleg_markOutliers(// output, input
// is acceptable
double confidence0 = getConfidence(-1);
if( confidence0 < 0.0 )
- goto done;
+ {
+ free(factors);
+ return markedAny;
+ }
SAY_IF_VERBOSE("Initial confidence: %g", confidence0);
@@ -2466,7 +2488,6 @@ bool dogleg_markOutliers(// output, input
}
}
- done:
free(factors);
return markedAny;
}
@@ -2490,11 +2511,11 @@ void dogleg_reportOutliers( double (getConfidence)(int i_feature_exclude),
if(featureSize <= 1)
featureSize = 1;
- double* factors = malloc(Nfeatures * sizeof(double));
+ double* factors = static_cast<double*>(malloc(Nfeatures * sizeof(double)));
if(factors == NULL)
{
SAY("Error allocating factors");
- goto done;
+ free(factors);
}
dogleg_getOutliernessFactors(factors, scale,
@@ -2516,6 +2537,5 @@ void dogleg_reportOutliers( double (getConfidence)(int i_feature_exclude),
rot_confidence_drop_relative);
}
- done:
free(factors);
}

View File

@@ -13,7 +13,7 @@ def run_global_replacements(wpiutil_llvm_files):
# Rename namespace from llvm to wpi
content = content.replace("namespace llvm", "namespace wpi")
content = content.replace("llvm::", "wpi::")
content = content.replace("llvm:", "wpi:")
# Fix #includes
content = content.replace('include "llvm/ADT', 'include "wpi')
@@ -175,7 +175,7 @@ def copy_upstream_src(wpilib_root):
def main():
name = "llvm"
url = "https://github.com/llvm/llvm-project"
tag = "llvmorg-18.1.8"
tag = "llvmorg-19.1.6"
patch_options = {
"use_threeway": True,

View File

@@ -1,36 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:09:18 -0400
Subject: [PATCH 01/36] Remove StringRef, ArrayRef, and Optional
Subject: [PATCH 01/37] Remove StringRef, ArrayRef, and Optional
---
llvm/include/llvm/ADT/PointerUnion.h | 1 -
llvm/include/llvm/ADT/SmallSet.h | 2 +-
llvm/include/llvm/ADT/SmallString.h | 103 ++++++++++--------
llvm/include/llvm/ADT/SmallString.h | 101 ++++++++++--------
llvm/include/llvm/ADT/SmallVector.h | 7 +-
llvm/include/llvm/Support/Chrono.h | 10 +-
llvm/include/llvm/Support/Compiler.h | 2 +-
llvm/include/llvm/Support/ConvertUTF.h | 31 +++---
llvm/include/llvm/Support/ErrorHandling.h | 9 +-
.../llvm/Support/SmallVectorMemoryBuffer.h | 6 +-
llvm/include/llvm/Support/VersionTuple.h | 6 -
llvm/include/llvm/Support/VersionTuple.h | 6 --
.../llvm/Support/Windows/WindowsSupport.h | 4 +-
llvm/include/llvm/Support/raw_ostream.h | 46 +++++---
llvm/include/llvm/Support/xxhash.h | 16 +--
llvm/include/llvm/Support/raw_ostream.h | 46 ++++----
llvm/include/llvm/Support/xxhash.h | 18 ++--
llvm/lib/Support/ConvertUTFWrapper.cpp | 38 +++----
llvm/lib/Support/ErrorHandling.cpp | 13 +--
llvm/lib/Support/ErrorHandling.cpp | 13 ++-
llvm/lib/Support/SmallVector.cpp | 5 +-
llvm/lib/Support/raw_ostream.cpp | 25 ++---
llvm/lib/Support/xxhash.cpp | 10 +-
llvm/lib/Support/raw_ostream.cpp | 25 +++--
llvm/lib/Support/xxhash.cpp | 12 +--
llvm/unittests/ADT/DenseMapTest.cpp | 29 +----
llvm/unittests/ADT/FunctionExtrasTest.cpp | 12 +-
llvm/unittests/ADT/HashingTest.cpp | 2 +-
llvm/unittests/ADT/FunctionExtrasTest.cpp | 12 +--
llvm/unittests/ADT/SmallPtrSetTest.cpp | 1 -
llvm/unittests/ADT/SmallStringTest.cpp | 50 ++++-----
llvm/unittests/ADT/SmallVectorTest.cpp | 30 +----
llvm/unittests/ADT/SmallVectorTest.cpp | 30 ++----
llvm/unittests/Support/ConvertUTFTest.cpp | 41 ++++---
llvm/unittests/Support/xxhashTest.cpp | 4 +-
26 files changed, 232 insertions(+), 271 deletions(-)
llvm/unittests/Support/xxhashTest.cpp | 6 +-
25 files changed, 232 insertions(+), 273 deletions(-)
diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h
index 7d4ed02b622626bb8043acb57b8ce7ed97a5f949..8ac68dbc0a791b8ac0e0ca865e69024cb642aa70 100644
@@ -63,7 +62,7 @@ index a16e8ac6f07552d98250e808190b00ee270f12b3..aeee5f97799aea7e7588d7afba1e47b4
#include <type_traits>
#include <utility>
diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h
index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413b0e36e0f 100644
index be3193c6ef9beba622f39e3e76cd0f0c6dd422b0..9fab1a7726bc6745296f5ebb24aee4055408e5f5 100644
--- a/llvm/include/llvm/ADT/SmallString.h
+++ b/llvm/include/llvm/ADT/SmallString.h
@@ -15,8 +15,9 @@
@@ -137,14 +136,12 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
std::copy(Ref.begin(), Ref.end(), this->begin() + CurrentSize);
CurrentSize += Ref.size();
}
@@ -89,26 +90,30 @@ public:
@@ -89,26 +90,28 @@ public:
/// Check for string equality. This is more efficient than compare() when
/// the relative ordering of inequal strings isn't needed.
- [[nodiscard]] bool equals(StringRef RHS) const { return str().equals(RHS); }
+ [[nodiscard]] bool equals(std::string_view RHS) const {
+ return str().equals(RHS);
+ }
- [[nodiscard]] bool equals(StringRef RHS) const { return str() == RHS; }
+ [[nodiscard]] bool equals(std::string_view RHS) const { return str() == RHS; }
/// Check for string equality, ignoring case.
- [[nodiscard]] bool equals_insensitive(StringRef RHS) const {
@@ -173,7 +170,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
return str().compare_numeric(RHS);
}
@@ -116,14 +121,14 @@ public:
@@ -116,14 +119,14 @@ public:
/// @name String Predicates
/// @{
@@ -194,7 +191,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
}
/// @}
@@ -142,7 +147,7 @@ public:
@@ -142,7 +145,7 @@ public:
///
/// \returns The index of the first occurrence of \p Str, or npos if not
/// found.
@@ -203,7 +200,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
return str().find(Str, From);
}
@@ -150,7 +155,8 @@ public:
@@ -150,7 +153,8 @@ public:
///
/// \returns The index of the last occurrence of \p C, or npos if not
/// found.
@@ -213,7 +210,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
return str().rfind(C, From);
}
@@ -158,7 +164,9 @@ public:
@@ -158,7 +162,9 @@ public:
///
/// \returns The index of the last occurrence of \p Str, or npos if not
/// found.
@@ -224,7 +221,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
/// Find the first character in the string that is \p C, or npos if not
/// found. Same as find.
@@ -170,7 +178,8 @@ public:
@@ -170,7 +176,8 @@ public:
/// not found.
///
/// Complexity: O(size() + Chars.size())
@@ -234,7 +231,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
return str().find_first_of(Chars, From);
}
@@ -184,15 +193,15 @@ public:
@@ -184,15 +191,15 @@ public:
/// \p Chars, or npos if not found.
///
/// Complexity: O(size() + Chars.size())
@@ -253,7 +250,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
return str().find_last_of(C, From);
}
@@ -200,8 +209,8 @@ public:
@@ -200,8 +207,8 @@ public:
/// found.
///
/// Complexity: O(size() + Chars.size())
@@ -264,7 +261,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
return str().find_last_of(Chars, From);
}
@@ -214,7 +223,9 @@ public:
@@ -214,7 +221,9 @@ public:
/// Return the number of non-overlapped occurrences of \p Str in the
/// string.
@@ -275,7 +272,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
/// @}
/// @name Substring Operations
@@ -229,8 +240,8 @@ public:
@@ -229,8 +238,8 @@ public:
/// \param N The number of characters to included in the substring. If \p N
/// exceeds the number of characters remaining in the string, the string
/// suffix (starting with \p Start) will be returned.
@@ -286,7 +283,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
return str().substr(Start, N);
}
@@ -244,15 +255,15 @@ public:
@@ -244,15 +253,15 @@ public:
/// substring. If this is npos, or less than \p Start, or exceeds the
/// number of characters remaining in the string, the string suffix
/// (starting with \p Start) will be returned.
@@ -306,7 +303,7 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
}
// TODO: Make this const, if it's safe...
@@ -262,20 +273,20 @@ public:
@@ -262,20 +271,20 @@ public:
return this->data();
}
@@ -332,10 +329,10 @@ index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413
return *this;
}
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 09676d792dfebd88e5c8eace666b3ab0044a962e..c96fd0e4956ee6d586f85dc79623de137e781ce0 100644
index 17444147b102a9636fe4f0f48cfb647aaaf3ed6b..94d8da059f4f8bad50039b0d0b7993396707829c 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -27,13 +27,12 @@
@@ -28,13 +28,12 @@
#include <limits>
#include <memory>
#include <new>
@@ -350,7 +347,7 @@ index 09676d792dfebd88e5c8eace666b3ab0044a962e..c96fd0e4956ee6d586f85dc79623de13
template <typename IteratorT> class iterator_range;
template <class Iterator>
@@ -127,7 +126,7 @@ template <class T, typename = void> struct SmallVectorAlignmentAndSize {
@@ -128,7 +127,7 @@ template <class T, typename = void> struct SmallVectorAlignmentAndSize {
};
/// This is the part of SmallVectorTemplateBase which does not depend on whether
@@ -359,7 +356,7 @@ index 09676d792dfebd88e5c8eace666b3ab0044a962e..c96fd0e4956ee6d586f85dc79623de13
/// to avoid unnecessarily requiring T to be complete.
template <typename T, typename = void>
class SmallVectorTemplateCommon
@@ -1242,7 +1241,7 @@ public:
@@ -1243,7 +1242,7 @@ public:
template <typename U,
typename = std::enable_if_t<std::is_convertible<U, T>::value>>
@@ -412,10 +409,10 @@ index 71859af7c7e4a595140475daf356744f52d14d24..9c9ba7002310eba5113c14957f769702
bool show_unit = consumeShowUnit(Style);
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index 8c315d255bb772d9e3c100adbd2c07b61283219b..6789f0413d8dc94cb465b6e66506b036449ee186 100644
index d8e3794babc7449b436fa1d0bd858dab5198664b..7710bd9a08148289b5ba3b1f2dae5cccc4f26d4d 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -319,7 +319,7 @@
@@ -327,7 +327,7 @@
#endif
/// LLVM_GSL_POINTER - Apply this to non-owning classes like
@@ -639,7 +636,7 @@ index d3aacd14b2097b1e7e13c1003987c1fd52e0cf76..aabdb2f14668a990329b57f5454a0d7d
template <typename HandleTraits>
diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316ffa15939 100644
index df9ee2e5a78586d2a2e0eb6e0698953169f7bc58..18bdf4b7d3b96d42d93ca1e4800233b34be42a78 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -14,13 +14,12 @@
@@ -657,7 +654,7 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
#include <string>
#include <string_view>
#include <system_error>
@@ -208,7 +207,22 @@ public:
@@ -221,7 +220,22 @@ public:
return *this;
}
@@ -681,7 +678,7 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
// Inline fast path, particularly for strings with a known length.
size_t Size = Str.size();
@@ -241,7 +255,7 @@ public:
@@ -254,7 +268,7 @@ public:
// Inline fast path, particularly for constant strings where a sufficiently
// smart compiler will simplify strlen.
@@ -690,7 +687,7 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
}
raw_ostream &operator<<(const std::string &Str) {
@@ -249,10 +263,6 @@ public:
@@ -262,10 +276,6 @@ public:
return write(Str.data(), Str.length());
}
@@ -701,7 +698,7 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
raw_ostream &operator<<(const SmallVectorImpl<char> &Str) {
return write(Str.data(), Str.size());
}
@@ -285,7 +295,7 @@ public:
@@ -298,7 +308,7 @@ public:
/// Output \p Str, turning '\\', '\t', '\n', '"', and anything that doesn't
/// satisfy llvm::isPrint into an escape sequence.
@@ -710,7 +707,7 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
raw_ostream &write(unsigned char C);
raw_ostream &write(const char *Ptr, size_t Size);
@@ -501,14 +511,14 @@ public:
@@ -511,14 +521,14 @@ public:
/// As a special case, if Filename is "-", then the stream will use
/// STDOUT_FILENO instead of opening a file. This will not close the stdout
/// descriptor.
@@ -730,7 +727,7 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access,
sys::fs::OpenFlags Flags);
@@ -613,7 +623,7 @@ public:
@@ -630,7 +640,7 @@ public:
/// Open the specified file for reading/writing/seeking. If an error occurs,
/// information about the error is put into EC, and the stream should be
/// immediately destroyed.
@@ -739,7 +736,7 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
raw_fd_stream(int fd, bool shouldClose);
@@ -695,8 +705,8 @@ public:
@@ -716,8 +726,8 @@ public:
void flush() = delete;
@@ -747,10 +744,10 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
- StringRef str() const { return StringRef(OS.data(), OS.size()); }
+ /// Return a std::string_view for the vector contents.
+ std::string_view str() const { return std::string_view(OS.data(), OS.size()); }
SmallVectorImpl<char> &buffer() { return OS; }
void reserveExtraSpace(uint64_t ExtraSize) override {
OS.reserve(tell() + ExtraSize);
@@ -753,7 +763,7 @@ class Error;
@@ -777,7 +787,7 @@ class Error;
/// for other names. For raw_fd_ostream instances, the stream writes to
/// a temporary file. The final output file is atomically replaced with the
/// temporary file after the \p Write function is finished.
@@ -760,10 +757,10 @@ index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316
raw_ostream &operator<<(raw_ostream &OS, std::nullopt_t);
diff --git a/llvm/include/llvm/Support/xxhash.h b/llvm/include/llvm/Support/xxhash.h
index 0cef3a54e50d70177a7401324f7a4daca83c6599..3e19ebabb7ad0ff437220d9fdfe59a313386762a 100644
index 5f8a7ab360abe24e86286b2bd6b83df7ca5fa7d3..5267e22a45f6c0c6e3bc9ca1966ed9842772918e 100644
--- a/llvm/include/llvm/Support/xxhash.h
+++ b/llvm/include/llvm/Support/xxhash.h
@@ -38,16 +38,18 @@
@@ -38,17 +38,19 @@
#ifndef LLVM_SUPPORT_XXHASH_H
#define LLVM_SUPPORT_XXHASH_H
@@ -775,6 +772,7 @@ index 0cef3a54e50d70177a7401324f7a4daca83c6599..3e19ebabb7ad0ff437220d9fdfe59a31
+#include <string_view>
namespace llvm {
-uint64_t xxHash64(llvm::StringRef Data);
-uint64_t xxHash64(llvm::ArrayRef<uint8_t> Data);
+uint64_t xxHash64(std::string_view Data);
@@ -787,7 +785,16 @@ index 0cef3a54e50d70177a7401324f7a4daca83c6599..3e19ebabb7ad0ff437220d9fdfe59a31
+inline uint64_t xxh3_64bits(std::string_view data) {
+ return xxh3_64bits(span(reinterpret_cast<const uint8_t*>(data.data()), data.size()));
}
}
/*-**********************************************************************
@@ -72,7 +74,7 @@ struct XXH128_hash_t {
};
/// XXH3's 128-bit variant.
-XXH128_hash_t xxh3_128bits(ArrayRef<uint8_t> data);
+XXH128_hash_t xxh3_128bits(span<const uint8_t> data);
} // namespace llvm
diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp
index 3fa7365e72d34a5db941d1cbe2b1beebad5c10e6..d53462e742e61d3476915d5b2c5aa63772e78a8a 100644
@@ -922,7 +929,7 @@ index 3fa7365e72d34a5db941d1cbe2b1beebad5c10e6..d53462e742e61d3476915d5b2c5aa637
Result);
} else if (sizeof(wchar_t) == 4) {
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index b8b3b7424ac6b1de782e739782f9671194ce77a1..0aa13a0f78eb370b2a673ca4a773f26820575052 100644
index cb42e28c04a86dd60deae6fdb0b87850c1bf3727..561509e0efdf15f6e534f0621a5964d92511114c 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -14,7 +14,6 @@
@@ -1001,7 +1008,7 @@ index b6ce37842040b36fc79770ca0296255f2bb42a1a..4f6fee18b659adcbfd79822832f91417
}
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca487cde23 100644
index 2ce54faa9857e68d9c7de4ad28f6cfa5bae86908..2dbb0674406e1860fdd0c266df64003e45b12fa3 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -167,7 +167,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) {
@@ -1013,7 +1020,7 @@ index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca
bool UseHexEscapes) {
for (unsigned char c : Str) {
switch (c) {
@@ -570,7 +570,7 @@ void format_object_base::home() {
@@ -564,7 +564,7 @@ void format_object_base::home() {
// raw_fd_ostream
//===----------------------------------------------------------------------===//
@@ -1022,7 +1029,7 @@ index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca
sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access,
sys::fs::OpenFlags Flags) {
assert((Access & sys::fs::FA_Write) &&
@@ -596,25 +596,25 @@ static int getFD(StringRef Filename, std::error_code &EC,
@@ -590,25 +590,25 @@ static int getFD(StringRef Filename, std::error_code &EC,
return FD;
}
@@ -1053,7 +1060,7 @@ index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca
sys::fs::CreationDisposition Disp,
sys::fs::FileAccess Access,
sys::fs::OpenFlags Flags)
@@ -686,8 +686,7 @@ raw_fd_ostream::~raw_fd_ostream() {
@@ -680,8 +680,7 @@ raw_fd_ostream::~raw_fd_ostream() {
// has_error() and clear the error flag with clear_error() before
// destructing raw_ostream objects which may have errors.
if (has_error())
@@ -1063,7 +1070,7 @@ index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca
/*gen_crash_diag=*/false);
}
@@ -706,7 +705,7 @@ raw_fd_ostream::~raw_fd_ostream() {
@@ -700,7 +699,7 @@ raw_fd_ostream::~raw_fd_ostream() {
// the input is UTF-8 or transcode from the local codepage to UTF-8 before
// quoting it. If they don't, this may mess up the encoding, but this is still
// probably the best compromise we can make.
@@ -1072,7 +1079,7 @@ index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca
SmallVector<wchar_t, 256> WideText;
// Fall back to ::write if it wasn't valid UTF-8.
@@ -749,7 +748,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
@@ -746,7 +745,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) {
// If this is a Windows console device, try re-encoding from UTF-8 to UTF-16
// and using WriteConsoleW. If that fails, fall back to plain write().
if (IsWindowsConsole)
@@ -1081,7 +1088,7 @@ index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca
return;
#endif
@@ -925,7 +924,7 @@ raw_ostream &llvm::nulls() {
@@ -922,7 +921,7 @@ raw_ostream &llvm::nulls() {
// File Streams
//===----------------------------------------------------------------------===//
@@ -1090,7 +1097,7 @@ index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca
: raw_fd_ostream(getFD(Filename, EC, sys::fs::CD_CreateAlways,
sys::fs::FA_Write | sys::fs::FA_Read,
sys::fs::OF_None),
@@ -998,7 +997,7 @@ void buffer_ostream::anchor() {}
@@ -1007,7 +1006,7 @@ void buffer_ostream::anchor() {}
void buffer_unique_ostream::anchor() {}
@@ -1100,10 +1107,10 @@ index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca
if (OutputFileName == "-")
return Write(outs());
diff --git a/llvm/lib/Support/xxhash.cpp b/llvm/lib/Support/xxhash.cpp
index 577f14189caff7d74377f7b28d8332deef4c62c4..b9c15e885a1751eaca43317323bd7a85fa201073 100644
index cdb76d57e2c1df67e07c39f5e59284ab0ce07984..2496050eef7349ad82b54ffa6fb6bff8278c8364 100644
--- a/llvm/lib/Support/xxhash.cpp
+++ b/llvm/lib/Support/xxhash.cpp
@@ -84,11 +84,11 @@ static uint64_t XXH64_avalanche(uint64_t hash) {
@@ -100,11 +100,11 @@ static uint64_t XXH64_avalanche(uint64_t hash) {
return hash;
}
@@ -1118,7 +1125,7 @@ index 577f14189caff7d74377f7b28d8332deef4c62c4..b9c15e885a1751eaca43317323bd7a85
uint64_t H64;
if (Len >= 32) {
@@ -144,7 +144,7 @@ uint64_t llvm::xxHash64(StringRef Data) {
@@ -160,7 +160,7 @@ uint64_t llvm::xxHash64(StringRef Data) {
return XXH64_avalanche(H64);
}
@@ -1127,7 +1134,7 @@ index 577f14189caff7d74377f7b28d8332deef4c62c4..b9c15e885a1751eaca43317323bd7a85
return xxHash64({(const char *)Data.data(), Data.size()});
}
@@ -394,7 +394,7 @@ static uint64_t XXH3_hashLong_64b(const uint8_t *input, size_t len,
@@ -550,7 +550,7 @@ static uint64_t XXH3_hashLong_64b(const uint8_t *input, size_t len,
(uint64_t)len * PRIME64_1);
}
@@ -1136,12 +1143,21 @@ index 577f14189caff7d74377f7b28d8332deef4c62c4..b9c15e885a1751eaca43317323bd7a85
auto *in = data.data();
size_t len = data.size();
if (len <= 16)
@@ -1020,7 +1020,7 @@ XXH3_hashLong_128b(const uint8_t *input, size_t len, const uint8_t *secret,
return h128;
}
-llvm::XXH128_hash_t llvm::xxh3_128bits(ArrayRef<uint8_t> data) {
+llvm::XXH128_hash_t llvm::xxh3_128bits(span<const uint8_t> data) {
size_t len = data.size();
const uint8_t *input = data.data();
diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp
index cc3244528f27e2bd7eaa385d8b7f49b2fbb7a3e6..b710ac07461ba58faa99cedeae7f209dc0f5902b 100644
index d1bbdde8dfc267770b9d98808de54381571f2785..e93e18423507655ce8275a0718d8e5d01915985f 100644
--- a/llvm/unittests/ADT/DenseMapTest.cpp
+++ b/llvm/unittests/ADT/DenseMapTest.cpp
@@ -9,11 +9,11 @@
#include "llvm/ADT/DenseMap.h"
@@ -10,11 +10,11 @@
#include "CountCopyAndMove.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/DenseMapInfoVariant.h"
-#include "llvm/ADT/StringRef.h"
@@ -1153,8 +1169,8 @@ index cc3244528f27e2bd7eaa385d8b7f49b2fbb7a3e6..b710ac07461ba58faa99cedeae7f209d
#include <utility>
#include <variant>
@@ -499,31 +499,6 @@ TEST(DenseMapCustomTest, ReserveTest) {
}
@@ -523,31 +523,6 @@ TEST(DenseMapCustomTest, InsertOrAssignTest) {
EXPECT_EQ(1, CountCopyAndMove::MoveAssignments);
}
-// Make sure DenseMap works with StringRef keys.
@@ -1185,7 +1201,7 @@ index cc3244528f27e2bd7eaa385d8b7f49b2fbb7a3e6..b710ac07461ba58faa99cedeae7f209d
// Key traits that allows lookup with either an unsigned or char* key;
// In the latter case, "a" == 0, "b" == 1 and so on.
struct TestDenseMapInfo {
@@ -761,7 +736,7 @@ TEST(DenseMapCustomTest, VariantSupport) {
@@ -785,7 +760,7 @@ TEST(DenseMapCustomTest, VariantSupport) {
// Test that gTest prints map entries as pairs instead of opaque objects.
// See third-party/unittest/googletest/internal/custom/gtest-printers.h
TEST(DenseMapCustomTest, PairPrinting) {
@@ -1228,21 +1244,8 @@ index fc856a976946bf6decda9b6724cac66afc7bdcd6..aff9d61c7f0d48834123b04b74a2e4f7
TEST(UniqueFunctionTest, SFINAE) {
EXPECT_EQ("not a function", returns("boo!"));
diff --git a/llvm/unittests/ADT/HashingTest.cpp b/llvm/unittests/ADT/HashingTest.cpp
index ab13ee833ce556945fb9526fd13d8bd5f3e5c95a..3e80467ebd0efddcf2cbbe003bb91f1475ca9cb3 100644
--- a/llvm/unittests/ADT/HashingTest.cpp
+++ b/llvm/unittests/ADT/HashingTest.cpp
@@ -295,7 +295,7 @@ TEST(HashingTest, HashCombineRangeGoldenTest) {
#endif
};
for (unsigned i = 0; i < sizeof(golden_data)/sizeof(*golden_data); ++i) {
- StringRef str = golden_data[i].s;
+ std::string_view str = golden_data[i].s;
hash_code hash = hash_combine_range(str.begin(), str.end());
#if 0 // Enable this to generate paste-able text for the above structure.
std::string member_str = "\"" + str.str() + "\",";
diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp
index a97f2617cbf70783f3569709f7ee1bff03baebd2..7ed8670fd31ea2a14e6ba7f59a8ac8e35046890c 100644
index b45318d076a3d846b7810ce8cdaed7d2d97eca87..a39b11b9f82156a78b9ad7ce7b8c28855829e611 100644
--- a/llvm/unittests/ADT/SmallPtrSetTest.cpp
+++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp
@@ -12,7 +12,6 @@
@@ -1621,11 +1624,11 @@ index 6e75fbae0969ba1bf0a76c4d79a123e405a8dae7..3b07d344f15a555f11ad5f8177a0a65b
// Overlong sequences of the above.
EXPECT_TRUE(CheckConvertUTF8ToUnicodeScalars(
diff --git a/llvm/unittests/Support/xxhashTest.cpp b/llvm/unittests/Support/xxhashTest.cpp
index 7d78de6772b5159459572fe11633c76d04b86907..d61a5acd21f4d685ca631d3adb20c2649e050bc3 100644
index 84308ce130e72818b553ea4185e8542d13182b3c..ef9a43690974ba586acc681e9f8ac49d4661031e 100644
--- a/llvm/unittests/Support/xxhashTest.cpp
+++ b/llvm/unittests/Support/xxhashTest.cpp
@@ -12,7 +12,7 @@
using namespace llvm;
@@ -32,7 +32,7 @@ static void fillTestBuffer(uint8_t *buffer, size_t len) {
}
TEST(xxhashTest, Basic) {
- EXPECT_EQ(0xef46db3751d8e999U, xxHash64(StringRef()));
@@ -1633,7 +1636,7 @@ index 7d78de6772b5159459572fe11633c76d04b86907..d61a5acd21f4d685ca631d3adb20c264
EXPECT_EQ(0x33bf00a859c4ba3fU, xxHash64("foo"));
EXPECT_EQ(0x48a37c90ad27a659U, xxHash64("bar"));
EXPECT_EQ(0x69196c1b3af0bff9U,
@@ -31,7 +31,7 @@ TEST(xxhashTest, xxh3) {
@@ -51,7 +51,7 @@ TEST(xxhashTest, xxh3) {
}
#define F(len, expected) \
@@ -1642,3 +1645,12 @@ index 7d78de6772b5159459572fe11633c76d04b86907..d61a5acd21f4d685ca631d3adb20c264
F(0, 0x2d06800538d394c2);
F(1, 0xd0d496e05c553485);
F(2, 0x84d625edb7055eac);
@@ -90,7 +90,7 @@ TEST(xxhashTest, xxh3_128bits) {
#define F(len, expected) \
EXPECT_EQ(XXH128_hash_t(expected), \
- xxh3_128bits(ArrayRef(sanityBuffer, size_t(len))))
+ xxh3_128bits(span(sanityBuffer, size_t(len))))
F(0, (XXH128_hash_t{0x6001C324468D497FULL,
0x99AA06D3014798D8ULL})); /* empty string */

View File

@@ -1,20 +1,20 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:12:41 -0400
Subject: [PATCH 02/36] Wrap std::min/max calls in parens, for Windows warnings
Subject: [PATCH 02/37] Wrap std::min/max calls in parens, for Windows warnings
---
llvm/include/llvm/ADT/DenseMap.h | 4 ++--
llvm/include/llvm/ADT/SmallVector.h | 6 +++---
llvm/include/llvm/Support/ConvertUTF.h | 2 +-
llvm/include/llvm/Support/MathExtras.h | 18 +++++++++---------
4 files changed, 15 insertions(+), 15 deletions(-)
llvm/include/llvm/Support/MathExtras.h | 20 ++++++++++----------
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004be6facafb 100644
index 7ccc9445c0a7b882b424b2431858ea596d0eb58f..c4764fffa845a7f9eb69f262aa0ee728d08b1655 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -416,7 +416,7 @@ protected:
@@ -432,7 +432,7 @@ protected:
return 0;
// +1 is required because of the strict equality.
// For example if NumEntries is 48, we need to return 401.
@@ -23,7 +23,7 @@ index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004b
}
void moveFromOldBuckets(BucketT *OldBucketsBegin, BucketT *OldBucketsEnd) {
@@ -852,7 +852,7 @@ public:
@@ -868,7 +868,7 @@ public:
// Reduce the number of buckets.
unsigned NewNumBuckets = 0;
if (OldNumEntries)
@@ -33,10 +33,10 @@ index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004b
this->BaseT::initEmpty();
return;
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index c96fd0e4956ee6d586f85dc79623de137e781ce0..d7600fe209a58deb07c63e2553f9dad62e06e973 100644
index 94d8da059f4f8bad50039b0d0b7993396707829c..85bf5172e419b1b58f53d3cf00d4aabb58877c33 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -55,7 +55,7 @@ protected:
@@ -56,7 +56,7 @@ protected:
/// The maximum value of the Size_T used.
static constexpr size_t SizeTypeMax() {
@@ -45,7 +45,7 @@ index c96fd0e4956ee6d586f85dc79623de137e781ce0..d7600fe209a58deb07c63e2553f9dad6
}
SmallVectorBase() = delete;
@@ -289,7 +289,7 @@ public:
@@ -290,7 +290,7 @@ public:
size_type size_in_bytes() const { return size() * sizeof(T); }
size_type max_size() const {
@@ -54,7 +54,7 @@ index c96fd0e4956ee6d586f85dc79623de137e781ce0..d7600fe209a58deb07c63e2553f9dad6
}
size_t capacity_in_bytes() const { return capacity() * sizeof(T); }
@@ -721,7 +721,7 @@ public:
@@ -722,7 +722,7 @@ public:
}
// Assign over existing elements.
@@ -77,10 +77,10 @@ index 5c0e3009c25446a34882fb98329b1d955231bb39..72321022beb373945f7935ed72944fd6
/* Some fundamental constants */
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h
index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c91ba725d 100644
index e568e42afcf4d20dba137346953ff4be9d27ffc7..d9de2e92d5b07bce1d02ffcfda614b9079d2df91 100644
--- a/llvm/include/llvm/Support/MathExtras.h
+++ b/llvm/include/llvm/Support/MathExtras.h
@@ -311,26 +311,26 @@ template <> constexpr inline size_t CTLog2<1>() { return 0; }
@@ -338,26 +338,26 @@ template <> constexpr size_t CTLog2<1>() { return 0; }
/// (32 bit edition.)
/// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2
inline unsigned Log2_32(uint32_t Value) {
@@ -111,7 +111,16 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
}
/// A and B are either alignments or offsets. Return the minimum alignment that
@@ -482,7 +482,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) {
@@ -417,7 +417,7 @@ constexpr uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator) {
// happens only when Numerator = INT_MIN and Denominator = -1.
template <typename U, typename V>
constexpr bool divideSignedWouldOverflow(U Numerator, V Denominator) {
- return Numerator == std::numeric_limits<U>::min() && Denominator == -1;
+ return Numerator == (std::numeric_limits<U>::min)() && Denominator == -1;
}
/// Returns the integer ceil(Numerator / Denominator). Signed version.
@@ -605,7 +605,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) {
T Z = X + Y;
Overflowed = (Z < X || Z < Y);
if (Overflowed)
@@ -120,7 +129,7 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
else
return Z;
}
@@ -495,7 +495,7 @@ std::enable_if_t<std::is_unsigned_v<T>, T> SaturatingAdd(T X, T Y, T Z,
@@ -618,7 +618,7 @@ std::enable_if_t<std::is_unsigned_v<T>, T> SaturatingAdd(T X, T Y, T Z,
bool Overflowed = false;
T XY = SaturatingAdd(X, Y, &Overflowed);
if (Overflowed)
@@ -129,7 +138,7 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
return SaturatingAdd(XY, Z, Args...);
}
@@ -519,7 +519,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) {
@@ -642,7 +642,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) {
// Special case: if X or Y is 0, Log2_64 gives -1, and Log2Z
// will necessarily be less than Log2Max as desired.
int Log2Z = Log2_64(X) + Log2_64(Y);
@@ -138,7 +147,7 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
int Log2Max = Log2_64(Max);
if (Log2Z < Log2Max) {
return X * Y;
@@ -639,9 +639,9 @@ std::enable_if_t<std::is_signed_v<T>, T> MulOverflow(T X, T Y, T &Result) {
@@ -764,9 +764,9 @@ std::enable_if_t<std::is_signed_v<T>, T> MulOverflow(T X, T Y, T &Result) {
// Check how the max allowed absolute value (2^n for negative, 2^(n-1) for
// positive) divided by an argument compares to the other.
if (IsNegative)
@@ -147,6 +156,6 @@ index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c
else
- return UX > (static_cast<U>(std::numeric_limits<T>::max())) / UY;
+ return UX > (static_cast<U>((std::numeric_limits<T>::max)())) / UY;
#endif
}
} // End llvm namespace

View File

@@ -1,14 +1,14 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:13:55 -0400
Subject: [PATCH 03/36] Change unique_function storage size
Subject: [PATCH 03/37] Change unique_function storage size
---
llvm/include/llvm/ADT/FunctionExtras.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index c0bc30c7450fe4b2bc6b9b448824eedc8b132e52..5641a913d0a35ee2911cf872ad90c3dc864f20f5 100644
index 49e0e8ab0db400d0a362746342099578257b2eea..3ce85530b718666afa1dafbf60699c1add423ea6 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -79,7 +79,7 @@ using EnableIfCallable = std::enable_if_t<std::disjunction<
@@ -28,4 +28,4 @@ index c0bc30c7450fe4b2bc6b9b448824eedc8b132e52..5641a913d0a35ee2911cf872ad90c3dc
+ // provide four pointers worth of storage here.
// This is mutable as an inlined `const unique_function<void() const>` may
// still modify its own mutable members.
mutable std::aligned_storage_t<InlineStorageSize, alignof(void *)>
alignas(void *) mutable std::byte InlineStorage[InlineStorageSize];

View File

@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:17:19 -0400
Subject: [PATCH 04/36] Threading updates
Subject: [PATCH 04/37] Threading updates
- Remove guards for threads and exception
- Prefer scope gaurd over lock gaurd
@@ -12,10 +12,10 @@ Subject: [PATCH 04/36] Threading updates
3 files changed, 11 insertions(+), 43 deletions(-)
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index 6789f0413d8dc94cb465b6e66506b036449ee186..e608f8ea3a837a04d9c29c8bb7a1fab527d512bb 100644
index 7710bd9a08148289b5ba3b1f2dae5cccc4f26d4d..2a6accec1e74c9869d724c7733cc75ab6af9dc8d 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -555,7 +555,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -563,7 +563,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
/// initialize to some constant value. In almost all circumstances this is most
/// appropriate for use with a pointer, integer, or small aggregation of
/// pointers and integers.
@@ -23,7 +23,7 @@ index 6789f0413d8dc94cb465b6e66506b036449ee186..e608f8ea3a837a04d9c29c8bb7a1fab5
#if __has_feature(cxx_thread_local) || defined(_MSC_VER)
#define LLVM_THREAD_LOCAL thread_local
#else
@@ -563,11 +562,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -571,11 +570,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
// we only need the restricted functionality that provides.
#define LLVM_THREAD_LOCAL __thread
#endif
@@ -36,7 +36,7 @@ index 6789f0413d8dc94cb465b6e66506b036449ee186..e608f8ea3a837a04d9c29c8bb7a1fab5
/// \macro LLVM_ENABLE_EXCEPTIONS
/// Whether LLVM is built with exception support.
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb8ba1276e 100644
index 561509e0efdf15f6e534f0621a5964d92511114c..89829dc4faff0b2667ded462444e0eaeec53fd01 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -44,7 +44,6 @@ static void *ErrorHandlerUserData = nullptr;
@@ -83,7 +83,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
handler = ErrorHandler;
handlerData = ErrorHandlerUserData;
}
@@ -126,18 +118,14 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
@@ -126,9 +118,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler,
void *user_data) {
@@ -91,9 +91,10 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
- std::lock_guard<std::mutex> Lock(BadAllocErrorHandlerMutex);
-#endif
+ std::scoped_lock Lock(BadAllocErrorHandlerMutex);
assert(!ErrorHandler && "Bad alloc error handler already registered!\n");
assert(!BadAllocErrorHandler &&
"Bad alloc error handler already registered!\n");
BadAllocErrorHandler = handler;
BadAllocErrorHandlerUserData = user_data;
@@ -136,9 +126,7 @@ void llvm::install_bad_alloc_error_handler(fatal_error_handler_t handler,
}
void llvm::remove_bad_alloc_error_handler() {
@@ -104,7 +105,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
BadAllocErrorHandler = nullptr;
BadAllocErrorHandlerUserData = nullptr;
}
@@ -148,9 +136,7 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
@@ -149,9 +137,7 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
{
// Only acquire the mutex while reading the handler, so as not to invoke a
// user-supplied callback under a lock.
@@ -115,7 +116,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
Handler = BadAllocErrorHandler;
HandlerData = BadAllocErrorHandlerUserData;
}
@@ -160,10 +146,6 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
@@ -161,10 +147,6 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
llvm_unreachable("bad alloc handler should not return");
}
@@ -126,7 +127,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
// Don't call the normal error handler. It may allocate memory. Directly write
// an OOM to stderr and abort.
const char *OOMMessage = "LLVM ERROR: out of memory\n";
@@ -172,15 +154,8 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
@@ -173,15 +155,8 @@ void llvm::report_bad_alloc_error(const char *Reason, bool GenCrashDiag) {
(void)!::write(2, Reason, strlen(Reason));
(void)!::write(2, Newline, strlen(Newline));
abort();
@@ -142,7 +143,7 @@ index 0aa13a0f78eb370b2a673ca4a773f26820575052..637b669a7d0dae69ef4b34955f21a9fb
// Causes crash on allocation failure. It is called prior to the handler set by
// 'install_bad_alloc_error_handler'.
static void out_of_memory_new_handler() {
@@ -195,7 +170,6 @@ void llvm::install_out_of_memory_new_handler() {
@@ -196,7 +171,6 @@ void llvm::install_out_of_memory_new_handler() {
assert((old == nullptr || old == out_of_memory_new_handler) &&
"new-handler already installed");
}

View File

@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:28:13 -0400
Subject: [PATCH 05/36] \#ifdef guard safety
Subject: [PATCH 05/37] \#ifdef guard safety
Prevents redefinition if someone is pulling in real LLVM, since the macros are in global namespace
---
@@ -9,7 +9,7 @@ Prevents redefinition if someone is pulling in real LLVM, since the macros are i
1 file changed, 42 insertions(+)
diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2a451c037 100644
index 2a6accec1e74c9869d724c7733cc75ab6af9dc8d..cb99bf5efe87d98fd73108c189182a28998bcbe9 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -90,6 +90,7 @@
@@ -137,19 +137,23 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
#if __has_attribute(returns_nonnull)
#define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
#elif defined(_MSC_VER)
@@ -277,9 +296,11 @@
@@ -277,6 +296,7 @@
#else
#define LLVM_ATTRIBUTE_RETURNS_NONNULL
#endif
+#endif
/// LLVM_ATTRIBUTE_RESTRICT - Annotates a pointer to tell the compiler that
/// it is not aliased in the current scope.
@@ -288,6 +308,7 @@
/// \macro LLVM_ATTRIBUTE_RETURNS_NOALIAS Used to mark a function as returning a
/// pointer that does not alias any other valid pointer.
+#ifndef LLVM_ATTRIBUTE_RETURNS_NOALIAS
#ifdef __GNUC__
#define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
#elif defined(_MSC_VER)
@@ -287,8 +308,10 @@
@@ -295,8 +316,10 @@
#else
#define LLVM_ATTRIBUTE_RETURNS_NOALIAS
#endif
@@ -160,7 +164,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
#if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough)
#define LLVM_FALLTHROUGH [[fallthrough]]
#elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
@@ -300,6 +323,7 @@
@@ -308,6 +331,7 @@
#else
#define LLVM_FALLTHROUGH
#endif
@@ -168,7 +172,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
/// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that
/// they are constant initialized.
@@ -334,11 +358,13 @@
@@ -342,11 +366,13 @@
/// LLVM_EXTENSION - Support compilers where we have a keyword to suppress
/// pedantic diagnostics.
@@ -182,7 +186,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
/// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
/// to an expression which states that it is undefined behavior for the
@@ -347,14 +373,17 @@
@@ -355,14 +381,17 @@
/// '#else' is intentionally left out so that other macro logic (e.g.,
/// LLVM_ASSUME_ALIGNED and llvm_unreachable()) can detect whether
/// LLVM_BUILTIN_UNREACHABLE has a definition.
@@ -200,7 +204,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
#if __has_builtin(__builtin_trap) || defined(__GNUC__)
# define LLVM_BUILTIN_TRAP __builtin_trap()
#elif defined(_MSC_VER)
@@ -366,10 +395,12 @@
@@ -374,10 +403,12 @@
#else
# define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0
#endif
@@ -213,7 +217,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
#if __has_builtin(__builtin_debugtrap)
# define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap()
#elif defined(_MSC_VER)
@@ -383,9 +414,11 @@
@@ -391,9 +422,11 @@
// program to abort if encountered.
# define LLVM_BUILTIN_DEBUGTRAP
#endif
@@ -225,7 +229,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
#if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__)
# define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a)
#elif defined(LLVM_BUILTIN_UNREACHABLE)
@@ -394,6 +427,7 @@
@@ -402,6 +435,7 @@
#else
# define LLVM_ASSUME_ALIGNED(p, a) (p)
#endif
@@ -233,7 +237,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
/// \macro LLVM_PACKED
/// Used to specify a packed structure.
@@ -413,6 +447,7 @@
@@ -421,6 +455,7 @@
/// long long l;
/// };
/// LLVM_PACKED_END
@@ -241,7 +245,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
#ifdef _MSC_VER
# define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop))
# define LLVM_PACKED_START __pragma(pack(push, 1))
@@ -422,6 +457,7 @@
@@ -430,6 +465,7 @@
# define LLVM_PACKED_START _Pragma("pack(push, 1)")
# define LLVM_PACKED_END _Pragma("pack(pop)")
#endif
@@ -249,7 +253,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
/// \macro LLVM_MEMORY_SANITIZER_BUILD
/// Whether LLVM itself is built with MemorySanitizer instrumentation.
@@ -513,11 +549,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -521,11 +557,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
/// \macro LLVM_NO_SANITIZE
/// Disable a particular sanitizer for a function.
@@ -263,7 +267,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
/// Mark debug helper function definitions like dump() that should not be
/// stripped from debug builds.
@@ -525,17 +563,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -533,17 +571,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
/// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always
/// get stripped in release builds.
// FIXME: Move this to a private config.h as it's not usable in public headers.
@@ -284,7 +288,7 @@ index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2
#if defined(_MSC_VER)
#define LLVM_PRETTY_FUNCTION __FUNCSIG__
#elif defined(__GNUC__) || defined(__clang__)
@@ -543,6 +584,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
@@ -551,6 +592,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
#else
#define LLVM_PRETTY_FUNCTION __func__
#endif

View File

@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
Date: Sat, 7 May 2022 22:37:34 -0400
Subject: [PATCH 06/36] Explicitly use std::
Subject: [PATCH 06/37] Explicitly use std::
---
llvm/include/llvm/ADT/SmallSet.h | 2 +-
@@ -24,10 +24,10 @@ index aeee5f97799aea7e7588d7afba1e47b4fa3d8c7b..4969dfb0d61c2fad805c9cb7bc0184ea
/// Inequality comparison for SmallSet.
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index 637b669a7d0dae69ef4b34955f21a9fb8ba1276e..0b87b375de67dc18647e3ebe646bf323dd05e8c5 100644
index 89829dc4faff0b2667ded462444e0eaeec53fd01..ea8d60426ead7163550b73e0fdc32cb11bb089cb 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -213,7 +213,7 @@ void LLVMResetFatalErrorHandler() {
@@ -249,7 +249,7 @@ std::error_code llvm::mapLastWindowsError() {
// I'd rather not double the line count of the following.
#define MAP_ERR_TO_COND(x, y) \
case x: \
@@ -37,10 +37,10 @@ index 637b669a7d0dae69ef4b34955f21a9fb8ba1276e..0b87b375de67dc18647e3ebe646bf323
std::error_code llvm::mapWindowsError(unsigned EV) {
switch (EV) {
diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp
index 7ed8670fd31ea2a14e6ba7f59a8ac8e35046890c..531f81ab5b3fc1dcff731230f3cb7649cb90aedf 100644
index a39b11b9f82156a78b9ad7ce7b8c28855829e611..a6c2b329f072639706aa221feb8c08e33533f813 100644
--- a/llvm/unittests/ADT/SmallPtrSetTest.cpp
+++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp
@@ -298,7 +298,7 @@ TEST(SmallPtrSetTest, dereferenceAndIterate) {
@@ -259,7 +259,7 @@ TEST(SmallPtrSetTest, dereferenceAndIterate) {
// Sort. We should hit the first element just once and the final element N
// times.

Some files were not shown because too many files have changed in this diff Show More