Permalink
Browse files

moved render template to mnm

  • Loading branch information...
1 parent bf92286 commit 4d32a7acec2d9ddcf820d3d8e0e17e49f518aa80 @joeferner committed Feb 14, 2012
Showing with 70 additions and 1,414,158 deletions.
  1. +1 −0 .gitignore
  2. +16 −1 mnm.js
  3. +53 −53 render-templates.js
  4. +0 −1,414,104 wxapi.json
View
1 .gitignore
@@ -6,3 +6,4 @@ node_modules
.lock*
npm-debug.log
.idea
+wxapi.json
View
17 mnm.js
@@ -4,6 +4,7 @@ var path = require('path');
var childProcess = require('child_process');
var Builder = require('mnm');
var builder = new Builder();
+var RenderTemplates = require('./render-templates.js');
builder.appendUnique('CXXFLAGS', ['-Isrc/', '-Isrc-dummy/']);
@@ -20,12 +21,26 @@ function build(wxCxxFlags, wxLibs) {
builder.run();
}
+var renderTemplates = true;
+for(var i=0; i<process.argv.length; i++) {
+ if(process.argv[i] == '--skip-render-templates') {
+ renderTemplates = false;
+ }
+}
+
// get the wx command line flags
runCommandLine('wx-config', ['--cxxflags'], function(err, wxCxxFlags) {
if(err) { builder.fail(err); return; }
runCommandLine('wx-config', ['--libs'], function(err, wxLibs) {
if(err) { builder.fail(err); return; }
- build(wxCxxFlags, wxLibs);
+ if(renderTemplates) {
+ RenderTemplates.renderTemplates(function(err){
+ if(err) { builder.fail(err); return; }
+ build(wxCxxFlags, wxLibs);
+ });
+ }else{
+ build(wxCxxFlags, wxLibs);
+ }
});
});
View
106 render-templates.js 100755 → 100644
@@ -1,5 +1,3 @@
-#!/usr/bin/env node
-
var path = require('path');
var fs = require('fs');
var util = require('util');
@@ -76,66 +74,68 @@ var files = [
*/
];
-fs.readFile('./wxapi.json', 'utf8', function(err, data) {
- if(err) {
- console.error("reading xml file");
- fs.readFile('./wxapi.xml', 'utf8', function(err, data) {
- if(err) { throw err; }
- console.log("wxapi.xml read");
-
- var xmlParser = new xml2js.Parser({
- explicitRoot: true,
- explicitArray: true,
- mergeAttrs: true
- });
- xmlParser.parseString(data, function(err, result) {
- if(err) { throw err; }
- console.log("wxapi.xml parsed");
-
- var apiJson = {
- classNameToId: {},
- subClasses: {}
- };
- for(var elementName in result['GCC_XML']) {
- var elem = result['GCC_XML'][elementName];
- for(var i=0; i<elem.length; i++) {
- var id = elem[i]['id'];
- apiJson[id] = elem[i];
- apiJson[id].elementName = elementName;
- if(elementName == "Class" || elementName == "Enumeration" || elementName == "Union") {
- var name = removeTemplateFromClassName(elem[i]['name']);
- apiJson.classNameToId[name] = id;
- var bases = elem[i]['bases'];
- if(bases) {
- bases = bases.split(' ');
- for(var baseIdx=0; baseIdx<bases.length; baseIdx++) {
- var base = bases[baseIdx];
- if(base == "") { continue; }
- var subClasses = apiJson.subClasses[base];
- if(!subClasses) {
- apiJson.subClasses[base] = [];
+exports.renderTemplates = function(callback) {
+ fs.readFile('./wxapi.json', 'utf8', function(err, data) {
+ if(err) {
+ console.error("reading xml file");
+ fs.readFile('./wxapi.xml', 'utf8', function(err, data) {
+ if(err) { callback(err); return; }
+ console.log("wxapi.xml read");
+
+ var xmlParser = new xml2js.Parser({
+ explicitRoot: true,
+ explicitArray: true,
+ mergeAttrs: true
+ });
+ xmlParser.parseString(data, function(err, result) {
+ if(err) { callback(err); return; }
+ console.log("wxapi.xml parsed");
+
+ var apiJson = {
+ classNameToId: {},
+ subClasses: {}
+ };
+ for(var elementName in result['GCC_XML']) {
+ var elem = result['GCC_XML'][elementName];
+ for(var i=0; i<elem.length; i++) {
+ var id = elem[i]['id'];
+ apiJson[id] = elem[i];
+ apiJson[id].elementName = elementName;
+ if(elementName == "Class" || elementName == "Enumeration" || elementName == "Union") {
+ var name = removeTemplateFromClassName(elem[i]['name']);
+ apiJson.classNameToId[name] = id;
+ var bases = elem[i]['bases'];
+ if(bases) {
+ bases = bases.split(' ');
+ for(var baseIdx=0; baseIdx<bases.length; baseIdx++) {
+ var base = bases[baseIdx];
+ if(base == "") { continue; }
+ var subClasses = apiJson.subClasses[base];
+ if(!subClasses) {
+ apiJson.subClasses[base] = [];
+ }
+ apiJson.subClasses[base].push(id);
}
- apiJson.subClasses[base].push(id);
}
}
}
}
- }
- fs.writeFile('./wxapi.json', JSON.stringify(apiJson, null, '\t'), function(err) {
- if(err) { throw err; }
+ fs.writeFile('./wxapi.json', JSON.stringify(apiJson, null, '\t'), function(err) {
+ if(err) { callback(err); return; }
- renderFiles(files, apiJson, function() { console.log("done"); });
+ renderFiles(files, apiJson, function() { console.log("done"); callback(); });
+ });
});
});
- });
- } else {
- console.error("wxapi.json read");
- var json = JSON.parse(data);
- console.error("json parsed");
- renderFiles(files, json, function() { console.log("done"); });
- }
-});
+ } else {
+ console.error("wxapi.json read");
+ var json = JSON.parse(data);
+ console.error("json parsed");
+ renderFiles(files, json, function() { console.log("done"); callback(); });
+ }
+ });
+};
function lookupClassById(rawJson, typeId) {
var clazz = rawJson[typeId];
View
1,414,104 wxapi.json
0 additions, 1,414,104 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit 4d32a7a

Please sign in to comment.