mirror of
https://github.com/apple/swift-crypto
synced 2026-11-29 05:14:21 +00:00
[CI] Adopt GitHub actions (#280)
This commit is contained in:
1 parent
21f7878f2b
commit
ae321d29be
200 files changed
+449
-908
No files matched your search
+73
-76
@@ -7,15 +7,14 @@
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
import contextlib
|
||||
import subprocess
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
# OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for
|
||||
@@ -49,85 +48,85 @@ NON_PERL_FILES = {
|
||||
|
||||
|
||||
def FindCMakeFiles(directory):
|
||||
"""Returns list of all CMakeLists.txt files recursively in directory."""
|
||||
cmakefiles = []
|
||||
"""Returns list of all CMakeLists.txt files recursively in directory."""
|
||||
cmakefiles = []
|
||||
|
||||
for (path, _, filenames) in os.walk(directory):
|
||||
for filename in filenames:
|
||||
if filename == 'CMakeLists.txt':
|
||||
cmakefiles.append(os.path.join(path, filename))
|
||||
for (path, _, filenames) in os.walk(directory):
|
||||
for filename in filenames:
|
||||
if filename == 'CMakeLists.txt':
|
||||
cmakefiles.append(os.path.join(path, filename))
|
||||
|
||||
return cmakefiles
|
||||
return cmakefiles
|
||||
|
||||
|
||||
def ExtractPerlAsmFromCMakeFile(cmakefile):
|
||||
"""Parses the contents of the CMakeLists.txt file passed as an argument and
|
||||
returns a list of all the perlasm() directives found in the file."""
|
||||
perlasms = []
|
||||
with open(cmakefile) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line.startswith('perlasm('):
|
||||
continue
|
||||
if not line.endswith(')'):
|
||||
raise ValueError('Bad perlasm line in %s' % cmakefile)
|
||||
# Remove "perlasm(" from start and ")" from end
|
||||
params = line[8:-1].split()
|
||||
if len(params) < 4:
|
||||
raise ValueError('Bad perlasm line in %s: %s' % (cmakefile, line))
|
||||
perlasms.append({
|
||||
'arch': params[1],
|
||||
'output': os.path.join(os.path.dirname(cmakefile), params[2]),
|
||||
'input': os.path.join(os.path.dirname(cmakefile), params[3]),
|
||||
'extra_args': params[4:],
|
||||
})
|
||||
"""Parses the contents of the CMakeLists.txt file passed as an argument and
|
||||
returns a list of all the perlasm() directives found in the file."""
|
||||
perlasms = []
|
||||
with open(cmakefile) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line.startswith('perlasm('):
|
||||
continue
|
||||
if not line.endswith(')'):
|
||||
raise ValueError('Bad perlasm line in %s' % cmakefile)
|
||||
# Remove "perlasm(" from start and ")" from end
|
||||
params = line[8:-1].split()
|
||||
if len(params) < 4:
|
||||
raise ValueError('Bad perlasm line in %s: %s' % (cmakefile, line))
|
||||
perlasms.append({
|
||||
'arch': params[1],
|
||||
'output': os.path.join(os.path.dirname(cmakefile), params[2]),
|
||||
'input': os.path.join(os.path.dirname(cmakefile), params[3]),
|
||||
'extra_args': params[4:],
|
||||
})
|
||||
|
||||
return perlasms
|
||||
return perlasms
|
||||
|
||||
|
||||
def ReadPerlAsmOperations():
|
||||
"""Returns a list of all perlasm() directives found in CMake config files in
|
||||
src/."""
|
||||
perlasms = []
|
||||
cmakefiles = FindCMakeFiles('boringssl')
|
||||
"""Returns a list of all perlasm() directives found in CMake config files in
|
||||
src/."""
|
||||
perlasms = []
|
||||
cmakefiles = FindCMakeFiles('boringssl')
|
||||
|
||||
for cmakefile in cmakefiles:
|
||||
perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile))
|
||||
for cmakefile in cmakefiles:
|
||||
perlasms.extend(ExtractPerlAsmFromCMakeFile(cmakefile))
|
||||
|
||||
return perlasms
|
||||
return perlasms
|
||||
|
||||
|
||||
def PerlAsm(output_filename, input_filename, perlasm_style, extra_args):
|
||||
"""Runs the a perlasm script and puts the output into output_filename."""
|
||||
base_dir = os.path.dirname(output_filename)
|
||||
if not os.path.isdir(base_dir):
|
||||
os.makedirs(base_dir)
|
||||
subprocess.check_call(
|
||||
['perl', input_filename, perlasm_style] + extra_args + [output_filename])
|
||||
"""Runs the a perlasm script and puts the output into output_filename."""
|
||||
base_dir = os.path.dirname(output_filename)
|
||||
if not os.path.isdir(base_dir):
|
||||
os.makedirs(base_dir)
|
||||
subprocess.check_call(
|
||||
['perl', input_filename, perlasm_style] + extra_args + [output_filename])
|
||||
|
||||
|
||||
def WriteAsmFiles(perlasms):
|
||||
"""Generates asm files from perlasm directives for each supported OS x
|
||||
platform combination."""
|
||||
asmfiles = {}
|
||||
"""Generates asm files from perlasm directives for each supported OS x
|
||||
platform combination."""
|
||||
asmfiles = {}
|
||||
|
||||
for perlasm in perlasms:
|
||||
for (osname, arch, perlasm_style, extra_args, asm_ext) in OS_ARCH_COMBOS:
|
||||
if arch != perlasm['arch']:
|
||||
continue
|
||||
key = (osname, arch)
|
||||
outDir = '%s-%s' % key
|
||||
for perlasm in perlasms:
|
||||
for (osname, arch, perlasm_style, extra_args, asm_ext) in OS_ARCH_COMBOS:
|
||||
if arch != perlasm['arch']:
|
||||
continue
|
||||
key = (osname, arch)
|
||||
outDir = '%s-%s' % key
|
||||
|
||||
filename = os.path.basename(perlasm['input'])
|
||||
output = perlasm['output']
|
||||
if not output.startswith('boringssl/crypto'):
|
||||
raise ValueError('output missing crypto: %s' % output)
|
||||
output = os.path.join(outDir, output[17:])
|
||||
output = '%s-%s.%s' % (output, osname, asm_ext)
|
||||
per_command_extra_args = extra_args + perlasm['extra_args']
|
||||
PerlAsm(output, perlasm['input'], perlasm_style, per_command_extra_args)
|
||||
asmfiles.setdefault(key, []).append(output)
|
||||
output = perlasm['output']
|
||||
if not output.startswith('boringssl/crypto'):
|
||||
raise ValueError('output missing crypto: %s' % output)
|
||||
output = os.path.join(outDir, output[17:])
|
||||
output = '%s-%s.%s' % (output, osname, asm_ext)
|
||||
per_command_extra_args = extra_args + perlasm['extra_args']
|
||||
PerlAsm(output, perlasm['input'], perlasm_style, per_command_extra_args)
|
||||
asmfiles.setdefault(key, []).append(output)
|
||||
|
||||
return asmfiles
|
||||
return asmfiles
|
||||
|
||||
|
||||
def preprocessor_arch_for_arch(arch):
|
||||
@@ -152,7 +151,7 @@ def preprocessor_platform_for_os(osname):
|
||||
|
||||
def asm_target(osname, arch, asm):
|
||||
components = asm.split('/')
|
||||
new_components = ["boringssl/crypto"] + components[1:-1] + [components[-1].replace('.S', '.' + osname + '.' + arch + '.S')]
|
||||
new_components = ["boringssl/crypto"] + components[1:-1] + [components[-1].replace('.S', '.' + osname + '.' + arch + '.S')] # noqa: E501
|
||||
return '/'.join(new_components)
|
||||
|
||||
|
||||
@@ -160,11 +159,11 @@ def munge_file(pp_arch, pp_platform, source_lines, sink):
|
||||
"""
|
||||
Wraps a single assembly file in appropriate defines.
|
||||
"""
|
||||
sink.write(b"#if defined(%b) && defined(%b)\n" % (pp_arch.encode(), pp_platform.encode()))
|
||||
sink.write(b"#if defined(%b) && defined(%b)\n" % (pp_arch.encode(), pp_platform.encode())) # noqa: E501
|
||||
for line in source_lines:
|
||||
sink.write(line)
|
||||
|
||||
sink.write(b"#endif // defined(%b) && defined(%b)\n" % (pp_arch.encode(), pp_platform.encode()))
|
||||
sink.write(b"#endif // defined(%b) && defined(%b)\n" % (pp_arch.encode(), pp_platform.encode())) # noqa: E501
|
||||
|
||||
|
||||
def munge_all_files(osname, arch, asms):
|
||||
@@ -175,11 +174,10 @@ def munge_all_files(osname, arch, asms):
|
||||
pp_arch = preprocessor_arch_for_arch(arch)
|
||||
pp_platform = preprocessor_platform_for_os(osname)
|
||||
target = asm_target(osname, arch, asm)
|
||||
|
||||
|
||||
with open(asm, 'rb') as source:
|
||||
with open(target, 'wb') as sink:
|
||||
munge_file(pp_arch, pp_platform, source, sink)
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
@@ -194,15 +192,14 @@ def main():
|
||||
|
||||
for ((osname, arch), asm_files) in NON_PERL_FILES.items():
|
||||
for asm_file in asm_files:
|
||||
with open(asm_file, 'rb') as f:
|
||||
lines = f.readlines()
|
||||
with open(asm_file, 'rb') as f:
|
||||
lines = f.readlines()
|
||||
pp_arch = preprocessor_arch_for_arch(arch)
|
||||
pp_platform = preprocessor_platform_for_os(osname)
|
||||
|
||||
with open(asm_file, 'wb') as sink:
|
||||
munge_file(pp_arch, pp_platform, lines, sink)
|
||||
|
||||
pp_arch = preprocessor_arch_for_arch(arch)
|
||||
pp_platform = preprocessor_platform_for_os(osname)
|
||||
|
||||
with open(asm_file, 'wb') as sink:
|
||||
munge_file(pp_arch, pp_platform, lines, sink)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2024 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
log() { printf -- "** %s\n" "$*" >&2; }
|
||||
error() { printf -- "** ERROR: %s\n" "$*" >&2; }
|
||||
fatal() { error "$@"; exit 1; }
|
||||
|
||||
log "Checking if the cmake files are up-to-date..."
|
||||
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
FIRST_OUT="$(git status --porcelain)"
|
||||
_=$("$here"/update-cmake-lists.sh 2>&1)
|
||||
SECOND_OUT="$(git status --porcelain)"
|
||||
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
|
||||
error "Changes in the cmake files detected. Please run the update-cmake-lists.sh script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log "✅ cmake files are up-to-date."
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2019-2022 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -eu
|
||||
|
||||
function usage() {
|
||||
echo >&2 "Usage: $0 REPO-GITHUB-URL NEW-VERSION OLD-VERSIONS..."
|
||||
echo >&2
|
||||
echo >&2 "This script requires a Swift 5.6+ toolchain."
|
||||
echo >&2
|
||||
echo >&2 "Examples:"
|
||||
echo >&2
|
||||
echo >&2 "Check between main and tag 2.0.5 of swift-crypto:"
|
||||
echo >&2 " $0 https://github.com/apple/swift-crypto main 2.0.5"
|
||||
echo >&2
|
||||
echo >&2 "Check between HEAD and commit 64cf63d7 using the provided toolchain:"
|
||||
echo >&2 " xcrun --toolchain org.swift.5120190702a $0 ../some-local-repo HEAD 64cf63d7"
|
||||
}
|
||||
|
||||
if [[ $# -lt 3 ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmpdir=$(mktemp -d /tmp/.check-api_XXXXXX)
|
||||
repo_url=$1
|
||||
new_tag=$2
|
||||
shift 2
|
||||
|
||||
repodir="$tmpdir/repo"
|
||||
git clone "$repo_url" "$repodir"
|
||||
git -C "$repodir" fetch -q origin '+refs/pull/*:refs/remotes/origin/pr/*'
|
||||
cd "$repodir"
|
||||
git checkout -q "$new_tag"
|
||||
|
||||
for old_tag in "$@"; do
|
||||
echo "Checking public API breakages from $old_tag to $new_tag"
|
||||
|
||||
swift package diagnose-api-breaking-changes "$old_tag"
|
||||
done
|
||||
|
||||
echo done
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2023 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -eu
|
||||
|
||||
sourcedir=$(dirname "$(readlink -f $0)")/..
|
||||
workingdir=$(mktemp -d)
|
||||
projectname=$(basename $workingdir)
|
||||
|
||||
cd $workingdir
|
||||
swift package init
|
||||
|
||||
cat << EOF > Package.swift
|
||||
// swift-tools-version: 5.9
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "interop",
|
||||
platforms: [.macOS(.v10_15)],
|
||||
products: [
|
||||
.library(
|
||||
name: "interop",
|
||||
targets: ["interop"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "$sourcedir")
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "interop",
|
||||
// Depend on all products of swift-crypto to make sure they're all
|
||||
// compatible with cxx interop.
|
||||
dependencies: [
|
||||
.product(name: "Crypto", package: "swift-crypto"),
|
||||
.product(name: "_CryptoExtras", package: "swift-crypto")
|
||||
],
|
||||
swiftSettings: [.interoperabilityMode(.Cxx)]
|
||||
)
|
||||
]
|
||||
)
|
||||
EOF
|
||||
|
||||
cat << EOF > Sources/$projectname/$(echo $projectname | tr . _).swift
|
||||
import Crypto
|
||||
import _CryptoExtras
|
||||
EOF
|
||||
|
||||
swift build
|
||||
@@ -7,7 +7,7 @@
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
@@ -15,6 +15,6 @@
|
||||
|
||||
set -eu
|
||||
find . -name '*.gyb' | \
|
||||
while read file; do \
|
||||
while read -r file; do \
|
||||
./scripts/gyb --line-directive '' -o "${file%.gyb}" "$file"; \
|
||||
done
|
||||
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2019 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -eu
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
contributors=$( cd "$here"/.. && git shortlog -es | cut -f2 | sed 's/^/- /' )
|
||||
|
||||
cat > "$here/../CONTRIBUTORS.md" <<- EOF
|
||||
For the purpose of tracking copyright, this is the list of individuals and
|
||||
organizations who have contributed source code to SwiftCrypto.
|
||||
|
||||
For employees of an organization/company where the copyright of work done
|
||||
by employees of that company is held by the company itself, only the company
|
||||
needs to be listed here.
|
||||
|
||||
## COPYRIGHT HOLDERS
|
||||
|
||||
- Apple Inc. (all contributors with '@apple.com')
|
||||
|
||||
### Contributors
|
||||
|
||||
$contributors
|
||||
|
||||
## Updating this list
|
||||
|
||||
Please do not edit this file manually. It is generated using \`./scripts/generate_contributors_list.sh\`.
|
||||
If a name is misspelled or appearing multiple times: add an entry in \`./.mailmap\` (see [docs](https://git-scm.com/docs/git-shortlog#_mapping_authors))
|
||||
EOF
|
||||
@@ -1,109 +0,0 @@
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2018-2019 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -e
|
||||
|
||||
my_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
root_path="$my_path/.."
|
||||
version=$(git describe --abbrev=0 --tags || echo "0.0.0")
|
||||
modules=(Crypto)
|
||||
|
||||
if [[ "$(uname -s)" == "Linux" ]]; then
|
||||
# build code if required
|
||||
if [[ ! -d "$root_path/.build/x86_64-unknown-linux" ]]; then
|
||||
swift build
|
||||
fi
|
||||
# setup source-kitten if required
|
||||
mkdir -p "$root_path/.build/sourcekitten"
|
||||
source_kitten_source_path="$root_path/.build/sourcekitten/source"
|
||||
if [[ ! -d "$source_kitten_source_path" ]]; then
|
||||
git clone https://github.com/jpsim/SourceKitten.git "$source_kitten_source_path"
|
||||
fi
|
||||
source_kitten_path="$source_kitten_source_path/.build/debug"
|
||||
if [[ ! -d "$source_kitten_path" ]]; then
|
||||
rm -rf "$source_kitten_source_path/.swift-version"
|
||||
cd "$source_kitten_source_path" && swift build && cd "$root_path"
|
||||
fi
|
||||
# generate
|
||||
for module in "${modules[@]}"; do
|
||||
if [[ ! -f "$root_path/.build/sourcekitten/$module.json" ]]; then
|
||||
"$source_kitten_path/sourcekitten" doc --spm --module-name $module > "$root_path/.build/sourcekitten/$module.json"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
jazzy_dir="$root_path/.build/jazzy"
|
||||
rm -rf "$jazzy_dir"
|
||||
mkdir -p "$jazzy_dir"
|
||||
|
||||
# prep index
|
||||
module_switcher="$jazzy_dir/README.md"
|
||||
cat > "$module_switcher" <<"EOF"
|
||||
# SwiftCrypto Docs
|
||||
|
||||
SwiftCrypto is a SwiftCrypto package.
|
||||
|
||||
To get started with SwiftCrypto, [`import Crypto`](../Crypto/index.html).
|
||||
EOF
|
||||
|
||||
# run jazzy
|
||||
if ! command -v jazzy > /dev/null; then
|
||||
gem install jazzy --no-ri --no-rdoc
|
||||
fi
|
||||
|
||||
jazzy_args=(--clean
|
||||
--author 'SwiftCrypto team'
|
||||
--readme "$module_switcher"
|
||||
--author_url https://github.com/apple/swift-crypto
|
||||
--github_url https://github.com/apple/swift-crypto
|
||||
--github-file-prefix https://github.com/apple/swift-crypto/tree/$version
|
||||
--theme fullwidth
|
||||
--swift-build-tool spm)
|
||||
|
||||
for module in "${modules[@]}"; do
|
||||
args=("${jazzy_args[@]}" --output "$jazzy_dir/docs/$version/$module" --docset-path "$jazzy_dir/docset/$version/$module"
|
||||
--module "$module" --module-version $version
|
||||
--root-url "https://apple.github.io/swift-crypto/docs/$version/$module/")
|
||||
if [[ "$(uname -s)" == "Linux" ]]; then
|
||||
args+=(--sourcekitten-sourcefile "$root_path/.build/sourcekitten/$module.json")
|
||||
fi
|
||||
jazzy "${args[@]}"
|
||||
done
|
||||
|
||||
# push to github pages
|
||||
if [[ $PUSH == true ]]; then
|
||||
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
|
||||
GIT_AUTHOR=$(git --no-pager show -s --format='%an <%ae>' HEAD)
|
||||
git fetch origin +gh-pages:gh-pages
|
||||
git checkout gh-pages
|
||||
rm -rf "docs/$version"
|
||||
rm -rf "docs/current"
|
||||
cp -r "$jazzy_dir/docs/$version" docs/
|
||||
cp -r "docs/$version" docs/current
|
||||
git add --all docs
|
||||
echo '<html><head><meta http-equiv="refresh" content="0; url=docs/current/Crypto/index.html" /></head></html>' > index.html
|
||||
git add index.html
|
||||
touch .nojekyll
|
||||
git add .nojekyll
|
||||
changes=$(git diff-index --name-only HEAD)
|
||||
if [[ -n "$changes" ]]; then
|
||||
echo -e "changes detected\n$changes"
|
||||
git commit --author="$GIT_AUTHOR" -m "publish $version docs"
|
||||
git push origin gh-pages
|
||||
else
|
||||
echo "no changes detected"
|
||||
fi
|
||||
git checkout -f $BRANCH_NAME
|
||||
fi
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env python2.7
|
||||
|
||||
import gyb
|
||||
gyb.main()
|
||||
+6
-7
@@ -51,7 +51,7 @@ def split_lines(s):
|
||||
If the lines are later concatenated, the result is s, possibly
|
||||
with a single appended newline.
|
||||
"""
|
||||
return [l + '\n' for l in s.split('\n')]
|
||||
return [line + '\n' for line in s.split('\n')]
|
||||
|
||||
|
||||
# text on a line up to the first '$$', '${', or '%%'
|
||||
@@ -74,8 +74,7 @@ tokenize_re = re.compile(
|
||||
^
|
||||
(?:
|
||||
(?P<gybLines>
|
||||
(?P<_indent> [\ \t]* % (?! [{%] ) [\ \t]* ) (?! [\ \t] | ''' +
|
||||
linesClose + r''' ) .*
|
||||
(?P<_indent> [\ \t]* % (?! [{%] ) [\ \t]* ) (?! [\ \t] | ''' + linesClose + r''' ) .* # noqa: E501
|
||||
( \n (?P=_indent) (?! ''' + linesClose + r''' ) .* ) *
|
||||
)
|
||||
| (?P<gybLinesClose> [\ \t]* % [ \t]* ''' + linesClose + r''' )
|
||||
@@ -612,8 +611,8 @@ class ASTNode(object):
|
||||
return ' []'
|
||||
|
||||
return '\n'.join(
|
||||
['', indent + '['] +
|
||||
[x.__str__(indent + 4 * ' ') for x in self.children] +
|
||||
['', indent + '['] + # noqa: W504
|
||||
[x.__str__(indent + 4 * ' ') for x in self.children] + # noqa: W504
|
||||
[indent + ']'])
|
||||
|
||||
|
||||
@@ -657,7 +656,7 @@ class Literal(ASTNode):
|
||||
|
||||
def __str__(self, indent=''):
|
||||
return '\n'.join(
|
||||
[indent + x for x in ['Literal:'] +
|
||||
[indent + x for x in ['Literal:'] + # noqa: W504
|
||||
strip_trailing_nl(self.text).split('\n')])
|
||||
|
||||
|
||||
@@ -748,7 +747,7 @@ class Code(ASTNode):
|
||||
s = indent + 'Code: {' + source_lines[0] + '}'
|
||||
else:
|
||||
s = indent + 'Code:\n' + indent + '{\n' + '\n'.join(
|
||||
indent + 4 * ' ' + l for l in source_lines
|
||||
indent + 4 * ' ' + line for line in source_lines
|
||||
) + '\n' + indent + '}'
|
||||
return s + self.format_children(indent)
|
||||
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) 2019-2023 Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
|
||||
set -eu
|
||||
here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
function replace_acceptable_years() {
|
||||
# this needs to replace all acceptable forms with 'YEARS'
|
||||
sed -e 's/20[12][8901]-20[12][90123]/YEARS/' -e 's/20[12][901234]/YEARS/'
|
||||
}
|
||||
|
||||
printf "=> Checking for unacceptable language... "
|
||||
# This greps for unacceptable terminology. The square bracket[s] are so that
|
||||
# "git grep" doesn't find the lines that greps :).
|
||||
# We exclude the vendored BoringSSL copy from this check.
|
||||
unacceptable_terms=(
|
||||
-e blacklis[t]
|
||||
-e whitelis[t]
|
||||
-e slav[e]
|
||||
-e sanit[y]
|
||||
)
|
||||
if git grep --color=never -i "${unacceptable_terms[@]}" ':(exclude)Sources/CCryptoBoringSSL*' > /dev/null; then
|
||||
printf "\033[0;31mUnacceptable language found.\033[0m\n"
|
||||
git grep -i "${unacceptable_terms[@]}" ':(exclude)Sources/CCryptoBoringSSL*'
|
||||
exit 1
|
||||
fi
|
||||
printf "\033[0;32mokay.\033[0m\n"
|
||||
|
||||
# Run gyb, if generated files was changed -> fail
|
||||
printf "=> Detecting manual edits in generated Swift files by comparing to gyb output\n"
|
||||
FIRST_OUT="$(git status --porcelain)"
|
||||
out=$($here/generate_boilerplate_files_with_gyb.sh 2>&1)
|
||||
SECOND_OUT="$(git status --porcelain)"
|
||||
if [ "$out" == *"error"* ]; then
|
||||
printf "\033[0;31merror!\033[0m\n"
|
||||
echo $out
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
|
||||
printf "\033[0;31mRunning gyb results in changes! Have you manually edited the generated Swift files? Or did you forget to run gyb and commit changes?\033[0m\n"
|
||||
exit 1
|
||||
fi
|
||||
printf "\033[0;32mokay.\033[0m\n"
|
||||
|
||||
printf "=> Detecting changes in source files for CMake build\n"
|
||||
FIRST_OUT="$(git status --porcelain)"
|
||||
out=$($here/update_cmakelists.sh 2>&1)
|
||||
SECOND_OUT="$(git status --porcelain)"
|
||||
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
|
||||
printf "\033[0;31mThere are source file changes! Have you added or renamed source files? Or did you forget to run 'update_cmakelists.sh' and commit changes?\033[0m\n"
|
||||
exit 1
|
||||
fi
|
||||
printf "\033[0;32mokay.\033[0m\n"
|
||||
|
||||
printf "=> Checking format\n"
|
||||
FIRST_OUT="$(git status --porcelain)"
|
||||
# only checking directory named BoringSSL, rest is shared code and we need to preserve original format
|
||||
shopt -u dotglob
|
||||
find Sources/* Tests/* -name BoringSSL -type d | while IFS= read -r d; do
|
||||
printf " * checking $d... "
|
||||
out=$(swiftformat "$d" 2>&1)
|
||||
SECOND_OUT="$(git status --porcelain)"
|
||||
if [[ "$out" == *"error"*] && ["$out" != "*No eligible files" ]]; then
|
||||
printf "\033[0;31merror!\033[0m\n"
|
||||
echo $out
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$FIRST_OUT" != "$SECOND_OUT" ]]; then
|
||||
printf "\033[0;31mformatting issues!\033[0m\n"
|
||||
git --no-pager diff
|
||||
exit 1
|
||||
fi
|
||||
printf "\033[0;32mokay.\033[0m\n"
|
||||
done
|
||||
|
||||
printf "=> Checking #defines..."
|
||||
if grep 'development = true' Package.swift > /dev/null; then
|
||||
printf "\033[0;31mstill in development mode!\033[0m Comment out CRYPTO_IN_SWIFTPM_FORCE_BUILD_API.\n"
|
||||
exit 1
|
||||
else
|
||||
printf "\033[0;32mokay.\033[0m\n"
|
||||
fi
|
||||
|
||||
printf "=> Checking license headers\n"
|
||||
tmp=$(mktemp /tmp/.swift-crypto-soundness_XXXXXX)
|
||||
|
||||
for language in swift-or-c bash dtrace cmake; do
|
||||
printf " * $language... "
|
||||
declare -a matching_files
|
||||
declare -a exceptions
|
||||
expections=( )
|
||||
matching_files=( -name '*' )
|
||||
case "$language" in
|
||||
swift-or-c)
|
||||
exceptions=( -path '*Sources/CCryptoBoringSSL/*' -o -name 'Package.swift' )
|
||||
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
|
||||
cat > "$tmp" <<"EOF"
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftCrypto open source project
|
||||
//
|
||||
// Copyright (c) YEARS Apple Inc. and the SwiftCrypto project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
EOF
|
||||
;;
|
||||
bash)
|
||||
matching_files=( -name '*.sh' )
|
||||
cat > "$tmp" <<"EOF"
|
||||
#!/bin/bash
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) YEARS Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
EOF
|
||||
;;
|
||||
dtrace)
|
||||
matching_files=( -name '*.d' )
|
||||
cat > "$tmp" <<"EOF"
|
||||
#!/usr/sbin/dtrace -q -s
|
||||
/*===----------------------------------------------------------------------===*
|
||||
*
|
||||
* This source file is part of the SwiftCrypto open source project
|
||||
*
|
||||
* Copyright (c) YEARS Apple Inc. and the SwiftCrypto project authors
|
||||
* Licensed under Apache License v2.0
|
||||
*
|
||||
* See LICENSE.txt for license information
|
||||
* See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*===----------------------------------------------------------------------===*/
|
||||
EOF
|
||||
;;
|
||||
cmake)
|
||||
matching_files=( -name 'SwiftSupport.cmake' -o -name 'CMakeLists.txt' )
|
||||
cat > "$tmp" <<"EOF"
|
||||
##===----------------------------------------------------------------------===##
|
||||
##
|
||||
## This source file is part of the SwiftCrypto open source project
|
||||
##
|
||||
## Copyright (c) YEARS Apple Inc. and the SwiftCrypto project authors
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
##===----------------------------------------------------------------------===##
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
echo >&2 "ERROR: unknown language '$language'"
|
||||
;;
|
||||
esac
|
||||
|
||||
expected_lines=$(cat "$tmp" | wc -l)
|
||||
expected_sha=$(cat "$tmp" | shasum)
|
||||
|
||||
(
|
||||
cd "$here/.."
|
||||
find . \
|
||||
\( \! -path './.build/*' -a \
|
||||
\( "${matching_files[@]}" \) -a \
|
||||
\( \! \( "${exceptions[@]}" \) \) \) | while read line; do
|
||||
if [[ "$(cat "$line" | replace_acceptable_years | head -n $expected_lines | shasum)" != "$expected_sha" ]]; then
|
||||
printf "\033[0;31mmissing headers in file '$line'!\033[0m\n"
|
||||
diff -u <(cat "$line" | replace_acceptable_years | head -n $expected_lines) "$tmp"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
printf "\033[0;32mokay.\033[0m\n"
|
||||
)
|
||||
done
|
||||
|
||||
rm "$tmp"
|
||||
@@ -7,7 +7,7 @@
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
@@ -22,6 +22,7 @@ case "$(uname -s)" in
|
||||
find=gfind # brew install findutils
|
||||
;;
|
||||
*)
|
||||
# shellcheck disable=SC2209
|
||||
find=find
|
||||
;;
|
||||
esac
|
||||
@@ -31,12 +32,12 @@ function update_cmakelists_source() {
|
||||
|
||||
src_exts=("*.c" "*.swift")
|
||||
num_exts=${#src_exts[@]}
|
||||
echo "Finding source files (${src_exts[@]}) under $src_root"
|
||||
echo "Finding source files (" "${src_exts[@]}" ") under $src_root"
|
||||
|
||||
# Build file extensions argument for `find`
|
||||
declare -a exts_arg
|
||||
exts_arg+=(-name "${src_exts[0]}")
|
||||
for (( i=1; i<$num_exts; i++ ));
|
||||
for (( i=1; i<num_exts; i++ ));
|
||||
do
|
||||
exts_arg+=(-o -name "${src_exts[$i]}")
|
||||
done
|
||||
@@ -46,9 +47,9 @@ function update_cmakelists_source() {
|
||||
exceptions=("$@")
|
||||
# Add path exceptions for `find`
|
||||
if (( ${#exceptions[@]} )); then
|
||||
echo "Excluding source paths (${exceptions[@]}) under $src_root"
|
||||
echo "Excluding source paths (" "${exceptions[@]}" ") under $src_root"
|
||||
num_exceptions=${#exceptions[@]}
|
||||
for (( i=0; i<$num_exceptions; i++ ));
|
||||
for (( i=0; i<num_exceptions; i++ ));
|
||||
do
|
||||
exts_arg+=(! -path "${exceptions[$i]}")
|
||||
done
|
||||
@@ -7,7 +7,7 @@
|
||||
## Licensed under Apache License v2.0
|
||||
##
|
||||
## See LICENSE.txt for license information
|
||||
## See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
## See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
##
|
||||
## SPDX-License-Identifier: Apache-2.0
|
||||
##
|
||||
@@ -101,9 +101,9 @@ function mangle_symbols {
|
||||
)
|
||||
|
||||
# Now cross compile for our targets.
|
||||
docker run -t -i --rm --privileged -v$(pwd):/src -w/src --platform linux/arm64 swift:5.9-jammy \
|
||||
docker run -t -i --rm --privileged -v"$(pwd)":/src -w/src --platform linux/arm64 swift:5.9-jammy \
|
||||
swift build --product CCryptoBoringSSL
|
||||
docker run -t -i --rm --privileged -v$(pwd):/src -w/src --platform linux/amd64 swift:5.9-jammy \
|
||||
docker run -t -i --rm --privileged -v"$(pwd)":/src -w/src --platform linux/amd64 swift:5.9-jammy \
|
||||
swift build --product CCryptoBoringSSL
|
||||
|
||||
# Now we need to generate symbol mangles for Linux. We can do this in
|
||||
@@ -133,6 +133,7 @@ function mangle_symbols {
|
||||
echo "ADDING symbol mangling"
|
||||
perl -pi -e '$_ .= qq(\n#define BORINGSSL_PREFIX CCryptoBoringSSL\n) if /#define OPENSSL_HEADER_BASE_H/' "$DSTROOT/include/openssl/base.h"
|
||||
|
||||
# shellcheck disable=SC2044
|
||||
for assembly_file in $(find "$DSTROOT" -name "*.S")
|
||||
do
|
||||
$sed -i '1 i #define BORINGSSL_PREFIX CCryptoBoringSSL' "$assembly_file"
|
||||
@@ -145,6 +146,7 @@ case "$(uname -s)" in
|
||||
sed=gsed
|
||||
;;
|
||||
*)
|
||||
# shellcheck disable=SC2209
|
||||
sed=sed
|
||||
;;
|
||||
esac
|
||||
@@ -218,7 +220,7 @@ echo "COPYING boringssl"
|
||||
for pattern in "${PATTERNS[@]}"
|
||||
do
|
||||
for i in $SRCROOT/$pattern; do
|
||||
path=${i#$SRCROOT}
|
||||
path=${i#"$SRCROOT"}
|
||||
dest="$DSTROOT$path"
|
||||
dest_dir=$(dirname "$dest")
|
||||
mkdir -p "$dest_dir"
|
||||
@@ -255,6 +257,7 @@ echo "RENAMING header files"
|
||||
rmdir "include/openssl"
|
||||
|
||||
# Now change the imports from "<openssl/X> to "<CCryptoBoringSSL_X>", apply the same prefix to the 'boringssl_prefix_symbols' headers.
|
||||
# shellcheck disable=SC2038
|
||||
find . -name "*.[ch]" -or -name "*.cc" -or -name "*.S" -or -name "*.c.inc" | xargs $sed -i -e 's+include <openssl/\([[:alpha:]/]*/\)\{0,1\}+include <\1CCryptoBoringSSL_+' -e 's+include <boringssl_prefix_symbols+include <CCryptoBoringSSL_boringssl_prefix_symbols+' -e 's+include "openssl/\([[:alpha:]/]*/\)\{0,1\}+include "\1CCryptoBoringSSL_+'
|
||||
|
||||
# Okay now we need to rename the headers adding the prefix "CCryptoBoringSSL_".
|
||||
@@ -266,6 +269,7 @@ echo "RENAMING header files"
|
||||
done 3< <(find . -name "*.h" -print0 | sort -rz)
|
||||
|
||||
# Finally, make sure we refer to them by their prefixed names, and change any includes from angle brackets to quotation marks.
|
||||
# shellcheck disable=SC2038
|
||||
find . -name "*.h" | xargs $sed -i -e 's+include "\([[:alpha:]/]*/\)\{0,1\}+include "\1CCryptoBoringSSL_+' -e 's+include <\([[:alpha:]/]*/\)\{0,1\}CCryptoBoringSSL_\(.*\)>+include "\1CCryptoBoringSSL_\2"+'
|
||||
popd
|
||||
)
|
||||
@@ -274,6 +278,7 @@ echo "RENAMING header files"
|
||||
echo "PROTECTING against executable stacks"
|
||||
(
|
||||
cd "$DSTROOT"
|
||||
# shellcheck disable=SC2038
|
||||
find . -name "*.S" | xargs $sed -i '$ a #if defined(__linux__) && defined(__ELF__)\n.section .note.GNU-stack,"",%progbits\n#endif\n'
|
||||
)
|
||||
|
||||
@@ -292,7 +297,7 @@ cat << EOF > "$DSTROOT/include/CCryptoBoringSSL.h"
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.md for the list of SwiftCrypto project authors
|
||||
// See CONTRIBUTORS.txt for the list of SwiftCrypto project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user