summaryrefslogtreecommitdiff
path: root/scripts/generate-style-code.js
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/generate-style-code.js')
-rwxr-xr-xscripts/generate-style-code.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/generate-style-code.js b/scripts/generate-style-code.js
index 0bac355071..aed676c990 100755
--- a/scripts/generate-style-code.js
+++ b/scripts/generate-style-code.js
@@ -197,6 +197,8 @@ const layerCpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer.cpp.ej
const propertiesHpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer_properties.hpp.ejs', 'utf8'), {strict: true});
const propertiesCpp = ejs.compile(fs.readFileSync('src/mbgl/style/layers/layer_properties.cpp.ejs', 'utf8'), {strict: true});
+const collator = new Intl.Collator("en-US");
+
// Add this mock property that our SDF line shader needs so that it gets added to the list of
// "data driven" properties.
spec.paint_line['line-floor-width'] = {
@@ -214,12 +216,20 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
return memo;
}, []);
+ // JSON doesn't have a defined order. We're going to sort them alphabetically
+ // to get a deterministic order.
+ layoutProperties.sort((a, b) => collator.compare(a.name, b.name));
+
const paintProperties = Object.keys(spec[`paint_${type}`]).reduce((memo, name) => {
spec[`paint_${type}`][name].name = name;
memo.push(spec[`paint_${type}`][name]);
return memo;
}, []);
+ // JSON doesn't have a defined order. We're going to sort them alphabetically
+ // to get a deterministic order.
+ paintProperties.sort((a, b) => collator.compare(a.name, b.name));
+
return {
type: type,
layoutProperties: layoutProperties,
@@ -254,6 +264,10 @@ const lightProperties = Object.keys(spec[`light`]).reduce((memo, name) => {
return memo;
}, []);
+// JSON doesn't have a defined order. We're going to sort them alphabetically
+// to get a deterministic order.
+lightProperties.sort((a, b) => collator.compare(a.name, b.name));
+
const lightHpp = ejs.compile(fs.readFileSync('include/mbgl/style/light.hpp.ejs', 'utf8'), {strict: true});
const lightCpp = ejs.compile(fs.readFileSync('src/mbgl/style/light.cpp.ejs', 'utf8'), {strict: true});
writeIfModified(`include/mbgl/style/light.hpp`, lightHpp({properties: lightProperties}));