Improve vendor-boringssl.sh script to make it work better (#396)

Updates for the `scripts/vendor-boringssl.h` script that make it a bit
easier to use and ensure you don't accidentally get an update of
BoringSSL you don't want.

### Motivation:

I was working on investigating building a Swift SDK for #223 and ran
into a couple of things that I saw could be improved. Not all need to be
done, but at the very least I feel the boringssl revision lock should be
considered. @Lukasa

### Modifications:

- Add missing invocation of `$sed` in the script- `gsed` was being
invoked instead, although everywhere else `$sed` was used (typo).
- Support locking `BORINGSSL_REVISION` to a specific revision number
through an argument to the script. This way the script can be re-run
without unintentionally upgrading boringssl.
- Remove the non-existent `boringssl_prefix_symbols_nasm.inc` exclude
from the `CCryptoBoringSSL` target. I'm guessing it was there for an
older version of boringssl, but no longer there with the current
revision?

### Result:

The `scripts/vendor_boringssl.sh` script behaves a bit better and can be
run without upgrading the boringssl version unless explicitly desired.
This commit is contained in:
Jesse L. Zamora authored and GitHub committed 2025-08-11 17:09:16 +01:00
1 parent 2347f20e24
commit c066b057ed
2 files changed
+13 -4

No files matched your search

-1
View File
@@ -98,7 +98,6 @@ let package = Package(
name: "CCryptoBoringSSL",
exclude: privacyManifestExclude + [
"hash.txt",
"include/boringssl_prefix_symbols_nasm.inc",
"CMakeLists.txt",
/*
* These files are excluded to support WASI libc which doesn't provide <netdb.h>.
+13 -3
View File
@@ -45,6 +45,11 @@ DSTROOT=Sources/CCryptoBoringSSL
TMPDIR=$(mktemp -d /tmp/.workingXXXXXX)
SRCROOT="${TMPDIR}/src/boringssl.googlesource.com/boringssl"
# BoringSSL revision can be passed as the first argument to this script.
if [ "$#" -gt 0 ]; then
BORINGSSL_REVISION="$1"
fi
# This function namespaces the awkward inline functions declared in OpenSSL
# and BoringSSL.
function namespace_inlines {
@@ -170,9 +175,14 @@ echo "CLONING boringssl"
mkdir -p "$SRCROOT"
git clone https://boringssl.googlesource.com/boringssl "$SRCROOT"
cd "$SRCROOT"
BORINGSSL_REVISION=$(git rev-parse HEAD)
if [ "$BORINGSSL_REVISION" ]; then
echo "CHECKING OUT boringssl@${BORINGSSL_REVISION}"
git checkout "$BORINGSSL_REVISION"
else
BORINGSSL_REVISION=$(git rev-parse HEAD)
echo "CLONED boringssl@${BORINGSSL_REVISION}"
fi
cd "$HERE"
echo "CLONED boringssl@${BORINGSSL_REVISION}"
echo "OBTAINING submodules"
(
@@ -248,7 +258,7 @@ echo "DISABLING assembly on x86 Windows"
# x86 Windows builds require nasm for acceleration. SwiftPM can't do that right now,
# so we disable the assembly.
cd "$DSTROOT"
gsed -i "/#define OPENSSL_HEADER_BASE_H/a#if defined(_WIN32) && (defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86))\n#define OPENSSL_NO_ASM\n#endif" "include/openssl/base.h"
$sed -i "/#define OPENSSL_HEADER_BASE_H/a#if defined(_WIN32) && (defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86))\n#define OPENSSL_NO_ASM\n#endif" "include/openssl/base.h"
)