-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
109 lines (87 loc) · 2.64 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
set positional-arguments
base_rust_folder := "rust"
components_folder := base_rust_folder + "/src/ecs/components"
systems_folder := base_rust_folder + "/src/ecs/systems"
sync_folder := base_rust_folder + "/src/ecs/sync"
rust_indent_size := "4"
default:
just --list
build:
cargo build
run:
make run
clippy:
cargo clippy -- -D warnings
fmt:
cargo fmt --all -- --check
fmt-fix:
cargo fmt --all
lint: fmt clippy
generate-component component:
#!/usr/bin/env ruby
struct_name = '{{component}}'.split('_').reduce('') { |acc, elt| acc + elt.capitalize }
filepath = '{{components_folder}}/{{component}}.rs'
raise 'File already exists. Aborting.' if File.exists? filepath
File.open(filepath, 'w') do |f|
f.puts 'use bevy_ecs::prelude::*;'
f.puts ''
f.puts '#[derive(Component)]'
f.puts "pub struct #{struct_name} {"
f.puts '}'
end
File.open('{{components_folder}}/mod.rs', 'a') do |f|
f.puts 'mod {{component}};'
f.puts "pub use {{component}}::#{struct_name};"
end
generate-system system:
#!/usr/bin/env ruby
def indent(n = 1)
' ' * {{rust_indent_size}} * n
end
filepath = '{{systems_folder}}/{{system}}.rs'
raise 'File already exists. Aborting.' if File.exists? filepath
File.open(filepath, 'w') do |f|
f.puts 'use bevy_ecs::prelude::*;'
f.puts ''
f.puts 'use crate::ecs::components::*;'
f.puts ''
f.puts 'pub fn {{system}}('
f.puts "#{indent}query: Query<>,"
f.puts ') {'
f.puts indent
f.puts '}'
end
File.open('{{systems_folder}}/mod.rs', 'a') do |f|
f.puts 'mod {{system}};'
f.puts 'pub use {{system}}::{{system}};'
end
generate-sync system:
#!/usr/bin/env ruby
def indent(n = 1)
' ' * {{rust_indent_size}} * n
end
filepath = '{{sync_folder}}/{{system}}.rs'
raise 'File already exists. Aborting.' if File.exists? filepath
File.open(filepath, 'w') do |f|
f.puts 'use bevy_ecs::prelude::*;'
f.puts ''
f.puts 'use crate::ecs::components::*;'
f.puts 'use crate::engine::Owner;'
f.puts ''
f.puts 'pub fn {{system}}('
f.puts "#{indent}owner: Res<Owner>,"
f.puts "#{indent}query: Query<>,"
f.puts ') {'
f.puts indent
f.puts '}'
end
File.open('{{sync_folder}}/mod.rs', 'a') do |f|
f.puts 'mod {{system}};'
f.puts 'pub use {{system}}::{{system}};'
end
alias r := run
alias l := lint
alias b := build
alias gc := generate-component
alias gs := generate-system
alias gsc := generate-sync