protobuffs.mk 866 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (c) 2015, Loïc Hoguin <essen@ninenines.eu>
  2. # This file is part of erlang.mk and subject to the terms of the ISC License.
  3. # Verbosity.
  4. proto_verbose_0 = @echo " PROTO " $(filter %.proto,$(?F));
  5. proto_verbose = $(proto_verbose_$(V))
  6. # Core targets.
  7. define compile_proto
  8. @mkdir -p ebin/ include/
  9. $(proto_verbose) $(call erlang,$(call compile_proto.erl,$(1)))
  10. $(proto_verbose) erlc +debug_info -o ebin/ ebin/*.erl
  11. @rm ebin/*.erl
  12. endef
  13. define compile_proto.erl
  14. [begin
  15. Dir = filename:dirname(filename:dirname(F)),
  16. protobuffs_compile:generate_source(F,
  17. [{output_include_dir, Dir ++ "/include"},
  18. {output_src_dir, Dir ++ "/ebin"}])
  19. end || F <- string:tokens("$(1)", " ")],
  20. halt().
  21. endef
  22. ifneq ($(wildcard src/),)
  23. ebin/$(PROJECT).app:: $(shell find src -type f -name \*.proto 2>/dev/null)
  24. $(if $(strip $?),$(call compile_proto,$?))
  25. endif