Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kauwua committed Apr 18, 2024
0 parents commit 9557930
Show file tree
Hide file tree
Showing 96 changed files with 11,145 additions and 0 deletions.
125 changes: 125 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# SPDX-License-Identifier: GPL-2.0
#
# clang-format configuration file. Intended for clang-format >= 11.
#
# For more information, see:
#
# Documentation/process/clang-format.rst
# https://clang.llvm.org/docs/ClangFormat.html
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
# based on Linux Kernel v6.5
---
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: true #Modified
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: true #Modified
AllowShortIfStatementsOnASingleLine: true #Modified
AllowShortLoopsOnASingleLine: true #Modified
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: true #Modified
AfterEnum: true #Modified
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true #Modified
AfterUnion: true #Modified
AfterExternBlock: false
BeforeCatch: true #Modified
BeforeElse: true #Modified
IndentBraces: false
SplitEmptyFunction: false #Modified
SplitEmptyRecord: false #Modified
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
# BreakBeforeInheritanceComma: false
# BreakBeforeTernaryOperators: false
# BreakConstructorInitializersBeforeComma: false
# BreakConstructorInitializers: BeforeComma
# BreakAfterJavaFieldAnnotations: false
# BreakStringLiterals: false
ColumnLimit: 0 # modified, no column limit
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4 # Modified
ContinuationIndentWidth: 4 # Modified
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false

IncludeBlocks: Preserve
IncludeCategories: # Modified
- Regex: '^((<|")([[:alnum:].]+)/)'
Priority: 3
- Regex: '<[[:alnum:].]+>'
Priority: 2
- Regex: '.*'
Priority: 1
SortPriority: 0
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4 # Modified
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4 # Modified
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true

# Taken from git's rules
PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60

PointerAlignment: Left # Modified
ReflowComments: false
SortIncludes: CaseInsensitive # Modified
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptForEachMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 4 # Modified
UseTab: Always
...
148 changes: 148 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Build

on:
push:
branches: [ main, hydradancer ]
pull_request:
branches: [ main, hydradancer ]

env:
RISCV_GCC_PATH: /opt/gcc_riscv/xpack-riscv-none-elf-gcc-12.2.0-1/bin

jobs:
Firmware-build-and-upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout submodules
run: |
git submodule update --init
cd submodules/wch-ch56x-lib
git submodule update --init
cd ../..
git fetch --prune --unshallow
- name: Cache GCC archive
uses: actions/cache@v3
with:
path: /opt/gcc_riscv
key: gcc-riscv-${{ runner.os }}-${{ hashFiles('xpack-riscv-none-elf-gcc-12.2.0-1-linux-x64.tar.gz') }}
restore-keys: gcc-riscv-${{ runner.os }}-

- name: Use GCC archive cache
run: |
ls /opt/gcc_riscv/xpack-riscv-none-elf-gcc-12.2.0-1/bin/riscv-none-elf-gcc || true
- name: Restore GCC archive cache
if: steps.use-cache.outputs.cache-hit != 'true'
run: |
mkdir -p /opt/gcc_riscv
wget https://github.com/hydrausb3/riscv-none-elf-gcc-xpack/releases/download/12.2.0-1/xpack-riscv-none-elf-gcc-12.2.0-1-linux-x64.tar.gz
tar xvfz xpack-riscv-none-elf-gcc-12.2.0-1-linux-x64.tar.gz -C /opt/gcc_riscv/
- name: Verify GCC installation
run: |
export PATH="$PATH:${{ env.RISCV_GCC_PATH }}"
riscv-none-elf-gcc --version
- name: Get build timestamp
id: id_date
shell: bash
run: echo "timestamp=$(date +%Y-%m-%d-%H-%M-%S)" >> $GITHUB_OUTPUT

- name: Get app version + timestamp
id: id_version
run: echo "app_version=$(git describe --tags HEAD)-${{steps.id_date.outputs.timestamp}}" >> $GITHUB_OUTPUT

