From f8d1e1f71690fe66c5d5399a353839fcd30b3ba2 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 8 Mar 2018 14:26:22 +0100 Subject: [PATCH] use git versioning at compilation time under windows for version debug message --- platform.txt | 4 ++-- tools/MakeCoreVer.bat | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tools/MakeCoreVer.bat diff --git a/platform.txt b/platform.txt index e27c30db05..09ad1c5224 100644 --- a/platform.txt +++ b/platform.txt @@ -72,8 +72,8 @@ compiler.elf2hex.extra_flags= ## needs bash, git, and echo recipe.hooks.core.prebuild.1.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_VER 0x`git --git-dir {runtime.platform.path}/.git rev-parse --short=8 HEAD 2>/dev/null || echo ffffffff` >{build.path}/core/core_version.h" recipe.hooks.core.prebuild.2.pattern=bash -c "mkdir -p {build.path}/core && echo \#define ARDUINO_ESP8266_GIT_DESC `cd {runtime.platform.path}; git describe --tags 2>/dev/null || echo unix-{version}` >>{build.path}/core/core_version.h" -## windows-compatible version without git -recipe.hooks.core.prebuild.1.pattern.windows=cmd.exe /c mkdir {build.path}\core & (echo #define ARDUINO_ESP8266_GIT_VER 0x00000000 & echo #define ARDUINO_ESP8266_GIT_DESC win-{version} ) > {build.path}\core\core_version.h +## windows-compatible version - HELP NEEDED: this line below does not work because of unquotable spaces in {runtime.platform.path}="C:\Program Files\..." even when calling with 'cmd.exe /c ...' +recipe.hooks.core.prebuild.1.pattern.windows="{runtime.platform.path}\tools\MakeCoreVer.bat" "{build.path}" "{runtime.platform.path}" "{version}" recipe.hooks.core.prebuild.2.pattern.windows= ## Compile c files diff --git a/tools/MakeCoreVer.bat b/tools/MakeCoreVer.bat new file mode 100644 index 0000000000..15ab4c201c --- /dev/null +++ b/tools/MakeCoreVer.bat @@ -0,0 +1,29 @@ +@echo off + +set buildpath=%1 +set platformpath=%2 +set version=%3 + +REM test by hand, from .\tools +REM set buildpath=. +REM set platformpath=.. +REM set version=3.7.2-plus + +REM todo: check args + +if not exist "%buildpath%\core" mkdir "%buildpath%\core" + +git --version > nul +if NOT ERRORLEVEL 1 goto :git + +echo *** git is not available +( echo #define ARDUINO_ESP8266_GIT_VER 0x00000000 & echo #define ARDUINO_ESP8266_GIT_DESC win-%version% ) > "%buildpath%\core\core_version.h" +goto :end + +:git +REM echo without newline: echo | set /p="nonewline" + +( echo | set /p="#define ARDUINO_ESP8266_GIT_VER 0x" & git --git-dir "%platformpath%/.git" rev-parse --short=8 HEAD ) > "%buildpath%\core\core_version.h" +( echo | set /p="#define ARDUINO_ESP8266_GIT_DESC " & git --git-dir "%platformpath%/.git" describe --tags ) >> "%buildpath%\core\core_version.h" + +:end