Skip to content

Commit

Permalink
Update aws-lc-sys generation workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jun 30, 2024
1 parent 4027a6b commit 1fa1d90
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 22 deletions.
84 changes: 79 additions & 5 deletions .github/workflows/sys-bindings-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,51 @@ jobs:
env:
AWS_LC_SYS_NO_PREFIX: "1"
run: |
cargo test -p aws-lc-sys --features bindgen,ssl
cargo test -p aws-lc-sys --features bindgen
- name: Collect symbols
run: |
./scripts/build/collect_symbols.sh -c aws-lc-sys
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols from ${{ matrix.os }}"
collect-windows-symbols-and-commit:
if: github.repository == 'aws/aws-lc-rs'
runs-on: windows-latest
strategy:
fail-fast: true
matrix:
target:
- 'aarch64-pc-windows-msvc'
- 'x86_64-pc-windows-msvc'
- 'x86_64-pc-windows-gnu'
- 'i686-pc-windows-msvc'
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.ref_name }}
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: ilammy/setup-nasm@v1
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v4
- uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- name: No-prefix build for ${{ matrix.target }}
env:
AWS_LC_SYS_NO_PREFIX: "1"
run: |
cargo ${{ (matrix.target == 'aarch64-pc-windows-msvc' && 'build') || 'test' }} -p aws-lc-sys --features bindgen --target ${{ matrix.target }}
- name: Collect symbols
shell: bash
run: |
./scripts/build/collect_symbols.sh -c aws-lc-sys -t ${{ matrix.target }}
- name: Commit & Push changes
shell: bash
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols from ${{ matrix.target }}"
collect-cross-symbols-and-commit:
if: github.repository == 'aws/aws-lc-rs'
runs-on: ubuntu-latest
Expand All @@ -67,14 +106,14 @@ jobs:
env:
AWS_LC_SYS_NO_PREFIX: "1"
run: |
cross test -p aws-lc-sys --features bindgen,ssl --target ${{ matrix.target }}
cross test -p aws-lc-sys --features bindgen --target ${{ matrix.target }}
- name: Collect symbols
run: |
./scripts/build/collect_symbols.sh -c aws-lc-sys -t ${{ matrix.target }}
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols for ${{ matrix.target }}"
generate-headers-and-commit:
needs: [ collect-cross-symbols-and-commit, collect-symbols-and-commit ]
needs: [ collect-cross-symbols-and-commit, collect-symbols-and-commit, collect-windows-symbols-and-commit ]
if: github.repository == 'aws/aws-lc-rs'
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -116,9 +155,44 @@ jobs:
env:
AWS_LC_SYS_INTERNAL_BINDGEN: "1"
run: |
cargo test -p aws-lc-sys --features bindgen,ssl
cargo test -p aws-lc-sys --features bindgen
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated bindings from ${{ matrix.os }}"
generate-windows-bindings-and-commit:
needs: generate-headers-and-commit
if: github.repository == 'aws/aws-lc-rs'
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
target:
- 'aarch64-pc-windows-msvc'
- 'x86_64-pc-windows-msvc'
- 'x86_64-pc-windows-gnu'
- 'i686-pc-windows-msvc'
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
ref: ${{ github.ref_name }}
- uses: dtolnay/rust-toolchain@master
id: toolchain
with:
toolchain: stable
target: ${{ matrix.target }}
- uses: ilammy/setup-nasm@v1
- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@v4
- uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- name: Generate bindings for ${{ matrix.target }}
env:
AWS_LC_SYS_INTERNAL_BINDGEN: "1"
run: |
cargo test -p aws-lc-sys --features bindgen --target ${{ matrix.target }}
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated bindings for ${{ matrix.target }}"
generate-cross-bindings-and-commit:
needs: generate-headers-and-commit
if: github.repository == 'aws/aws-lc-rs'
Expand All @@ -139,7 +213,7 @@ jobs:
env:
AWS_LC_SYS_INTERNAL_BINDGEN: "1"
run: |
cross test -p aws-lc-sys --features bindgen,ssl --target ${{ matrix.target }}
cross test -p aws-lc-sys --features bindgen --target ${{ matrix.target }}
- name: Commit & Push changes
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated bindings for ${{ matrix.target }}"
collect-src-and-commit:
Expand Down
35 changes: 18 additions & 17 deletions scripts/build/collect_symbols.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,15 @@ function filter_symbols() {
}

