Skip to content

Commit b424fe8

Browse files
authored
Proxy derive macros, rustc plugin codegen, safety improvements (#67)
* adds LuaProxy derive macro * bevy_api_gen is now a rustc extension which can work on arbitrary codebases * removed some unsafe blocks * all wrappers are now Clone regardless if the underlying type is due to Arc * added high level documentation
1 parent 667945c commit b424fe8

File tree

199 files changed

+37707
-18264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+37707
-18264
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[env]
2-
TARGET_DIR={ value = "target", relative = true }
2+
TARGET_DIR = { value = "target", relative = true }

.gitattributes

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
bevy_script_api/src/generated.rs linguist-generated
2-
bevy_script_api/src/generated.rs -diff -merge
3-
4-
**/*generated*.rs linguist-generated
5-
**/*generated*.rs -diff -merge
1+
crates/bevy_script_api/providers/*.rs linguist-generated
2+
crates/bevy_script_api/providers/*.rs -diff -merge

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
run_args: [
1717
{os: windows-latest, lua: lua54, cross: null},
1818
{os: macOS-latest, lua: lua54, cross: null},
19-
{os: ubuntu-latest, lua: lua54, cross: aarch64-unknown-linux-gnu},
19+
# {os: ubuntu-latest, lua: lua54, cross: aarch64-unknown-linux-gnu}, see https://github.com/houseabsolute/actions-rust-cross/issues/15
2020
{os: ubuntu-latest, lua: lua51, cross: null},
2121
{os: ubuntu-latest, lua: lua52, cross: null},
2222
{os: ubuntu-latest, lua: lua53, cross: null},

.rustfmt.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# max_width = 60
2+
# use_small_heuristics = "Max"
3+
# format_generated_files = false

.vscode/launch.json

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
{
22
// Use IntelliSense to learn about possible attributes.
33
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
77
{
88
"type": "lldb",
99
"request": "launch",
10-
"name": "Debug unit tests in library 'bevy_mod_scripting'",
11-
"cargo": {
12-
"args": [
13-
"test",
14-
"--no-run",
15-
"--lib",
16-
"--package=bevy_mod_scripting"
17-
],
18-
"filter": {
19-
"name": "bevy_mod_scripting",
20-
"kind": "lib"
21-
}
22-
},
23-
"args": [],
10+
"name": "Debug specific unit test",
11+
"preLaunchTask": "Build specific package's unit tests",
12+
"program": "${workspaceFolder}/target/debug/test_binary",
2413
"env": {
25-
"CARGO_MANIFEST_DIR": "${workspaceFolder}/bevy_mod_scripting"
14+
"CARGO_MANIFEST_DIR": "${workspaceFolder}/bevy_mod_scripting",
15+
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib"
2616
},
27-
"cwd": "${workspaceFolder}"
17+
"cwd": "${workspaceFolder}",
2818
},
2919
{
3020
"name": "Debug example 'game_of_life_lua'",
@@ -45,7 +35,8 @@
4535
"args": [],
4636
"cwd": "${workspaceFolder}",
4737
"env": {
48-
"CARGO_MANIFEST_DIR": "${workspaceFolder}"
38+
"CARGO_MANIFEST_DIR": "${workspaceFolder}",
39+
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib"
4940
}
5041
},
5142
{

.vscode/settings.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
"lldb.showDisassembly": "never",
44
"lldb.dereferencePointers": true,
55
"lldb.consoleMode": "commands",
6-
"rust-analyzer.cargo.features": [
7-
"lua54",
8-
"lua_script_api",
9-
"rhai",
10-
"rhai_script_api",
11-
"teal",
12-
"rune"
6+
"[rust]": {
7+
"editor.formatOnSave": true,
8+
"editor.formatOnSaveMode": "file",
9+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
10+
},
11+
"rust-analyzer.rustc.source": "discover",
12+
"rust-analyzer.linkedProjects": [
13+
"./crates/bevy_api_gen/Cargo.toml",
14+
"Cargo.toml",
1315
],
14-
"rust-analyzer.server.extraEnv": {
15-
"RUSTUP_TOOLCHAIN": "stable"
16-
}
16+
"rust-analyzer.check.invocationStrategy": "per_workspace",
17+
"rust-analyzer.check.invocationLocation": "workspace",
18+
"rust-analyzer.check.overrideCommand": [
19+
"/home/makspll/git/bevy_mod_scripting/check.sh"
20+
],
21+
"rust-analyzer.showUnlinkedFileNotification": false,
22+
// "rust-analyzer.semanticHighlighting.operator.enable": false
1723
}

.vscode/tasks.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"version": "2.0.0",
3+
"inputs": [
4+
{
5+
"id": "test_name",
6+
"type": "promptString",
7+
"description": "Run only tests including this string in their name",
8+
"default": ""
9+
},
10+
{
11+
"id": "package",
12+
"type": "promptString",
13+
"description": "The crate location of this unit test",
14+
"default": "bevy_mod_scripting"
15+
}
16+
],
17+
"tasks": [
18+
{
19+
"label": "Build specific package's unit tests",
20+
"type": "process",
21+
"command": "make",
22+
"args": [
23+
"build_test_in_package",
24+
"PACKAGE=${input:package}",
25+
"TEST_NAME=${input:test_name}"
26+
]
27+
}
28+
]
29+
}

Cargo.toml

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,47 @@ rhai_script_api = ["bevy_script_api/rhai"]
6161
rune = ["bevy_mod_scripting_rune"]
6262

6363
[dependencies]
64-
bevy = { version = "0.13", default-features = false }
65-
bevy_mod_scripting_core = { path = "bevy_mod_scripting_core", version = "0.5.0" }
66-
bevy_mod_scripting_lua = { path = "languages/bevy_mod_scripting_lua", version = "0.5.0", optional = true }
67-
bevy_mod_scripting_rhai = { path = "languages/bevy_mod_scripting_rhai", version = "0.5.0", optional = true }
68-
bevy_mod_scripting_rune = { path = "languages/bevy_mod_scripting_rune", version = "0.5.0", optional = true }
69-
bevy_script_api = { path = "bevy_script_api", version = "0.5.0", optional = true }
64+
bevy = { workspace = true }
65+
bevy_mod_scripting_core = { workspace = true }
66+
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.5.0", optional = true }
67+
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.5.0", optional = true }
68+
bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.5.0", optional = true }
69+
bevy_script_api = { path = "crates/bevy_script_api", version = "0.5.0", optional = true }
7070

7171

72+
[workspace.dependencies]
73+
bevy = { version = "=0.13.1", default-features = false }
74+
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.5.0" }
75+
bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.5.0" }
76+
7277
[dev-dependencies]
73-
bevy = { version = "0.13" }
78+
bevy = { workspace = true, default-features = true }
7479
clap = { version = "4.1", features = ["derive"] }
7580
rand = "0.8.5"
7681
bevy_console = "0.11.1"
7782
rhai-rand = "0.1"
7883

7984
[workspace]
80-
resolver = "2"
8185
members = [
82-
"bevy_mod_scripting_core",
83-
"bevy_event_priority",
84-
"bevy_mod_scripting_derive",
85-
"bevy_api_gen",
86-
"bevy_script_api",
87-
"languages/bevy_mod_scripting_lua",
88-
"languages/bevy_mod_scripting_lua_derive",
89-
"languages/bevy_mod_scripting_rhai",
90-
"languages/bevy_mod_scripting_rhai_derive",
91-
"languages/bevy_mod_scripting_rune",
92-
"bevy_mod_scripting_common",
86+
"crates/bevy_mod_scripting_core",
87+
"crates/bevy_event_priority",
88+
"crates/bevy_script_api",
89+
"crates/languages/bevy_mod_scripting_lua",
90+
"crates/languages/bevy_mod_scripting_lua_derive",
91+
"crates/languages/bevy_mod_scripting_rhai",
92+
"crates/languages/bevy_mod_scripting_rhai_derive",
93+
"crates/languages/bevy_mod_scripting_rune",
94+
"crates/bevy_mod_scripting_common",
9395
]
96+
resolver = "2"
97+
exclude = ["bevy_api_gen"]
9498

9599
[profile.dev]
100+
debug = 1
96101
opt-level = 1
97102

98103
[profile.dev.package."*"]
104+
debug = 0
99105
opt-level = 3
100106

101107
[profile.ephemeral-build]
@@ -105,16 +111,25 @@ codegen-units = 8
105111
incremental = false
106112
debug = false
107113

108-
109114
[[example]]
110115
name = "console_integration_lua"
111116
path = "examples/lua/console_integration.rs"
112-
required-features = ["lua54", "lua_script_api", "bevy/file_watcher"]
117+
required-features = [
118+
"lua54",
119+
"lua_script_api",
120+
"bevy/file_watcher",
121+
"bevy/multi-threaded",
122+
]
113123

114124
[[example]]
115125
name = "console_integration_rhai"
116126
path = "examples/rhai/console_integration.rs"
117-
required-features = ["rhai", "rhai_script_api", "bevy/file_watcher"]
127+
required-features = [
128+
"rhai",
129+
"rhai_script_api",
130+
"bevy/file_watcher",
131+
"bevy/multi-threaded",
132+
]
118133

119134
[[example]]
120135
name = "complex_game_loop_lua"
@@ -124,12 +139,22 @@ required-features = ["lua54"]
124139
[[example]]
125140
name = "game_of_life_lua"
126141
path = "examples/lua/game_of_life.rs"
127-
required-features = ["lua54", "teal", "lua_script_api", "bevy/file_watcher"]
142+
required-features = [
143+
"lua54",
144+
"lua_script_api",
145+
"bevy/file_watcher",
146+
"bevy/multi-threaded",
147+
]
128148

129149
[[example]]
130150
name = "game_of_life_rhai"
131151
path = "examples/rhai/game_of_life.rs"
132-
required-features = ["rhai", "rhai_script_api", "bevy/file_watcher"]
152+
required-features = [
153+
"rhai",
154+
"rhai_script_api",
155+
"bevy/file_watcher",
156+
"bevy/multi-threaded",
157+
]
133158

134159
[[example]]
135160
name = "event_recipients_lua"
@@ -156,11 +181,6 @@ name = "bevy_api_rhai"
156181
path = "examples/rhai/bevy_api.rs"
157182
required-features = ["rhai", "rhai_script_api"]
158183

159-
[[example]]
160-
name = "multiple_events_rhai"
161-
path = "examples/rhai/multiple_events_rhai.rs"
162-
required-features = ["rhai", "rhai_script_api"]
163-
164184
[[example]]
165185
name = "wrappers"
166186
path = "examples/wrappers.rs"

0 commit comments

Comments
 (0)