summaryrefslogtreecommitdiff
path: root/themes/src/tools
diff options
context:
space:
mode:
authormattkae <mattkae@protonmail.com>2023-08-13 16:02:22 -0400
committermattkae <mattkae@protonmail.com>2023-08-13 16:02:22 -0400
commit056d4560f72a9ec281f8df31aa2a7d8241d6adf1 (patch)
treed0bcbe3ad5dd9e4efb662389b1aa6806cc4365ef /themes/src/tools
parentb6a666e96ffd04bd6d52be8fd9899faf27b751db (diff)
Generating a cpp file for shaders
Diffstat (limited to 'themes/src/tools')
-rw-r--r--themes/src/tools/shader.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/themes/src/tools/shader.js b/themes/src/tools/shader.js
index 27c8682..54ba6e0 100644
--- a/themes/src/tools/shader.js
+++ b/themes/src/tools/shader.js
@@ -15,16 +15,23 @@ files.forEach(file => {
const splitText = text.split('\n');
const splitName = file.split('.');
const def = `SHADER_${splitName.join('_').toUpperCase()}`;
- let result = `#ifndef ${def} \n`;
- result += `#define ${def} \n`;
- result += `const char* ${def.toLowerCase()} = `
+ let header_result = `#ifndef ${def} \n`;
+ const filename = splitName.join('_');
+ const header_name = filename + ".h";
+ const cpp_name = filename + ".cpp";
+ header_result += `#define ${def} \n`;
+ header_result += `extern const char* ${def.toLowerCase()};\n`;
+ header_result += '#endif\n';
+ fs.writeFileSync(path.join(out_directory, header_name), header_result);
+
+ let cpp_result = `#include "${header_name}"\n\n`
+ cpp_result += `const char* ${def.toLowerCase()} = `
splitText.forEach((line, index) => {
- result += "\"" + line + " \\n\"";
+ cpp_result += "\"" + line + " \\n\"";
if (index == splitText.length - 1)
- result += ";\n";
+ cpp_result += ";\n";
else
- result += "\n";
+ cpp_result += "\n";
});
- result += '#endif\n';
- fs.writeFileSync(path.join(out_directory, splitName.join('_') + '.h'), result);
+ fs.writeFileSync(path.join(out_directory, cpp_name), cpp_result);
});