Skip to content

Commit 364ff78

Browse files
committed
Update aws-lc-sys generation workflow
1 parent 57f7b6e commit 364ff78

File tree

2 files changed

+98
-25
lines changed

2 files changed

+98
-25
lines changed

.github/workflows/sys-bindings-generator.yml

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,58 @@ jobs:
3131
- uses: dtolnay/rust-toolchain@stable
3232
- uses: actions/setup-go@v4
3333
with:
34-
go-version: '>=1.18'
34+
go-version: '>=1.20'
3535
- name: Install current Bash on macOS
3636
if: runner.os == 'macOS'
3737
run: brew install bash coreutils
3838
- name: No-prefix build for ${{ matrix.os }}
3939
env:
4040
AWS_LC_SYS_NO_PREFIX: "1"
4141
run: |
42-
cargo test -p aws-lc-sys --features bindgen,ssl
42+
cargo test -p aws-lc-sys --features bindgen
4343
- name: Collect symbols
4444
run: |
4545
./scripts/build/collect_symbols.sh -c aws-lc-sys
4646
- name: Commit & Push changes
4747
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols from ${{ matrix.os }}"
48+
collect-windows-symbols-and-commit:
49+
if: github.repository == 'aws/aws-lc-rs'
50+
runs-on: windows-latest
51+
strategy:
52+
fail-fast: true
53+
matrix:
54+
target:
55+
- 'aarch64-pc-windows-msvc'
56+
- 'x86_64-pc-windows-msvc'
57+
- 'x86_64-pc-windows-gnu'
58+
- 'i686-pc-windows-msvc'
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
submodules: 'recursive'
63+
ref: ${{ github.ref_name }}
64+
- uses: dtolnay/rust-toolchain@master
65+
id: toolchain
66+
with:
67+
toolchain: stable
68+
target: ${{ matrix.target }}
69+
- if: contains(matrix.target, 'x86') || contains(matrix.target, 'i686')
70+
uses: ilammy/setup-nasm@v1
71+
- uses: actions/setup-go@v4
72+
with:
73+
go-version: '>=1.20'
74+
- name: No-prefix build for ${{ matrix.target }}
75+
env:
76+
AWS_LC_SYS_NO_PREFIX: "1"
77+
run: |
78+
cargo ${{ (matrix.target == 'aarch64-pc-windows-msvc' && 'build') || 'test' }} -p aws-lc-sys --features bindgen --target ${{ matrix.target }}
79+
- name: Collect symbols
80+
shell: bash
81+
run: |
82+
./scripts/build/collect_symbols.sh -c aws-lc-sys -t ${{ matrix.target }}
83+
- name: Commit & Push changes
84+
shell: bash
85+
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols from ${{ matrix.target }}"
4886
collect-cross-symbols-and-commit:
4987
if: github.repository == 'aws/aws-lc-rs'
5088
runs-on: ubuntu-latest
@@ -60,21 +98,21 @@ jobs:
6098
- uses: dtolnay/rust-toolchain@stable
6199
- uses: actions/setup-go@v4
62100
with:
63-
go-version: '>=1.18'
101+
go-version: '>=1.20'
64102
- name: Install cross
65103
run: cargo install cross --locked --git https://github.com/cross-rs/cross
66104
- name: No-prefix build for ${{ matrix.target }}
67105
env:
68106
AWS_LC_SYS_NO_PREFIX: "1"
69107
run: |
70-
cross test -p aws-lc-sys --features bindgen,ssl --target ${{ matrix.target }}
108+
cross test -p aws-lc-sys --features bindgen --target ${{ matrix.target }}
71109
- name: Collect symbols
72110
run: |
73111
./scripts/build/collect_symbols.sh -c aws-lc-sys -t ${{ matrix.target }}
74112
- name: Commit & Push changes
75113
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Symbols for ${{ matrix.target }}"
76114
generate-headers-and-commit:
77-
needs: [ collect-cross-symbols-and-commit, collect-symbols-and-commit ]
115+
needs: [ collect-cross-symbols-and-commit, collect-symbols-and-commit, collect-windows-symbols-and-commit ]
78116
if: github.repository == 'aws/aws-lc-rs'
79117
runs-on: ubuntu-latest
80118
steps:
@@ -88,7 +126,7 @@ jobs:
88126
- uses: dtolnay/rust-toolchain@stable
89127
- uses: actions/setup-go@v4
90128
with:
91-
go-version: '>=1.18'
129+
go-version: '>=1.20'
92130
- name: Generate Prefix Headers
93131
run: ./scripts/generate/_generate_prefix_headers.sh -c aws-lc-sys
94132
- name: Update sys-crate metadata
@@ -116,9 +154,43 @@ jobs:
116154
env:
117155
AWS_LC_SYS_INTERNAL_BINDGEN: "1"
118156
run: |
119-
cargo test -p aws-lc-sys --features bindgen,ssl
157+
cargo test -p aws-lc-sys --features bindgen
120158
- name: Commit & Push changes
121159
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated bindings from ${{ matrix.os }}"
160+
generate-windows-bindings-and-commit:
161+
needs: generate-headers-and-commit
162+
if: github.repository == 'aws/aws-lc-rs'
163+
runs-on: windows-latest
164+
strategy:
165+
fail-fast: false
166+
matrix:
167+
target:
168+
- 'aarch64-pc-windows-msvc'
169+
- 'x86_64-pc-windows-msvc'
170+
- 'x86_64-pc-windows-gnu'
171+
- 'i686-pc-windows-msvc'
172+
steps:
173+
- uses: actions/checkout@v4
174+
with:
175+
submodules: 'recursive'
176+
ref: ${{ github.ref_name }}
177+
- uses: dtolnay/rust-toolchain@master
178+
id: toolchain
179+
with:
180+
toolchain: stable
181+
target: ${{ matrix.target }}
182+
- if: contains(matrix.target, 'x86') || contains(matrix.target, 'i686')
183+
uses: ilammy/setup-nasm@v1
184+
- uses: actions/setup-go@v4
185+
with:
186+
go-version: '>=1.20'
187+
- name: Generate bindings for ${{ matrix.target }}
188+
env:
189+
AWS_LC_SYS_INTERNAL_BINDGEN: "1"
190+
run: |
191+
cargo test -p aws-lc-sys --features bindgen --target ${{ matrix.target }}
192+
- name: Commit & Push changes
193+
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated bindings for ${{ matrix.target }}"
122194
generate-cross-bindings-and-commit:
123195
needs: generate-headers-and-commit
124196
if: github.repository == 'aws/aws-lc-rs'
@@ -139,7 +211,7 @@ jobs:
139211
env:
140212
AWS_LC_SYS_INTERNAL_BINDGEN: "1"
141213
run: |
142-
cross test -p aws-lc-sys --features bindgen,ssl --target ${{ matrix.target }}
214+
cross test -p aws-lc-sys --features bindgen --target ${{ matrix.target }}
143215
- name: Commit & Push changes
144216
run: ./scripts/ci/ci_add_commit_rebase_push.sh "Generated bindings for ${{ matrix.target }}"
145217
collect-src-and-commit:

