[Qt-creator] JSON wizard: build systems and sub-projects
Christian Gagneraud
chgans at gmail.com
Sun May 12 12:03:12 CEST 2019
Hi there,
In my attempt to add a unified "subdirs" project and make all projects
templates "subproject" friendly, I discovered a few grey area, and
would like to discuss what they are how we could fix them.
1. "supportedProjectType" and "enabled" properties are currently
redundant (in the way they are used), consider:
"supportedProjectTypes": [ "CMakeProjectManager.CMakeProject",
"Qbs.QbsProject", "Qt4ProjectManager.Qt4Project" ],
and
"enabled": "%{JS: value('Plugins').indexOf('QbsProjectManager') >= 0
|| value('Plugins').indexOf('QmakeProjectManager') >= 0 ||
value('Plugins').indexOf('CMakeProjectManager') >= 0}",
They both express the same thing, but using different approaches. IMHO
enabled should be used to express further conditions on top of the
supported project types.
2. "Define Build System" page.
Currently the boiler plate attempt to identify the "Project type" to
generate, but doesn't rely/use the semantic of the
"supportedProjectType" above.
Instead they use the HasPlugin concept to map the build system tool
(aka, "qmake", "qbs", "cmake"), which is actually equivalent to the
project type (the wizard doesn't care about the tool, it cares about
the project manager it targets: CMakeProjectManager.CMakeProject,
Qbs.QbsProject, ...).
This page also suffers from selecting an index as a default, instead of a value.
It would be nice to be able to write:
"default": "%{ProjectTypeKey},
"items":
[
{
"trKey": "qmake",
"value": "%{QmakeProjectTypeKey}",
"condition": "%{HasQmake}"
},
...
]
3 "generator"
They both need, in the case of the "subdirs" project, to know if it is
a top/sub project, and which project type (build system) it is for.
Ideally, i would like to be able to write:
{
"source": "subdirs.qbs",
"target": "%{QbsProjectFile}",
"openAsProject": "%{IsTopProject}",
"openInEditor": "%{IsSubProject}",
"condition": "%{IsQbsProject}"
},
...
4. "Summary" page
Similar to the "build system" page, there is a need to select the
default sub-project, and disable the combo box.
5. Ideas to achieve that
I did some quick hack in the ProjectNode, there is a "buildKey()"
there, that returns the build target key, so i added a
"projectTypeKey()" that returns the project manager's project ID
(CMakeProjectManager.CMakeProject, ...), and which is injected wizard
environment.
With the above and proper macro nesting, it should be possible to
define the following wizard options:
- IsSubProject, IsTopProject
- HasCMake, HasQmake, HasQbs
- IsCMake, IsQmake, IsQbs
- top project:
by comparing the "Build system" page choice
- sub-project
by comparing the injected "projectType" (same values as above)
The HasFoo, IsFoo and ProjectType could all rely on the project
manager key. No need to deal with project manager key, plugin names
and build tool names.
My 2 cents.
More information about the Qt-creator
mailing list