summaryrefslogtreecommitdiff
path: root/bin/build-style.js
diff options
context:
space:
mode:
Diffstat (limited to 'bin/build-style.js')
-rwxr-xr-xbin/build-style.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/bin/build-style.js b/bin/build-style.js
new file mode 100755
index 0000000000..227c164a28
--- /dev/null
+++ b/bin/build-style.js
@@ -0,0 +1,38 @@
+#!/usr/bin/env node
+'use strict';
+
+var fs = require('fs');
+
+var name = 'style';
+var data = fs.readFileSync('resources/style.pbf');
+
+var length = data.length;
+
+var header = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n\n';
+header += '#ifndef LLMR_RESOURCE_' + name.toUpperCase() + '\n';
+header += '#define LLMR_RESOURCE_' + name.toUpperCase() + '\n';
+header += '\n';
+header += 'namespace llmr {\n';
+header += 'namespace resources {\n';
+header += '\n';
+header += 'extern const unsigned char ' + name + '[];\n';
+header += 'extern const unsigned long ' + name + '_size;\n';
+header += '\n';
+header += '}\n';
+header += '}\n';
+header += '\n';
+header += '#endif\n';
+fs.writeFileSync('include/llmr/resources/' + name + '.hpp', header);
+
+var code = '// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.\n';
+code += '#include <llmr/resources/' + name + '.hpp>\n';
+code += '\n';
+code += 'using namespace llmr;\n';
+code += '\n';
+code += 'const unsigned char resources::' + name + '[] = {\n';
+code += ' ' + Array.prototype.join.call(data, ', ') + '\n';
+code += '};\n';
+code += 'const unsigned long resources::' + name + '_size = sizeof(resources::' + name + ');\n';
+
+fs.writeFileSync('src/resources/' + name + '.cpp', code);
+