/core/externals/update-engine/externals/google-toolbox-for-mac/BuildScripts/BuildAllSDKs.sh

http://macfuse.googlecode.com/ · Shell · 110 lines · 70 code · 8 blank · 32 comment · 15 complexity · 0e8719ce357a8b494aa033381d2e772a MD5 · raw file

  1. #!/bin/sh
  2. # BuildAllSDKs.sh
  3. #
  4. # This script builds the Tiger, Leopard, and SnowLeopard versions of the
  5. # requested target in the current basic config (debug, release, debug-gcov).
  6. #
  7. # Copyright 2006-2011 Google Inc.
  8. #
  9. # Licensed under the Apache License, Version 2.0 (the "License"); you may not
  10. # use this file except in compliance with the License. You may obtain a copy
  11. # of the License at
  12. #
  13. # http://www.apache.org/licenses/LICENSE-2.0
  14. #
  15. # Unless required by applicable law or agreed to in writing, software
  16. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  17. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  18. # License for the specific language governing permissions and limitations under
  19. # the License.
  20. # This scrit runs as the build script, it actually exits having really done no
  21. # build. Instead it creates and launches and AppleScript that then drives
  22. # Xcode to do the real builds cycling through configurations/projects to get
  23. # everything done.
  24. GTM_PROJECT_TARGET="$1"
  25. STARTING_TARGET="${TARGET_NAME}"
  26. SCRIPT_APP="${TMPDIR}DoBuild.app"
  27. REQUESTED_BUILD_STYLE=$(echo "${BUILD_STYLE}" | sed -E "s/(.*OrLater)-(.*)/\2/")
  28. # See if we were told to clean instead of build.
  29. PROJECT_ACTION="build"
  30. if [ "${ACTION}" == "clean" ]; then
  31. PROJECT_ACTION="clean"
  32. fi
  33. # get available SDKs and PLATFORMS
  34. AVAILABLE_MACOS_SDKS=`eval ls ${DEVELOPER_SDK_DIR}`
  35. AVAILABLE_PLATFORMS=`eval ls ${DEVELOPER_DIR}/Platforms`
  36. GTM_OPEN_EXTRAS=""
  37. GTM_BUILD_EXTRAS=""
  38. # build up our GTM parts
  39. if [ "${GTM_PROJECT_TARGET}" != "" ]; then
  40. GTM_OPEN_EXTRAS="
  41. if \"${AVAILABLE_PLATFORMS}\" contains \"MacOSX.platform\" then
  42. open posix file \"${SRCROOT}/GTM.xcodeproj\"
  43. end if"
  44. GTM_BUILD_EXTRAS="
  45. if \"${AVAILABLE_PLATFORMS}\" contains \"MacOSX.platform\" then
  46. tell project \"GTM\"
  47. -- wait for stub build to finish before kicking off the real builds.
  48. set x to 0
  49. repeat while currently building
  50. delay 0.5
  51. set x to x + 1
  52. if x > 6 then
  53. display alert \"GTM is still building, can't start.\"
  54. return
  55. end if
  56. end repeat
  57. -- do the GTM builds
  58. with timeout of 9999 seconds
  59. if \"{$AVAILABLE_MACOS_SDKS}\" contains \"MacOSX10.4u.sdk\" then
  60. set active target to target \"${GTM_PROJECT_TARGET}\"
  61. set buildResult to ${PROJECT_ACTION} using build configuration \"TigerOrLater-${REQUESTED_BUILD_STYLE}\"
  62. set active target to target \"${STARTING_TARGET}\"
  63. if buildResult is not equal to \"Build succeeded\" then
  64. return
  65. end if
  66. end if
  67. if \"{$AVAILABLE_MACOS_SDKS}\" contains \"MacOSX10.5.sdk\" then
  68. set active target to target \"${GTM_PROJECT_TARGET}\"
  69. set buildResult to ${PROJECT_ACTION} using build configuration \"LeopardOrLater-${REQUESTED_BUILD_STYLE}\"
  70. set active target to target \"${STARTING_TARGET}\"
  71. if buildResult is not equal to \"Build succeeded\" then
  72. return
  73. end if
  74. end if
  75. if \"{$AVAILABLE_MACOS_SDKS}\" contains \"MacOSX10.6.sdk\" then
  76. set active target to target \"${GTM_PROJECT_TARGET}\"
  77. set buildResult to ${PROJECT_ACTION} using build configuration \"SnowLeopardOrLater-${REQUESTED_BUILD_STYLE}\"
  78. set active target to target \"${STARTING_TARGET}\"
  79. if buildResult is not equal to \"Build succeeded\" then
  80. return
  81. end if
  82. end if
  83. end timeout
  84. end tell
  85. end if"
  86. fi
  87. # build up our GTM AppleScript
  88. OUR_BUILD_SCRIPT="on run
  89. tell application \"Xcode\"
  90. activate
  91. ${GTM_OPEN_EXTRAS}
  92. ${GTM_BUILD_EXTRAS}
  93. end tell
  94. end run"
  95. # Xcode won't actually let us spawn this and run it w/ osascript because it
  96. # watches and waits for everything we have spawned to exit before the build is
  97. # considered done, so instead we compile this to a script app, and then use
  98. # open to invoke it, there by escaping our little sandbox.
  99. # xcode defeats this: ( echo "${OUR_BUILD_SCRIPT}" | osascript - & )
  100. rm -rf "${SCRIPT_APP}"
  101. echo "${OUR_BUILD_SCRIPT}" | osacompile -o "${SCRIPT_APP}" -x
  102. open "${SCRIPT_APP}"