diff --git a/tools/cmake/kconfig.cmake b/tools/cmake/kconfig.cmake index 97702935e..bd1a30668 100644 --- a/tools/cmake/kconfig.cmake +++ b/tools/cmake/kconfig.cmake @@ -123,15 +123,19 @@ function(__kconfig_generate_config sdkconfig sdkconfig_defaults) string(REPLACE ";" " " kconfigs "${kconfigs}") string(REPLACE ";" " " kconfig_projbuilds "${kconfig_projbuilds}") + # Place the long environment arguments into an input file + # to work around command line length limits for execute_process + # on Windows & CMake < 3.11 + configure_file( + "${idf_path}/tools/kconfig_new/confgen.env.in" + "${CMAKE_CURRENT_BINARY_DIR}/confgen.env") + set(confgen_basecommand ${python} ${idf_path}/tools/kconfig_new/confgen.py --kconfig ${root_kconfig} --config ${sdkconfig} ${defaults_arg} - --env "COMPONENT_KCONFIGS=${kconfigs}" - --env "COMPONENT_KCONFIGS_PROJBUILD=${kconfig_projbuilds}" - --env "IDF_CMAKE=y" - --env "IDF_TARGET=${idf_target}") + --env-file "${CMAKE_CURRENT_BINARY_DIR}/confgen.env") idf_build_get_property(build_dir BUILD_DIR) set(config_dir ${build_dir}/config) diff --git a/tools/kconfig_new/confgen.env.in b/tools/kconfig_new/confgen.env.in new file mode 100644 index 000000000..e639c4d3a --- /dev/null +++ b/tools/kconfig_new/confgen.env.in @@ -0,0 +1,6 @@ +{ + "COMPONENT_KCONFIGS": "${kconfigs}", + "COMPONENT_KCONFIGS_PROJBUILD": "${kconfig_projbuilds}", + "IDF_CMAKE": "y", + "IDF_TARGET": "${idf_target}" +} diff --git a/tools/kconfig_new/confgen.py b/tools/kconfig_new/confgen.py index bbd4e2804..d4e875290 100755 --- a/tools/kconfig_new/confgen.py +++ b/tools/kconfig_new/confgen.py @@ -198,6 +198,10 @@ def main(): parser.add_argument('--env', action='append', default=[], help='Environment to set when evaluating the config file', metavar='NAME=VAL') + parser.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.') + args = parser.parse_args() for fmt, filename in args.output: @@ -214,6 +218,10 @@ def main(): for name, value in args.env: os.environ[name] = value + if args.env_file is not None: + env = json.load(args.env_file) + os.environ.update(env) + config = kconfiglib.Kconfig(args.kconfig) config.disable_redun_warnings() config.disable_override_warnings()