cmake: Use environment variables file for all config binaries

This commit is contained in:
Angus Gratton
2019-06-27 20:30:42 +10:00
committed by Angus Gratton
parent 26db058339
commit f1e07663c4
6 changed files with 50 additions and 31 deletions

View File

@@ -16,6 +16,7 @@
#
import argparse
import json
import sys
import tempfile
import subprocess
@@ -30,6 +31,17 @@ from pyparsing import ParseException, ParseFatalException
from io import StringIO
def _update_environment(args):
env = [(name, value) for (name,value) in (e.split("=",1) for e in args.env)]
for name, value in env:
value = " ".join(value.split())
os.environ[name] = value
if args.env_file is not None:
env = json.load(args.env_file)
os.environ.update(env)
def main():
argparser = argparse.ArgumentParser(description="ESP-IDF linker script generator")
@@ -68,6 +80,10 @@ def main():
action='append', default=[],
help='Environment to set when evaluating the config file', metavar='NAME=VAL')
argparser.add_argument('--env-file', type=argparse.FileType('r'),
help='Optional file to load environment variables from. Contents '
'should be a JSON object where each key/value pair is a variable.')
argparser.add_argument(
"--objdump",
help="Path to toolchain objdump")
@@ -93,7 +109,9 @@ def main():
generation_model = GenerationModel()
sdkconfig = SDKConfig(kconfig_file, config_file, args.env)
_update_environment(args) # assign args.env and args.env_file to os.environ
sdkconfig = SDKConfig(kconfig_file, config_file)
for fragment_file in fragment_files:
try: