makerelease.sh 3.0 KB

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