PageRenderTime 2199ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/hphp/util/generate-buildinfo.sh

https://gitlab.com/iranjith4/hhvm
Shell | 71 lines | 42 code | 14 blank | 15 comment | 8 complexity | a3aaaf3ccd3d2f35d8b7ca579dff62af MD5 | raw file
  1. #!/bin/bash
  2. # Hacky way of disabling fbmake's pre_command.
  3. if [ ! -z "${FBMAKE_PRE_COMMAND_OUTDIR}" ]; then
  4. exit 0
  5. fi
  6. if echo $1 | grep -q -e 'install_dir=' -e 'fbcode_dir=' ; then
  7. # Skip --install_dir and --fbcode_dir.
  8. shift 2
  9. fi
  10. DIR=$(pwd -P)
  11. if git rev-parse --show-toplevel >& /dev/null; then
  12. root=$(git rev-parse --show-toplevel)
  13. compiler="git describe --all --long --abbrev=40 --always"
  14. find_files="git ls-files -- hphp"
  15. elif hg root >& /dev/null; then
  16. root=$(hg root)
  17. if [ -f "$root/fbcode/.projectid" ]; then
  18. root="$root/fbcode"
  19. fi
  20. compiler="hg --config trusted.users='*' log -l1 -r'reverse(::.) & file(\"$root/**\")' -T'{branch}-0-g{sub(r\"^\$\",node,mirrornode(\"fbcode\",\"git\"))}\n' 2> /dev/null"
  21. find_files="hg files -I hphp/"
  22. else
  23. root=$DIR/../../
  24. # Building outside of a git repo, use system time instead. This will make the
  25. # sha appear to change constantly, but without any insight into file state,
  26. # it's the safest fallback
  27. compiler='date +%s_%N'
  28. find_files='find hphp \( -type f -o -type l \) \! -iregex ".*\(~\|#.*\|\.swp\|/tags\|/.bash_history\|/out\)" | LC_ALL=C sort'
  29. fi
  30. ################################################################################
  31. unset CDPATH
  32. cd $root || exit 1
  33. if [ -z "${COMPILER_ID}" ]; then
  34. COMPILER_ID=$(sh -c "$compiler")
  35. fi
  36. ################################################################################
  37. # Compute a hash that can be used as a unique repo schema identifier. The
  38. # identifier incorporates the current git revision and local modifications to
  39. # managed files, but it intentionally ignores unmanaged files (even though they
  40. # could conceivably contain source code that meaningfully changes the repo
  41. # schema), because for some work flows the added instability of schema IDs is a
  42. # cure worse than the disease.
  43. if [ -z "${HHVM_REPO_SCHEMA}" ] ; then
  44. HHVM_REPO_SCHEMA=$(sh -c "$find_files" | \
  45. grep -v '^hphp/\(benchmarks\|bin\|hack\|hphp\|neo\|public_tld\|test\|tools\|util\|vixl\|zend\)' | \
  46. tr '\n' '\0' | xargs -0 cat | sha1sum | cut -b-40)
  47. fi
  48. ################################################################################
  49. if [ -z "${INSTALL_DIR}" ]; then
  50. INSTALL_DIR=${DIR}
  51. fi
  52. COMPILER_FILE="${INSTALL_DIR}/generated-compiler-id.txt"
  53. REPO_SCHEMA_FILE="${INSTALL_DIR}/generated-repo-schema-id.txt"
  54. INPUT=$1
  55. OUTPUT="${INSTALL_DIR}/hhvm"
  56. echo -n "${COMPILER_ID}" > "${COMPILER_FILE}"
  57. echo -n "${HHVM_REPO_SCHEMA}" > "${REPO_SCHEMA_FILE}"