Add a MLT=0 build for a tippecanoe without MapLibre Tile support

MapLibre Tile support pulls in the maplibre-tile-spec submodule and needs
cmake to build it, which is a lot to ask of anyone who only wants to work
with Mapbox Vector Tiles.

`make MLT=0` compiles with -DNO_MLT, skips the submodule and its cmake
build entirely, and drops the MLT tests from `make test`. The result needs
no dependencies beyond the ones MVT already needed, and can be built from
a checkout with no submodules at all.

Everything that touches the MLT library is behind the #ifdef, which is
just the two files that were written for it. The option parsing and the
tile format helpers stay compiled either way, so nothing else needs to
know: --output-format=mlt reports that the build has no MLT support rather
than being an unrecognized value, and a tile that is recognized as MLT
reports the same instead of being misparsed as a protobuf, since the
format sniffing itself doesn't need the library.

CI builds and tests this configuration from a checkout without submodules,
so it can't quietly stop working.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LxhELiLtpUFwrPSWwTYdHG
This commit is contained in:
Claude
2026-08-06 18:05:42 +00:00
parent 13f1c3b6e4
commit c70d98afe8
6 changed files with 94 additions and 19 deletions
+19 -4
View File
@@ -1,8 +1,6 @@
#include "mlt.hpp"
#include "errors.hpp"
#include <mlt/encoder.hpp>
#include <algorithm>
#include <cstdint>
#include <cstdio>
@@ -12,7 +10,11 @@
#include <string>
#include <vector>
#ifndef NO_MLT
#include <mlt/encoder.hpp>
using Vertex = mlt::Encoder::Vertex;
#endif
int output_format = OUTPUT_MVT;
bool mlt_sort_features = true;
@@ -22,7 +24,12 @@ void set_output_format(char **argv, const char *format) {
if (strcmp(format, "mvt") == 0 || strcmp(format, "pbf") == 0) {
output_format = OUTPUT_MVT;
} else if (strcmp(format, "mlt") == 0) {
#ifdef NO_MLT
fprintf(stderr, "%s: this build was compiled without MapLibre Tile support\n", argv[0]);
exit(EXIT_ARGS);
#else
output_format = OUTPUT_MLT;
#endif
} else {
fprintf(stderr, "%s: --output-format must be 'mvt' or 'mlt'\n", argv[0]);
exit(EXIT_ARGS);
@@ -38,13 +45,19 @@ const char *tile_format_extension(int format) {
}
std::string encode_tile(mvt_tile &tile, int format) {
#ifndef NO_MLT
if (format == OUTPUT_MLT) {
return encode_as_mlt(tile, mlt_sort_features, mlt_pretessellate);
} else {
return tile.encode();
}
#else
(void) format;
#endif
return tile.encode();
}
#ifndef NO_MLT
// An MLT property column has a single type for the whole layer, while MVT
// values each carry their own type, so a type that can hold every value of
// an attribute has to be chosen before the layer can be converted.
@@ -327,3 +340,5 @@ std::string encode_as_mlt(const mvt_tile &tile, bool sort_features, bool pretess
auto bytes = encoder.encode(layers, config);
return std::string(reinterpret_cast<const char *>(bytes.data()), bytes.size());
}
#endif