-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
119 lines (91 loc) · 3.65 KB
/
justfile
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
set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
set dotenv-load
# default to steam default game dir
DEFAULT_GAME_DIR := join("C:\\", "Program Files (x86)", "Steam", "steamapps", "common", "Cyberpunk 2077")
game_dir := env_var_or_default("GAME_DIR", DEFAULT_GAME_DIR)
plugin_name := 'loot_icons_extension_fix'
script_name := 'LootIconsExtensionFix'
# codebase (here)
red4ext_bin_dir := join(justfile_directory(), "target")
redscript_repo_dir := join(justfile_directory(), "reds")
# game files
red4ext_deploy_dir := join("red4ext", "plugins", plugin_name)
redscript_deploy_dir := join("r6", "scripts", script_name)
red_cache_dir := join("r6", "cache")
[private]
setup path:
@if (!(Test-Path '{{path}}')) { [void](New-Item '{{path}}' -ItemType Directory); Write-Host "Created folder at {{path}}"; }
[private]
delete path:
@if (Test-Path '{{path}}') { [void](Remove-Item -Force -Recurse '{{path}}'); Write-Host "Deleted folder at {{path}}"; }
[private]
copy from to:
@Copy-Item -Force '{{from}}' '{{to}}'
@Write-Host "Copied {{from}} -> {{to}}"
[private]
copy-recurse from to:
@Copy-Item -Force -Recurse '{{from}}' '{{to}}'
@Write-Host "Copied {{from}} -> {{to}}"
# 🕓 log current time
[private]
now:
@Write-Host "$(Get-Date) $_"
# 📦 build Rust RED4Ext plugin
build PROFILE='debug' TO=game_dir: (setup join(TO, red4ext_deploy_dir))
@'{{ if PROFILE == "release" { `cargo build --release` } else { `cargo build` } }}'
@just copy '{{ join(red4ext_bin_dir, PROFILE, plugin_name + ".dll") }}' '{{ join(TO, red4ext_deploy_dir, plugin_name + ".dll") }}'
@just now
alias b := build
# 🧑💻 build & reload
dev: (build) reload
# 🧐 debug with CodeLLDB
lldb TO=game_dir: dev
@just copy '{{ join(red4ext_bin_dir, "debug", plugin_name + ".pdb") }}' '{{ join(TO, red4ext_deploy_dir, plugin_name + ".pdb") }}'
@just now
checksum IN OUT:
Get-FileHash -Path "{{IN}}" -Algorithm SHA256 | Select-Object -ExpandProperty Hash > "{{OUT}}"
# 🤖 package in CI
ci TO: (setup join(TO, red4ext_deploy_dir)) (setup join(TO, redscript_deploy_dir)) (build 'release' TO) (reload TO)
# 🔥 clear cache
clear:
@if(Test-Path "{{ join(red_cache_dir, 'final.redscripts.bk') }}" ) { \
Write-Host "replacing {{ join(red_cache_dir, 'final.redscripts.bk') }} with {{ join(red_cache_dir, 'final.redscripts.bk') }}"; \
cp -Force '{{ join(red_cache_dir, "final.redscripts.bk") }}' '{{ join(red_cache_dir, "final.redscripts") }}'; \
Remove-Item -Force -Path '{{ join(red_cache_dir, "final.redscripts.bk") }}'; \
} else { \
Write-Host "missing {{ join(red_cache_dir, 'final.redscripts.bk') }}"; \
}
# 🔄 overwrite Redscript file(s)
reload TO=game_dir: (setup join(TO, redscript_deploy_dir))
@just copy-recurse '{{ join(redscript_repo_dir, "*") }}' '{{ join(TO, redscript_deploy_dir) }}'
@just now
alias r := reload
# 🗑️ uninstall mod
uninstall FROM=game_dir:
just delete '{{ join(FROM, red4ext_deploy_dir) }}'
just delete '{{ join(FROM, redscript_deploy_dir) }}'
# 📐 format code
format:
@cargo fmt
# 🎨 lint code
@lint:
cargo clippy --fix --allow-dirty --allow-staged
cargo fix --allow-dirty --allow-staged
just format
alias l := lint
# 🔷 quality insurance (format, lint, etc)
qa:
@cargo clippy -- -D warnings
@cargo fix
@cargo fmt --check
# ✅ unit-tests
@test:
echo 'TODO'; exit 0
alias t := test
# ☑️ compilation check
check:
@cargo check --all
alias c := check
# 🗒️ documentation
@doc:
cargo doc --open --no-deps --document-private-items