diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-07-08 11:35:43 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-08-17 08:08:20 +0200 |
commit | 584d4be174c6ac8cd0f3395c3852bfe1516f09a5 (patch) | |
tree | 9e8aafe467de28bf80c6bb861f6abec139454d29 /util | |
parent | 2f9a294252ae44defd4d8ae1b3c09d8e36ee0612 (diff) |
CMake: Re-implement configure/qmake's command line handling in CMake
We extend configurejson2cmake to read the "commandline"
information from configure.json. This data is then translated to CMake function
calls and written it into commandline.cmake files.
We extend QtProcessConfigureArgs.cmake to pick up those commandline.cmake
files to feed our command line handling code, which is a
re-implementation of the command line handling in qt_configure.prf.
The command line handler sets INPUT_xxx variables, similar to
configure/qmake's config.input.xxx variables. The INPUT_xxx values are
translated
- to -DFEATURE_xxx=ON/OFF arguments if the input represents a feature,
- to corresponding CMake variables if such a variable is known,
- or to -DINPUT_xxx=yyy CMake arguments.
Configure arguments that have an entry in
cmake/configure-cmake-mapping.md are actually implemented. Other
arguments are likely to need more work.
Task-number: QTBUG-85373
Change-Id: Ia96baa673fc1fb88e73ba05a1afb473aa074b37d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'util')
-rwxr-xr-x | util/cmake/configurejson2cmake.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index d164f270f5..b3b0a9bc01 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -1284,6 +1284,64 @@ def processReportHelper(ctx, entries, cm_fh): else: print(f" XXXX UNHANDLED REPORT TYPE {entry}.") +def parseCommandLineCustomHandler(ctx, data, cm_fh): + cm_fh.write(f"qt_commandline_custom({data})\n") + +def parseCommandLineOptions(ctx, data, cm_fh): + for key in data: + args = [key] + option = data[key] + if isinstance(option, str): + args += ["TYPE", option] + else: + if "type" in option: + args += ["TYPE", option["type"]] + if "name" in option: + args += ["NAME", option["name"]] + if "value" in option: + args += ["VALUE", option["value"]] + if "values" in option: + values = option["values"] + if isinstance(values, list): + args += ["VALUES", ' '.join(option["values"])] + else: + args += ["MAPPING"] + for lhs in values: + args += [lhs, values[lhs]] + + cm_fh.write(f"qt_commandline_option({' '.join(args)})\n") + +def parseCommandLinePrefixes(ctx, data, cm_fh): + for key in data: + cm_fh.write(f"qt_commandline_prefix({key} {data[key]})\n") + +def parseCommandLineAssignments(ctx, data, cm_fh): + for key in data: + cm_fh.write(f"qt_commandline_assignment({key} {data[key]})\n") + +def processCommandLine(ctx, data, cm_fh): + print(" commandline:") + + if "subconfigs" in data: + for subconf in data["subconfigs"]: + cm_fh.write(f"qt_commandline_subconfig({subconf})\n") + + if "commandline" not in data: + return + + commandLine = data["commandline"] + if "custom" in commandLine: + print(" custom:") + parseCommandLineCustomHandler(ctx, commandLine["custom"], cm_fh) + if "options" in commandLine: + print(" options:") + parseCommandLineOptions(ctx, commandLine["options"], cm_fh) + if "prefix" in commandLine: + print(" prefix:") + parseCommandLinePrefixes(ctx, commandLine["prefix"], cm_fh) + if "assignments" in commandLine: + print(" assignments:") + parseCommandLineAssignments(ctx, commandLine["assignments"], cm_fh) def processInputs(ctx, data, cm_fh): print(" inputs:") @@ -1377,6 +1435,9 @@ def processJson(path, ctx, data): ctx = processFiles(ctx, data) + with special_cased_file(path, "qt_cmdline.cmake") as cm_fh: + processCommandLine(ctx, data, cm_fh) + with special_cased_file(path, "configure.cmake") as cm_fh: cm_fh.write("\n\n#### Inputs\n\n") |