1
0
mirror of https://github.com/danog/tl-schema.git synced 2024-12-02 09:18:01 +01:00
tl-schema/utils/parse.sh
Viktor Oreshkin 007afbbf9a Add parse.sh
Update parse.sh
2017-07-03 11:27:50 +03:00

41 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
tlm="$(dirname $0)/converter.py"
savedpath="$PWD"
cd $1
if [ -f "config.js" ]; then
( \
echo 'Config={}; Config.Schema={};'; \
grep 'Config.Schema.API' config.js; \
echo ';console.log(JSON.stringify(Config.Schema.API));' \
) | node > "$savedpath/schema.json"
grep 'Config.Schema.API.layer' config.js
cd $savedpath
# Two times because of Vector
$tlm schema.json; $tlm schema.tl
$tlm schema.json; $tlm schema.tl
elif [ -f "scheme.tl" ]; then
if ! grep 'LAYER' scheme.tl; then
if [ -f "mtpCoreTypes.h" ]; then
if ! grep 'mtpCurrentLayer' mtpCoreTypes.h; then
grep 'mtpLayerMax' -B 1 mtpCoreTypes.h|head -n 1
fi
elif [ -f "core_types.h" ]; then
grep 'mtpCurrentLayer' core_types.h
fi
fi
ln="$(grep -n 'Main application API' scheme.tl | cut -d ':' -f 1)"
tail -n "+$ln" scheme.tl > $savedpath/schema.tl
cd $savedpath
# Two times because of Vector
$tlm schema.tl; $tlm schema.json
$tlm schema.tl; $tlm schema.json
fi