build_zip.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # Copyright 2020 Google LLC
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS,
  9. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. # See the License for the specific language governing permissions and
  11. # limitations under the License.
  12. set -x
  13. REPO=`pwd`
  14. if [[ $# -ne 4 ]]; then
  15. cat 2>&2 <<EOF
  16. USAGE: $1 [output_directory]
  17. USAGE: $2 [custom-spec-repos]
  18. USAGE: $3 [`build-release` or `build-head`]
  19. USAGE: $4 [`static` or `dynamic`]
  20. EOF
  21. exit 1
  22. fi
  23. # The release build won't generage Carthage distro if the curreent
  24. # PackageManifest version has already been released.
  25. carthage_version_check="--enable-carthage-version-check"
  26. # The first and only argument to this script should be the name of the
  27. # output directory.
  28. OUTPUT_DIR="$REPO/$1"
  29. CUSTOM_SPEC_REPOS="$2"
  30. BUILD_MODE="$3"
  31. LINKING_TYPE="$4"
  32. if [[ "$BUILD_MODE" == "build-head" ]]; then
  33. echo "Building zip from head."
  34. build_head_option="--local-podspec-path"
  35. build_head_value="$REPO"
  36. carthage_version_check="--disable-carthage-version-check"
  37. elif [[ "$BUILD_MODE" == "build-release" ]]; then
  38. echo "Building zip from release tag."
  39. else
  40. echo "Defaulting to `build_release`."
  41. fi
  42. if [[ "$LINKING_TYPE" == "dynamic" ]]; then
  43. linking_mode="--dynamic"
  44. elif [[ "$LINKING_TYPE" == "static" ]]; then
  45. linking_mode="--no-dynamic"
  46. else
  47. echo "Defaulting to `static`."
  48. linking_mode="--no-dynamic"
  49. fi
  50. source_repo=()
  51. IFS=','
  52. read -a specrepo <<< "${CUSTOM_SPEC_REPOS}"
  53. cd ReleaseTooling
  54. swift run zip-builder --keep-build-artifacts --update-pod-repo \
  55. ${linking_mode} ${build_head_option} ${build_head_value} \
  56. --output-dir "${OUTPUT_DIR}" \
  57. "${carthage_version_check}" \
  58. --custom-spec-repos "${specrepo[@]}"