[Build] Fix compile time defines strings with spaces

For example the ESP Board Name was incorrect.

```
ESP Board Name:	Espressif Generic 1 4M Flash ESPEasy 1810k Code/OTA 316k FS
```
`ESP32` was replaced with a `1` in the string.
This commit is contained in:
TD-er
2022-08-21 12:46:34 +02:00
parent bdd1091393
commit a17741f961
2 changed files with 15 additions and 10 deletions
+10 -5
View File
@@ -12,15 +12,20 @@
// End of defines being patched by the Python build script.
// Uncrustify must not be used on macros, so turn it off.
// *INDENT-OFF*
// Need to add quotes around defines as the PIO build tools make it hard to include the string quotes.
#define STRINGIFY(s) STRINGIFY1(s)
#define STRINGIFY1(s) # s
#define STRINGIFY1(s) #s
// Uncrustify must not be used on macros, but we're now done, so turn Uncrustify on again.
// *INDENT-ON*
const __FlashStringHelper* get_binary_filename() {
#ifndef SET_BUILD_BINARY_FILENAME
return F("firmware.bin");
#else // ifndef SET_BUILD_BINARY_FILENAME
return F(STRINGIFY(SET_BUILD_BINARY_FILENAME));
return F(SET_BUILD_BINARY_FILENAME);
#endif // ifndef SET_BUILD_BINARY_FILENAME
}
@@ -46,7 +51,7 @@ const __FlashStringHelper* get_build_platform() {
#ifndef SET_BUILD_PLATFORM
return F("");
#else // ifndef SET_BUILD_PLATFORM
return F(STRINGIFY(SET_BUILD_PLATFORM));
return F(SET_BUILD_PLATFORM);
#endif // ifndef SET_BUILD_PLATFORM
}
@@ -54,13 +59,13 @@ const __FlashStringHelper* get_git_head() {
#ifndef SET_BUILD_GIT_HEAD
return F("");
#else // ifndef SET_BUILD_GIT_HEAD
return F(STRINGIFY(SET_BUILD_GIT_HEAD));
return F(SET_BUILD_GIT_HEAD);
#endif // ifndef SET_BUILD_GIT_HEAD
}
const __FlashStringHelper * get_board_name() {
#ifdef SET_BOARD_NAME
return F(STRINGIFY(SET_BOARD_NAME));
return F(SET_BOARD_NAME);
#elif defined(ARDUINO_BOARD)
return F(ARDUINO_BOARD);
#else
+5 -5
View File
@@ -22,7 +22,7 @@ def get_git_description():
from pygit2 import Repository
try:
repo = Repository('.')
return "'{0}_{1}'".format(repo.head.shorthand, repo.revparse_single('HEAD').short_id)
return "{0}_{1}".format(repo.head.shorthand, repo.revparse_single('HEAD').short_id)
except:
return 'No_.git_dir'
except ImportError:
@@ -56,10 +56,10 @@ def gen_compiletime_defines(node):
return env.Object(
node,
CPPDEFINES=env["CPPDEFINES"]
+ [("SET_BUILD_BINARY_FILENAME", create_binary_filename())]
+ [("SET_BOARD_NAME", get_board_name())]
+ [("SET_BUILD_PLATFORM", platform.platform())]
+ [("SET_BUILD_GIT_HEAD", get_git_description())],
+ [("SET_BUILD_BINARY_FILENAME", '\\"%s\\"' % create_binary_filename())]
+ [("SET_BOARD_NAME", '\\"%s\\"' % get_board_name())]
+ [("SET_BUILD_PLATFORM", '\\"%s\\"' % platform.platform())]
+ [("SET_BUILD_GIT_HEAD", '\\"%s\\"' % get_git_description())],
CCFLAGS=env["CCFLAGS"]
)