generate_files 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. function do_lemon() {
  28. local input="$1"
  29. local name=$(basename "${input}")
  30. (
  31. cd generated &&
  32. rm -f "${name}" &&
  33. cp ../"${input}" "${name}" &&
  34. ../lemon/lemon "${name}"
  35. )
  36. }
  37. mkdir -p generated
  38. bproto tests/bproto_test.bproto bproto_test
  39. bproto protocol/msgproto.bproto msgproto
  40. bproto protocol/addr.bproto addr
  41. bstruct tests/bstruct_test.bstruct bstruct_test
  42. bstruct security/OTPChecker.bstruct OTPChecker
  43. do_flex predicate/BPredicate.l BPredicate
  44. do_bison predicate/BPredicate.y BPredicate
  45. "${PHP_CMD[@]}" blog_generator/blog.php --input-file blog_channels.txt --output-dir "${OUT_DIR}"
  46. do_lemon ncdconfig/NCDConfigParser_parse.y