diff --git a/.github/workflows/sys-bindings-generator.yml b/.github/workflows/sys-bindings-generator.yml index c57f8b31083..f943e356e47 100644 --- a/.github/workflows/sys-bindings-generator.yml +++ b/.github/workflows/sys-bindings-generator.yml @@ -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 @@ -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: @@ -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' @@ -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: diff --git a/scripts/build/collect_symbols.sh b/scripts/build/collect_symbols.sh index 43defea1747..ec324e150d8 100755 --- a/scripts/build/collect_symbols.sh +++ b/scripts/build/collect_symbols.sh @@ -61,7 +61,7 @@ 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() { @@ -69,11 +69,7 @@ function filter_macho_symbols() { } 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)" @@ -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