summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-01-10 16:04:06 -0800
committerKonstantin Käfer <mail@kkaefer.com>2018-01-24 08:35:31 -0800
commite7e6cffcf354cc3d2427103b628f924bb39d7fb0 (patch)
tree0622789f5a19ecb22b4ce1195ae769f45fa04998
parent13d27c700e4b0590c4f1c365bfa36cf2a07c437d (diff)
downloadqtlocation-mapboxgl-e7e6cffcf354cc3d2427103b628f924bb39d7fb0.tar.gz
[build] convert CMake file list generation code to JavaScript
Bash sorting is weird...
-rw-r--r--cmake/benchmark-files.cmake19
-rw-r--r--cmake/core-files.cmake3
-rw-r--r--cmake/files.cmake.ejs13
-rw-r--r--cmake/test-files.cmake59
-rwxr-xr-xscripts/generate-benchmark-files.sh20
-rwxr-xr-xscripts/generate-cmake-files.js32
-rwxr-xr-xscripts/generate-core-files.sh20
-rwxr-xr-xscripts/generate-test-files.sh20
8 files changed, 83 insertions, 103 deletions
diff --git a/cmake/benchmark-files.cmake b/cmake/benchmark-files.cmake
index 9161209128..fdafcf30f9 100644
--- a/cmake/benchmark-files.cmake
+++ b/cmake/benchmark-files.cmake
@@ -1,30 +1,27 @@
-# Do not edit. Regenerate this with ./scripts/generate-benchmark-files.sh
+# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js
set(MBGL_BENCHMARK_FILES
# api
benchmark/api/query.benchmark.cpp
benchmark/api/render.benchmark.cpp
+ # benchmark
+ benchmark/include/mbgl/benchmark.hpp
+ benchmark/src/main.cpp
+ benchmark/src/mbgl/benchmark/benchmark.cpp
+ benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp
+
# function
benchmark/function/camera_function.benchmark.cpp
benchmark/function/composite_function.benchmark.cpp
benchmark/function/source_function.benchmark.cpp
- # include/mbgl
- benchmark/include/mbgl/benchmark.hpp
-
# parse
benchmark/parse/filter.benchmark.cpp
benchmark/parse/tile_mask.benchmark.cpp
benchmark/parse/vector_tile.benchmark.cpp
- # src
- benchmark/src/main.cpp
-
- # src/mbgl/benchmark
- benchmark/src/mbgl/benchmark/benchmark.cpp
- benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp
-
# util
benchmark/util/dtoa.benchmark.cpp
+
)
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake
index 8148fcdc88..24d5262799 100644
--- a/cmake/core-files.cmake
+++ b/cmake/core-files.cmake
@@ -1,4 +1,4 @@
-# Do not edit. Regenerate this with ./scripts/generate-core-files.sh
+# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js
set(MBGL_CORE_FILES
# actor
@@ -740,4 +740,5 @@ set(MBGL_CORE_FILES
src/mbgl/util/version.cpp
src/mbgl/util/version.hpp
src/mbgl/util/work_request.cpp
+
)
diff --git a/cmake/files.cmake.ejs b/cmake/files.cmake.ejs
new file mode 100644
index 0000000000..57126509ed
--- /dev/null
+++ b/cmake/files.cmake.ejs
@@ -0,0 +1,13 @@
+<%
+ const name = locals.name;
+ const groups = locals.groups;
+-%>
+# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js
+
+set(MBGL_<%- snakeCaseUpper(name) %>_FILES
+<% for (const key of Object.keys(groups).sort()) { -%>
+ # <%- key %>
+ <%- groups[key].sort().join('\n ') %>
+
+<% } -%>
+)
diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake
index 73f1546308..790198a55e 100644
--- a/cmake/test-files.cmake
+++ b/cmake/test-files.cmake
@@ -1,4 +1,4 @@
-# Do not edit. Regenerate this with ./scripts/generate-test-files.sh
+# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js
set(MBGL_TEST_FILES
# actor
@@ -29,9 +29,6 @@ set(MBGL_TEST_FILES
test/gl/context.test.cpp
test/gl/object.test.cpp
- # include/mbgl
- test/include/mbgl/test.hpp
-
# map
test/map/map.test.cpp
test/map/prefetch.test.cpp
@@ -55,23 +52,6 @@ set(MBGL_TEST_FILES
test/sprite/sprite_loader.test.cpp
test/sprite/sprite_parser.test.cpp
- # src/mbgl/test
- test/src/mbgl/test/fake_file_source.hpp
- test/src/mbgl/test/fixture_log_observer.cpp
- test/src/mbgl/test/fixture_log_observer.hpp
- test/src/mbgl/test/getrss.cpp
- test/src/mbgl/test/getrss.hpp
- test/src/mbgl/test/stub_file_source.cpp
- test/src/mbgl/test/stub_file_source.hpp
- test/src/mbgl/test/stub_geometry_tile_feature.hpp
- test/src/mbgl/test/stub_layer_observer.hpp
- test/src/mbgl/test/stub_render_source_observer.hpp
- test/src/mbgl/test/stub_style_observer.hpp
- test/src/mbgl/test/stub_tile_observer.hpp
- test/src/mbgl/test/test.cpp
- test/src/mbgl/test/util.cpp
- test/src/mbgl/test/util.hpp
-
# storage
test/storage/asset_file_source.test.cpp
test/storage/default_file_source.test.cpp
@@ -85,6 +65,15 @@ set(MBGL_TEST_FILES
test/storage/resource.test.cpp
test/storage/sqlite.test.cpp
+ # style
+ test/style/filter.test.cpp
+ test/style/properties.test.cpp
+ test/style/source.test.cpp
+ test/style/style.test.cpp
+ test/style/style_image.test.cpp
+ test/style/style_layer.test.cpp
+ test/style/style_parser.test.cpp
+
# style/conversion
test/style/conversion/function.test.cpp
test/style/conversion/geojson_options.test.cpp
@@ -97,9 +86,6 @@ set(MBGL_TEST_FILES
test/style/expression/expression.test.cpp
test/style/expression/util.test.cpp
- # style
- test/style/filter.test.cpp
-
# style/function
test/style/function/camera_function.test.cpp
test/style/function/composite_function.test.cpp
@@ -107,13 +93,23 @@ set(MBGL_TEST_FILES
test/style/function/interval_stops.test.cpp
test/style/function/source_function.test.cpp
- # style
- test/style/properties.test.cpp
- test/style/source.test.cpp
- test/style/style.test.cpp
- test/style/style_image.test.cpp
- test/style/style_layer.test.cpp
- test/style/style_parser.test.cpp
+ # test
+ test/include/mbgl/test.hpp
+ test/src/mbgl/test/fake_file_source.hpp
+ test/src/mbgl/test/fixture_log_observer.cpp
+ test/src/mbgl/test/fixture_log_observer.hpp
+ test/src/mbgl/test/getrss.cpp
+ test/src/mbgl/test/getrss.hpp
+ test/src/mbgl/test/stub_file_source.cpp
+ test/src/mbgl/test/stub_file_source.hpp
+ test/src/mbgl/test/stub_geometry_tile_feature.hpp
+ test/src/mbgl/test/stub_layer_observer.hpp
+ test/src/mbgl/test/stub_render_source_observer.hpp
+ test/src/mbgl/test/stub_style_observer.hpp
+ test/src/mbgl/test/stub_tile_observer.hpp
+ test/src/mbgl/test/test.cpp
+ test/src/mbgl/test/util.cpp
+ test/src/mbgl/test/util.hpp
# text
test/text/cross_tile_symbol_index.test.cpp
@@ -156,4 +152,5 @@ set(MBGL_TEST_FILES
test/util/token.test.cpp
test/util/unique_any.test.cpp
test/util/url.test.cpp
+
)
diff --git a/scripts/generate-benchmark-files.sh b/scripts/generate-benchmark-files.sh
deleted file mode 100755
index 0fb274cf31..0000000000
--- a/scripts/generate-benchmark-files.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -o pipefail
-
-echo "# Do not edit. Regenerate this with ./scripts/generate-benchmark-files.sh" > cmake/benchmark-files.cmake
-echo "" >> cmake/benchmark-files.cmake
-echo "set(MBGL_BENCHMARK_FILES" >> cmake/benchmark-files.cmake
-PREFIX=
-for FILE in $(git ls-files "benchmark/*.hpp" "benchmark/*.cpp" "benchmark/*.h" "benchmark/*.c" | sort) ; do
- CURRENT_PREFIX=$(dirname ${FILE#benchmark/})
- if [ "${PREFIX}" != "${CURRENT_PREFIX}" ]; then
- if [ ! -z "${PREFIX}" ]; then echo "" >> cmake/benchmark-files.cmake ; fi
- echo " # ${CURRENT_PREFIX}" >> cmake/benchmark-files.cmake
- PREFIX="${CURRENT_PREFIX}"
- fi
- echo " ${FILE}" >> cmake/benchmark-files.cmake
-done
-echo ")" >> cmake/benchmark-files.cmake
-git diff cmake/benchmark-files.cmake
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' ]);
diff --git a/scripts/generate-core-files.sh b/scripts/generate-core-files.sh
deleted file mode 100755
index 27754306e1..0000000000
--- a/scripts/generate-core-files.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -o pipefail
-
-echo "# Do not edit. Regenerate this with ./scripts/generate-core-files.sh" > cmake/core-files.cmake
-echo "" >> cmake/core-files.cmake
-echo "set(MBGL_CORE_FILES" >> cmake/core-files.cmake
-PREFIX=
-for FILE in $(git ls-files "include/*.hpp" "include/*.h" "src/*.hpp" "src/*.cpp" "src/*.h" "src/*.c" | perl -p -e "s/^((src|include)\/(mbgl\/)?(.+)\/\w+\.\w+)$/\$4#\$1/g" | sort) ; do
- CURRENT_PREFIX="${FILE%#*}"
- if [ "${PREFIX}" != "${CURRENT_PREFIX}" ]; then
- if [ ! -z "${PREFIX}" ]; then echo "" >> cmake/core-files.cmake ; fi
- echo " # ${CURRENT_PREFIX}" >> cmake/core-files.cmake
- PREFIX="${CURRENT_PREFIX}"
- fi
- echo " ${FILE#*#}" >> cmake/core-files.cmake
-done
-echo ")" >> cmake/core-files.cmake
-git diff cmake/core-files.cmake
diff --git a/scripts/generate-test-files.sh b/scripts/generate-test-files.sh
deleted file mode 100755
index 5f507d3edf..0000000000
--- a/scripts/generate-test-files.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -o pipefail
-
-echo "# Do not edit. Regenerate this with ./scripts/generate-test-files.sh" > cmake/test-files.cmake
-echo "" >> cmake/test-files.cmake
-echo "set(MBGL_TEST_FILES" >> cmake/test-files.cmake
-PREFIX=
-for FILE in $(git ls-files "test/*.hpp" "test/*.cpp" "test/*.h" "test/*.c" | sort) ; do
- CURRENT_PREFIX=$(dirname ${FILE#test/})
- if [ "${PREFIX}" != "${CURRENT_PREFIX}" ]; then
- if [ ! -z "${PREFIX}" ]; then echo "" >> cmake/test-files.cmake ; fi
- echo " # ${CURRENT_PREFIX}" >> cmake/test-files.cmake
- PREFIX="${CURRENT_PREFIX}"
- fi
- echo " ${FILE}" >> cmake/test-files.cmake
-done
-echo ")" >> cmake/test-files.cmake
-git diff cmake/test-files.cmake