|
| 1 | +#!/bin/bash |
| 2 | +##===----------------------------------------------------------------------===## |
| 3 | +## |
| 4 | +## This source file is part of the SwiftNIO open source project |
| 5 | +## |
| 6 | +## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors |
| 7 | +## Licensed under Apache License v2.0 |
| 8 | +## |
| 9 | +## See LICENSE.txt for license information |
| 10 | +## See CONTRIBUTORS.txt for the list of SwiftNIO project authors |
| 11 | +## |
| 12 | +## SPDX-License-Identifier: Apache-2.0 |
| 13 | +## |
| 14 | +##===----------------------------------------------------------------------===## |
| 15 | + |
| 16 | +set -eu |
| 17 | + |
| 18 | +function usage() { |
| 19 | + echo "$0 [-u] VERSION" |
| 20 | + echo |
| 21 | + echo "OPTIONS:" |
| 22 | + echo " -u: Additionally, upload the podspecs as they are generated" |
| 23 | +} |
| 24 | + |
| 25 | +OPTIND=1 |
| 26 | +upload=false |
| 27 | +while getopts ":u" opt; do |
| 28 | + case $opt in |
| 29 | + u) |
| 30 | + upload=true |
| 31 | + ;; |
| 32 | + \?) |
| 33 | + usage |
| 34 | + exit 1 |
| 35 | + ;; |
| 36 | + esac |
| 37 | +done |
| 38 | +shift "$((OPTIND-1))" |
| 39 | + |
| 40 | +if [[ $# -eq 0 ]]; then |
| 41 | + echo "Must provide target version" |
| 42 | + exit 1 |
| 43 | +fi |
| 44 | + |
| 45 | +version=$1 |
| 46 | +newline=$'\n' |
| 47 | + |
| 48 | +here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 49 | +tmpfile=$(mktemp -d /tmp/.build_podspecsXXXXXX) |
| 50 | +echo "Building podspecs in $tmpfile" |
| 51 | + |
| 52 | +# We have a name transformation here. We want the pod names to be |
| 53 | +# SwiftX or CX, but our target names aren't. We add SwiftX to the front |
| 54 | +# of all NIO targets, and then remove it in the source files declaration |
| 55 | +# if needed. |
| 56 | +targets=( $("${here}/list_topsorted_dependencies.sh" -l -r | grep -v "NIOPriorityQueue" | sed 's/^NIO/SwiftNIO/') ) |
| 57 | + |
| 58 | +for target in "${targets[@]}"; do |
| 59 | + echo "Building podspec for $target" |
| 60 | + |
| 61 | + dependencies=() |
| 62 | + |
| 63 | + while read -r raw_dependency; do |
| 64 | + dependencies+=( "${newline} s.dependency '$raw_dependency', s.version.to_s" ) |
| 65 | + done < <("${here}/list_topsorted_dependencies.sh" -d "${target#Swift}" | grep -v "NIOPriorityQueue" | sed 's/^NIO/SwiftNIO/') |
| 66 | + |
| 67 | + libraries="" |
| 68 | + |
| 69 | + if [[ "$target" == "CNIOZlib" ]]; then |
| 70 | + libraries="s.libraries = 'z'" |
| 71 | + fi |
| 72 | + |
| 73 | + cat > "${tmpfile}/${target}.podspec" <<- EOF |
| 74 | +Pod::Spec.new do |s| |
| 75 | + s.name = '$target' |
| 76 | + s.version = '$version' |
| 77 | + s.license = { :type => 'Apache 2.0', :file => 'LICENSE.txt' } |
| 78 | + s.summary = 'Event-driven network application framework for high performance protocol servers & clients, non-blocking.' |
| 79 | + s.homepage = 'https://github.com/apple/swift-nio' |
| 80 | + s.author = 'Apple Inc.' |
| 81 | + s.source = { :git => 'https://github.com/apple/swift-nio.git', :tag => s.version.to_s } |
| 82 | + s.documentation_url = 'https://apple.github.io/swift-nio/docs/current/NIO/index.html' |
| 83 | + s.module_name = '${target#Swift}' |
| 84 | +
|
| 85 | + s.swift_version = '4.1' |
| 86 | + s.cocoapods_version = '>=1.1.0' |
| 87 | + s.ios.deployment_target = '10.0' |
| 88 | + s.osx.deployment_target = '10.10' |
| 89 | + s.tvos.deployment_target = '10.0' |
| 90 | +
|
| 91 | + s.source_files = 'Sources/${target#Swift}/**/*.{swift,c,h}' |
| 92 | + ${dependencies[*]-} |
| 93 | + $libraries |
| 94 | +end |
| 95 | +EOF |
| 96 | + |
| 97 | + if $upload; then |
| 98 | + echo "Uploading ${tmpfile}/${target}.podspec" |
| 99 | + pod trunk push "${tmpfile}/${target}.podspec" |
| 100 | + fi |
| 101 | + |
| 102 | +done |
0 commit comments