mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
PlatformIO: generate core_version.h when using feature/stage (#5917)
* platformio: generate core_version.h when using feature/stage * quote command line * Modify CPPFLAGS conditionally
This commit is contained in:
committed by
Ivan Kravets
parent
4e0e4e4340
commit
c5efb922ca
@ -24,6 +24,9 @@ http://arduino.cc/en/Reference/HomePage
|
||||
|
||||
# Extends: https://github.com/platformio/platform-espressif8266/blob/develop/builder/main.py
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from os.path import isdir, join
|
||||
|
||||
from SCons import Builder, Util
|
||||
@ -220,6 +223,41 @@ app_ld = env.Command(
|
||||
"Generating LD script $TARGET"))
|
||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", app_ld)
|
||||
|
||||
#
|
||||
# Dynamic core_version.h for staging builds
|
||||
#
|
||||
|
||||
def platform_txt_version(default):
|
||||
with open(join(FRAMEWORK_DIR, "platform.txt"), "r") as platform_txt:
|
||||
for line in platform_txt:
|
||||
if not line:
|
||||
continue
|
||||
k, delim, v = line.partition("=")
|
||||
if not delim:
|
||||
continue
|
||||
if k == "version":
|
||||
return v.strip()
|
||||
|
||||
return default
|
||||
|
||||
if isdir(join(FRAMEWORK_DIR, ".git")):
|
||||
cmd = '"$PYTHONEXE" "{script}" -b "$BUILD_DIR" -p "{framework_dir}" -v {version}'
|
||||
fmt = {
|
||||
"script": join(FRAMEWORK_DIR, "tools", "makecorever.py"),
|
||||
"framework_dir": FRAMEWORK_DIR,
|
||||
"version": platform_txt_version("unspecified")
|
||||
}
|
||||
|
||||
env.Prepend(CPPPATH=[
|
||||
join("$BUILD_DIR", "core")
|
||||
])
|
||||
core_version = env.Command(
|
||||
join("$BUILD_DIR", "core", "core_version.h"),
|
||||
join(FRAMEWORK_DIR, ".git"),
|
||||
env.VerboseAction(cmd.format(**fmt), "Generating $TARGET")
|
||||
)
|
||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", core_version)
|
||||
|
||||
|
||||
#
|
||||
# Target: Build Core Library
|
||||
|
Reference in New Issue
Block a user