Skip to content

Commit

Permalink
link openssl statically for Windows (#3118)
Browse files Browse the repository at this point in the history
* ci: fix windows pipeline

* vendor openssl for windows

* add comment for the workaround

(cherry picked from commit 49d2298)
  • Loading branch information
yihau authored and mergify[bot] committed Oct 14, 2024
1 parent 0b64361 commit d4e4f23
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 18 deletions.
12 changes: 12 additions & 0 deletions .github/scripts/install-all-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

os_name="$1"

# shellcheck source=.github/scripts/install-openssl.sh
source "$here/install-openssl.sh" "$os_name"
# shellcheck source=.github/scripts/install-proto.sh
source "$here/install-proto.sh" "$os_name"
18 changes: 18 additions & 0 deletions .github/scripts/install-openssl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e

os_name="$1"

case "$os_name" in
"Windows")
choco install openssl --version 3.3.2 --install-arguments="'/DIR=C:\OpenSSL'" -y
export OPENSSL_LIB_DIR="C:\OpenSSL\lib\VC\x64\MT"
export OPENSSL_INCLUDE_DIR="C:\OpenSSL\include"
;;
"macOS") ;;
"Linux") ;;
*)
echo "Unknown Operating System"
;;
esac
2 changes: 0 additions & 2 deletions ...hub/scripts/cargo-clippy-before-script.sh → .github/scripts/install-proto.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ os_name="$1"

case "$os_name" in
"Windows")
vcpkg install openssl:x64-windows-static-md
vcpkg integrate install
choco install protoc
export PROTOC='C:\ProgramData\chocolatey\lib\protoc\tools\bin\protoc.exe'
;;
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ jobs:
with:
version: "v0.8.1"

- shell: bash
run: .github/scripts/cargo-clippy-before-script.sh ${{ runner.os }}
# took the workaround from https://github.com/sfackler/rust-openssl/issues/2149
- name: Set Perl environment variables
if: runner.os == 'Windows'
run: |
echo "PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
echo "OPENSSL_SRC_PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- shell: bash
run: |
source .github/scripts/install-all-deps.sh ${{ runner.os }}
source ci/rust-version.sh nightly
rustup component add clippy --toolchain "$rust_nightly"
scripts/cargo-clippy-nightly.sh
13 changes: 9 additions & 4 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ jobs:
run: |
git checkout ${{ inputs.commit }}
# took the workaround from https://github.com/sfackler/rust-openssl/issues/2149
- name: Set Perl environment variables
run: |
echo "PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
echo "OPENSSL_SRC_PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- name: Build
id: build
shell: bash
run: |
vcpkg install openssl:x64-windows-static-md
vcpkg integrate install
choco install protoc
export PROTOC="C:\ProgramData\chocolatey\lib\protoc\tools\bin\protoc.exe"
# install all deps
source .github/scripts/install-all-deps.sh ${{ runner.os }}
source /tmp/env.sh
echo "tag=$CI_TAG" >> $GITHUB_OUTPUT
eval "$(ci/channel-info.sh)"
Expand Down
13 changes: 3 additions & 10 deletions storage-bigtable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ http = { workspace = true }
hyper = { workspace = true }
hyper-proxy = { workspace = true }
log = { workspace = true }
# openssl is a dependency of the goauth and smpl_jwt crates, but explicitly
# declare it here as well to activate the "vendored" feature that builds OpenSSL
openssl = { workspace = true, features = ["vendored"] }
prost = { workspace = true }
prost-types = { workspace = true }
serde = { workspace = true }
Expand All @@ -36,16 +39,6 @@ tokio = { workspace = true }
tonic = { workspace = true, features = ["tls", "transport"] }
zstd = { workspace = true }

# openssl is a dependency of the goauth and smpl_jwt crates, but explicitly
# declare it here as well to activate the "vendored" feature that builds OpenSSL
# statically...
[target."cfg(not(windows))".dependencies]
openssl = { workspace = true, features = ["vendored"] }
# ...except on Windows to avoid having to deal with getting CI past a build-time
# Perl dependency
[target."cfg(windows)".dependencies]
openssl = { workspace = true, features = [] }

[lib]
crate-type = ["lib"]
name = "solana_storage_bigtable"
Expand Down

0 comments on commit d4e4f23

Please sign in to comment.