Remove build_podspec.sh (#2094)
Motivation: We no longer support Cocoapods. Modifications: - Remove build_podspec.sh and associated scripts Result: Less unused code.
This commit is contained in:
parent
5868651f58
commit
1a4028a96b
|
@ -1,123 +0,0 @@
|
|||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftNIO open source project
|
||||
##
|
||||
## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -eu
|
||||
|
||||
function usage() {
|
||||
echo "$0 [-u] [-f skipUpToTarget] version"
|
||||
echo
|
||||
echo "OPTIONS:"
|
||||
echo " -u: Additionally, upload the podspecs as they are generated"
|
||||
echo " -f: Skip over all targets before the specified target"
|
||||
}
|
||||
|
||||
OPTIND=1
|
||||
upload=false
|
||||
skip_until=""
|
||||
|
||||
while getopts ":uf:" opt; do
|
||||
case $opt in
|
||||
u)
|
||||
upload=true
|
||||
;;
|
||||
f)
|
||||
skip_until="$OPTARG"
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift "$((OPTIND-1))"
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=$1
|
||||
newline=$'\n'
|
||||
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
tmpfile=$(mktemp -d /tmp/.build_podspecsXXXXXX)
|
||||
echo "Building podspecs in $tmpfile"
|
||||
|
||||
# We have a name transformation here. We want the pod names to be
|
||||
# SwiftX or CX, but our target names aren't. We add SwiftX to the front
|
||||
# of all NIO targets, and then remove it in the source files declaration
|
||||
# if needed.
|
||||
targets=( $("${here}/list_topsorted_dependencies.sh" -l -r | grep -v "NIOPriorityQueue" | sed 's/^NIO/SwiftNIO/') )
|
||||
|
||||
for target in "${targets[@]}"; do
|
||||
if [[ -n "$skip_until" && "$target" != "$skip_until" ]]; then
|
||||
echo "Skipping $target"
|
||||
continue
|
||||
elif [[ "$skip_until" == "$target" ]]; then
|
||||
skip_until=""
|
||||
fi
|
||||
|
||||
echo "Building podspec for $target"
|
||||
|
||||
dependencies=()
|
||||
|
||||
while read -r raw_dependency; do
|
||||
dependencies+=( "${newline} s.dependency '$raw_dependency', s.version.to_s" )
|
||||
done < <("${here}/list_transitive_dependencies.py" "${target#Swift}" | grep -v "NIOPriorityQueue" | sed 's/^NIO/SwiftNIO/')
|
||||
|
||||
libraries=""
|
||||
|
||||
if [[ "$target" == "CNIOZlib" ]]; then
|
||||
libraries="s.libraries = 'z'"
|
||||
fi
|
||||
|
||||
compiler_flags=""
|
||||
if [[ "$target" == "CNIODarwin" ]]; then
|
||||
compiler_flags="s.compiler_flags = '-D__APPLE_USE_RFC_3542=1'"
|
||||
fi
|
||||
|
||||
cat > "${tmpfile}/${target}.podspec" <<- EOF
|
||||
Pod::Spec.new do |s|
|
||||
s.name = '$target'
|
||||
s.version = '$version'
|
||||
s.license = { :type => 'Apache 2.0', :file => 'LICENSE.txt' }
|
||||
s.summary = 'Event-driven network application framework for high performance protocol servers & clients, non-blocking.'
|
||||
s.homepage = 'https://github.com/apple/swift-nio'
|
||||
s.author = 'Apple Inc.'
|
||||
s.source = { :git => 'https://github.com/apple/swift-nio.git', :tag => s.version.to_s }
|
||||
s.documentation_url = 'https://apple.github.io/swift-nio/docs/current/NIO/index.html'
|
||||
s.module_name = '${target#Swift}'
|
||||
|
||||
s.swift_version = '5.4'
|
||||
s.cocoapods_version = '>=1.6.0'
|
||||
s.ios.deployment_target = '10.0'
|
||||
s.osx.deployment_target = '10.10'
|
||||
s.tvos.deployment_target = '10.0'
|
||||
s.watchos.deployment_target = '6.0'
|
||||
|
||||
s.source_files = 'Sources/${target#Swift}/**/*.{swift,c,h}'
|
||||
${dependencies[*]-}
|
||||
$libraries
|
||||
$compiler_flags
|
||||
end
|
||||
EOF
|
||||
|
||||
if $upload; then
|
||||
pod repo update # last chance of getting the latest versions of previous pushed pods
|
||||
echo "Uploading ${tmpfile}/${target}.podspec"
|
||||
pod trunk push "${tmpfile}/${target}.podspec" --synchronous
|
||||
fi
|
||||
|
||||
done
|
|
@ -1,92 +0,0 @@
|
|||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftNIO open source project
|
||||
##
|
||||
## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
function usage() {
|
||||
echo "$0 -l"
|
||||
echo
|
||||
echo "OPTIONS:"
|
||||
echo " -l: Only dependencies of library targets"
|
||||
echo " -r: Reverse the output"
|
||||
echo " -d <PACKAGE>: Prints the dependencies of the given module"
|
||||
}
|
||||
|
||||
function tac_compat() {
|
||||
sed '1!G;h;$!d'
|
||||
}
|
||||
|
||||
tmpfile=$(mktemp /tmp/.list_topsorted_dependencies_XXXXXX)
|
||||
|
||||
only_libs=false
|
||||
do_reversed=false
|
||||
module_dependency=""
|
||||
while getopts "lrd:" opt; do
|
||||
case $opt in
|
||||
l)
|
||||
only_libs=true
|
||||
;;
|
||||
r)
|
||||
do_reversed=true
|
||||
;;
|
||||
d)
|
||||
module_dependency="$OPTARG"
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
transform=cat
|
||||
if $do_reversed; then
|
||||
transform=tac_compat
|
||||
fi
|
||||
|
||||
if [[ ! -z "$module_dependency" ]]; then
|
||||
swift package dump-package | jq -r ".targets |
|
||||
map(select(.name == \"$module_dependency\" and .type == \"regular\") | .dependencies | map(.byName | first)) | .[] | .[]"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
(
|
||||
cd "$here/.."
|
||||
if $only_libs; then
|
||||
find Sources -name 'main.swift' | cut -d/ -f2 >> "$tmpfile"
|
||||
swift package dump-package | jq '.products |
|
||||
map(select(.type | has("library") | not)) |
|
||||
map(.name) | .[]' | tr -d '"' \
|
||||
>> "$tmpfile"
|
||||
fi
|
||||
swift package dump-package | jq '.targets |
|
||||
map (.name) as $names |
|
||||
map(.name as $name |
|
||||
select(.name == $name and .type == "regular") |
|
||||
{ "\($name)": .dependencies | map(.byName | first) | map(. as $current | $names | map(select($current == .))) | flatten } ) |
|
||||
map(to_entries[]) |
|
||||
map("\(.key) \(.value | .[])") |
|
||||
.[]' | \
|
||||
tr -d '"' | \
|
||||
tsort | "$transform" | while read -r line; do
|
||||
if ! grep -q "^$line\$" "$tmpfile"; then
|
||||
echo "$line"
|
||||
fi
|
||||
done
|
||||
)
|
||||
|
||||
rm "$tmpfile"
|
|
@ -1,119 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftNIO open source project
|
||||
##
|
||||
## Copyright (c) 2022 Apple Inc. and the SwiftNIO project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
import json
|
||||
import sys
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
def dump_package(path):
|
||||
output = subprocess.check_output(["swift", "package", "dump-package"], cwd=path)
|
||||
parsed = json.loads(output)
|
||||
return parsed
|
||||
|
||||
|
||||
def clone_package(name, url, tag, directory):
|
||||
path = directory + "/" + name
|
||||
command = ["git", "clone", "--depth", "1", "--branch", tag, url, path]
|
||||
subprocess.check_output(command, stderr=subprocess.DEVNULL)
|
||||
return path
|
||||
|
||||
|
||||
class TransitiveDependencyResolver(object):
|
||||
def __init__(self, temp_dir):
|
||||
# Temporary directory to clone dependencies to.
|
||||
self._temp_dir = temp_dir
|
||||
# Cache of package dumps keyed by name.
|
||||
self._packages = {}
|
||||
|
||||
package = dump_package(".")
|
||||
self._root_package = package["name"]
|
||||
self._packages[self._root_package] = package
|
||||
|
||||
def find_transitive_depenencies(self, module_name):
|
||||
# All transitive dependencies. This doubles as the 'visited' modules so
|
||||
# we need to remove the target module once we're done.
|
||||
dependencies = set()
|
||||
|
||||
# Start from the root package.
|
||||
self._find_transitive_dependencies(
|
||||
module_name, self._packages[self._root_package], dependencies
|
||||
)
|
||||
|
||||
dependencies.remove(module_name)
|
||||
return dependencies
|
||||
|
||||
def _find_transitive_dependencies(self, module_name, package, dependencies):
|
||||
if module_name in dependencies:
|
||||
# Already visited
|
||||
return
|
||||
|
||||
dependencies.add(module_name)
|
||||
# Visit all dependencies of this module.
|
||||
for target in package["targets"]:
|
||||
if target["name"] != module_name:
|
||||
# Not a target we care about.
|
||||
continue
|
||||
|
||||
for dependency in target["dependencies"]:
|
||||
if "byName" in dependency:
|
||||
# Target dependency from the package currently being
|
||||
# searched.
|
||||
self._find_transitive_dependencies(
|
||||
dependency["byName"][0], package, dependencies
|
||||
)
|
||||
elif "product" in dependency:
|
||||
# Dependency is from another package.
|
||||
dependency_name = dependency["product"][0]
|
||||
package_name = dependency["product"][1]
|
||||
self._ensure_package_is_cached(package, package_name)
|
||||
self._find_transitive_dependencies(
|
||||
dependency_name, self._packages[package_name], dependencies
|
||||
)
|
||||
|
||||
def _ensure_package_is_cached(self, package, package_name):
|
||||
if package_name in self._packages:
|
||||
return
|
||||
|
||||
# Find the package dependency with the right name.
|
||||
for package_dependency in package["dependencies"]:
|
||||
dependency = package_dependency["sourceControl"][0]
|
||||
|
||||
is_right_package = (
|
||||
dependency["identity"] == package_name
|
||||
or dependency.get("nameForTargetDependencyResolutionOnly")
|
||||
== package_name
|
||||
)
|
||||
|
||||
if not is_right_package:
|
||||
continue
|
||||
|
||||
url = dependency["location"]["remote"][0]
|
||||
version = dependency["requirement"]["range"][0]["lowerBound"]
|
||||
# Path to cloned package.
|
||||
path = clone_package(package_name, url, version, self._temp_dir)
|
||||
self._packages[package_name] = dump_package(path)
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print("USAGE: {} MODULE".format(sys.argv[0]))
|
||||
exit(1)
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
resolver = TransitiveDependencyResolver(temp_dir)
|
||||
for dependency in resolver.find_transitive_depenencies(sys.argv[1]):
|
||||
print(dependency)
|
Loading…
Reference in New Issue