diff --git a/Makefile b/Makefile index 228b98d63..8368ea2cf 100644 --- a/Makefile +++ b/Makefile @@ -70,4 +70,7 @@ protobuf_check: ## check that generated protobuf headers are up to date ./tools/build_protobuf --check gen: mocks templates protobuf ## regeneate auto-generated files from sources + make -C python coins_json + gen_check: mocks_check templates_check protobuf_check ## check validity of auto-generated files + make -C python coins_json_check diff --git a/python/Makefile b/python/Makefile index 1f6091610..2574c5152 100644 --- a/python/Makefile +++ b/python/Makefile @@ -11,16 +11,14 @@ clean-gen: ## remove generated files rm -f trezorlib/messages/*.py rm -f trezorlib/coins.json +coins_json: + ./helper-scripts/build-coins-json.sh + +coins_json_check: + ./helper-scripts/build-coins-json.sh --check + gen: clean-gen - $(PYTHON) ../common/tools/cointool.py dump \ - --list --support \ - --include-type=bitcoin \ - --exclude=icon \ - -o trezorlib/coins.json - $(PYTHON) ../common/protob/pb2py \ - -o trezorlib/messages \ - -P ..protobuf \ - ../common/protob/*.proto + make -C .. gen build: $(SETUP) build diff --git a/python/helper-scripts/build-coins-json.sh b/python/helper-scripts/build-coins-json.sh new file mode 100755 index 000000000..1fa89b66b --- /dev/null +++ b/python/helper-scripts/build-coins-json.sh @@ -0,0 +1,24 @@ +#!/bin/bash +cd $(dirname $0)/.. + +DEST=trezorlib/coins.json + +BUILD_COINS_AT="../common/tools/cointool.py dump \ + --list --support \ + --include-type=bitcoin \ + --exclude=icon \ + -o \ +" + +if [ "$1" == "--check" ]; then + TMP=$(mktemp) + $BUILD_COINS_AT $TMP + diff -q $DEST $TMP + if [ "$?" -ne 0 ]; then + echo "Please run $0" + fi + rm $TMP + exit $ERR +else + $BUILD_COINS_AT $DEST +fi diff --git a/python/trezorlib/coins.py b/python/trezorlib/coins.py index 349677297..e0910bde3 100644 --- a/python/trezorlib/coins.py +++ b/python/trezorlib/coins.py @@ -24,7 +24,7 @@ COINS_JSON = os.path.join(os.path.dirname(__file__), "coins.json") def _load_coins_json(): # Load coins.json to local variables - # NOTE: coins.json is generated via `make generated` command. + # NOTE: coins.json is generated via `make coins_json` command. with open(COINS_JSON) as coins_json: return json.load(coins_json)