function filter_nm_symbols() {
grep -v -E '^_Z' | grep -v 'BORINGSSL_bcm_' | grep -v 'BORINGSSL_integrity_test'
grep -v -E '^_Z' | grep -v -E '^\?' | grep -v 'BORINGSSL_bcm_' | grep -v 'BORINGSSL_integrity_test'
}

function filter_macho_symbols() {
grep -E '^_' | sed -e 's/^_\(.*\)/\1/'
}

function find_libcrypto() {
find "${REPO_ROOT}/target" -type f \( -name "lib*crypto.a" -o -name "lib*crypto.so" -o -name "lib*crypto.dylib" \) | grep "${CRATE_NAME}"
}

function find_libssl() {
find "${REPO_ROOT}/target" -type f \( -name "lib*ssl.a" -o -name "lib*ssl.so" -o -name "lib*ssl.dylib" \) | grep "${CRATE_NAME}"
find "${REPO_ROOT}/target" -type f \( -name "*crypto.lib" -o -name "lib*crypto.a" -o -name "lib*crypto.so" -o -name "lib*crypto.dylib" \) | grep "${CRATE_NAME}"
}

LIBCRYPTO_PATH="$(find_libcrypto)"
Expand All @@ -82,22 +78,27 @@ if [[ "${?}" -ne 0 ]]; then
exit 1
fi

LIBSSL_PATH="$(find_libssl)"
if [[ "${?}" -ne 0 ]]; then
echo "Unable to find libssl"
exit 1
fi

mkdir -p "$(dirname "${SYMBOLS_FILE}")"
echo Writing symbols to: ${SYMBOLS_FILE}

if [[ "${LIBCRYPTO_PATH}" = *.dylib ]]; then
nm --extern-only --defined-only -j "${LIBCRYPTO_PATH}" "${LIBSSL_PATH}" | grep -v "${REPO_ROOT}" | sort | uniq | filter_macho_symbols | filter_nm_symbols | filter_symbols >"${SYMBOLS_FILE}"
elif [[ "${LIBCRYPTO_PATH}" = *.so ]]; then
nm --extern-only --defined-only --format=just-symbols "${LIBCRYPTO_PATH}" "${LIBSSL_PATH}" | grep -v "${REPO_ROOT}" | sort | uniq | filter_nm_symbols | filter_symbols >"${SYMBOLS_FILE}"
if [[ "${PLATFORM}" = *-msvc ]]; then
if [[ "${PLATFORM}" = aarch64-* ]]; then
MSVC_ARCH=arm64
elif [[ "${PLATFORM}" = i686-* ]]; then
MSVC_ARCH=x86
else
MSVC_ARCH=x64
fi
DUMPBIN="$(echo /c/Program\ Files/Microsoft\ Visual\ Studio/*/Professional/VC/Tools/MSVC/*/bin/Hostx64/${MSVC_ARCH}/dumpbin.exe | tail -n 1)"
PATH="$(dirname "${DUMPBIN}")":"${PATH}"
dumpbin //EXPORTS //SYMBOLS ${LIBCRYPTO_PATH} | grep External | grep SECT1 | sed -e 's/.*External\s*|\s*\(.*\)$/\1/'| egrep '^\w' | sort | uniq | filter_symbols >"${SYMBOLS_FILE}"
elif [[ "${LIBCRYPTO_PATH}" = *.dylib ]]; then
nm --extern-only --defined-only -j "${LIBCRYPTO_PATH}" | grep -v "${REPO_ROOT}" | sort | uniq | filter_macho_symbols | filter_nm_symbols | filter_symbols >"${SYMBOLS_FILE}"
elif [[ "${LIBCRYPTO_PATH}" = *.so || "${LIBCRYPTO_PATH}" = *.lib ]]; then
nm --extern-only --defined-only --format=just-symbols "${LIBCRYPTO_PATH}" | grep -v "${REPO_ROOT}" | sort | uniq | filter_nm_symbols | filter_symbols >"${SYMBOLS_FILE}"
else
pushd "${AWS_LC_DIR}"
go run -mod readonly "${AWS_LC_DIR}"/util/read_symbols.go "${LIBCRYPTO_PATH}" "${LIBSSL_PATH}" | filter_symbols >"${SYMBOLS_FILE}"
go run -mod readonly "${AWS_LC_DIR}"/util/read_symbols.go "${LIBCRYPTO_PATH}" | filter_symbols >"${SYMBOLS_FILE}"
popd
fi

Expand Down

0 comments on commit 1fa1d90

Please sign in to comment.