diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2018-01-10 16:04:06 -0800 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-01-24 08:35:31 -0800 |
commit | e7e6cffcf354cc3d2427103b628f924bb39d7fb0 (patch) | |
tree | 0622789f5a19ecb22b4ce1195ae769f45fa04998 /scripts/generate-cmake-files.js | |
parent | 13d27c700e4b0590c4f1c365bfa36cf2a07c437d (diff) | |
download | qtlocation-mapboxgl-e7e6cffcf354cc3d2427103b628f924bb39d7fb0.tar.gz |
[build] convert CMake file list generation code to JavaScript
Bash sorting is weird...
Diffstat (limited to 'scripts/generate-cmake-files.js')
-rwxr-xr-x | scripts/generate-cmake-files.js | 32 |
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' ]); |