Skip to content

Commit

Permalink
CMake Improvements (#615)
Browse files Browse the repository at this point in the history
* Fix builds on native Windows

Previously, builds would fail with a message stating that there's no such command "true".
CMAKE_C[XX]_ARCHIVE_FINISH is not a boolean option, but instead should be a string for how to run ranlib. This simply sets that to the default, but it could instead be removed in the future now that GCC binutils has lto automatically loading.

* Add CMake toolchain file for LLVMEmbeddedToolchainForArm

* Update linker arguments of both base and GCC-specific toolchain setups

This removes the arguments that LLD cannot receive from the base default_build file, and moves them to the GCC-specific toolchain setup. This reformats all linker arguments to allow for CMake to auto-format them depending on the toolchain (clang uses -Xlinker instead of -Wl).

* Remove illegal constexpr definitions

constexpr cannot take the result of a cast that is equivalent to a reinterpret_cast, as defined by the C++ standard. GCC may allow it, but it's technically illegal and clang errors.

* Remove attribute naked

Naked is not allowed for functions that contain bodies other than asm functions. Per the GCC docs: "The only statements that can be safely included in naked functions are asm statements that do not have operands. All other statements, including declarations of local variables, if statements, and so forth, should be avoided."

GCC silently allows this, but Clang notes this as a hard failure. Instead, the Default_Handler is marked as a generic interrupt, and the Reset_Handler is unmarked due to acting as the executable entrypoint.

* Add DAISY_STORAGE configure option

This allows for configure-time selection of the linker script used by CMake, either at the command like with -DDAISY_STORAGE=qspi or in libraries that use libDaisy (by defining DAISY_STORAGE before inclusion).

* Remove unused variable

Squashes 7+ warnings of this due to inclusion by other files.

* Splits the monolithic CMakeLists.txt file into a semi-proper structure

This separates the massive root CMakeLists.txt file into libraries and places the respective configuration files closer to their source.

* Split toolchain into architecture and GNU

This ensures that we have architecture-specific configurations in a dedicated file while the LLVM and GNU toolchain files deal with their respective compilers only

* Remove unnecessary comparison

config_ is never nullptr as it is initialized with the instantiation of a SaiHandle::Impl

This allows -Werror to work on GCC.

* Fix complications of rebase

* Update linkerscripts

* Add DaisyProject cmake file and use for default_build

* Add missing libraries and source files to CMakeLists

* Add CMakeLists for examples

* Add CMake config for tests

* Fix issues from merge

* add toolchain auto-detection

* Add patch requirements to .gitattributes

* Fix some problems with the autodetection

* Add extra tools to GNU toolchain

* Work on github actions a bit

* Better bin/hex generation (multi-config)

* Store TOOLCHAIN_PREFIX in the CMake cache

* Change cross-compiling mechanism

* Fix SAI warnings

* Formatting

* Add some comments, move module path adjustment

* Build examples as part of CMake CI Build job

* Enable verbose build in GitHub Action

* Fix silly mistake with missing the GCC config

* group examples, add sane optimization defaults

* remove weird naming from example targets now that they're grouped

* move NDEBUG to standalone and DaisyProject

* Separate tests CMake project

* Fix merge resolution, toolchain integration

* Move system_stm32h7xx.c to static CMSIS Device library

* Fix strequal comparison

* Fix cmake/DaisyProject.cmake

Co-authored-by: Aleksei Savartsov <[email protected]>

* Fix compile option propagation; remove semihost

* add `-fno-finite-loops` to LLVM toolchain file

* Remove hal_map.c from CMakeLists.txt

* Update llvm toolchains (ubuntu-latest no longer has libtinfo.so)

* Change runtime lib arch for LLVM (see ARM-software/LLVM-embedded-toolchain-for-Arm#482)

* Remove support for older LLVM Embedded toolchains

* remove -fno-builtin

* Update examples CMakeLists.txt, reduce Clang CI expectations

---------

Co-authored-by: Aleksei Savartsov <[email protected]>
  • Loading branch information
stellar-aria and asavartsov authored Oct 18, 2024
1 parent 39aab66 commit bd13385
Show file tree
Hide file tree
Showing 70 changed files with 1,015 additions and 428 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
*.filters text eol=crlf
*.props text eol=crlf
*.xml text eol=crlf
*.patch text eol=lf
64 changes: 49 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
submodules: recursive
- name: Setup arm-none-eabi-gcc
uses: fiam/arm-none-eabi-gcc@v1
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '9-2019-q4'
- name: Setup python
Expand All @@ -47,22 +47,56 @@ jobs:
- name: Build Examples
run: ./ci/build_examples.py -f core doc src tests Drivers

build-cmake:
build-cmake-gcc:
runs-on: ubuntu-latest

strategy:
matrix:
version: [latest, '13.3.Rel1', '12.3.Rel1', '11.3.Rel1', '10.3-2021.10', '9-2020-q2']

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup arm-none-eabi-gcc
uses: fiam/arm-none-eabi-gcc@v1
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '9-2019-q4'
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.20.x'
- name: Configure Library
run: cmake -S . -B build -G "Unix Makefiles" -D CMAKE_TOOLCHAIN_FILE=cmake/toolchains/stm32h750xx.cmake -D TOOLCHAIN_PREFIX=$(which arm-none-eabi-gcc | sed -e "s/bin\/arm-none-eabi-gcc//")
- name: Build Library
run: cmake --build build
release: ${{ matrix.version }}

- name: Setup CMake
uses: lukka/get-cmake@latest

- name: Configure
run: cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=Release

- name: Build All
run: cmake --build build --target examples --verbose

build-cmake-llvm:
runs-on: ubuntu-latest

strategy:
matrix:
version: [latest, '19.1.1']

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install LLVM Embedded Toolchain for Arm
uses: stellar-aria/llvm-embedded-toolchain-for-arm-action@latest
with:
release: ${{ matrix.version }}

- name: Setup CMake
uses: lukka/get-cmake@latest

- name: Configure
run: cmake -B build -G Ninja -D CMAKE_BUILD_TYPE=Release

- name: Build All
run: cmake --build build --target BootloaderBlink --verbose # TODO: make this build all examples
26 changes: 14 additions & 12 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'
jobs:
jobs:
###############################################################################
# builds the automated tests with clang; runs tests and exports results
googleTest:
Expand All @@ -24,23 +24,25 @@ jobs:
with:
submodules: recursive

- name: Build
run: |
cd tests
make release
- name: Setup CMake
uses: lukka/get-cmake@latest

- name: Configure CMake
run: cmake -B build -S tests

- name: Build Tests
run: cmake --build build

- name: Run Tests
run: |
cd tests/build/bin
./libDaisy_gtest --gtest_output=xml:gtestresults.xml
run: ctest --test-dir build --output-junit results/gtestresults.xml

- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Results
path: tests/build/bin/**/*.xml
path: build/results/*.xml

event_file:
name: "Event File"
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ LLVM/
transcode report.txt
/examples/*/build
/example_projects/*/build
/build
/build*
/doc/*.md
/core/build
/doc/html
Expand All @@ -129,6 +129,6 @@ VisualGDBCache
vs/*.log

tests/libDaisy_gtest
tests/build/bin/
tests/build/
examples/**/build/

9 changes: 5 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"recommendations": [
"ms-vscode.cpptools",
"ms-vscode.cpptools",
"xaver.clang-format",
"davidschuldenfrei.gtest-adapter",
"vadimcn.vscode-lldb"
"vadimcn.vscode-lldb",
"ms-vscode.cmake-tools",
"matepek.vscode-catch2-test-adapter",
]
}
}
5 changes: 2 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
},
"preLaunchTask": "build-libDaisy-tests",
"osx": {
"type": "lldb",
"MIMode": "lldb",
},
"windows": {
Expand Down Expand Up @@ -48,9 +47,9 @@
"monitor reset"
],
"request": "launch",
"runToMain": true,
"runToEntryPoint": "true",
"servertype": "openocd",
"showDevDebugOutput": true,
"showDevDebugOutput": "none",
"svdFile": "${workspaceRoot}/.vscode/STM32H750x.svd",
"type": "cortex-debug"
}
Expand Down
9 changes: 5 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
]
},
"testMate.cpp.test.executables": "tests/build/bin/*",
"gtest-adapter.debugConfig": [
"Launch Tests Locally"
"cmake.sourceDirectory": [
"${workspaceFolder}",
"${workspaceFolder}/tests",
],
"gtest-adapter.supportLocation": true,
}
"cmake.buildDirectory": "${sourceDirectory}/build",
}
Loading

0 comments on commit bd13385

Please sign in to comment.