Add optional split output location to codegen scripts (#2152)
This commit is contained in:
@@ -15,8 +15,8 @@ const args = (() => {
|
||||
const parser = new ArgumentParser({
|
||||
description: "MapLibre Shader Tools"
|
||||
});
|
||||
parser.add_argument("--root", "--r", {
|
||||
help: "Directory root to place generated code",
|
||||
parser.add_argument("--out", "--o", {
|
||||
help: "Directory root to write generated code.",
|
||||
required: false
|
||||
});
|
||||
return parser.parse_args();
|
||||
@@ -787,7 +787,8 @@ const lightProperties = Object.keys(spec['light']).reduce((memo, name) => {
|
||||
const lightDoc = spec['light-cocoa-doc'];
|
||||
const lightType = 'light';
|
||||
|
||||
const root = args.root ? args.root : path.dirname(path.dirname(path.dirname(__dirname)));
|
||||
const root = path.dirname(path.dirname(path.dirname(__dirname)));
|
||||
const outLocation = args.out ? args.out : root;
|
||||
|
||||
const layerH = readAndCompile('platform/darwin/src/MLNStyleLayer.h.ejs', root);
|
||||
const layerPrivateH = readAndCompile('platform/darwin/src/MLNStyleLayer_Private.h.ejs', root);
|
||||
@@ -801,11 +802,11 @@ const lightH = readAndCompile('platform/darwin/src/MLNLight.h.ejs', root);
|
||||
const lightM = readAndCompile('platform/darwin/src/MLNLight.mm.ejs', root);
|
||||
const testLight = readAndCompile('platform/darwin/test/MLNLightTest.mm.ejs', root);
|
||||
writeIfModified(`platform/darwin/src/MLNLight.h`, duplicatePlatformDecls(
|
||||
lightH({ properties: lightProperties, doc: lightDoc, type: lightType })), root);
|
||||
lightH({ properties: lightProperties, doc: lightDoc, type: lightType })), outLocation);
|
||||
writeIfModified(`platform/darwin/src/MLNLight.mm`,
|
||||
lightM({ properties: lightProperties, doc: lightDoc, type: lightType }), root);
|
||||
lightM({ properties: lightProperties, doc: lightDoc, type: lightType }), outLocation);
|
||||
writeIfModified(`platform/darwin/test/MLNLightTest.mm`,
|
||||
testLight({ properties: lightProperties, doc: lightDoc, type: lightType }), root);
|
||||
testLight({ properties: lightProperties, doc: lightDoc, type: lightType }), outLocation);
|
||||
|
||||
const layers = _(spec.layer.type.values).map((value, layerType) => {
|
||||
const layoutProperties = Object.keys(spec[`layout_${layerType}`]).reduce((memo, name) => {
|
||||
@@ -879,13 +880,13 @@ for (var layer of layers) {
|
||||
}
|
||||
|
||||
writeIfModified(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.h`,
|
||||
duplicatePlatformDecls(layerH(layer)), root);
|
||||
duplicatePlatformDecls(layerH(layer)), outLocation);
|
||||
writeIfModified(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}_Private.h`,
|
||||
duplicatePlatformDecls(layerPrivateH(layer)), root);
|
||||
duplicatePlatformDecls(layerPrivateH(layer)), outLocation);
|
||||
writeIfModified(`platform/darwin/src/${prefix}${camelize(layer.type)}${suffix}.mm`,
|
||||
layerM(layer), root);
|
||||
layerM(layer), outLocation);
|
||||
writeIfModified(`platform/darwin/test/${prefix}${camelize(layer.type)}${suffix}Tests.mm`,
|
||||
testLayers(layer), root);
|
||||
testLayers(layer), outLocation);
|
||||
}
|
||||
|
||||
// Extract examples for guides from unit tests.
|
||||
@@ -927,21 +928,21 @@ writeIfModified(`platform/ios/docs/guides/For Style Authors.md`, forStyleAuthors
|
||||
os: 'iOS',
|
||||
renamedProperties: renamedPropertiesByLayerType,
|
||||
layers: layers,
|
||||
}), root);
|
||||
}), outLocation);
|
||||
writeIfModified(`platform/macos/docs/guides/For Style Authors.md`, forStyleAuthorsMD({
|
||||
os: 'macOS',
|
||||
renamedProperties: renamedPropertiesByLayerType,
|
||||
layers: layers,
|
||||
}), root);
|
||||
}), outLocation);
|
||||
writeIfModified(`platform/ios/docs/guides/Migrating to Expressions.md`, ddsGuideMD({
|
||||
os: 'iOS',
|
||||
}), root);
|
||||
}), outLocation);
|
||||
writeIfModified(`platform/macos/docs/guides/Migrating to Expressions.md`, ddsGuideMD({
|
||||
os: 'macOS',
|
||||
}), root);
|
||||
}), outLocation);
|
||||
writeIfModified(`platform/ios/docs/guides/Tile URL Templates.md`, templatesMD({
|
||||
os: 'iOS',
|
||||
}), root);
|
||||
}), outLocation);
|
||||
writeIfModified(`platform/macos/docs/guides/Tile URL Templates.md`, templatesMD({
|
||||
os: 'macOS',
|
||||
}), root);*/
|
||||
}), rooutLocationot);*/
|
||||
|
||||
@@ -14,8 +14,8 @@ const args = (() => {
|
||||
const parser = new ArgumentParser({
|
||||
description: "MapLibre Shader Tools"
|
||||
});
|
||||
parser.add_argument("--root", "--r", {
|
||||
help: "Directory root to place generated code",
|
||||
parser.add_argument("--out", "--o", {
|
||||
help: "Directory root to write generated code.",
|
||||
required: false
|
||||
});
|
||||
return parser.parse_args();
|
||||
@@ -222,7 +222,8 @@ global.defaultValue = function (property) {
|
||||
};
|
||||
|
||||
console.log("Generating style code...");
|
||||
const root = args.root ? args.root : path.dirname(__dirname);
|
||||
const root = path.dirname(__dirname);
|
||||
const outLocation = args.out ? args.out : root;
|
||||
|
||||
const layerHpp = readAndCompile(`include/mbgl/style/layers/layer.hpp.ejs`, root);
|
||||
const layerCpp = readAndCompile(`src/mbgl/style/layers/layer.cpp.ejs`, root);
|
||||
@@ -275,16 +276,16 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
|
||||
for (const layer of layers) {
|
||||
const layerFileName = layer.type.replace('-', '_');
|
||||
|
||||
writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.hpp`, propertiesHpp(layer), root);
|
||||
writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.cpp`, propertiesCpp(layer), root);
|
||||
writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.hpp`, propertiesHpp(layer), outLocation);
|
||||
writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer_properties.cpp`, propertiesCpp(layer), outLocation);
|
||||
|
||||
// Remove our fake property for the external interace.
|
||||
if (layer.type === 'line') {
|
||||
layer.paintProperties = layer.paintProperties.filter(property => property.name !== 'line-floor-width');
|
||||
}
|
||||
|
||||
writeIfModified(`include/mbgl/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer), root);
|
||||
writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer), root);
|
||||
writeIfModified(`include/mbgl/style/layers/${layerFileName}_layer.hpp`, layerHpp(layer), outLocation);
|
||||
writeIfModified(`src/mbgl/style/layers/${layerFileName}_layer.cpp`, layerCpp(layer), outLocation);
|
||||
}
|
||||
|
||||
// Light
|
||||
@@ -302,5 +303,5 @@ lightProperties.sort((a, b) => collator.compare(a.name, b.name));
|
||||
|
||||
const lightHpp = readAndCompile(`include/mbgl/style/light.hpp.ejs`, root);
|
||||
const lightCpp = readAndCompile(`src/mbgl/style/light.cpp.ejs`, root);
|
||||
writeIfModified(`include/mbgl/style/light.hpp`, lightHpp({properties: lightProperties}), root);
|
||||
writeIfModified(`src/mbgl/style/light.cpp`, lightCpp({properties: lightProperties}), root);
|
||||
writeIfModified(`include/mbgl/style/light.hpp`, lightHpp({properties: lightProperties}), outLocation);
|
||||
writeIfModified(`src/mbgl/style/light.cpp`, lightCpp({properties: lightProperties}), outLocation);
|
||||
|
||||
@@ -62,7 +62,7 @@ ${precision} ${type} ${name} = u_${name};
|
||||
return source.replace(re, (match, operation, precision, type, name) => {
|
||||
const attrType = type === 'float' ? 'vec2' : 'vec4';
|
||||
const unpackType = name.match(/color/) ? 'color' : attrType;
|
||||
|
||||
|
||||
if (pragmaMap[name]) {
|
||||
if (operation === 'define') {
|
||||
return `#ifndef HAS_UNIFORM_u_${name}
|
||||
@@ -140,7 +140,7 @@ ${precision} ${type} ${name} = u_${name};
|
||||
return source.replace(re, (match, operation, precision, type, name) => {
|
||||
const attrType = type === 'float' ? 'vec2' : 'vec4';
|
||||
const unpackType = name.match(/color/) ? 'color' : attrType;
|
||||
|
||||
|
||||
if (pragmaMap[name]) {
|
||||
if (operation === 'define') {
|
||||
return `#ifndef HAS_UNIFORM_u_${name}
|
||||
@@ -202,8 +202,8 @@ const args = (() => {
|
||||
const parser = new ArgumentParser({
|
||||
description: "MapLibre Shader Tools"
|
||||
});
|
||||
parser.add_argument("--root", "--r", {
|
||||
help: "Directory root to place generated code",
|
||||
parser.add_argument("--out", "--o", {
|
||||
help: "Directory root to write generated code.",
|
||||
required: false
|
||||
});
|
||||
parser.add_argument("--compress", "--c", {
|
||||
@@ -220,9 +220,10 @@ const args = (() => {
|
||||
|
||||
|
||||
// Generate shader source headers
|
||||
const root = args.root ? args.root : path.dirname(__dirname);
|
||||
const root = path.dirname(__dirname);
|
||||
const outLocation = args.out ? args.out : root;
|
||||
const shaderRoot = path.join(root, "shaders");
|
||||
const outputRoot = path.join(root, "include/mbgl/shaders");
|
||||
const outputRoot = path.join(outLocation, "include/mbgl/shaders");
|
||||
let generatedHeaders = [];
|
||||
let shaderNames = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user