Skip to content

Commit 481e91c

Browse files
committed
windows config
1 parent 89f0e74 commit 481e91c

File tree

3 files changed

+128
-17
lines changed

3 files changed

+128
-17
lines changed

.cargo/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[target.x86_64-pc-windows-gnu]
2+
linker = "/usr/bin/x86_64-w64-mingw32-gcc"
3+
ar = "/usr/x86_64-w64-mingw32/bin/ar"

.circleci/config.yml

Lines changed: 102 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2
22

33
jobs:
4-
binary:
4+
linux:
55
docker:
66
- image: circleci/rust:latest
77

@@ -15,34 +15,113 @@ jobs:
1515
sudo chown -R circleci:circleci /usr/local/cargo
1616
fi
1717
- restore_cache:
18-
key: cargo-cache-{{ checksum "Cargo.lock" }}-{{ checksum "Cargo.toml" }}
18+
key: cargo-cache-linux-{{ checksum "Cargo.lock" }}-{{ checksum "Cargo.toml" }}
1919

20-
# - run:
21-
# name: Use a Nightly Build
22-
# command: rustup override set nightly
20+
# - run:
21+
# name: Install Rust Stable
22+
# command: rustup toolchain install stable
2323

2424
- run:
25-
name: Install cross
26-
command: cargo install cross
25+
name: Use Stable as Default
26+
command: rustup override set stable
2727

2828
- run:
2929
name: Show Version
3030
command: |
3131
rustc --version --verbose
3232
rustup --version
3333
cargo --version --verbose
34-
cross --version
3534
3635
- run:
3736
name: Build Binary
3837
command: cargo build --release
3938

39+
- save_cache:
40+
key: cargo-cache-linux-{{ checksum "Cargo.lock" }}-{{ checksum "Cargo.toml" }}
41+
paths:
42+
- "~/.cargo/"
43+
- "~/.rustup/"
44+
- "./target"
45+
- "/usr/local/cargo"
46+
47+
- run:
48+
name: "Generate hash file"
49+
command: "cd target/release && sha256sum library-loader > library-loader.checksum"
50+
51+
- run:
52+
name: "Verify hash"
53+
command: "cd target/release && sha256sum -c library-loader.checksum"
54+
55+
- run:
56+
name: "Show hash"
57+
command: "cd target/release && cat library-loader.checksum"
58+
59+
- store_artifacts:
60+
name: Store Build
61+
path: "./target/release/library-loader"
62+
destination: "/artifacts/library-loader"
63+
64+
- store_artifacts:
65+
name: Store Build Checksum
66+
path: "./target/release/library-loader.checksum"
67+
destination: "/artifacts/library-loader.checksum"
68+
69+
windows:
70+
docker:
71+
- image: circleci/rust:latest
72+
73+
steps:
74+
- checkout
75+
76+
- run:
77+
name: Change Permissions for Cargo Cache
78+
command: |
79+
if [ -d "/usr/local/cargo" ]; then
80+
sudo chown -R circleci:circleci /usr/local/cargo
81+
fi
82+
- restore_cache:
83+
key: cargo-cache-windows-{{ checksum "Cargo.lock" }}-{{ checksum "Cargo.toml" }}
84+
85+
- run:
86+
name: Install Rust Stable
87+
command: rustup toolchain install stable
88+
89+
- run:
90+
name: Use Stable as Default
91+
command: rustup override set stable
92+
93+
- run:
94+
name: Show Version
95+
command: |
96+
rustc --version --verbose
97+
rustup --version
98+
cargo --version --verbose
99+
100+
- run:
101+
name: Install mingw-w64
102+
command: sudo apt install mingw-w64 -y
103+
104+
- run:
105+
name: Install the stable-x86_64-pc-windows-gnu toolchain
106+
command: rustup toolchain install stable-x86_64-pc-windows-gnu
107+
108+
- run:
109+
name: Install rust-std for target x86_64-pc-windows-gnu
110+
command: rustup component add rust-std --target=x86_64-pc-windows-gnu
111+
112+
- run:
113+
name: Copy a working version of crt2.o into the rust toolchain
114+
command: |
115+
export CRT2="/usr/local/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib.crt2.o"
116+
sudo mv $CRT2 "$CRT2.bak"
117+
sudo cp /usr/x86_64-w64-mingw32/lib/crt2.o $CRT2
118+
40119
- run:
41120
name: Build Binary
42-
command: cross build --release --target=x86_64-pc-windows-gnu
121+
command: cargo build --target=x86_64-pc-windows-gnu
43122

44123
- save_cache:
45-
key: cargo-cache-{{ checksum "Cargo.lock" }}-{{ checksum "Cargo.toml" }}
124+
key: cargo-cache-windows-{{ checksum "Cargo.lock" }}-{{ checksum "Cargo.toml" }}
46125
paths:
47126
- "~/.cargo/"
48127
- "~/.rustup/"
@@ -51,24 +130,30 @@ jobs:
51130

52131
- run:
53132
name: "Generate hash file"
54-
command: "cd target/release && sha256sum library-loader > library-loader_checksum"
133+
command: "cd target/x86_64-pc-windows-gnu && sha256sum library-loader.exe > library-loader.exe.checksum"
55134

56135
- run:
57136
name: "Verify hash"
58-
command: "cd target/release && sha256sum -c library-loader_checksum"
137+
command: "cd target/x86_64-pc-windows-gnu && sha256sum -c library-loader.exe.checksum"
138+
139+
- run:
140+
name: "Show hash"
141+
command: "cd target/x86_64-pc-windows-gnu && cat library-loader.exe.checksum"
59142

60143
- store_artifacts:
61144
name: Store Build
62-
path: "./target/release/library-loader"
63-
destination: "/artifacts/library-loader"
145+
path: "./target/x86_64-pc-windows-gnu/library-loader.exe"
146+
destination: "/windows/library-loader.exe"
64147

65148
- store_artifacts:
66149
name: Store Build Checksum
67-
path: "./target/release/library-loader_checksum"
68-
destination: "/artifacts/library-loader_checksum"
150+
path: "./target/x86_64-pc-windows-gnu/library-loader.exe.checksum"
151+
destination: "/windows/library-loader.exe.checksum"
69152

70153
workflows:
71154
version: 2
72155
build:
73156
jobs:
74-
- binary
157+
- linux
158+
- windows
159+
# - macos

.circleci/windows.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Steps:
2+
sudo apt install mingw-w64
3+
4+
rustup toolchain install stable
5+
6+
rustup default stable
7+
8+
rustup toolchain install stable-x86_64-pc-windows-gnu
9+
10+
rustup component add rust-std --target=x86_64-pc-windows-gnu
11+
12+
export CRT2="/usr/local/rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib.crt2.o"
13+
sudo mv $CRT2 "$CRT2.bak"
14+
sudo cp /usr/x86_64-w64-mingw32/lib/crt2.o $CRT2
15+
16+
cargo build --target=x86_64-pc-windows-gnu
17+
18+
19+
`.cargo/config`:
20+
[target.x86_64-pc-windows-gnu]
21+
linker = "/usr/bin/x86_64-w64-mingw32-gcc"
22+
ar = "/usr/x86_64-w64-mingw32/bin/ar"
23+

0 commit comments

Comments
 (0)