joeylib2/scripts/check-tiled.sh

39 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# check-tiled.sh - Host gate for tools/tiled2joey, which turns a map
# made in Tiled into a tile sheet (baked into tile banks by assetbake) and
# one jlTileMapPaste map per tile layer (docs/Assets.adoc). tiledCheck
# (tests/gate/tiledCheck.c) writes one map as TMX and as TMJ, with every flip
# Tiled can ask for, two tilesets (one external, with a margin and spacing),
# and every layer encoding the tool reads; both must convert to the sheet and
# maps worked out by hand, the sheet must bake, and maps it cannot take (16x16
# tiles, a tileset that is not indexed) must be refused.
#
# Usage: scripts/check-tiled.sh
# Exit: 0 PASS, 1 FAIL
set -uo pipefail
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
source "$repo/scripts/lib/joeyEnv.sh"
label=check-tiled
work=$(mktemp -d -t joeylib-tiled.XXXXXX)
trap 'rm -rf "$work"' EXIT
# The converter, and the assetbake the sheet is baked with: make/tools.mk's,
# which tiledCheck runs from JOEY_BUILD's tools/.
make -s -f "$repo/make/tools.mk" tiled2joey assetbake > /dev/null || exit 1
tiledCheck=$(joeyTool tiledCheck) || exit 1
out=$("$tiledCheck" "$repo" "$work")
status=$?
echo "$out"
checks=$(grep -c '^TILED:' <<< "$out")
if [ "$status" -ne 0 ]; then
echo "$label: FAIL ($(grep -c 'FAIL' <<< "$out") of $checks checks failed)"
exit 1
fi
echo "$label: PASS ($checks checks: TMX and TMJ, every flip, two tilesets, three layer encodings, the bake, two refusals)"
exit 0