2014-03-11 11:30:14 +01:00
|
|
|
import qbs 1.0
|
2018-03-01 14:59:40 +01:00
|
|
|
import qbs.File
|
2013-07-09 13:54:46 +02:00
|
|
|
import qbs.FileInfo
|
2018-03-01 14:59:40 +01:00
|
|
|
import qbs.TextFile
|
|
|
|
|
import qbs.Utilities
|
2012-02-09 14:30:09 +01:00
|
|
|
|
|
|
|
|
Module {
|
2012-06-19 15:36:27 +08:00
|
|
|
Depends { id: qtcore; name: "Qt.core" }
|
2016-05-17 10:50:51 +02:00
|
|
|
Depends { name: "qtc" }
|
2012-04-10 17:28:05 +02:00
|
|
|
|
2018-03-01 14:59:40 +01:00
|
|
|
// TODO: Wrap the VCS specific stuff in a dedicated module
|
|
|
|
|
property bool hasVcs: Utilities.versionCompare(qbs.version, "1.10") >= 0
|
2018-04-04 13:12:41 +02:00
|
|
|
property bool useVcsData: hasVcs
|
|
|
|
|
Depends { name: "vcs"; condition: useVcsData }
|
2018-03-01 14:59:40 +01:00
|
|
|
Properties {
|
2018-04-04 13:12:41 +02:00
|
|
|
condition: useVcsData
|
2018-03-09 16:33:09 +01:00
|
|
|
vcs.headerFileName: undefined
|
2018-03-01 14:59:40 +01:00
|
|
|
vcs.repoDir: {
|
|
|
|
|
// TODO: Could something like this be incorporated into the vcs module?
|
|
|
|
|
// Currently, the default repo dir is project.sourceDirectory, which
|
|
|
|
|
// does not make sense for Qt Creator.
|
|
|
|
|
var dir = sourceDirectory;
|
|
|
|
|
while (true) {
|
|
|
|
|
if (File.exists(FileInfo.joinPaths(dir, ".git")))
|
|
|
|
|
return dir;
|
|
|
|
|
var newDir = FileInfo.path(dir);
|
|
|
|
|
if (newDir === dir || dir === project.sourceDirectory) {
|
|
|
|
|
console.warn("No git repository found for product " + product.name
|
|
|
|
|
+ ", revision information will not be evailable.");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
dir = newDir;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-26 17:29:38 +02:00
|
|
|
additionalProductTypes: ["qt_plugin_metadata"]
|
2012-04-25 11:57:06 +02:00
|
|
|
|
2012-02-09 14:30:09 +01:00
|
|
|
Rule {
|
2014-08-26 17:29:38 +02:00
|
|
|
inputs: ["pluginJsonIn"]
|
2012-02-09 14:30:09 +01:00
|
|
|
|
|
|
|
|
Artifact {
|
2014-08-26 17:29:38 +02:00
|
|
|
fileTags: ["qt_plugin_metadata"]
|
|
|
|
|
filePath: {
|
|
|
|
|
var destdir = FileInfo.joinPaths(product.moduleProperty("Qt.core",
|
2017-07-07 11:41:55 +02:00
|
|
|
"generatedHeadersDir"), input.fileName);
|
2014-08-26 17:29:38 +02:00
|
|
|
return destdir.replace(/\.[^\.]*$/,'')
|
|
|
|
|
}
|
2012-02-09 14:30:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prepare: {
|
|
|
|
|
var cmd = new JavaScriptCommand();
|
2014-03-27 13:43:03 +01:00
|
|
|
cmd.description = "prepare " + FileInfo.fileName(output.filePath);
|
2012-02-09 14:30:09 +01:00
|
|
|
cmd.highlight = "codegen";
|
2014-08-26 17:29:38 +02:00
|
|
|
cmd.pluginJsonReplacements = product.pluginJsonReplacements;
|
2013-03-26 16:58:50 +01:00
|
|
|
cmd.plugin_depends = [];
|
|
|
|
|
var deps = product.dependencies;
|
|
|
|
|
for (var d in deps) {
|
|
|
|
|
var depdeps = deps[d].dependencies;
|
|
|
|
|
for (var dd in depdeps) {
|
2014-08-26 17:29:38 +02:00
|
|
|
if (depdeps[dd].name == 'pluginjson') {
|
2013-03-26 16:58:50 +01:00
|
|
|
cmd.plugin_depends.push(deps[d].name);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cmd.plugin_recommends = product.pluginRecommends
|
2015-03-04 09:25:08 +02:00
|
|
|
cmd.plugin_test_depends = product.pluginTestDepends
|
2012-04-25 11:57:06 +02:00
|
|
|
|
2012-02-09 14:30:09 +01:00
|
|
|
cmd.sourceCode = function() {
|
|
|
|
|
var i;
|
2014-08-26 17:29:38 +02:00
|
|
|
var vars = pluginJsonReplacements || {};
|
2014-03-27 13:43:03 +01:00
|
|
|
var inf = new TextFile(input.filePath);
|
2012-02-09 14:30:09 +01:00
|
|
|
var all = inf.readAll();
|
|
|
|
|
// replace quoted quotes
|
2012-06-19 15:36:27 +08:00
|
|
|
all = all.replace(/\\\"/g, '"');
|
2012-02-09 14:30:09 +01:00
|
|
|
// replace config vars
|
2016-05-17 10:50:51 +02:00
|
|
|
var qtcVersion = product.moduleProperty("qtc", "qtcreator_version");
|
|
|
|
|
vars['QTCREATOR_VERSION'] = qtcVersion;
|
|
|
|
|
vars['QTCREATOR_COMPAT_VERSION']
|
|
|
|
|
= product.moduleProperty("qtc", "qtcreator_compat_version");
|
|
|
|
|
vars['IDE_VERSION_MAJOR'] = product.moduleProperty("qtc", "ide_version_major");
|
|
|
|
|
vars['IDE_VERSION_MINOR'] = product.moduleProperty("qtc", "ide_version_minor");
|
|
|
|
|
vars['IDE_VERSION_RELEASE'] = product.moduleProperty("qtc", "ide_version_release");
|
2017-08-24 14:31:22 +02:00
|
|
|
vars['QTCREATOR_COPYRIGHT_YEAR']
|
|
|
|
|
= product.moduleProperty("qtc", "qtcreator_copyright_year")
|
2018-03-01 14:59:40 +01:00
|
|
|
if (!vars['QTC_PLUGIN_REVISION'])
|
|
|
|
|
vars['QTC_PLUGIN_REVISION'] = product.vcs ? (product.vcs.repoState || "") : "";
|
2014-08-26 17:29:38 +02:00
|
|
|
var deplist = [];
|
2013-03-26 16:58:50 +01:00
|
|
|
for (i in plugin_depends) {
|
2016-05-17 10:50:51 +02:00
|
|
|
deplist.push(" { \"Name\" : \"" + plugin_depends[i] + "\", \"Version\" : \"" + qtcVersion + "\" }");
|
2013-03-26 16:58:50 +01:00
|
|
|
}
|
|
|
|
|
for (i in plugin_recommends) {
|
2016-05-17 10:50:51 +02:00
|
|
|
deplist.push(" { \"Name\" : \"" + plugin_recommends[i] + "\", \"Version\" : \"" + qtcVersion + "\", \"Type\" : \"optional\" }");
|
2013-03-26 16:58:50 +01:00
|
|
|
}
|
2015-03-04 09:25:08 +02:00
|
|
|
for (i in plugin_test_depends) {
|
2016-05-17 10:50:51 +02:00
|
|
|
deplist.push(" { \"Name\" : \"" + plugin_test_depends[i] + "\", \"Version\" : \"" + qtcVersion + "\", \"Type\" : \"test\" }");
|
2015-03-04 09:25:08 +02:00
|
|
|
}
|
2014-08-26 17:29:38 +02:00
|
|
|
deplist = deplist.join(",\n")
|
|
|
|
|
vars['dependencyList'] = "\"Dependencies\" : [\n" + deplist + "\n ]";
|
2012-02-09 14:30:09 +01:00
|
|
|
for (i in vars) {
|
2013-03-28 13:42:56 +01:00
|
|
|
all = all.replace(new RegExp('\\\$\\\$' + i + '(?!\w)', 'g'), vars[i]);
|
2012-02-09 14:30:09 +01:00
|
|
|
}
|
2014-03-27 13:43:03 +01:00
|
|
|
var file = new TextFile(output.filePath, TextFile.WriteOnly);
|
2012-02-09 14:30:09 +01:00
|
|
|
file.truncate();
|
|
|
|
|
file.write(all);
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
return cmd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|