選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

241 行
4.4 KiB

  1. #!/bin/sh
  2. tmpdir="$TMPDIR"
  3. if [ -z "${tmpdir}" ]; then tmpdir="$TEMP"; fi
  4. if [ -z "${tmpdir}" ]; then tmpdir="$TEMPDIR"; fi
  5. if [ -z "${tmpdir}" ]; then tmpdir="$TMP"; fi
  6. if [ -z "${tmpdir}" ]; then tmpdir="/tmp"; fi
  7. conffile="`mktemp -q "${tmpdir}/lol-bitten-XXXXXXXX" 2>/dev/null`"
  8. if [ "${conffile}" = "" ]; then
  9. conffile="`mktemp 2>/dev/null`"
  10. fi
  11. scriptfile=""
  12. builddir="${tmpdir}/lol-bitten-`whoami`"
  13. url="http://lolengine.net/builds"
  14. #
  15. # Utility functions
  16. #
  17. append() {
  18. echo "$*" >> "${conffile}"
  19. }
  20. cleanup() {
  21. rm -f "${conffile}" "${scriptfile}"
  22. rm -rf "${builddir}"
  23. }
  24. bailout() {
  25. cleanup
  26. # Exit gracefully
  27. exit 0
  28. }
  29. trap bailout EXIT HUP INT QUIT ABRT KILL ALRM TERM
  30. #
  31. # Fork if necessary
  32. #
  33. if [ "$1" = "--forked" ]; then
  34. shift
  35. scriptfile="$1"
  36. shift
  37. else
  38. cp "$0" "${conffile}"
  39. chmod +x "${conffile}"
  40. exec "${conffile}" --forked "${conffile}" "$@"
  41. exit 0
  42. fi
  43. #
  44. # Check for command line
  45. #
  46. if [ "$#" != 2 ]; then
  47. echo "Usage: run-bitten.sh <username> <password>"
  48. exit 1
  49. fi
  50. #
  51. # Clean up working directory
  52. #
  53. cleanup
  54. if [ -e "${builddir}" ]; then
  55. echo "Error: cannot get rid of ${builddir}"
  56. exit 1
  57. fi
  58. #
  59. # Operating system information
  60. #
  61. append "[os]"
  62. append "name = `uname -srmo 2>/dev/null || uname -srm`"
  63. append "version = 0"
  64. family="`uname -s | tr A-Z a-z`"
  65. case "$family" in
  66. mingw*) family="windows" ;;
  67. darwin*) family="osx" ;;
  68. esac
  69. append "family = $family"
  70. # This random token prevents HTTP conflicts when several instances
  71. # are run from the same machine.
  72. append "token = $$$RANDOM"
  73. append ""
  74. #
  75. # Hardware information
  76. #
  77. append "[machine]"
  78. name="`uname -n | tr A-Z a-z | sed 's/[.].*//'`"
  79. case "$name" in
  80. d*e*s*o*v*) name="putois" ;;
  81. esac
  82. append "name = $name"
  83. processor="`uname -m`"
  84. case "$processor" in
  85. x86_64) processor="amd64"
  86. if test "`getconf LONG_BIT 2>/dev/null`" = 32; then
  87. processor="i386"
  88. fi ;;
  89. i*86) processor="i386" ;;
  90. esac
  91. # Windows defines a lot of crazy shit, try to make sense of it
  92. case "$PROCESSOR_ARCHITECTURE" in
  93. amd64|AMD64) processor="amd64" ;;
  94. x86|X86) processor="i386" ;;
  95. esac
  96. case "$PROCESSOR_ARCHITEW6432" in
  97. amd64|AMD64) processor="amd64" ;;
  98. x86|X86) processor="i386" ;;
  99. esac
  100. append "processor = $processor"
  101. append ""
  102. #
  103. # Authentication information
  104. #
  105. append "[authentication]"
  106. append "username = $1"
  107. append "password = $2"
  108. append ""
  109. #
  110. # Visual Studio configuration
  111. #
  112. # FIXME: we also need to check for the Visual Studio SDK
  113. append "[msvc]"
  114. if [ -n "$VS100COMNTOOLS" ]; then
  115. append "version = 10"
  116. elif [ -n "$VS110COMNTOOLS" ]; then
  117. append "version = 11"
  118. elif [ -n "$VS90COMNTOOLS" ]; then
  119. append "version = 9"
  120. fi
  121. append ""
  122. #
  123. # iOS development kit
  124. #
  125. append "[ios]"
  126. if [ -d "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk" ]; then
  127. append "version = 6.1"
  128. fi
  129. append ""
  130. #
  131. # mingw32 / mingw-w64
  132. #
  133. append "[mingw64]"
  134. if x86_64-w64-mingw32-g++ --version >/dev/null 2>&1; then
  135. append "version = $(x86_64-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
  136. fi
  137. append ""
  138. append "[mingw32]"
  139. if i686-w64-mingw32-g++ --version >/dev/null 2>&1; then
  140. append "version = $(i686-w64-mingw32-g++ --version | sed -ne 's/.*g++ *([^)]*) *//p')"
  141. fi
  142. append ""
  143. #
  144. # Emscripten
  145. #
  146. append "[emscripten]"
  147. if em++ --version >/dev/null 2>&1; then
  148. append "version = $(em++ --version | sed -ne 's/.*emcc.* \([0-9.]\{1,\}\).*/\1/p')"
  149. fi
  150. append ""
  151. #
  152. # Android NDK
  153. #
  154. append "[ndk]"
  155. if [ "$family" != "windows" ]; then
  156. if [ -f "$ANDROID_NDK_ROOT/RELEASE.TXT" ]; then
  157. append "version = $(cat "$ANDROID_NDK_ROOT/RELEASE.TXT")"
  158. fi
  159. fi
  160. append ""
  161. #
  162. # Raspberry Pi cross-compiler
  163. #
  164. append "[raspi]"
  165. if [ "$family" != "windows" ]; then
  166. if [ -d "$RASPI_SDK_ROOT/tools" ]; then
  167. append "version = 0"
  168. fi
  169. fi
  170. append ""
  171. #
  172. # Show what we just did here
  173. #
  174. cat "${conffile}"
  175. #
  176. # Fix system
  177. #
  178. if [ "$family" = "osx" ]; then
  179. # The version of Subversion shipped by Apple is antique; try to
  180. # use the one in /usr/local/bin instead.
  181. PATH="/usr/local/bin:$PATH"
  182. export PATH
  183. # HACK: the version of llvm-g++ shipped by Apple has an insane
  184. # memory leak; use clang++ instead.
  185. CC="clang"
  186. export CC
  187. CXX="clang++"
  188. export CXX
  189. fi
  190. #
  191. # Launch everything
  192. #
  193. while : ; do
  194. bitten-slave "$url" \
  195. -f "${conffile}" \
  196. --name "$name" \
  197. --work-dir="${builddir}"
  198. rm -rf "${builddir}"
  199. sleep 10
  200. done
  201. exit 0