mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-07-26 10:38:52 +00:00
fix clang format workflow, update hackrf submodule, fix subghzd compilation warning, remove flashsize.h (#2992)
* trying to fix clang format workflow
* try without docker repo, classic apt install
* find what installed clang format 18 version is
* removed auto generated flashsize
* comment on flashsize.h
* modified to use repo owned clang-format binaries
* code format for windows hosts
* add clang-format binaries for linux x86_64/arm64, macos-arm64, windows x86_64
* add helper script to download specific llvm clang-format version
* add helper to download missing libraries (use docker)
* use custom clang-format
* fix ui_subghzd.cpp:85:29: warning: narrowing conversion of 'this->ui::SubGhzDRecentEntryDetailView::cnt' from 'uint32_t' {aka 'long unsigned int'} to 'uint16_t' {aka 'short unsigned int'} [-Wnarrowing]
* remove auto generated file
* Update tools/clang-format.sh
* removed fallback
* updated hackrf submodule
This commit is contained in:
@@ -3,7 +3,7 @@ name: Check formatting
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
check_date:
|
||||
check_format:
|
||||
runs-on: ubuntu-latest
|
||||
name: Check formatting
|
||||
strategy:
|
||||
@@ -13,12 +13,20 @@ jobs:
|
||||
- "firmware/application"
|
||||
- "firmware/baseband"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: print latest_commit
|
||||
run: echo ${{ github.sha }}
|
||||
- name: clang-format Check
|
||||
uses: jidicula/clang-format-action@v4.11.0
|
||||
with:
|
||||
clang-format-version: '18'
|
||||
check-path: ${{ matrix.path }}
|
||||
fallback-style: Chromium
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: clang-format check (repo pinned)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
CF="./tools/clang-format.sh"
|
||||
chmod +x "$CF" || true
|
||||
|
||||
"$CF" --version
|
||||
|
||||
ROOT="${{ matrix.path }}"
|
||||
find "$ROOT" -type f \( \
|
||||
-name '*.c' -o -name '*.cpp' -o \
|
||||
-name '*.h' -o -name '*.hpp' \
|
||||
\) -print0 \
|
||||
| xargs -0 -r "$CF" --dry-run --Werror --style=file
|
||||
|
||||
+2
-1
@@ -83,4 +83,5 @@ venv/
|
||||
# generated bitmap arr file
|
||||
# TODO: generate bitmap during build, since we use python during build anyway, lemme know if this is a bad idea @zxkmm
|
||||
/firmware/tools/bitmap.hpp
|
||||
firmware/flashsize.h
|
||||
# flashsize is generated by cmake
|
||||
/firmware/flashsize.h
|
||||
|
||||
@@ -43,7 +43,7 @@ bool read_keeloq_file(const fs::path& path, KeeloqData& data) {
|
||||
|
||||
data.mf_name = std::string{chunks[0]};
|
||||
data.serial = std::strtoul(chunks[1].data(), NULL, 16);
|
||||
data.counter = (uint16_t)std::atoi(chunks[2].data());
|
||||
data.counter = std::atoi(chunks[2].data());
|
||||
data.btn = (uint8_t)std::atoi(chunks[3].data());
|
||||
|
||||
return true;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
struct KeeloqData {
|
||||
std::string mf_name{};
|
||||
uint32_t serial = 0;
|
||||
uint16_t counter = 0;
|
||||
uint32_t counter = 0;
|
||||
uint8_t btn = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
// DO NOT EDIT: IT IS AUTO GENERATED BY CMAKE!!!!
|
||||
|
||||
// clang-format off
|
||||
//Allowed fw size in MB
|
||||
#define FLASH_SIZE_MB 4
|
||||
//Current compiled fw size in MB
|
||||
#define FLASH_SIZE_LIMIT_MB 3.5
|
||||
// clang-format on
|
||||
@@ -0,0 +1,37 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Run from repo root (script is in repo root)
|
||||
$CF = Join-Path $PSScriptRoot "tools\clang-format.ps1"
|
||||
|
||||
if (-not (Test-Path $CF)) {
|
||||
throw "ERROR: $CF not found. Did you commit tools\clang-format.ps1 and the pinned binaries?"
|
||||
}
|
||||
|
||||
# Print version for traceability
|
||||
& $CF --version | Write-Host
|
||||
|
||||
# Collect files (PowerShell-native; avoids xargs/find differences on Windows)
|
||||
$roots = @(
|
||||
"firmware/common",
|
||||
"firmware/baseband",
|
||||
"firmware/application",
|
||||
"firmware/test/application",
|
||||
"firmware/test/baseband"
|
||||
)
|
||||
|
||||
$files = foreach ($r in $roots) {
|
||||
if (Test-Path $r) {
|
||||
Get-ChildItem -Path $r -Recurse -File -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Extension -in @(".h", ".hpp", ".c", ".cpp") } |
|
||||
ForEach-Object { $_.FullName }
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $files -or $files.Count -eq 0) {
|
||||
Write-Host "No matching source files found."
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Format in place
|
||||
& $CF -style=file -i -- $files
|
||||
exit $LASTEXITCODE
|
||||
+15
-2
@@ -1,4 +1,18 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Run from repo root (script is in repo root)
|
||||
CF="./tools/clang-format.sh"
|
||||
|
||||
# Sanity check
|
||||
if [ ! -x "$CF" ]; then
|
||||
echo "ERROR: $CF not found or not executable." >&2
|
||||
echo "Did you commit the pinned clang-format binaries and wrappers under tools/ ?" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Print version for traceability
|
||||
"$CF" --version
|
||||
|
||||
find firmware/common \
|
||||
firmware/baseband \
|
||||
@@ -7,5 +21,4 @@ find firmware/common \
|
||||
firmware/test/baseband \
|
||||
\( -iname '*.h' -o -iname '*.hpp' -o -iname '*.c' -o -iname '*.cpp' \) \
|
||||
-print0 | \
|
||||
xargs -0 clang-format-18 -style=file -i
|
||||
|
||||
xargs -0 -r "$CF" -style=file -i
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$Ver = "18.1.8"
|
||||
$Root = Resolve-Path (Join-Path $PSScriptRoot "..")
|
||||
|
||||
$Bin = Join-Path $Root "tools\clang-format-bin\$Ver\windows-x86_64\clang-format.exe"
|
||||
if (-not (Test-Path $Bin)) {
|
||||
throw "Missing clang-format binary: $Bin"
|
||||
}
|
||||
|
||||
& $Bin @args
|
||||
exit $LASTEXITCODE
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
VER="18.1.8"
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
OS="$(uname -s)"
|
||||
ARCH="$(uname -m)"
|
||||
|
||||
case "$OS" in
|
||||
Linux) OS_ID="linux" ;;
|
||||
Darwin) OS_ID="macos" ;;
|
||||
*) echo "Unsupported OS: $OS" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
case "$ARCH" in
|
||||
x86_64|amd64) ARCH_ID="x86_64" ;;
|
||||
arm64|aarch64) ARCH_ID="arm64" ;;
|
||||
*) echo "Unsupported arch: $ARCH" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
BIN="$ROOT/tools/clang-format-bin/$VER/$OS_ID-$ARCH_ID/clang-format"
|
||||
if [[ ! -x "$BIN" ]]; then
|
||||
echo "Missing clang-format binary: $BIN" >&2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
# Fix Ubuntu-built clang-format runtime deps on Debian/Arch by vendoring needed libs
|
||||
if [[ "$OS_ID" == "linux" ]]; then
|
||||
LIBDIR="$ROOT/tools/clang-format-bin/$VER/$OS_ID-$ARCH_ID/lib"
|
||||
if [[ -d "$LIBDIR" ]]; then
|
||||
export LD_LIBRARY_PATH="$LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$BIN" "$@"
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
VER="18.1.8"
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
DEST="$ROOT/tools/clang-format-bin/$VER"
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
base="https://github.com/llvm/llvm-project/releases/download/llvmorg-${VER}"
|
||||
|
||||
# Archives you said you want to support
|
||||
LINUX_X86="clang+llvm-${VER}-x86_64-linux-gnu-ubuntu-18.04.tar.xz"
|
||||
LINUX_A64="clang+llvm-${VER}-aarch64-linux-gnu.tar.xz"
|
||||
MAC_A64="clang+llvm-${VER}-arm64-apple-macos11.tar.xz"
|
||||
WIN_X86="clang+llvm-${VER}-x86_64-pc-windows-msvc.tar.xz"
|
||||
|
||||
mkdir -p \
|
||||
"$DEST/linux-x86_64" \
|
||||
"$DEST/linux-arm64" \
|
||||
"$DEST/macos-arm64" \
|
||||
"$DEST/windows-x86_64"
|
||||
|
||||
fetch_and_extract() {
|
||||
local archive="$1"
|
||||
local outpath="$2"
|
||||
local inner="$3"
|
||||
|
||||
echo "Downloading $archive"
|
||||
curl -fsSL "$base/$archive" -o "$TMP/$archive"
|
||||
|
||||
echo "Extracting $inner"
|
||||
tar -xf "$TMP/$archive" -C "$TMP"
|
||||
|
||||
# The tarball extracts into a single top-level directory; find it
|
||||
local topdir
|
||||
topdir="$(find "$TMP" -maxdepth 1 -type d -name "clang+llvm-${VER}-*" | head -n 1)"
|
||||
if [[ -z "${topdir:-}" ]]; then
|
||||
echo "Could not locate extracted directory for $archive" >&2
|
||||
exit 4
|
||||
fi
|
||||
|
||||
if [[ ! -f "$topdir/$inner" ]]; then
|
||||
echo "Missing expected file inside archive: $inner" >&2
|
||||
exit 5
|
||||
fi
|
||||
|
||||
cp "$topdir/$inner" "$outpath"
|
||||
rm -rf "$topdir"
|
||||
}
|
||||
|
||||
# Linux x86_64 -> clang-format
|
||||
fetch_and_extract "$LINUX_X86" "$DEST/linux-x86_64/clang-format" "bin/clang-format"
|
||||
chmod +x "$DEST/linux-x86_64/clang-format"
|
||||
|
||||
# Linux arm64 -> clang-format
|
||||
fetch_and_extract "$LINUX_A64" "$DEST/linux-arm64/clang-format" "bin/clang-format"
|
||||
chmod +x "$DEST/linux-arm64/clang-format"
|
||||
|
||||
# macOS arm64 -> clang-format
|
||||
fetch_and_extract "$MAC_A64" "$DEST/macos-arm64/clang-format" "bin/clang-format"
|
||||
chmod +x "$DEST/macos-arm64/clang-format"
|
||||
|
||||
# Windows x86_64 -> clang-format.exe
|
||||
fetch_and_extract "$WIN_X86" "$DEST/windows-x86_64/clang-format.exe" "bin/clang-format.exe"
|
||||
|
||||
echo
|
||||
echo "Done. Installed pinned clang-format binaries under:"
|
||||
echo " $DEST"
|
||||
echo
|
||||
echo "Verify:"
|
||||
"$ROOT/tools/clang-format" --version || true
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
VER="18.1.8"
|
||||
X86_DEST="clang-format-bin/${VER}/linux-x86_64/lib"
|
||||
ARM_DEST="clang-format-bin/${VER}/linux-arm64/lib"
|
||||
|
||||
mkdir -p "$X86_DEST" "$ARM_DEST"
|
||||
|
||||
docker run --rm \
|
||||
--platform linux/amd64 \
|
||||
-v "$PWD":/repo \
|
||||
ubuntu:18.04 \
|
||||
bash -lc "
|
||||
set -euo pipefail
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
apt-get update
|
||||
apt-get install -y --no-install-recommends ca-certificates dpkg-dev curl
|
||||
|
||||
mkdir -p /tmp/dl /tmp/t
|
||||
cd /tmp/dl
|
||||
|
||||
echo '[*] amd64: download + extract libtinfo5'
|
||||
apt-get download libtinfo5
|
||||
rm -rf /tmp/t && mkdir -p /tmp/t
|
||||
dpkg-deb -x /tmp/dl/libtinfo5_*_amd64.deb /tmp/t
|
||||
cp -av /tmp/t/lib/x86_64-linux-gnu/libtinfo.so.5* /repo/${X86_DEST}/
|
||||
|
||||
echo '[*] arm64: download libtinfo5 .deb directly + extract'
|
||||
# This is the Ubuntu 18.04 (bionic-updates) arm64 libtinfo5 package matching the amd64 one above.
|
||||
ARM_DEB='libtinfo5_6.1-1ubuntu1.18.04.1_arm64.deb'
|
||||
ARM_URL='http://ports.ubuntu.com/ubuntu-ports/pool/main/n/ncurses/'\"\$ARM_DEB\"
|
||||
|
||||
curl -fsSL \"\$ARM_URL\" -o \"/tmp/dl/\$ARM_DEB\"
|
||||
|
||||
rm -rf /tmp/t && mkdir -p /tmp/t
|
||||
dpkg-deb -x \"/tmp/dl/\$ARM_DEB\" /tmp/t
|
||||
cp -av /tmp/t/lib/aarch64-linux-gnu/libtinfo.so.5* /repo/${ARM_DEST}/
|
||||
|
||||
echo
|
||||
echo '[*] Done. Repo now contains:'
|
||||
ls -la /repo/${X86_DEST} || true
|
||||
ls -la /repo/${ARM_DEST} || true
|
||||
"
|
||||
Reference in New Issue
Block a user