summaryrefslogtreecommitdiff
path: root/scripts/generate-cmake-files.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/generate-cmake-files.js')
-rwxr-xr-xscripts/generate-cmake-files.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/generate-cmake-files.js b/scripts/generate-cmake-files.js
new file mode 100755
index 0000000000..4b6a8b8672
--- /dev/null
+++ b/scripts/generate-cmake-files.js
@@ -0,0 +1,32 @@
+#!/usr/bin/env node
+
+const child_process = require('child_process');
+const fs = require('fs');
+const ejs = require('ejs');
+
+require('./style-code');
+
+function generateCMakeListFile(name, regex, patterns) {
+ const files = child_process.execSync(`git ls-files ${patterns.map((p) => '"' + p + '"').join(' ')}`).toString().trim().split('\n');
+ var groups = {};
+ for (const file of files) {
+ const match = file.match(regex);
+ const group = match[1] || name;
+ if (!groups[group]) {
+ groups[group] = [];
+ }
+ groups[group].push(file);
+ }
+
+ const fileListCmake = ejs.compile(fs.readFileSync('cmake/files.cmake.ejs', 'utf8'), {strict: true});
+ writeIfModified(`cmake/${name}-files.cmake`, fileListCmake({ name: name, groups: groups }));
+}
+
+generateCMakeListFile('core', /^(?:src|include)\/(?:mbgl\/)?(.+)\/[^\/]+$/,
+ [ 'include/*.hpp', 'include/*.h', 'src/*.hpp', 'src/*.cpp', 'src/*.h', 'src/*.c' ]);
+
+generateCMakeListFile('benchmark', /^benchmark\/(?:(?:src|include)\/)?(?:mbgl\/)?(?:(.+)\/)?[^\/]+$/,
+ [ 'benchmark/*.hpp', 'benchmark/*.cpp', 'benchmark/*.h', 'benchmark/*.c' ]);
+
+generateCMakeListFile('test', /^test\/(?:(?:src|include)\/)?(?:mbgl\/)?(?:(.+)\/)?[^\/]+$/,
+ [ 'test/*.hpp', 'test/*.cpp', 'test/*.h', 'test/*.c' ]);