-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.toml
224 lines (192 loc) · 7.62 KB
/
Makefile.toml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
[config]
skip_core_tasks = true
default_to_workspace = false
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS = ["contracts/room-contract", "contracts/web-container-contract", "ui"]
CONTRACT_TARGET = "wasm32-unknown-unknown"
CONTRACT_NAME = "room_contract"
BUILD_PROFILE = "release"
# Comma-separated list of features to enable
UI_FEATURES = ""
[tasks.clean]
description = "Clean build artifacts"
command = "cargo"
args = ["clean"]
[tasks.build-room-contract]
description = "Build the room contract WASM"
command = "cargo"
args = ["build", "--profile", "${BUILD_PROFILE}", "--target", "${CONTRACT_TARGET}", "-p", "room-contract", "--target-dir", "target", "--offline"]
[tasks.build-web-container]
description = "Build the web container contract WASM"
command = "cargo"
args = ["build", "--profile", "${BUILD_PROFILE}", "--target", "${CONTRACT_TARGET}", "-p", "web-container-contract", "--target-dir", "target"]
[tasks.build-web-container-tool]
description = "Build the web container tool for native platform"
dependencies = ["build-web-container"]
command = "cargo"
args = ["build", "--profile", "${BUILD_PROFILE}", "--package", "web-container-tool", "--target-dir", "target/native", "--target", "x86_64-unknown-linux-gnu"]
[tasks.build-ui]
description = "Build the Dioxus UI"
dependencies = ["build-room-contract", "uncomment-base-path"]
env = { RIVER_BASE_PATH = "/v1/contract/web/29cBpyCAdKmmqPjriYGqxqNbt6TPVxKbkfRWDD9L7NUG" }
command = "dx"
args = ["build", "--${BUILD_PROFILE}", "--features", "${UI_FEATURES}"]
cwd = "./ui"
condition = { channels = ["stable", "beta", "nightly"] }
[tasks.uncomment-base-path]
private = true
script = '''
sed -i 's/#base_path/base_path/' ui/Dioxus.toml
'''
[tasks.comment-base-path]
private = true
script = '''
sed -i 's/^base_path/#base_path/' ui/Dioxus.toml
'''
[tasks.build-ui-with-cleanup]
description = "Build the Dioxus UI and clean up afterwards"
dependencies = ["build-ui", "comment-base-path"]
[tasks.compress-webapp]
description = "Compress the built webapp into tar.xz"
dependencies = ["build-ui-with-cleanup"]
script = '''
mkdir -p target/webapp
cd target/dx/river-ui/${BUILD_PROFILE}/web/public && \
tar -cJf ../../../../../webapp/webapp.tar.xz *
'''
[tasks.sign-webapp]
description = "Sign the compressed webapp"
dependencies = ["compress-webapp", "build-web-container-tool", "build-web-container"]
script = '''
seconds=$(date +%s)
version=$(( seconds / 60 ))
target/native/x86_64-unknown-linux-gnu/${BUILD_PROFILE}/web-container-tool sign \
--input target/webapp/webapp.tar.xz \
--output target/webapp/webapp.metadata \
--parameters target/webapp/webapp.parameters \
--version $version
'''
[tasks.build-ui-example]
description = "Build the Dioxus UI with example data"
env = { UI_FEATURES = "example-data" }
dependencies = ["build-contract"]
command = "dx"
args = ["build", "--${BUILD_PROFILE}", "--features", "${UI_FEATURES}"]
cwd = "./ui"
[tasks.build-ui-no-sync]
description = "Build the Dioxus UI without Freenet sync"
env = { UI_FEATURES = "no-sync" }
dependencies = ["build-contract"]
command = "dx"
args = ["build", "--${BUILD_PROFILE}", "--features", "${UI_FEATURES}"]
cwd = "./ui"
[tasks.build-ui-example-no-sync]
description = "Build the Dioxus UI with example data and no Freenet sync"
env = { UI_FEATURES = "example-data,no-sync" }
dependencies = ["build-contract"]
command = "dx"
args = ["build", "--${BUILD_PROFILE}", "--features", "${UI_FEATURES}"]
cwd = "./ui"
[tasks.test-web-container]
description = "Run tests for web-container-contract"
command = "cargo"
args = ["test", "--package", "web-container-contract", "--target-dir", "target/native", "--target", "x86_64-unknown-linux-gnu", "--lib", "--bins"]
[tasks.test-web-container-integration]
description = "Run integration tests for web-container-contract"
command = "cargo"
args = ["test", "--package", "web-container-contract", "--target-dir", "target/native", "--target", "x86_64-unknown-linux-gnu", "--test", "integration_tests"]
[tasks.test-room-contract]
description = "Run tests for room-contract"
command = "cargo"
args = ["test", "--package", "room-contract", "--target-dir", "target/native", "--target", "x86_64-unknown-linux-gnu"]
[tasks.test-scaffold]
description = "Run tests for scaffold crate"
command = "cargo"
args = ["test", "--package", "freenet-scaffold", "--target-dir", "target/native", "--target", "x86_64-unknown-linux-gnu"]
[tasks.test-common]
description = "Run tests for common crate"
command = "cargo"
args = ["test", "--package", "river-common", "--target-dir", "target/native", "--target", "x86_64-unknown-linux-gnu"]
[tasks.test]
description = "Run all tests"
dependencies = ["test-web-container", "test-web-container-integration", "test-room-contract", "test-scaffold", "test-common"]
[tasks.update-published-contract]
description = "Build, publish, and update the published contract files"
dependencies = ["build-web-container"]
script = '''
# Get the contract ID without publishing
contract_id=$(fdev get-contract-id \
--code target/wasm32-unknown-unknown/release/web_container_contract.wasm \
--parameters target/webapp/webapp.parameters)
# Update published files
mkdir -p published-contract
cp target/wasm32-unknown-unknown/release/web_container_contract.wasm published-contract/
cp target/webapp/webapp.parameters published-contract/
echo "$contract_id" > published-contract/contract-id.txt
echo "Published contract updated with ID: $contract_id"
echo "Please commit the changes to git"
'''
[tasks.publish-river]
description = "Publish River to Freenet using the committed contract version"
dependencies = ["sign-webapp"]
script = '''
if [ ! -f "published-contract/contract-id.txt" ]; then
echo "No published contract found"
exit 1
fi
contract_id=$(cat published-contract/contract-id.txt)
echo "Publishing using committed contract: $contract_id"
fdev publish \
--code published-contract/web_container_contract.wasm \
--parameters published-contract/webapp.parameters \
contract \
--webapp-archive target/webapp/webapp.tar.xz \
--webapp-metadata target/webapp/webapp.metadata
'''
[tasks.publish-river-debug]
description = "Publish River to Freenet in debug mode"
env = { BUILD_PROFILE = "debug" }
dependencies = ["sign-webapp"]
script = '''
if [ ! -f "published-contract/contract-id.txt" ]; then
echo "No published contract found"
exit 1
fi
contract_id=$(cat published-contract/contract-id.txt)
echo "Publishing using committed contract in debug mode: $contract_id"
fdev publish \
--code published-contract/web_container_contract.wasm \
--parameters published-contract/webapp.parameters \
contract \
--webapp-archive target/webapp/webapp.tar.xz \
--webapp-metadata target/webapp/webapp.metadata
'''
[tasks.clippy]
description = "Run clippy on all packages"
command = "cargo"
args = ["clippy", "--manifest-path", "./Cargo.toml", "--workspace", "--exclude", "freenet-stdlib", "--all-targets", "--", "-D", "warnings"]
[tasks.build]
description = "Build everything in release mode (optimized)"
dependencies = ["build-ui-with-cleanup", "build-web-container"]
[tasks.dev-example]
description = "Development build with example data"
env = { UI_FEATURES = "example-data", BUILD_PROFILE = "debug" }
dependencies = ["build-contract"]
command = "dx"
args = ["serve", "--features", "${UI_FEATURES}"]
cwd = "./ui"
[tasks.build-example]
description = "Build everything in release mode with example data"
dependencies = ["build-ui-example"]
[tasks.build-debug]
description = "Build everything in debug mode (faster builds)"
env = { BUILD_PROFILE = "debug" }
dependencies = ["build-ui"]
[tasks.dev]
description = "Development build"
env = { UI_FEATURES = "" }
dependencies = ["build-contract"]
command = "dx"
args = ["serve"]
cwd = "./ui"