summaryrefslogtreecommitdiff
path: root/scripts/generate-style-code.js
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-11-08 18:14:46 +0100
committerKonstantin Käfer <mail@kkaefer.com>2016-11-09 11:10:22 +0100
commit2411ec83b12fd2457f6f22fe5a4de9122503a2e2 (patch)
tree285d63d836d3f888c75175a72af619095947c98a /scripts/generate-style-code.js
parent4030e86c33c8863c4c255201e6a7f3ff447000ed (diff)
downloadqtlocation-mapboxgl-2411ec83b12fd2457f6f22fe5a4de9122503a2e2.tar.gz
[build] don't rewrite style code for every build
revert of 93166aef482ea5835d87231f88d369449398ccdf On Android, we always rewrote the style code files, which lead to gratuitous recompiles
Diffstat (limited to 'scripts/generate-style-code.js')
-rw-r--r--scripts/generate-style-code.js27
1 files changed, 10 insertions, 17 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js
index dcb527e8c9..005bc022df 100644
--- a/scripts/generate-style-code.js
+++ b/scripts/generate-style-code.js
@@ -5,6 +5,8 @@ const ejs = require('ejs');
const spec = require('mapbox-gl-style-spec').latest;
var colorParser = require('csscolorparser');
+require('./style-code');
+
function parseCSSColor(str) {
var color = colorParser.parseCSSColor(str);
return [
@@ -12,18 +14,6 @@ function parseCSSColor(str) {
];
}
-global.camelize = function (str) {
- return str.replace(/(?:^|-)(.)/g, function (_, x) {
- return x.toUpperCase();
- });
-}
-
-global.camelizeWithLeadingLowercase = function (str) {
- return str.replace(/-(.)/g, function (_, x) {
- return x.toUpperCase();
- });
-}
-
global.propertyType = function (property) {
if (/-translate-anchor$/.test(property.name)) {
return 'TranslateAnchorType';
@@ -121,16 +111,19 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
type: type,
layoutProperties: layoutProperties,
paintProperties: paintProperties,
+ doc: spec.layer.type.values[type].doc,
+ layoutPropertiesByName: spec[`layout_${type}`],
+ paintPropertiesByName: spec[`paint_${type}`],
};
});
for (const layer of layers) {
- fs.writeFileSync(`include/mbgl/style/layers/${layer.type}_layer.hpp`, layerHpp(layer));
- fs.writeFileSync(`src/mbgl/style/layers/${layer.type}_layer.cpp`, layerCpp(layer));
+ writeIfModified(`include/mbgl/style/layers/${layer.type}_layer.hpp`, layerHpp(layer));
+ writeIfModified(`src/mbgl/style/layers/${layer.type}_layer.cpp`, layerCpp(layer));
- fs.writeFileSync(`src/mbgl/style/layers/${layer.type}_layer_properties.hpp`, propertiesHpp(layer));
- fs.writeFileSync(`src/mbgl/style/layers/${layer.type}_layer_properties.cpp`, propertiesCpp(layer));
+ writeIfModified(`src/mbgl/style/layers/${layer.type}_layer_properties.hpp`, propertiesHpp(layer));
+ writeIfModified(`src/mbgl/style/layers/${layer.type}_layer_properties.cpp`, propertiesCpp(layer));
}
const propertySettersHpp = ejs.compile(fs.readFileSync('include/mbgl/style/conversion/make_property_setters.hpp.ejs', 'utf8'), {strict: true});
-fs.writeFileSync('include/mbgl/style/conversion/make_property_setters.hpp', propertySettersHpp({layers: layers}));
+writeIfModified('include/mbgl/style/conversion/make_property_setters.hpp', propertySettersHpp({layers: layers}));