Skip to content

Commit

Permalink
Set firmware version from git tags
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Feb 17, 2022
1 parent 702988a commit 3a76044
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 0 additions & 2 deletions Inc/firmware/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#include "firmware/hal_compat.hpp"
#include "firmware/motor_controller.hpp"

const char* const FIRMWARE_VERSION = "1.0.2";

// UART used for rosserial communication
static UART_HandleTypeDef& ROSSERIAL_UART = huart1;

Expand Down
13 changes: 13 additions & 0 deletions firmware_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import subprocess

Import("env")

ret = subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE, text=True)
build_version = ret.stdout.strip()
build_flag = "-D FIRMWARE_VERSION=\\\"" + build_version + "\\\""

print ("Firmware Revision: " + build_version)

env.Append(
BUILD_FLAGS=[build_flag]
)
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ debug_tool = stlink
upload_protocol = stlink
build_flags =
-D ROS_PLATFORM_STM32CUBE
extra_scripts =
pre:firmware_version.py

[platformio]
include_dir = Inc
Expand Down

0 comments on commit 3a76044

Please sign in to comment.