macformula / racecar

Monorepo for all firmware running on our custom ECUs.
https://macformula.github.io/racecar/
9 stars 2 forks source link

Project Setup Issues Following Documentation #218

Closed sokosam closed 1 month ago

sokosam commented 1 month ago

Sorry if this problem has already been addressed or if this was due to an error on my end

While following the tutorial to start a project, I kept encountering this error during compilation:

-- Configuring done (2.5s)
-- Generating done (0.1s)
-- Build files have been written to: C:/Users/Samue/Documents/MACFE/racecar/firmware/build/MyBlink/cli
Copying compile_commands.json to build for clangd.
cp build/MyBlink/cli/compile_commands.json build/compile_commands.json
process_begin: CreateProcess(NULL, cp build/MyBlink/cli/compile_commands.json build/compile_commands.json, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:28: config] Error 2
Full compilation log ``` PS C:\Users\Samue\Documents\MACFE\racecar\firmware> make PROJECT=MyBlink PLATFORM=cli cmake -B build/MyBlink/cli -S. -G"Unix Makefiles" -D PROJECT=MyBlink -D PLATFORM=cli -D PROJECT_NAME=MyBlink --log-level STATUS Build type: Debug -- Validating input arguments -- Verifying MyBlink is a project -- The directory "C:/Users/Samue/Documents/MACFE/racecar/firmware/projects/MyBlink" exists. -- Verifying MyBlink is a project - Valid -- Verifying cli is a platform under MyBlink -- The directory "C:/Users/Samue/Documents/MACFE/racecar/firmware/projects/MyBlink/platforms/cli" exists. -- Verifying cli is a platform under MyBlink - Valid -- Validating input arguments - Success -- Validating the MCAL Platform -- Searching for mcal configuration file -- The file "C:/Users/Samue/Documents/MACFE/racecar/firmware/projects/MyBlink/platforms/cli/mcal_conf.cmake" exists. -- Searching for mcal configuration file - Found -- Verifying the cli MCAL exists -- The directory "C:/Users/Samue/Documents/MACFE/racecar/firmware/mcal/cli" exists. -- Verifying the cli MCAL exists - Valid MCAL -- Finding MCAL postbuild file -- The file "C:/Users/Samue/Documents/MACFE/racecar/firmware/mcal/cli/PostBuild.cmake" exists. -- Finding MCAL postbuild file - Found -- Finding MCAL toolchain file -- The file "C:/Users/Samue/Documents/MACFE/racecar/firmware/mcal/cli/Toolchain.cmake" exists. -- Finding MCAL toolchain file - Found -- Validating the MCAL Platform - Success -- Building "MyBlink" for "cli" with mcal "cli". CMake Warning (dev) at CMakeLists.txt:108 (enable_language): project() should be called prior to this enable_language() call. This warning is for project developers. Use -Wno-dev to suppress it. -- The C compiler identification is GNU 12.1.0 -- The CXX compiler identification is GNU 12.1.0 -- The ASM compiler identification is GNU -- Found assembler: C:/Users/Samue/Downloads/winlibs-x86_64-posix-seh-gcc-12.1.0-llvm-14.0.6-mingw-w64ucrt-10.0.0-r3/mingw64/bin/gcc.exe CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-GNU.cmake:191 (enable_language): project() should be called prior to this enable_language() call. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-GNU-C.cmake:2 (__windows_compiler_gnu) C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeCInformation.cmake:48 (include) CMakeLists.txt:108 (enable_language) This warning is for project developers. Use -Wno-dev to suppress it. -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Users/Samue/Downloads/winlibs-x86_64-posix-seh-gcc-12.1.0-llvm-14.0.6-mingw-w64ucrt-10.0.0-r3/mingw64/bin/gcc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-GNU.cmake:191 (enable_language): project() should be called prior to this enable_language() call. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-GNU-CXX.cmake:2 (__windows_compiler_gnu) C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeCXXInformation.cmake:48 (include) CMakeLists.txt:108 (enable_language) This warning is for project developers. Use -Wno-dev to suppress it. -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Users/Samue/Downloads/winlibs-x86_64-posix-seh-gcc-12.1.0-llvm-14.0.6-mingw-w64ucrt-10.0.0-r3/mingw64/bin/c++.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-GNU.cmake:191 (enable_language): project() should be called prior to this enable_language() call. Call Stack (most recent call first): C:/Program Files/CMake/share/cmake-3.30/Modules/Platform/Windows-GNU-ASM.cmake:2 (__windows_compiler_gnu) C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeASMInformation.cmake:38 (include) CMakeLists.txt:108 (enable_language) This warning is for project developers. Use -Wno-dev to suppress it. -- Configuring done (2.5s) -- Generating done (0.1s) -- Build files have been written to: C:/Users/Samue/Documents/MACFE/racecar/firmware/build/MyBlink/cli Copying compile_commands.json to build for clangd. cp build/MyBlink/cli/compile_commands.json build/compile_commands.json process_begin: CreateProcess(NULL, cp build/MyBlink/cli/compile_commands.json build/compile_commands.json, ...) failed. make (e=2): The system cannot find the file specified. make: *** [Makefile:28: config] Error 2 ```

I assume this is due to the Makefile commands being written for linux, whilst I am working on Windows 11. Though on the documentation, there is no mention of OS requirements.

Work around:

In the Makefile, I temporarily changed the config section (25 - 36) to replace the following bash commands:

config:
    cmake -B $(BUILD_DIR) -S. $(GENERATOR) -D PROJECT=$(PROJECT) -D PLATFORM=$(PLATFORM) -D PROJECT_NAME=$(PROJECT_NAME) --log-level $(LOG_LEVEL)

    @echo Copying compile_commands.json to $(BUILD) for clangd.
-   cp $(BUILD_DIR)/compile_commands.json $(COMPILE_COMMANDS_DEST)
+   copy build\MyBlink\cli\compile_commands.json build\compile_commands.json

    @echo Ensure the .clangd file exists.
-       touch .clangd 

Which ended up producing the result as intended.

BlakeFreer commented 1 month ago

The Makefile uses Linux commands which are not available in the Windows command line. However, they are included in Git Bash which is installed with git on Windows (you should have it available if you called choco upgrade git ...).

I will add a note to the tutorial indicating that you have to us Git Bash. Thanks for catching the issue