makefile 1009 B

12345678910111213141516171819202122232425262728293031323334
  1. SHELL=/bin/bash
  2. .PHONY = clean
  3. directory := grammar
  4. # Get the path of this makefile.
  5. # Place this before include directives, if any.
  6. this := $(lastword $(MAKEFILE_LIST))
  7. $(directory)/urn_{parser,lexer,base_listener,listener,base_visitor,visitor}.go: $(directory)/Urn.g4 $(directory)/antlr
  8. $(SHELL) -c "./$(directory)/antlr -Dlanguage=Go -o $(directory) -package $(directory) -listener -no-visitor $<"
  9. $(directory)/antlr:
  10. @docker pull leodido/antlr
  11. @docker create --name antlr leodido/antlr
  12. @docker cp antlr:antlr $(directory)
  13. @docker rm antlr
  14. test: tcmd = "go test -v"
  15. ifdef COVERAGE
  16. test: tcmd = "go test -v -coverprofile=cov.out"
  17. endif
  18. test: $(directory)/urn_{parser,lexer,base_listener,listener,base_visitor,visitor}.go *_test.go
  19. $(SHELL) -c $(tcmd)
  20. cov.out:
  21. $(MAKE) -f $(this) test COVERAGE=yes
  22. coverage: cov.out
  23. @go tool cover -func=$<
  24. clean:
  25. rm -f $(directory)/urn_{parser,lexer,base_listener,listener,base_visitor,visitor}.go $(directory)/Urn{,Lexer}.tokens $(directory)/antlr *.out