Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# TinyAudioLink - Seamlessly transfer Audio between USB capable devices
# Copyright (C) 2019 Michael Fabian 'Xaymar' Dirks
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Basic Formatting
TabWidth: 4
UseTab: ForContinuationAndIndentation
ColumnLimit: 4194304
#- 0 does not respect the original line breaks!

# Language
Language: Cpp
Standard: Latest

# Indentation
AccessModifierOffset: -4
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
IndentCaseLabels: false
#IndentPPDirectives: true
IndentWidth: 4
IndentWrappedFunctionNames: true
NamespaceIndentation: All

# Includes
#IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<(c|)std'
Priority: 1
- Regex: '^<(hid|setup)'
Priority: 110
- Regex: '^<'
Priority: 100
- Regex: '^"'
Priority: 200
SortIncludes: true

# Alignment
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
DerivePointerAlignment: false
PointerAlignment: Left

# Wrapping and Breaking
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
# AfterExternBlock: false
AfterFunction: true
AfterNamespace: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
#BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: true
BreakAfterAttributes: Always
EmptyLineBeforeAccessModifier: LogicalBlock
SeparateDefinitionBlocks: Always

# Spaces
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
#SpaceBeforeCpp11BracedList: false
#SpaceBeforeCtorInitializerColon: true
#SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
#SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false

# Other
CommentPragmas: '^(!FIXME!|!TODO!|ToDo:)'
CompactNamespaces: false
DisableFormat: false
FixNamespaceComments: true
#ForEachMacros: ''
KeepEmptyLinesAtTheStartOfBlocks: false
ReflowComments: false
SortUsingDeclarations: true
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# TinyAudioLink - Seamlessly transfer Audio between USB capable devices
# Copyright (C) 2019 Michael Fabian 'Xaymar' Dirks
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4

[*.yml]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
indent_size = 2
204 changes: 204 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# AUTOGENERATED COPYRIGHT HEADER START
# Copyright (C) 2019-2024 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
# AUTOGENERATED COPYRIGHT HEADER END

name: Build

on:
push:
branches:
- '*'
tags:
- '*'
pull_request:
branches:
- '*'

concurrency:
group: build-${{ github.ref_name }}
cancel-in-progress: true

env:
CACHE_VERSION: "2024-01-25"

jobs:
native:
strategy:
fail-fast: false
matrix:
runner: [ "windows-2022", "windows-2019", "macos-14", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04" ]
include:
- runner: "windows-2022"
compiler: "MSVC"
platform: "windows"
name: "Windows 2022"
CMAKE_GENERATOR: "Visual Studio 17 2022"
CMAKE_GENERATOR_PLATFORM: "x64"

- runner: "windows-2019"
compiler: "MSVC"
platform: "windows"
name: "Windows 2019"
CMAKE_GENERATOR: "Visual Studio 16 2019"
CMAKE_GENERATOR_PLATFORM: "x64"

- runner: "macos-14"
compiler: "AppleClang"
platform: "macos"
name: "MacOS 14"
CMAKE_GENERATOR: "Xcode"
CMAKE_OSX_DEPLOYMENT_TARGET: "10.15"
CMAKE_OSX_ARCHITECTURES: "x86_64;arm64"

# Ubuntu 24.04 is GCC-14
- runner: "ubuntu-24.04"
compiler: "GCC-14"
platform: "linux"
name: "Ubuntu 24"
CMAKE_GENERATOR: "Ninja Multi-Config"

# Ubuntu 22.04 is GCC-12
- runner: "ubuntu-22.04"
compiler: "GCC-12"
platform: "linux"
name: "Ubuntu 22"
CMAKE_GENERATOR: "Ninja Multi-Config"

# Ubuntu 22.04 is GCC-10
- runner: "ubuntu-20.04"
compiler: "GCC-10"
platform: "linux"
name: "Ubuntu 20"
CMAKE_GENERATOR: "Ninja Multi-Config"

name: "${{ matrix.name}} (${{ matrix.compiler}})"
runs-on: "${{ matrix.runner }}"
env:
CMAKE_BUILD_TYPE: "Release"
CMAKE_GENERATOR: "${{ matrix.CMAKE_GENERATOR }}"
CMAKE_GENERATOR_PLATFORM: "${{ matrix.CMAKE_GENERATOR_PLATFORM }}"
CMAKE_SYSTEM_VERSION: "${{ matrix.CMAKE_SYSTEM_VERSION }}"
CMAKE_OSX_DEPLOYMENT_TARGET: "${{ matrix.CMAKE_OSX_DEPLOYMENT_TARGET }}"
CMAKE_OSX_ARCHITECTURES: "${{ matrix.CMAKE_OSX_ARCHITECTURES }}"
outputs:
version: ${{ steps.build.outputs.version }}
tag: ${{ steps.build.outputs.tag }}
steps:
- name: "Clone"
uses: "actions/checkout@v4"
with:
fetch-depth: 0
fetch-tags: true
submodules: "recursive"
- name: "Clone Tags"
shell: bash
run: git fetch origin +refs/tags/*:refs/tags/*
- name: "Prerequisites: Compiler (Linux)"
if: ${{ matrix.platform == 'linux' }}
shell: bash
run: |
# Install the appropriate compiler
IFS=$'-' compiler=($(echo "${{ matrix.compiler }}")) # ToDo: Can this be done without invoking a sub-shell?
echo "Installing '${compiler[0]}' version ${compiler[1]}..."
if [[ "${compiler[0]}" == "GCC" ]]; then
sudo apt-get install binutils gcc-${compiler[1]} g++-${compiler[1]}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${compiler[1]} 800 --slave /usr/bin/g++ g++ /usr/bin/g++-${compiler[1]}

echo "CMAKE_C_COMPILER=gcc-${compiler[1]}" >> "$GITHUB_ENV"
echo "CMAKE_CXX_COMPILER=g++-${compiler[1]}" >> "$GITHUB_ENV"
#echo "CMAKE_LINKER=ld" >> "$GITHUB_ENV"
elif [[ "${compiler[0]}" == "Clang" ]]; then
curl -jLo /tmp/llvm.sh "https://apt.llvm.org/llvm.sh"
chmod +x /tmp/llvm.sh
sudo /tmp/llvm.sh ${compiler[1]} all
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/lld lld /usr/bin/lld-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${compiler[1]} 800
sudo update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${compiler[1]} 800

echo "CMAKE_C_COMPILER=clang-${compiler[1]}" >> "$GITHUB_ENV"
echo "CMAKE_CXX_COMPILER=clang++-${compiler[1]}" >> "$GITHUB_ENV"
echo "CMAKE_LINKER=ld.lld-${compiler[1]}" >> "$GITHUB_ENV"
else
echo "Unknown Compiler"
exit 1
fi
sudo apt-get install ninja-build
- name: "Prerequisites: Compiler (MacOS)"
if: ${{ matrix.platform == 'macos' }}
uses: maxim-lobanov/setup-xcode@v1.6.0
with:
xcode-version: '15.2'
- name: "Prerequisites: Libraries (Linux)"
if: ${{ matrix.platform == 'linux' }}
shell: bash
run: |
sudo apt-get install libusb-dev
- name: "Build"
id: "build"
shell: bash
run: |
cmake -S. -Bbuild -DCMAKE_INSTALL_PREFIX=build/distrib

version="$(LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 cat "${{ github.workspace }}/build/version")"
_r=$?; if [[ $_r != 0 ]]; then exit $_r; fi
echo "version=${version}" >> "${GITHUB_OUTPUT}"
echo "tag=$(git describe --tags --exact-match HEAD 2>/dev/null)" >> "${GITHUB_OUTPUT}"

cmake --build build --config Release --target install
- name: "Artifacts"
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.name }}"
path: "${{ github.workspace }}/build/distrib"
if-no-files-found: error
compression-level: 0
release:
if: github.event_name != 'pull_request'
needs: [native]
strategy:
fail-fast: true
runs-on: "ubuntu-latest"
name: "Release"
steps:
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
with:
detached: true
- name: "Clone"
uses: "actions/checkout@v4"
- name: "Gather Artifacts"
uses: actions/download-artifact@v4
with:
path: "build/distrib"
- name: "Create Release"
shell: bash
id: "release"
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ "${{ needs.native.outputs.tag }}" != "" ]]; then
tag="${{ needs.native.outputs.tag }}"
title="Version ${{ needs.native.outputs.version }}"
flag="--latest"
else
tag="nightly"
title="Nightly ${{ needs.native.outputs.version }}"
flag="--prerelease"
fi
output=$(gh release delete "${tag}" --cleanup-tag --yes 2>&1) || [[ "${output}" == "release not found" ]]
gh release create "${tag}" --generate-notes ${flag} -t "${title}"
IFS=$'\n' els=($(find build/distrib -mindepth 1 -maxdepth 1 -type d))
_edx=${#els[@]}
for ((idx = 0; idx < ${_edx}; idx++ )); do
_el=${els[${idx}]}
name=$(basename "${_el}")
pushd "${_el}" && 7z a "${{ github.workspace }}/${name}.zip" "*" && popd
gh release upload "${tag}" "${{ github.workspace }}/${name}.zip#${name}"
done

# ToDo:
# - Use https://github.com/vmactions/freebsd-vm for FreeBSD, OpenBSD, NetBSD and DragonFlyBSD builds?
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
teensy_loader_cli
teensy_loader_cli.exe*
*.swp
build
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "cmake/modules/version"]
path = cmake/modules/version
url = https://github.com/Xaymar/cmake-version.git
[submodule "cmake/modules/clang"]
path = cmake/modules/clang
url = https://github.com/Xaymar/cmake-clang.git
Loading