Skip to content

Commit

Permalink
Put GITHUB_RUN_NUMBER into version string
Browse files Browse the repository at this point in the history
  • Loading branch information
jsphuebner committed May 3, 2024
1 parent f547021 commit 7a1c9c3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
30 changes: 15 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@ OBJCOPY = $(PREFIX)-objcopy
OBJDUMP = $(PREFIX)-objdump
MKDIR_P = mkdir -p
CFLAGS = -Os -Iinclude/ -Ilibopeninv/include -Ilibopencm3/include -Iexi -Iccs \
-fno-common -fno-builtin -DSTM32F1 \
-fno-common -fno-builtin -DSTM32F1 \
-mcpu=cortex-m3 -mthumb -std=gnu99 -ffunction-sections -fdata-sections
CPPFLAGS = -Og -ggdb -Wall -Wextra -Iinclude/ -Ilibopeninv/include -Ilibopencm3/include -Iexi -Iccs \
-fno-common -std=c++11 -pedantic -DSTM32F1 -DUSART_BAUDRATE=921600 \
-fno-common -std=c++11 -pedantic -DSTM32F1 -DUSART_BAUDRATE=921600 \
-ffunction-sections -fdata-sections -fno-builtin -fno-rtti -fno-exceptions -fno-unwind-tables -mcpu=cortex-m3 -mthumb
# Check if the variable GITHUB_RUN_NUMBER exists. When running on the github actions running, this
# variable is automatically available.
# Create a compiler define with the content of the variable. Or, if it does not exist, use replacement value 99999.
# Create a compiler define with the content of the variable. Or, if it does not exist, use replacement value 0.
EXTRACOMPILERFLAGS = $(shell \
if [ -z "$$GITHUB_RUN_NUMBER" ]; then echo "-DGITHUB_RUN_NUMBER=99999"; else echo "-DGITHUB_RUN_NUMBER=$$GITHUB_RUN_NUMBER"; fi \
)
if [ -z "$$GITHUB_RUN_NUMBER" ]; then echo "-DGITHUB_RUN_NUMBER=0"; else echo "-DGITHUB_RUN_NUMBER=$$GITHUB_RUN_NUMBER"; fi \
)

LDSCRIPT = linker.ld
LDFLAGS = -Llibopencm3/lib -T$(LDSCRIPT) -march=armv7 -nostartfiles -Wl,--gc-sections,-Map,linker.map
OBJSL = main.o hwinit.o stm32scheduler.o params.o terminal.o terminal_prj.o \
my_string.o digio.o my_fp.o printf.o anain.o \
param_save.o errormessage.o stm32_can.o canhardware.o canmap.o cansdo.o \
picontroller.o terminalcommands.o \
ipv6.o tcp.o \
my_string.o digio.o my_fp.o printf.o anain.o \
param_save.o errormessage.o stm32_can.o canhardware.o canmap.o cansdo.o \
picontroller.o terminalcommands.o \
ipv6.o tcp.o \
connMgr.o modemFinder.o pevStateMachine.o temperatures.o proximitypilot.o acOBC.o \
hardwareInterface.o hardwareVariants.o pushbutton.o udpChecksum.o \
homeplug.o myHelpers.o qca7000.o \
Expand Down Expand Up @@ -140,12 +140,12 @@ flash: images
@printf " FLASH $(BINARY).bin\n"
@# IMPORTANT: Don't use "resume", only "reset" will work correctly!
$(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
-f $(OPENOCD_FLASHER) \
-f $(OPENOCD_BOARD) \
-c "init" -c "reset halt" \
-c "flash write_image erase $(BINARY).hex" \
-c "reset" \
-c "shutdown" $(NULL)
-f $(OPENOCD_FLASHER) \
-f $(OPENOCD_BOARD) \
-c "init" -c "reset halt" \
-c "flash write_image erase $(BINARY).hex" \
-c "reset" \
-c "shutdown" $(NULL)

.PHONY: directories images clean

Expand Down
15 changes: 12 additions & 3 deletions include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/

//Define a version string of your firmware here
#define VER 0.38.B
#define VERSION 0.39

#include "myLogging.h"

Expand Down Expand Up @@ -75,7 +75,6 @@
PARAM_ENTRY(CAT_TEST, logging, MODULES, 0, 2047, DEFAULT_LOGGINGMASK, 15 ) \
VALUE_ENTRY(opmode, pevSttString, 2000 ) \
VALUE_ENTRY(version, VERSTR, 2001 ) \
VALUE_ENTRY(githubRunNumber, "", 2026 ) \
VALUE_ENTRY(lasterr, errorListString, 2002 ) \
VALUE_ENTRY(EvseVoltage, "V", 2006 ) \
VALUE_ENTRY(EvseCurrent, "A", 2010 ) \
Expand Down Expand Up @@ -118,7 +117,17 @@
#define CAT_COMM "Communication"
#define CAT_TEST "Testing"

#define VERSTR STRINGIFY(4=VER)
#define PARAM_ID_SUM_START_OFFSET GITHUB_RUN_NUMBER

#if GITHUB_RUN_NUMBER == 0 //local build
#define VER(G) VERSION.R
#else //github runner build
#define VER(G) VERSION.##G.B
#endif

#define VER2(G) VER(G)

#define VERSTR STRINGIFY(4=VER2(GITHUB_RUN_NUMBER))

/***** enums ******/

Expand Down
2 changes: 1 addition & 1 deletion libopeninv
4 changes: 1 addition & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,8 @@ extern "C" int main(void)
Terminal t(UART4, termCmds);
TerminalCommands::SetCanMap(canMap);

Param::SetInt(Param::githubRunNumber, GITHUB_RUN_NUMBER);

printf("This is Clara version %s\r\n", VERSTR);
printf("githubRunNumber %d\r\n", Param::GetInt(Param::githubRunNumber));
printf("githubRunNumber %d\r\n", GITHUB_RUN_NUMBER);
printf("logging is %d\r\n", Param::GetInt(Param::logging));
SetMacAddress();

Expand Down

0 comments on commit 7a1c9c3

Please sign in to comment.