Last active
February 12, 2020 04:22
-
-
Save joshcarp/32afc8d4ed5a51bc0847798a9fd3858c to your computer and use it in GitHub Desktop.
Sysl makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# User guide: | |
# make input=<inputfile> app=<appname> | |
# This will create a directory `app` and generate code into it | |
# if this script doesn't run, try running `pip2 uninstall sysl` or | |
# `pip uninstall sysl` as make might be running an old sysl version | |
TMP = .tmp# Cache the server lib directory in tmp | |
SERVERLIB = /var/tmp | |
TRANSLOCATION = .tmp/server-lib/codegen/transforms | |
TRANSFORMS= svc_error_types.sysl svc_handler.sysl svc_interface.sysl svc_router.sysl svc_types.sysl | |
GRAMMAR=$(wildcard .tmp/server-lib/codegen/grammars/go.gen.g) | |
START=goFile | |
app=Simple | |
# Always execute these with just `make` | |
.PHONY: setup clean gen | |
all: setup gen format tmp | |
# try to clone, then try to fetch and pull | |
setup: | |
# Syncing server-lib to $(SERVERLIB) | |
git clone https://github.service.anz/sysl/server-lib/ $(SERVERLIB)/server-lib || true # Don't fail | |
cd $(SERVERLIB)/server-lib && git fetch && git checkout tags/v0.1.8 || true | |
mkdir -p $(TMP)/server-lib/ | |
mkdir -p gen/${app} | |
# Copying server-lib to $(TMP) | |
cp -rf $(SERVERLIB)/server-lib $(TMP)/ | |
# Generate files with internal git service | |
gen: | |
$(foreach file, $(TRANSFORMS), $(shell sysl codegen --transform $(TRANSLOCATION)/$(file) --grammar ${GRAMMAR} --start ${START} --outdir=gen/${app} --app-name ${app} $(input))) | |
format: | |
gofmt -s -w gen/${app}/* | |
goimports -w gen/${app}/* | |
# Remove the tmp directory after | |
tmp: | |
rm -rf $(TMP) | |
# Remove the generated files | |
clean: | |
rm -rf ${app} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment