Skip to content

Commit cbe9a58

Browse files
committed
feat: add cargo make scripts
1 parent 793f65d commit cbe9a58

File tree

3 files changed

+213
-1
lines changed

3 files changed

+213
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
22
.release
33
/scripts
4-
/private
4+
/private
5+
.env

Makefile.toml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Load from the env file
2+
env_files = [{ path = ".env" }]
3+
4+
# Build Windows and Linux in parallel (Cross compiling with cargo cross)
5+
[tasks.build-all]
6+
run_task = { name = ["build-windows", "build-linux"], parallel = true }
7+
8+
# Build a Linux build
9+
[tasks.build-linux]
10+
run_task = [
11+
# Windows host taks
12+
{ name = [
13+
"build-linux-windows",
14+
"copy-build-linux-windows",
15+
], condition = { platforms = [
16+
"windows",
17+
] } },
18+
19+
# Linux host tasks
20+
{ name = [
21+
"build-linux-linux",
22+
"copy-build-linux-linux",
23+
], condition = { platforms = [
24+
"linux",
25+
] } },
26+
]
27+
28+
# Build a Windows Build
29+
[tasks.build-windows]
30+
run_task = [
31+
# Windows host tasks (Both UI builds must run sequentual as they use the same output path)
32+
{ name = [
33+
"build-windows-windows",
34+
"copy-build-windows-windows",
35+
"sign-windows",
36+
37+
"build-windows-native-windows",
38+
"copy-build-windows-native-windows",
39+
"sign-windows-native",
40+
], condition = { platforms = [
41+
"windows",
42+
] } },
43+
44+
# Linux host tasks
45+
{ name = [
46+
"build-windows-linux",
47+
"copy-build-windows-linux",
48+
49+
"build-windows-native-linux",
50+
"copy-build-windows-native-linux",
51+
], condition = { platforms = [
52+
"linux",
53+
] } },
54+
]
55+
56+
# Signs the windows executable
57+
[tasks.sign-windows]
58+
command = "${SIGNTOOL_PATH}"
59+
args = [
60+
"sign",
61+
"/fd",
62+
"SHA256",
63+
"/f",
64+
"${SIGN_FILE}",
65+
"/p",
66+
"${SIGN_PASSWORD}",
67+
".release/binaries/pocket-relay-client.exe",
68+
]
69+
70+
[tasks.sign-windows.condition]
71+
env_set = ["SIGN_FILE", "SIGN_PASSWORD", "SIGNTOOL_PATH"]
72+
platforms = ["windows"]
73+
files_exist = ["${SIGNTOOL_PATH}"]
74+
75+
# Signs the windows executable (Native UI)
76+
[tasks.sign-windows-native]
77+
command = "${SIGNTOOL_PATH}"
78+
args = [
79+
"sign",
80+
"/fd",
81+
"SHA256",
82+
"/f",
83+
"${SIGN_FILE}",
84+
"/p",
85+
"${SIGN_PASSWORD}",
86+
".release/binaries/pocket-relay-client-native.exe",
87+
]
88+
89+
90+
[tasks.sign-windows-native.condition]
91+
env_set = ["SIGN_FILE", "SIGN_PASSWORD", "SIGNTOOL_PATH"]
92+
platforms = ["windows"]
93+
files_exist = ["${SIGNTOOL_PATH}"]
94+
95+
# ---- Building from a windows host ----
96+
97+
# Build a Windows binary from a Windows host
98+
[tasks.build-windows-windows]
99+
command = "cargo"
100+
args = ["build", "--release"]
101+
102+
# Build a Windows binary (Native UI) from a Windows host
103+
[tasks.build-windows-native-windows]
104+
command = "cargo"
105+
args = ["build", "--release", "--no-default-features", "--features", "native"]
106+
107+
# Build the linux version (Requires cross be installed)
108+
[tasks.build-linux-windows]
109+
command = "cross"
110+
args = ["build", "--target", "x86_64-unknown-linux-gnu", "--release"]
111+
112+
# Copy the linux build to the releases folder
113+
[tasks.copy-build-linux-windows]
114+
script_runner = "@shell"
115+
script = "cp target/x86_64-unknown-linux-gnu/release/pocket-relay-client .release/binaries/pocket-relay-client"
116+
dependencies = ["create-release-dir"]
117+
118+
# Copy the Windows build to the releases folder
119+
[tasks.copy-build-windows-windows]
120+
script_runner = "@shell"
121+
script = "cp target/release/pocket-relay-client.exe .release/binaries/pocket-relay-client.exe"
122+
dependencies = ["create-release-dir"]
123+
124+
# Copy the Windows build to the releases folder
125+
[tasks.copy-build-windows-native-windows]
126+
script_runner = "@shell"
127+
script = "cp target/release/pocket-relay-client.exe .release/binaries/pocket-relay-client-native.exe"
128+
dependencies = ["create-release-dir"]
129+
130+
131+
# ---- Building from a linux host ----
132+
133+
# Build a Windows binary from a linux host
134+
[tasks.build-windows-linux]
135+
command = "cargo"
136+
args = ["build", "--target", "x86_64-pc-windows-gnu", "--release"]
137+
138+
139+
# Build a Windows binary (Native UI) from a linux host
140+
[tasks.build-windows-native-linux]
141+
command = "cargo"
142+
args = [
143+
"build",
144+
"--target",
145+
"x86_64-pc-windows-gnu",
146+
"--release",
147+
"--no-default-features",
148+
"--features",
149+
"native",
150+
]
151+
152+
153+
# Build the linux version (Requires cross be installed)
154+
[tasks.build-linux-linux]
155+
command = "cross"
156+
args = ["build", "--release"]
157+
158+
# Copy the linux build to the releases folder
159+
[tasks.copy-build-linux-linux]
160+
script_runner = "@shell"
161+
script = "cp target/release/pocket-relay-client .release/binaries/pocket-relay-client-linux"
162+
dependencies = ["create-release-dir"]
163+
164+
# Copy the Windows build to the releases folder
165+
[tasks.copy-build-windows-linux]
166+
script_runner = "@shell"
167+
script = "cp target/x86_64-pc-windows-gnu/release/pocket-relay-client.exe .release/binaries/pocket-relay-client.exe"
168+
dependencies = ["create-release-dir"]
169+
170+
# Copy the Windows build to the releases folder
171+
[tasks.copy-build-windows-native-linux]
172+
script_runner = "@shell"
173+
script = "cp target/x86_64-pc-windows-gnu/release/pocket-relay-client.exe .release/binaries/pocket-relay-client-native.exe"
174+
dependencies = ["create-release-dir"]
175+
176+
177+
# Create releases directory
178+
[tasks.create-release-dir]
179+
condition = { files_not_exist = [".release/binaries"] }
180+
script_runner = "@shell"
181+
script = "mkdir -p .release/binaries"

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,36 @@ target/release
9393
> If you are on Windows the file will be named pocket-relay-client.exe and if you are on Linux it will be named pocket-relay-client
9494
9595

