Skip to content

Commit

Permalink
Split the output build into two directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijith Sriram committed Oct 15, 2024
1 parent df65558 commit 4ca4d5a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
42 changes: 24 additions & 18 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,43 1,49 @@
@echo off
SETLOCAL EnableDelayedExpansion
cls
IF EXIST ".\out\" (
echo Deleting the out folder for a clean build
rmdir .\out /q /s
)

SET CMAKE_ARGS=-S %~dp0 -B %~dp0\out\build -DAPPL_TO_BUILD

@REM Get the application name to build
IF [%~1] == [] (
goto display_help
) ELSE (
SET CMAKE_ARGS=!CMAKE_ARGS!=%~1
)
SET CMAKE_ARGS=-S %~dp0

IF [%~2] == [] (
goto :display_help
) ELSE IF "%~2" EQU "EMULATOR" (
@REM Building for emulator, output will be a dll file
SET CMAKE_ARGS=!CMAKE_ARGS! -DBUILD_TARGET=EMULATOR
goto :build_target
SET BUILD_DIR=%~dp0/out/emulator
SET CMAKE_ARGS=!CMAKE_ARGS! -B !BUILD_DIR!
SET CMAKE_ARGS=!CMAKE_ARGS! -DBUILD_TARGET=EMULATOR -DAPPL_TO_BUILD

) ELSE IF "%~2" EQU "MCU" (
@REM Building to flash the arduino, output will be .hex file
@REM We need to have a different build generator when cross-compiling else the compiler settings
@REM defaults to msvc. If this happens then we cannot build binary for arduino, this is why we use -G argument
SET CMAKE_ARGS=!CMAKE_ARGS! -DBUILD_TARGET=MCU -G"MinGW Makefiles"
goto :build_target
SET BUILD_DIR=%~dp0/out/flash
SET CMAKE_ARGS=!CMAKE_ARGS! -B !BUILD_DIR!
SET CMAKE_ARGS=!CMAKE_ARGS! -DBUILD_TARGET=MCU -G"MinGW Makefiles" -DAPPL_TO_BUILD

) ELSE (
goto :display_help
)

@REM Get the application name to build
IF [%~1] == [] (
goto :display_help
) ELSE (
echo Application to build: %~1
SET CMAKE_ARGS=!CMAKE_ARGS!=%~1
goto :build_target
)

@REM Cleaning the out folder
IF EXIST ".\out\!BUILD_DIR!" (
echo Deleting the out folder for a clean build
rmdir .\out /q /s
)

:build_target
echo Generating the build files
echo Generating the build files !CMAKE_ARGS!
cmake !CMAKE_ARGS!
echo Building the target
cmake --build %~dp0\out\build
cmake --build !BUILD_DIR!
goto :eof

:display_help
Expand Down
2 changes: 1 addition & 1 deletion flash-arduino.bat
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
@echo off
SETLOCAL EnableDelayedExpansion
@REM Changing directory to easily reference the hex file
cd .\out\build\target
cd .\out\flash\target
@REM Flashing the arduino
"C:\Program Files (x86)\WinAVR\bin\avrdude.exe" -C "C:\Program Files (x86)\WinAVR\bin\avrdude.conf" -v -p ATmega328P -P COM3 -c arduino -b 115200 -D -U flash:w:final_exec.hex:i
12 changes: 6 additions & 6 deletions src/appl/blinkLed/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 1,11 @@
cmake_minimum_required(VERSION 3.25.0)

message("Building blinkLed")
set(SOURCES blinkLed.c)
set(HEADERS blinkLed.h)
add_library(blinkLed blinkLed.c)
set_target_properties(blinkLed PROPERTIES FOLDER "appls/blinkLed")
target_include_directories(blinkLed PRIVATE
message("Building blinkled")
set(SOURCES blinkled.c)
set(HEADERS blinkled.h)
add_library(blinkled blinkled.c)
set_target_properties(blinkled PROPERTIES FOLDER "appls/blinkled")
target_include_directories(blinkled PRIVATE
${CMAKE_SOURCE_DIR}/src/lib/timer
${CMAKE_SOURCE_DIR}/src/lib/eeprom
${CMAKE_SOURCE_DIR}/src/lib/pins)

0 comments on commit 4ca4d5a

Please sign in to comment.