pal_loader 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env bash
  2. while :
  3. do
  4. case "$1" in
  5. "SGX")
  6. SGX=1
  7. ;;
  8. "GDB")
  9. GDB=1
  10. ;;
  11. *)
  12. break
  13. ;;
  14. esac
  15. shift
  16. done
  17. if [ -n "$SGX" ] && [ "$SGX" != "0" ]; then
  18. export SGX=1
  19. # Sometimes, we end up with a stray SGX_RUN in the environment,
  20. # which makes the Makefile.Host unhappy
  21. unset SGX_RUN
  22. # The interaction of SGX and SGX_RUN is getting pretty unwieldly.
  23. # We should kill off SGX_RUN. Here, we can get in trouble
  24. # if the make invocation below gets SGX_RUN via an MAKEFLAGS
  25. # from a wrapper makefile (e.g., the regression tests)
  26. unset MAKEFLAGS
  27. fi
  28. RUNTIME_DIR=$(/usr/bin/dirname $(readlink -f ${BASH_SOURCE[0]}))
  29. PAL_HOST=$(/usr/bin/make --no-print-directory --quiet -f $RUNTIME_DIR/../Pal/src/Makefile.Host print_host 2>&1)
  30. MANIFEST=
  31. PREFIX=
  32. PAL_CMD=$RUNTIME_DIR/pal-$PAL_HOST
  33. if [ "$GDB" == "1" ]; then
  34. GDB=$RUNTIME_DIR/pal_gdb-$PAL_HOST
  35. if [ ! -f $GDB ]; then
  36. GDB="/usr/bin/gdb"
  37. fi
  38. fi
  39. if [ "$GDB" != "" ] && [ "$GDB" != "0" ]; then
  40. if [ -n "$INSIDE_EMACS" ]; then
  41. GDB="$GDB -i=mi"
  42. fi
  43. PREFIX="$GDB --args"
  44. fi
  45. if [ "$PERF" == "1" ]; then
  46. PREFIX="perf stat"
  47. fi
  48. if [ "$MEMUSG" == "1" ]; then
  49. PREFIX="$RUNTIME_DIR/../Scripts/memusg"
  50. fi
  51. while [ "$1" != "" ];
  52. do
  53. if [ "$MANIFEST" == "" ]; then
  54. MANIFEST=$1
  55. shift
  56. continue
  57. fi
  58. break
  59. done
  60. if [ ! -f "$PAL_CMD" ]; then
  61. echo "$PAL_CMD is not built, or security mode is not supported"
  62. exit 1
  63. fi
  64. exec $PREFIX $PAL_CMD $MANIFEST "$@"