From 05aba7141bf3285f152493ded12c1220527df790 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 26 Jul 2022 18:36:37 +0200 Subject: [PATCH] Add the AvrGcc toolchain to lock gcc version Substitute documentation to reference AvrGcc by default, which locks gcc to the dependency folder. AnyAvrGcc is inteded to use any system/external gcc version (as the name implies). --- .vscode/cmake-kits.json | 2 +- README.md | 8 +++----- cmake/AnyAvrGcc.cmake | 1 + cmake/AvrGcc.cmake | 6 ++++++ utils/build.py | 4 +++- 5 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 cmake/AvrGcc.cmake diff --git a/.vscode/cmake-kits.json b/.vscode/cmake-kits.json index 82462e2..7a9547e 100644 --- a/.vscode/cmake-kits.json +++ b/.vscode/cmake-kits.json @@ -1,7 +1,7 @@ [ { "name": "Local_gcc-avr-none-eabi", - "toolchainFile": "${workspaceFolder}/cmake/AnyAvrGcc.cmake", + "toolchainFile": "${workspaceFolder}/cmake/AvrGcc.cmake", "cmakeSettings": { "CMAKE_MAKE_PROGRAM": "${workspaceFolder}/.dependencies/ninja-1.10.2/ninja" } diff --git a/README.md b/README.md index 3e80259..d3a1411 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ # Prusa-Firmware-MMU-Private ## How to prepare build env and tools - -run `./utils/bootstrap.py` - +Run `./utils/bootstrap.py` `bootstrap.py` will now download all the "missing" dependencies into the `.dependencies` folder: - clang-format-9.0.0-noext @@ -14,7 +12,7 @@ run `./utils/bootstrap.py` ## How to build the preliminary project so far: Now the process is the same as in the Buddy Firmware: ``` -utils/build.py +./utils/build.py ``` builds the firmware.hex in build/mmu_release @@ -23,7 +21,7 @@ In case you'd like to build the project directly via cmake you can use an approa ``` mkdir build cd build -cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/AnyAvrGcc.cmake +cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=../cmake/AvrGcc.cmake ninja ``` diff --git a/cmake/AnyAvrGcc.cmake b/cmake/AnyAvrGcc.cmake index e050888..de36ceb 100644 --- a/cmake/AnyAvrGcc.cmake +++ b/cmake/AnyAvrGcc.cmake @@ -25,6 +25,7 @@ set(TOOLCHAIN_PREFIX avr-) if(AVR_TOOLCHAIN_DIR) # using toolchain set by AvrGcc.cmake (locked version) + message("ToolChain dir is ${AVR_TOOLCHAIN_DIR}") set(BINUTILS_PATH "${AVR_TOOLCHAIN_DIR}/bin") else() # search for ANY avr-gcc toolchain diff --git a/cmake/AvrGcc.cmake b/cmake/AvrGcc.cmake new file mode 100644 index 0000000..0c21a92 --- /dev/null +++ b/cmake/AvrGcc.cmake @@ -0,0 +1,6 @@ +get_filename_component(PROJECT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) + +set(AVR_GCC_VERSION 7.3.0) +set(AVR_TOOLCHAIN_DIR "${PROJECT_CMAKE_DIR}/../.dependencies/gcc-avr-${AVR_GCC_VERSION}/") + +include("${PROJECT_CMAKE_DIR}/AnyAvrGcc.cmake") diff --git a/utils/build.py b/utils/build.py index 3b33a59..9773e4e 100755 --- a/utils/build.py +++ b/utils/build.py @@ -69,6 +69,7 @@ class BuildType(Enum): class BuildConfiguration(ABC): + @abstractmethod def get_cmake_cache_entries(self): """Convert the build configuration to CMake cache entries.""" @@ -86,6 +87,7 @@ class BuildConfiguration(ABC): class FirmwareBuildConfiguration(BuildConfiguration): + def __init__(self, build_type: BuildType, toolchain: Path = None, @@ -103,7 +105,7 @@ class FirmwareBuildConfiguration(BuildConfiguration): @staticmethod def default_toolchain() -> Path: - return Path(__file__).resolve().parent.parent / 'cmake/AnyAvrGcc.cmake' + return Path(__file__).resolve().parent.parent / 'cmake/AvrGcc.cmake' def get_cmake_cache_entries(self): entries = []