makerelease.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/bin/sh
  2. srcdir="$(dirname "$0")"
  3. [ "$(echo "$srcdir" | cut -c1)" = '/' ] || srcdir="$PWD/$srcdir"
  4. srcdir="$srcdir/.."
  5. die() { echo "$*"; exit 1; }
  6. # Import the makerelease.lib
  7. # http://bues.ch/gitweb?p=misc.git;a=blob_plain;f=makerelease.lib;hb=HEAD
  8. for path in $(echo "$PATH" | tr ':' ' '); do
  9. [ -f "$MAKERELEASE_LIB" ] && break
  10. MAKERELEASE_LIB="$path/makerelease.lib"
  11. done
  12. [ -f "$MAKERELEASE_LIB" ] && . "$MAKERELEASE_LIB" || die "makerelease.lib not found."
  13. hook_get_version()
  14. {
  15. local file="$1/pyprofibus/version.py"
  16. local maj="$(cat "$file" | grep -e 'VERSION_MAJOR\s*=' | head -n1 | awk '{print $3;}')"
  17. local min="$(cat "$file" | grep -e 'VERSION_MINOR\s*=' | head -n1 | awk '{print $3;}')"
  18. version="$maj.$min"
  19. }
  20. hook_post_checkout()
  21. {
  22. info "Pulling in git submodules"
  23. git submodule update --init --recursive
  24. default_hook_post_checkout "$@"
  25. rm -r "$1"/maintenance
  26. }
  27. hook_testbuild()
  28. {
  29. default_hook_testbuild "$@"
  30. if which mpy-cross >/dev/null 2>&1; then
  31. # Try a Micropython test build.
  32. sh "$1/micropython/install.sh" --clean --build-only
  33. else
  34. warn "mpy-cross not available. Skipping Micropython test."
  35. fi
  36. }
  37. hook_regression_tests()
  38. {
  39. default_hook_regression_tests "$@"
  40. # Run selftests
  41. sh "$1/tests/run.sh"
  42. }
  43. do_build()
  44. {
  45. local target="$1"
  46. local checkout_dir="$2"
  47. local builddir="$checkout_dir/phy_fpga"
  48. local bindir="$builddir/bin/$target"
  49. make -C "$builddir" TARGET="$target"
  50. mkdir -p "$bindir"
  51. for ftype in .bin .asc .blif .rpt .json _yosys.log _nextpnr.log; do
  52. local binfile="${target}_pyprofibusphy${ftype}"
  53. cp "$builddir/$binfile" "$bindir/$binfile"
  54. done
  55. mv "$builddir/${target}_program.sh" "$bindir/${target}_program.sh"
  56. make -C "$builddir" TARGET="$target" clean
  57. }
  58. hook_pre_archives()
  59. {
  60. local archive_dir="$1"
  61. local checkout_dir="$2"
  62. do_build tinyfpga_bx "$checkout_dir"
  63. }
  64. hook_doc_archives()
  65. {
  66. local archive_dir="$1"
  67. local checkout_dir="$2"
  68. local doc_name="$project-doc-$version"
  69. local doc_dir="$tmpdir/$doc_name"
  70. mkdir "$doc_dir" ||\
  71. die "Failed to create directory '$doc_dir'"
  72. (
  73. cd "$checkout_dir" || die "Failed to cd '$checkout_dir'"
  74. rsync --recursive --prune-empty-dirs \
  75. --include='/doc/' \
  76. --include='/doc/**/' \
  77. --include='/doc/**.pdf' \
  78. --include='/doc/**.png' \
  79. --include='/doc/**.jpg' \
  80. --include='/doc/**.jpeg' \
  81. --include='/doc/**.1' \
  82. --include='/doc/**.html' \
  83. --include='/doc/**.txt' \
  84. --include='/doc/**.ods' \
  85. --include='/doc/**/README' \
  86. --include='/micropython/' \
  87. --include='/micropython/**/' \
  88. --include='/micropython/**.html' \
  89. --include='/*.html' \
  90. --include='/*.txt' \
  91. --exclude='*' \
  92. . "$doc_dir" ||\
  93. die "Failed to copy documentation."
  94. cd "$tmpdir" || die "Failed to cd '$tmpdir'"
  95. tar --owner=root --group=root -c -J -f "$archive_dir"/$doc_name.tar.xz \
  96. "$doc_name" ||\
  97. die "Failed to create doc archive."
  98. ) || die
  99. }
  100. project=pyprofibus
  101. default_archives=py-sdist-xz
  102. makerelease "$@"