Skip to content

Commit 67b2425

Browse files
authored
add a CocoaPods podspec generator (#54)
Motivation: Users ask for a CocoaPod. Unfortunately, the CocodPod `SwiftLog` is already taken, so I went for `SwiftLogAPI`. Modification: Add a podspec generator. Result: Happier users.
1 parent dbb9d24 commit 67b2425

File tree

3 files changed

+120
-6
lines changed

3 files changed

+120
-6
lines changed

NOTICE.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ This product contains a derivation of the Tony Stone's 'process_test_files.rb'.
3535

3636
---
3737

38-
This product contains a derivation of SwiftNIO locks.
38+
This product contains a derivation of the lock implementation and various
39+
scripts from SwiftNIO.
3940

4041
* LICENSE (Apache License 2.0):
4142
* https://www.apache.org/licenses/LICENSE-2.0

scripts/build_podspec.sh

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the Swift Logging API open source project
5+
##
6+
## Copyright (c) 2019 Apple Inc. and the Swift Logging API 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 Swift Logging API project authors
11+
##
12+
## SPDX-License-Identifier: Apache-2.0
13+
##
14+
##===----------------------------------------------------------------------===##
15+
16+
##===----------------------------------------------------------------------===##
17+
##
18+
## This source file is part of the SwiftNIO open source project
19+
##
20+
## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
21+
## Licensed under Apache License v2.0
22+
##
23+
## See LICENSE.txt for license information
24+
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
25+
##
26+
## SPDX-License-Identifier: Apache-2.0
27+
##
28+
##===----------------------------------------------------------------------===##
29+
30+
set -eu
31+
32+
function usage() {
33+
echo "$0 [-u] version"
34+
echo
35+
echo "OPTIONS:"
36+
echo " -u: Additionally upload the podspec"
37+
}
38+
39+
upload=false
40+
while getopts ":u" opt; do
41+
case $opt in
42+
u)
43+
upload=true
44+
;;
45+
\?)
46+
usage
47+
exit 1
48+
;;
49+
esac
50+
done
51+
shift "$((OPTIND-1))"
52+
53+
if [[ $# -eq 0 ]]; then
54+
echo "Must provide target version"
55+
exit 1
56+
fi
57+
58+
version=$1
59+
podspec_name="Logging"
60+
61+
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
62+
tmpdir=$(mktemp -d /tmp/.build_podspecsXXXXXX)
63+
echo "Building podspec in $tmpdir"
64+
65+
cat > "${tmpdir}/${podspec_name}.podspec" <<- EOF
66+
Pod::Spec.new do |s|
67+
s.name = '$podspec_name'
68+
s.version = '$version'
69+
s.license = { :type => 'Apache 2.0', :file => 'LICENSE.txt' }
70+
s.summary = 'A Logging API for Swift.'
71+
s.homepage = 'https://github.com/apple/swift-log'
72+
s.author = 'Apple Inc.'
73+
s.source = { :git => 'https://github.com/apple/swift-log.git', :tag => s.version.to_s }
74+
s.documentation_url = 'https://apple.github.io/swift-log'
75+
s.module_name = 'Logging'
76+
77+
s.swift_version = '5.0'
78+
s.cocoapods_version = '>=1.6.0'
79+
s.ios.deployment_target = '8.0'
80+
s.osx.deployment_target = '10.9'
81+
s.tvos.deployment_target = '9.0'
82+
s.watchos.deployment_target = '2.0'
83+
84+
s.source_files = 'Sources/Logging/**/*.swift'
85+
end
86+
EOF
87+
88+
if $upload; then
89+
echo "Uploading ${tmpdir}/${podspec_name}.podspec"
90+
pod trunk push "${tmpdir}/${podspec_name}.podspec"
91+
else
92+
echo "Linting ${tmpdir}/${podspec_name}.podspec"
93+
pod spec lint "${tmpdir}/${podspec_name}.podspec"
94+
fi

scripts/sanity.sh

+24-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,28 @@
1313
##
1414
##===----------------------------------------------------------------------===##
1515

16+
##===----------------------------------------------------------------------===##
17+
##
18+
## This source file is part of the SwiftNIO open source project
19+
##
20+
## Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors
21+
## Licensed under Apache License v2.0
22+
##
23+
## See LICENSE.txt for license information
24+
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
25+
##
26+
## SPDX-License-Identifier: Apache-2.0
27+
##
28+
##===----------------------------------------------------------------------===##
29+
1630
set -eu
1731
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1832

33+
function replace_acceptable_years() {
34+
# this needs to replace all acceptable forms with 'YEARS'
35+
sed -e 's/2018-2019/YEARS/' -e 's/2019/YEARS/'
36+
}
37+
1938
printf "=> Checking linux tests... "
2039
FIRST_OUT="$(git status --porcelain)"
2140
ruby "$here/../scripts/generate_linux_tests.rb" > /dev/null
@@ -45,7 +64,7 @@ for language in swift-or-c bash dtrace; do
4564
//
4665
// This source file is part of the Swift Logging API open source project
4766
//
48-
// Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
67+
// Copyright (c) YEARS Apple Inc. and the Swift Logging API project authors
4968
// Licensed under Apache License v2.0
5069
//
5170
// See LICENSE.txt for license information
@@ -64,7 +83,7 @@ EOF
6483
##
6584
## This source file is part of the Swift Logging API open source project
6685
##
67-
## Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
86+
## Copyright (c) YEARS Apple Inc. and the Swift Logging API project authors
6887
## Licensed under Apache License v2.0
6988
##
7089
## See LICENSE.txt for license information
@@ -83,7 +102,7 @@ EOF
83102
*
84103
* This source file is part of the Swift Logging API open source project
85104
*
86-
* Copyright (c) 2018-2019 Apple Inc. and the Swift Logging API project authors
105+
* Copyright (c) YEARS Apple Inc. and the Swift Logging API project authors
87106
* Licensed under Apache License v2.0
88107
*
89108
* See LICENSE.txt for license information
@@ -108,9 +127,9 @@ EOF
108127
\( \! -path './.build/*' -a \
109128
\( "${matching_files[@]}" \) -a \
110129
\( \! \( "${exceptions[@]}" \) \) \) | while read line; do
111-
if [[ "$(cat "$line" | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then
130+
if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then
112131
printf "\033[0;31mmissing headers in file '$line'!\033[0m\n"
113-
diff -u <(cat "$line" | head -n $expected_lines) "$tmp"
132+
diff -u <(cat "$line" | replace_acceptable_years | head -n $expected_lines) "$tmp"
114133
exit 1
115134
fi
116135
done

0 commit comments

Comments
 (0)