include.sh 933 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. SUPRESS_ALL_THE_ERRORS=yes
  3. set -e
  4. include="$(realpath "$1")"
  5. cargo build --release --manifest-path cbindgen/Cargo.toml
  6. cbindgen="$(realpath target/release/cbindgen)"
  7. if [ "$SUPRESS_ALL_THE_ERRORS" = "yes" ]; then
  8. echo -e "\e[91mNote: Warnings by cbindgen are suppressed in include.sh.\e[0m"
  9. fi
  10. jobs=()
  11. for config in src/header/*/cbindgen.toml
  12. do
  13. dir="$(dirname "$config")"
  14. name="$(basename "$dir")"
  15. if [ "${name:0:1}" != "_" ]
  16. then
  17. header="$include/${name/_//}.h"
  18. pushd "$dir" > /dev/null
  19. echo "$dir"
  20. cbindgen_cmd='"$cbindgen" -c cbindgen.toml -o "$header" mod.rs'
  21. if [ "$SUPRESS_ALL_THE_ERRORS" = "yes" ]; then
  22. eval "$cbindgen_cmd" 2>&1 | (grep "^ERROR" -A 3 || true) &
  23. else
  24. eval "$cbindgen_cmd" &
  25. fi
  26. jobs+=($!)
  27. popd > /dev/null
  28. fi
  29. done
  30. for job in "${jobs[@]}"
  31. do
  32. wait "$job"
  33. done