plugin_protobuffs.mk 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Protocol buffers plugin.
  2. PROTOBUFFS_TARGETS = $(call list_targets,protobuffs)
  3. .PHONY: protobuffs $(PROTOBUFFS_TARGETS)
  4. protobuffs: $(PROTOBUFFS_TARGETS)
  5. PROTOBUFFS_URL = https://raw.githubusercontent.com/basho/erlang_protobuffs/master/test/erlang_protobuffs_SUITE_data
  6. protobuffs-compile: build clean
  7. $i "Bootstrap a new OTP library named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  11. $i "Add protobuffs to the list of dependencies"
  12. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = protobuffs\n"}' $(APP)/Makefile
  13. $i "Download two proto files"
  14. $t mkdir $(APP)/src/proto/
  15. $t curl -s -o $(APP)/src/proto/empty.proto $(PROTOBUFFS_URL)/proto/empty.proto
  16. $t curl -s -o $(APP)/src/proto/simple.proto $(PROTOBUFFS_URL)/proto/simple.proto
  17. $i "Build the application"
  18. $t $(MAKE) -C $(APP) $v
  19. $i "Check that an Erlang module was generated and compiled"
  20. $t test -f $(APP)/src/empty_pb.erl
  21. $t test -f $(APP)/src/simple_pb.erl
  22. $t test -f $(APP)/include/empty_pb.hrl
  23. $t test -f $(APP)/include/simple_pb.hrl
  24. $t test -f $(APP)/ebin/empty_pb.beam
  25. $t test -f $(APP)/ebin/simple_pb.beam
  26. $i "Check that the generated modules are included in .app file"
  27. $t $(ERL) -pa $(APP)/ebin/ -eval " \
  28. ok = application:load($(APP)), \
  29. {ok, [empty_pb, simple_pb]} = application:get_key($(APP), modules), \
  30. halt()"
  31. protobuffs-makefile-change: build clean
  32. $i "Bootstrap a new OTP library named $(APP)"
  33. $t mkdir $(APP)/
  34. $t cp ../erlang.mk $(APP)/
  35. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  36. $i "Add protobuffs to the list of dependencies"
  37. $t perl -ni.bak -e 'print;if ($$.==1) {print "BUILD_DEPS = protobuffs\n"}' $(APP)/Makefile
  38. $i "Download two proto files"
  39. $t mkdir $(APP)/src/proto/
  40. $t curl -s -o $(APP)/src/proto/empty.proto $(PROTOBUFFS_URL)/proto/empty.proto
  41. $t curl -s -o $(APP)/src/proto/simple.proto $(PROTOBUFFS_URL)/proto/simple.proto
  42. $i "Build the application"
  43. $t $(MAKE) -C $(APP) $v
  44. $i "Touch the Makefile; check that all files get rebuilt"
  45. $t printf "%s\n" \
  46. $(APP)/ebin/empty_pb.beam \
  47. $(APP)/ebin/simple_pb.beam \
  48. $(APP)/ebin/$(APP).app \
  49. $(APP)/include/empty_pb.hrl \
  50. $(APP)/include/simple_pb.hrl \
  51. $(APP)/src/empty_pb.erl \
  52. $(APP)/src/proto/simple.proto \
  53. $(APP)/src/proto/empty.proto \
  54. $(APP)/src/simple_pb.erl \
  55. $(APP)/$(APP).d | sort > $(APP)/EXPECT
  56. $t $(SLEEP)
  57. $t touch $(APP)/Makefile
  58. $t $(SLEEP)
  59. $t $(MAKE) -C $(APP) $v
  60. $t find $(APP) -type f -newer $(APP)/Makefile -not -path "$(APP)/.erlang.mk/*" | sort | diff $(APP)/EXPECT -
  61. $t rm $(APP)/EXPECT