scripts/build/collect_symbols.sh

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,15 @@ function filter_symbols() {
6161
}
6262

6363
function filter_nm_symbols() {
64-
grep -v -E '^_Z' | grep -v 'BORINGSSL_bcm_' | grep -v 'BORINGSSL_integrity_test'
64+
grep -v -E '^_Z' | grep -v -E '^\?' | grep -v 'BORINGSSL_bcm_' | grep -v 'BORINGSSL_integrity_test'
6565
}
6666

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

7171
function find_libcrypto() {
72-
find "${REPO_ROOT}/target" -type f \( -name "lib*crypto.a" -o -name "lib*crypto.so" -o -name "lib*crypto.dylib" \) | grep "${CRATE_NAME}"
73-
}
74-
75-
function find_libssl() {
76-
find "${REPO_ROOT}/target" -type f \( -name "lib*ssl.a" -o -name "lib*ssl.so" -o -name "lib*ssl.dylib" \) | grep "${CRATE_NAME}"
72+
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}"
7773
}
7874

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

85-
LIBSSL_PATH="$(find_libssl)"
86-
if [[ "${?}" -ne 0 ]]; then
87-
echo "Unable to find libssl"
88-
exit 1
89-
fi
90-
9181
mkdir -p "$(dirname "${SYMBOLS_FILE}")"
9282
echo Writing symbols to: ${SYMBOLS_FILE}
9383

94-
if [[ "${LIBCRYPTO_PATH}" = *.dylib ]]; then
95-
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}"
96-
elif [[ "${LIBCRYPTO_PATH}" = *.so ]]; then
97-
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}"
84+
if [[ "${PLATFORM}" = *-msvc ]]; then
85+
if [[ "${PLATFORM}" = aarch64-* ]]; then
86+
MSVC_ARCH=arm64
87+
elif [[ "${PLATFORM}" = i686-* ]]; then
88+
MSVC_ARCH=x86
89+
else
90+
MSVC_ARCH=x64
91+
fi
92+
DUMPBIN="$(echo /c/Program\ Files/Microsoft\ Visual\ Studio/*/Professional/VC/Tools/MSVC/*/bin/Hostx64/${MSVC_ARCH}/dumpbin.exe | tail -n 1)"
93+
PATH="$(dirname "${DUMPBIN}")":"${PATH}"
94+
dumpbin //EXPORTS //SYMBOLS ${LIBCRYPTO_PATH} | grep External | grep SECT1 | sed -e 's/.*External\s*|\s*\(.*\)$/\1/'| egrep '^\w' | sort | uniq | filter_symbols >"${SYMBOLS_FILE}"
95+
elif [[ "${LIBCRYPTO_PATH}" = *.dylib ]]; then
96+
nm --extern-only --defined-only -j "${LIBCRYPTO_PATH}" | grep -v "${REPO_ROOT}" | sort | uniq | filter_macho_symbols | filter_nm_symbols | filter_symbols >"${SYMBOLS_FILE}"
97+
elif [[ "${LIBCRYPTO_PATH}" = *.so || "${LIBCRYPTO_PATH}" = *.lib ]]; then
98+
nm --extern-only --defined-only --format=just-symbols "${LIBCRYPTO_PATH}" | grep -v "${REPO_ROOT}" | sort | uniq | filter_nm_symbols | filter_symbols >"${SYMBOLS_FILE}"
9899
else
99100
pushd "${AWS_LC_DIR}"
100-
go run -mod readonly "${AWS_LC_DIR}"/util/read_symbols.go "${LIBCRYPTO_PATH}" "${LIBSSL_PATH}" | filter_symbols >"${SYMBOLS_FILE}"
101+
go run -mod readonly "${AWS_LC_DIR}"/util/read_symbols.go "${LIBCRYPTO_PATH}" | filter_symbols >"${SYMBOLS_FILE}"
101102
popd
102103
fi
103104

0 commit comments

Comments
 (0)