mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +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:
parent
4e0e4e4340
commit
c5efb922ca
@ -21,31 +21,53 @@ import argparse
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Generate core_version.h')
|
|
||||||
parser.add_argument('-b', '--build_path', action='store', required=True, help='build.path variable')
|
|
||||||
parser.add_argument('-p', '--platform_path', action='store', required=True, help='platform.path variable')
|
|
||||||
parser.add_argument('-v', '--version', action='store', required=True, help='version variable')
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
def generate(path, platform_path, git_ver="0xffffffff", git_desc="unspecified"):
|
||||||
|
def git(*args):
|
||||||
|
cmd = ["git", "-C", platform_path]
|
||||||
|
cmd.extend(args)
|
||||||
|
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
|
||||||
|
return proc.stdout.readlines()[0].strip()
|
||||||
|
|
||||||
core = args.build_path + '/core'
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(core)
|
git_ver = git("rev-parse", "--short=8", "HEAD")
|
||||||
|
git_desc = git("describe", "--tags")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
out = open(core + '/core_version.h', "w")
|
with open(path, "w") as out:
|
||||||
|
out.write("#define ARDUINO_ESP8266_GIT_VER 0x{}\n".format(git_ver))
|
||||||
|
out.write("#define ARDUINO_ESP8266_GIT_DESC {}\n".format(git_desc))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(description="Generate core_version.h")
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"-b", "--build_path", action="store", required=True, help="build.path variable"
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-p",
|
||||||
|
"--platform_path",
|
||||||
|
action="store",
|
||||||
|
required=True,
|
||||||
|
help="platform.path variable",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-v", "--version", action="store", required=True, help="version variable"
|
||||||
|
)
|
||||||
|
parser.add_argument("-i", "--include_dir", default="core")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
include_dir = os.path.join(args.build_path, args.include_dir)
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(['git', '--git-dir', args.platform_path + '/.git', 'rev-parse', '--short=8', 'HEAD'], stdout = subprocess.PIPE )
|
os.makedirs(include_dir)
|
||||||
git_ver = '0x' + p.stdout.readlines()[0].strip()
|
|
||||||
p = subprocess.Popen(['git', '--git-dir', args.platform_path + '/.git', 'describe', '--tags'], stdout = subprocess.PIPE )
|
|
||||||
git_desc = p.stdout.readlines()[0].strip()
|
|
||||||
except:
|
except:
|
||||||
git_ver = '0xffffffff'
|
pass
|
||||||
git_desc = args.version
|
|
||||||
|
|
||||||
out.write('#define ARDUINO_ESP8266_GIT_VER ' + git_ver + '\n')
|
generate(
|
||||||
out.write('#define ARDUINO_ESP8266_GIT_DESC ' + git_desc + '\n')
|
os.path.join(include_dir, "core_version.h"),
|
||||||
|
args.platform_path,
|
||||||
out.close()
|
git_desc=args.version,
|
||||||
|
)
|
||||||
|
@ -24,6 +24,9 @@ http://arduino.cc/en/Reference/HomePage
|
|||||||
|
|
||||||
# Extends: https://github.com/platformio/platform-espressif8266/blob/develop/builder/main.py
|
# Extends: https://github.com/platformio/platform-espressif8266/blob/develop/builder/main.py
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
from os.path import isdir, join
|
from os.path import isdir, join
|
||||||
|
|
||||||
from SCons import Builder, Util
|
from SCons import Builder, Util
|
||||||
@ -220,6 +223,41 @@ app_ld = env.Command(
|
|||||||
"Generating LD script $TARGET"))
|
"Generating LD script $TARGET"))
|
||||||
env.Depends("$BUILD_DIR/$PROGNAME$PROGSUFFIX", app_ld)
|
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
|
# Target: Build Core Library
|
||||||
|
Loading…
x
Reference in New Issue
Block a user