2014-03-11 11:30:14 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import qbs 1.0
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-05 10:00:19 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import qbs.TextFile
							 | 
						
					
						
							
								
									
										
										
										
											2013-07-09 13:54:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import qbs.FileInfo
							 | 
						
					
						
							
								
									
										
										
										
											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
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											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",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                         "generatedFilesDir"), input.fileName);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                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");
							 | 
						
					
						
							
								
									
										
										
										
											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;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 |