Skip to content

Commit 1d9e4c7

Browse files
Matanel Sindilevichpacman82
Matanel Sindilevich
authored andcommitted
Properly cross-build for Windows x86 and Ubuntu ARM64
1 parent 59e72e1 commit 1d9e4c7

File tree

3 files changed

+64
-59
lines changed

3 files changed

+64
-59
lines changed

.github/workflows/release.yml

+49-58
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@ jobs:
3636
uses: actions/checkout@v2
3737

3838
- name: Install latest rust toolchain
39-
uses: actions-rs/toolchain@v1
39+
uses: dtolnay/rust-toolchain@v1
4040
with:
4141
toolchain: stable
4242
target: i686-pc-windows-msvc
43-
default: true
44-
override: true
4543

4644
- name: Build
4745
run: |
48-
cargo build --release
49-
Compress-Archive -LiteralPath target/release/odbc2parquet.exe -DestinationPath odbc2parquet-win-x86.zip
46+
cargo build --release --target i686-pc-windows-msvc
47+
Compress-Archive -LiteralPath target/i686-pc-windows-msvc/release/odbc2parquet.exe -DestinationPath odbc2parquet-win-x86.zip
5048
5149
- name: Github Upload
5250
uses: svenstaro/upload-release-action@v2
@@ -91,6 +89,33 @@ jobs:
9189
asset_name: odbc2parquet-macos-x86_64.gz
9290
tag: ${{ github.ref }}
9391

92+
release_macos_arm64:
93+
name: Build and release macOS ARM64
94+
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
95+
runs-on: macos-latest # ARM-based macOS runner (Apple Silicon)
96+
97+
steps:
98+
- name: Checkout
99+
uses: actions/checkout@v2
100+
101+
- name: Install Unix ODBC
102+
run: |
103+
brew install unixodbc
104+
sudo ln -s /opt/homebrew/lib ~/lib
105+
106+
- name: Build
107+
run: |
108+
cargo build --release
109+
gzip --force target/release/odbc2parquet
110+
mv target/release/odbc2parquet.gz odbc2parquet-macos-arm64.gz
111+
112+
- name: Github Upload
113+
uses: svenstaro/upload-release-action@v2
114+
with:
115+
file: odbc2parquet-macos-arm64.gz
116+
asset_name: odbc2parquet-macos-arm64.gz
117+
tag: ${{ github.ref }}
118+
94119
release_ubuntu_x64:
95120
name: Build and release Ubuntu x86_64
96121
runs-on: ubuntu-latest
@@ -112,66 +137,32 @@ jobs:
112137
asset_name: odbc2parquet-ubuntu-x86_64.gz
113138
tag: ${{ github.ref }}
114139

115-
release_macos_arm64:
116-
name: Build and release macOS ARM64
117-
# https://github.com/actions/runner-images?tab=readme-ov-file#available-images
118-
runs-on: macos-latest # ARM-based macOS runner (Apple Silicon)
140+
release_ubuntu_arm64:
141+
name: Build and release Ubuntu ARM64
142+
runs-on: ubuntu-latest
119143

120144
steps:
121145
- name: Checkout
122146
uses: actions/checkout@v2
123147

124-
- name: Install Unix ODBC
125-
run: |
126-
brew install unixodbc
127-
sudo ln -s /opt/homebrew/lib ~/lib
148+
- name: Install latest rust toolchain
149+
uses: dtolnay/rust-toolchain@v1
150+
with:
151+
toolchain: stable
152+
target: aarch64-unknown-linux-gnu
128153

129-
- name: Build
130-
run: |
131-
cargo build --release
132-
gzip --force target/release/odbc2parquet
133-
mv target/release/odbc2parquet.gz odbc2parquet-macos-arm64.gz
154+
- name: Install cross for cross-compilation
155+
run: cargo install cross
134156

157+
- name: Cross-build for Ubuntu ARM (aarch64)
158+
run: |
159+
cross build --release --target aarch64-unknown-linux-gnu
160+
gzip --force target/aarch64-unknown-linux-gnu/release/odbc2parquet
161+
mv target/aarch64-unknown-linux-gnu/release/odbc2parquet.gz odbc2parquet-ubuntu-arm64.gz
162+
135163
- name: Github Upload
136164
uses: svenstaro/upload-release-action@v2
137165
with:
138-
file: odbc2parquet-macos-arm64.gz
139-
asset_name: odbc2parquet-macos-arm64.gz
140-
tag: ${{ github.ref }}
141-
142-
# Doesn't work yet. Needs package `aarch64-linux-gnu-gcc`
143-
#
144-
# release_ubuntu_arm64:
145-
# name: Build and release Ubuntu ARM64
146-
# # https://github.com/actions/runner-images?tab=readme-ov-file#available-images
147-
# runs-on: macos-latest # ARM-based macOS runner to cross-compile for Ubuntu ARM
148-
149-
# steps:
150-
# - name: Checkout
151-
# uses: actions/checkout@v2
152-
153-
# - name: Install latest rust toolchain
154-
# uses: actions-rs/toolchain@v1
155-
# with:
156-
# toolchain: stable
157-
# target: aarch64-unknown-linux-gnu
158-
# default: true
159-
# override: true
160-
161-
# - name: Install Unix ODBC
162-
# run: |
163-
# brew install unixodbc
164-
# sudo ln -s /opt/homebrew/lib ~/lib
165-
166-
# - name: Cross-build for Ubuntu ARM (aarch64)
167-
# run: |
168-
# cargo build --release --target aarch64-unknown-linux-gnu
169-
# gzip --force target/aarch64-unknown-linux-gnu/release/odbc2parquet
170-
# mv target/aarch64-unknown-linux-gnu/release/odbc2parquet.gz odbc2parquet-ubuntu-arm64.gz
171-
172-
# - name: Github Upload
173-
# uses: svenstaro/upload-release-action@v2
174-
# with:
175-
# file: odbc2parquet-ubuntu-arm64.gz
176-
# asset_name: odbc2parquet-ubuntu-arm64.gz
177-
# tag: ${{ github.ref }}
166+
file: odbc2parquet-ubuntu-arm64.gz
167+
asset_name: odbc2parquet-ubuntu-arm64.gz
168+
tag: ${{ github.ref }}

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
# IDEs
44
/.vscode/
5-
/.idea/
5+
/.idea/
6+
7+
# OSs
8+
.DS_Store

Cross.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[target.aarch64-unknown-linux-gnu]
2+
# Disable `build-std` for `aarch64-unknown-linux-gnu`,
3+
# since it already has a std library pre-built.
4+
build-std = false
5+
# Install unixodbc:arm64 and unixodbc-dev:arm64, see <https://github.com/cross-rs/cross/blob/main/docs/custom_images.md#adding-dependencies-to-existing-images>
6+
# Additional commands to run prior to building the package.
7+
# These override the commands present in `[build]`: they will not merge.
8+
pre-build = [
9+
"dpkg --add-architecture $CROSS_DEB_ARCH",
10+
"apt-get update && apt-get install --assume-yes unixodbc:$CROSS_DEB_ARCH unixodbc-dev:$CROSS_DEB_ARCH"
11+
]

0 commit comments

Comments
 (0)