Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/syncprocess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Syncing with Upstream
To sync this repository with the upstream google/boringssl repository while maintaining the lightweight SwiftPM structure:

1. Ensure Upstream Remote is Configured:
git remote add upstream https://github.com/google/boringssl

2. Run the Sync Script:
Execute the automation script from the root directory:

```
./scripts/sync-upstream.sh [commit-hash]
```
If no commit-hash is provided, it defaults to upstream/main.

10 changes: 10 additions & 0 deletions scripts/generate-err-data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

# Move to repository root
cd "$(dirname "$0")/.."

echo "--- Generating err_data.c ---"
go run ./util/pregenerate err_data.cc
cp -f gen/crypto/err_data.cc ./err_data.c
echo "SUCCESS: err_data.c generated and copied to root folder."
79 changes: 79 additions & 0 deletions scripts/sync-upstream.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
set -e

# Usage: ./scripts/sync-upstream.sh [commit-hash]
COMMIT_HASH=${1:-upstream/main}
TEMP_DIR=$(mktemp -d)
Comment thread
aslam9691 marked this conversation as resolved.
trap 'rm -rf "$TEMP_DIR"' EXIT

# 1. Define the files/folders you want to preserve
# Ensure these paths are relative to the repository root
PRESERVE=(
"Package.swift"
"PrivacyInfo.xcprivacy"
"README.md"
"scripts"
"docs"
".github"
"SwiftPMTests"
)
Comment thread
aslam9691 marked this conversation as resolved.

echo "--- Preserving local files ---"
for file in "${PRESERVE[@]}"; do
if [ -e "$file" ]; then
cp -r "$file" "$TEMP_DIR/"
fi
done

# 2. Fetch and reset
echo "--- Syncing to: $COMMIT_HASH ---"
if ! git remote | grep -q "^upstream$"; then
echo "ERROR: 'upstream' remote is not configured."
echo "Please run: git remote add upstream https://github.com/google/boringssl"
exit 1
fi
git fetch upstream
Comment thread
aslam9691 marked this conversation as resolved.
git reset --hard "$COMMIT_HASH"

# 3. Restore preserved files
echo "--- Restoring local files ---"
for file in "${PRESERVE[@]}"; do
clean_file="${file%/}"
target_name=$(basename "$clean_file")
if [ -e "$TEMP_DIR/$target_name" ]; then
if [ -d "$TEMP_DIR/$target_name" ]; then
mkdir -p "$clean_file"
cp -r "$TEMP_DIR/$target_name/." "$clean_file/"
else
cp "$TEMP_DIR/$target_name" "$clean_file"
fi
fi
done
Comment thread
aslam9691 marked this conversation as resolved.

# 4. Generate err_data.c
bash ./scripts/generate-err-data.sh

# 5. Cleanup function
cleanup() {
echo "--- Performing comprehensive cleanup ---"

# Directories
rm -rf rust/ infra/ fuzz/ third_party/googletest/
rm -rf third_party/wycheproof_testvectors/ pki/testdata/ gen/test_support/
rm -rf .swiftpm/ .bcr/ .build/

# Files and artifacts
find . -type f -not -path "./.git/*" \( -name "*_test.cc" -o -name "*_test.go" -o -name "*_tests.txt" -o -name "*_unittest.cc" \) -delete
rm -f .bazelrc
find . -not -path "./.git/*" -name ".DS_Store" -delete
}

cleanup

echo "--- Verifying build ---"
if swift build; then
echo "SUCCESS: Build verified."
else
echo "ERROR: Build failed."
exit 1
fi