- name: Build ${{ matrix.PROJECT_NAME }}
run: |
export PATH="$PATH:${{ env.RISCV_GCC_PATH }}"
cmake --toolchain ../cmake/wch-ch56x-toolchain.cmake -DCMAKE_BUILD_TYPE=release -DBUILD_TESTS=1 -DBUILD_TOOLS=1 -B build .
cmake --build build/
cmake --install build/
- name: Upload artifact all-firmwares${{steps.id_version.outputs.app_version}}
uses: actions/upload-artifact@v3
with:
name: all-firmwares${{steps.id_version.outputs.app_version}}
path: |
out/**/*.bin
out/**/*.elf
native_benchmarks:
runs-on: ubuntu-20.04
strategy:
matrix:
PROJECT_NAME: [test_loopback, test_speedtest]
steps:
- uses: actions/checkout@v3
- name: Checkout
run: |
git submodule update --init
git fetch --prune --unshallow
- name: Install prerequisites
run: |
set -x
sudo apt -q update
sudo apt install libusb-1.0-0-dev
- name: Get build timestamp
id: id_date
shell: bash
run: echo "timestamp=$(date +%Y-%m-%d-%H-%M-%S)" >> $GITHUB_OUTPUT

- name: Get app version + timestamp
id: id_version
run: echo "app_version=$(git describe --tags HEAD)-${{steps.id_date.outputs.timestamp}}" >> $GITHUB_OUTPUT

- name: Build app
shell: bash
run: |
cd hydradancer/tests/native/${{ matrix.PROJECT_NAME }}
make
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: native-${{ matrix.PROJECT_NAME }}${{steps.id_version.outputs.app_version}}
path: hydradancer/tests/native/${{ matrix.PROJECT_NAME }}/${{ matrix.PROJECT_NAME }}

facedancer_replacements:
runs-on: ubuntu-20.04
strategy:
matrix:
PROJECT_NAME: [facedancer_replacement_loopback, facedancer_replacement_speedtest]
steps:
- uses: actions/checkout@v3
- name: Checkout
run: |
git submodule update --init
git fetch --prune --unshallow
- name: Install prerequisites
run: |
set -x
sudo apt -q update
sudo apt install libusb-1.0-0-dev
- name: Get build timestamp
id: id_date
shell: bash
run: echo "timestamp=$(date +%Y-%m-%d-%H-%M-%S)" >> $GITHUB_OUTPUT

- name: Get app version + timestamp
id: id_version
run: echo "app_version=$(git describe --tags HEAD)-${{steps.id_date.outputs.timestamp}}" >> $GITHUB_OUTPUT

- name: Build app
shell: bash
run: |
cd hydradancer/tests/test_backend/${{ matrix.PROJECT_NAME }}
make
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: native-${{ matrix.PROJECT_NAME }}${{steps.id_version.outputs.app_version}}
path: hydradancer/tests/test_backend/${{ matrix.PROJECT_NAME }}/${{ matrix.PROJECT_NAME }}
14 changes: 14 additions & 0 deletions .github/workflows/Format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Format

on:
pull_request:
push:
branches: [main, hydradancer]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
out/
.vscode/
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "submodules/cargs"]
path = submodules/cargs
url = https://github.com/likle/cargs.git
[submodule "submodules/wch-ch56x-lib"]
path = submodules/wch-ch56x-lib
url = https://github.com/hydrausb3/wch-ch56x-lib
[submodule "submodules/wch-ch56x-bsp"]
path = submodules/wch-ch56x-bsp
url = https://github.com/hydrausb3/wch-ch56x-bsp
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/hhatto/autopep8
rev: v2.0.4
hooks:
- id: autopep8
- repo: https://github.com/pylint-dev/pylint
rev: v3.0.2
hooks:
- id: pylint
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.5
hooks:
- id: clang-format
exclude: "^submodules/"
Loading

0 comments on commit 9557930

Please sign in to comment.