96+
## Makefile.toml - Mainly used for maintainers
97+
98+
This project also includes a Makefile.toml for `cargo make` however its more intended for maintainers only in order to do cross compiling, building multiple versions in parallel, signing builds, etc
99+
100+
> Requires installing https://github.com/sagiegurari/cargo-make
101+
102+
### Building
103+
104+
#### Build Windows & Linux in parallel
105+
106+
```shell
107+
cargo make -t build-all
108+
```
109+
#### Building just Windows
110+
111+
```shell
112+
cargo make -t build-windows
113+
```
114+
115+
> [!NOTE]
116+
> When building for Windows on a Windows host you can sign the executable by providing a `SIGN_FILE` (File path to the .pfx file to use for signing) and `SIGN_PASSWORD` (The password to the .pdf file) you will also need to obtain a copy of signtool.exe and set the `SIGNTOOL_PATH` to be the path to that file
117+
>
118+
> After doing that Windows builds will be signed using the provided credentials
119+
120+
#### Building just Linux
121+
122+
```shell
123+
cargo make -t build-linux
124+
```
125+
96126
## 🔌 Credits
97127

98128
This repository contains files from [https://github.com/Erik-JS/masseffect-binkw32](https://github.com/Erik-JS/masseffect-binkw32) in the /legacy directory as they were embedded in previous versions of the client in order to disable certificate verification

0 commit comments

Comments
 (0)