autoincreasing build number

aixakt
Posts: 1
Joined: Sun Mar 25, 2018 7:51 pm

autoincreasing build number

Postby aixakt » Sun Mar 25, 2018 7:58 pm

Hi everybody,

I work with the ESP32 IDF in several IoT-Projects. Most I use over the air updates and I need to know which build is running.

Has anyone an idea how I can get automatically increasing build number with every build. I need the number in my program.

Thanks
aixakt

User avatar
kolban
Posts: 1570
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: autoincreasing build number

Postby kolban » Mon Mar 26, 2018 6:06 pm

What about using the C macros __date__ and __time__ which produce string representations of the date and time. Instead of creating a "build number" create a "build date/time"?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Available for ESP32 consulting.

WiFive
Posts: 1817
Joined: Tue Dec 01, 2015 7:35 am

Re: autoincreasing build number

Postby WiFive » Mon Mar 26, 2018 8:52 pm

You should be able to do this in makefile try googling "makefile automatic build number" for examples

markwj
Posts: 82
Joined: Tue Mar 08, 2016 5:03 am

Re: autoincreasing build number

Postby markwj » Thu Mar 29, 2018 6:10 am

Have a look here for how we do it on ESP32:

https://github.com/openvehicles/Open-Ve ... MS.V3/main

Look in component.mk and ovms_version.{h,cpp}.

We don't use incrementing build numbers (but wouldn't be hard to adapt to that), but instead the output of:

git describe --always --tags --dirty

That comes out looking like this:

3.1.001-11-g2f50fc1-dirty/factory/main

We get the version, the incremental commit number, the hash of the last commit, an indication of whether that commit is dirty or not, and then finally we add on whether we are factory/ota and which stream (for ota updates).

We also make sure the code has the version number embedded surrounded by '########' style markers, so we can search through flash to find out the version number.

meneldor
Posts: 50
Joined: Mon Dec 25, 2017 7:28 am

Re: autoincreasing build number

Postby meneldor » Fri May 11, 2018 12:56 pm

markwj wrote:Have a look here for how we do it on ESP32:

https://github.com/openvehicles/Open-Ve ... MS.V3/main

Look in component.mk and ovms_version.{h,cpp}.

We don't use incrementing build numbers (but wouldn't be hard to adapt to that), but instead the output of:

git describe --always --tags --dirty

That comes out looking like this:

3.1.001-11-g2f50fc1-dirty/factory/main

We get the version, the incremental commit number, the hash of the last commit, an indication of whether that commit is dirty or not, and then finally we add on whether we are factory/ota and which stream (for ota updates).

We also make sure the code has the version number embedded surrounded by '########' style markers, so we can search through flash to find out the version number.

@markwj, could you tell me please, what this line in component.mk does:

Code: Select all

COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive -T main/ovms_boot.ld

markwj
Posts: 82
Joined: Tue Mar 08, 2016 5:03 am

Re: autoincreasing build number

Postby markwj » Fri May 11, 2018 1:25 pm

meneldor wrote:@markwj, could you tell me please, what this line in component.mk does:

Code: Select all

COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive -T main/ovms_boot.ld


Includes all components, whether or not they are actually referenced.

Who is online

Users browsing this forum: No registered users and 5 guests