generate_files 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. set -e
  3. PHP_CMD=( php )
  4. FLEX_CMD=( flex )
  5. BISON_CMD=( bison )
  6. OUT_DIR="generated/"
  7. function bproto() {
  8. local input="$1"
  9. local name="$2"
  10. "${PHP_CMD[@]}" bproto_generator/bproto.php --input-file "${input}" --output-dir "${OUT_DIR}" --name "bproto_${name}"
  11. }
  12. function bstruct() {
  13. local input="$1"
  14. local name="$2"
  15. "${PHP_CMD[@]}" bstruct_generator/bstruct.php --input-file "${input}" --output-dir "${OUT_DIR}" --name "bstruct_${name}"
  16. }
  17. function do_flex() {
  18. local input="$1"
  19. local name="$2"
  20. "${FLEX_CMD[@]}" -o "${OUT_DIR}/flex_${name}.c" --header-file="${OUT_DIR}/flex_${name}.h" "${input}"
  21. }
  22. function do_bison() {
  23. local input="$1"
  24. local name="$2"
  25. "${BISON_CMD[@]}" -d -o "${OUT_DIR}/bison_${name}.c" "${input}"
  26. }
  27. mkdir -p generated
  28. bproto tests/bproto_test.bproto bproto_test
  29. bproto protocol/msgproto.bproto msgproto
  30. bproto protocol/addr.bproto addr
  31. bstruct tests/bstruct_test.bstruct bstruct_test
  32. bstruct security/OTPChecker.bstruct OTPChecker
  33. do_flex predicate/BPredicate.l BPredicate
  34. do_bison predicate/BPredicate.y BPredicate
  35. "${PHP_CMD[@]}" blog_generator/blog.php --input-file blog_channels.txt --output-dir "${OUT_DIR}"