Skip to content

Commit

Permalink
Proxy derive macros, rustc plugin codegen, safety improvements (#67)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
makspll committed Apr 4, 2024
1 parent 667945c commit b424fe8
Show file tree
Hide file tree
Showing 199 changed files with 37,707 additions and 18,264 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[env]
TARGET_DIR={ value = "target", relative = true }
TARGET_DIR = { value = "target", relative = true }
7 changes: 2 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
bevy_script_api/src/generated.rs linguist-generated
bevy_script_api/src/generated.rs -diff -merge

**/*generated*.rs linguist-generated
**/*generated*.rs -diff -merge
crates/bevy_script_api/providers/*.rs linguist-generated
crates/bevy_script_api/providers/*.rs -diff -merge
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
run_args: [
{os: windows-latest, lua: lua54, cross: null},
{os: macOS-latest, lua: lua54, cross: null},
{os: ubuntu-latest, lua: lua54, cross: aarch64-unknown-linux-gnu},
# {os: ubuntu-latest, lua: lua54, cross: aarch64-unknown-linux-gnu}, see https://github.com/houseabsolute/actions-rust-cross/issues/15
{os: ubuntu-latest, lua: lua51, cross: null},
{os: ubuntu-latest, lua: lua52, cross: null},
{os: ubuntu-latest, lua: lua53, cross: null},
Expand Down
3 changes: 3 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# max_width = 60
# use_small_heuristics = "Max"
# format_generated_files = false
27 changes: 9 additions & 18 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in library 'bevy_mod_scripting'",
"cargo": {
"args": [
"test",
"--no-run",
"--lib",
"--package=bevy_mod_scripting"
],
"filter": {
"name": "bevy_mod_scripting",
"kind": "lib"
}
},
"args": [],
"name": "Debug specific unit test",
"preLaunchTask": "Build specific package's unit tests",
"program": "${workspaceFolder}/target/debug/test_binary",
"env": {
"CARGO_MANIFEST_DIR": "${workspaceFolder}/bevy_mod_scripting"
"CARGO_MANIFEST_DIR": "${workspaceFolder}/bevy_mod_scripting",
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib"
},
"cwd": "${workspaceFolder}"
"cwd": "${workspaceFolder}",
},
{
"name": "Debug example 'game_of_life_lua'",
Expand All @@ -45,7 +35,8 @@
"args": [],
"cwd": "${workspaceFolder}",
"env": {
"CARGO_MANIFEST_DIR": "${workspaceFolder}"
"CARGO_MANIFEST_DIR": "${workspaceFolder}",
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:HOME}/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib"
}
},
{
Expand Down
26 changes: 16 additions & 10 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
"lldb.showDisassembly": "never",
"lldb.dereferencePointers": true,
"lldb.consoleMode": "commands",
"rust-analyzer.cargo.features": [
"lua54",
"lua_script_api",
"rhai",
"rhai_script_api",
"teal",
"rune"
"[rust]": {
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
"rust-analyzer.rustc.source": "discover",
"rust-analyzer.linkedProjects": [
"./crates/bevy_api_gen/Cargo.toml",
"Cargo.toml",
],
"rust-analyzer.server.extraEnv": {
"RUSTUP_TOOLCHAIN": "stable"
}
"rust-analyzer.check.invocationStrategy": "per_workspace",
"rust-analyzer.check.invocationLocation": "workspace",
"rust-analyzer.check.overrideCommand": [
"/home/makspll/git/bevy_mod_scripting/check.sh"
],
"rust-analyzer.showUnlinkedFileNotification": false,
// "rust-analyzer.semanticHighlighting.operator.enable": false
}
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "2.0.0",
"inputs": [
{
"id": "test_name",
"type": "promptString",
"description": "Run only tests including this string in their name",
"default": ""
},
{
"id": "package",
"type": "promptString",
"description": "The crate location of this unit test",
"default": "bevy_mod_scripting"
}
],
"tasks": [
{
"label": "Build specific package's unit tests",
"type": "process",
"command": "make",
"args": [
"build_test_in_package",
"PACKAGE=${input:package}",
"TEST_NAME=${input:test_name}"
]
}
]
}
78 changes: 49 additions & 29 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,41 +61,47 @@ rhai_script_api = ["bevy_script_api/rhai"]
rune = ["bevy_mod_scripting_rune"]

[dependencies]
bevy = { version = "0.13", default-features = false }
bevy_mod_scripting_core = { path = "bevy_mod_scripting_core", version = "0.5.0" }
bevy_mod_scripting_lua = { path = "languages/bevy_mod_scripting_lua", version = "0.5.0", optional = true }
bevy_mod_scripting_rhai = { path = "languages/bevy_mod_scripting_rhai", version = "0.5.0", optional = true }
bevy_mod_scripting_rune = { path = "languages/bevy_mod_scripting_rune", version = "0.5.0", optional = true }
bevy_script_api = { path = "bevy_script_api", version = "0.5.0", optional = true }
bevy = { workspace = true }
bevy_mod_scripting_core = { workspace = true }
bevy_mod_scripting_lua = { path = "crates/languages/bevy_mod_scripting_lua", version = "0.5.0", optional = true }
bevy_mod_scripting_rhai = { path = "crates/languages/bevy_mod_scripting_rhai", version = "0.5.0", optional = true }
bevy_mod_scripting_rune = { path = "crates/languages/bevy_mod_scripting_rune", version = "0.5.0", optional = true }
bevy_script_api = { path = "crates/bevy_script_api", version = "0.5.0", optional = true }


[workspace.dependencies]
bevy = { version = "=0.13.1", default-features = false }
bevy_mod_scripting_core = { path = "crates/bevy_mod_scripting_core", version = "0.5.0" }
bevy_mod_scripting_common = { path = "crates/bevy_mod_scripting_common", version = "0.5.0" }

[dev-dependencies]
bevy = { version = "0.13" }
bevy = { workspace = true, default-features = true }
clap = { version = "4.1", features = ["derive"] }
rand = "0.8.5"
bevy_console = "0.11.1"
rhai-rand = "0.1"

[workspace]
resolver = "2"
members = [
"bevy_mod_scripting_core",
"bevy_event_priority",
"bevy_mod_scripting_derive",
"bevy_api_gen",
"bevy_script_api",
"languages/bevy_mod_scripting_lua",
"languages/bevy_mod_scripting_lua_derive",
"languages/bevy_mod_scripting_rhai",
"languages/bevy_mod_scripting_rhai_derive",
"languages/bevy_mod_scripting_rune",
"bevy_mod_scripting_common",
"crates/bevy_mod_scripting_core",
"crates/bevy_event_priority",
"crates/bevy_script_api",
"crates/languages/bevy_mod_scripting_lua",
"crates/languages/bevy_mod_scripting_lua_derive",
"crates/languages/bevy_mod_scripting_rhai",
"crates/languages/bevy_mod_scripting_rhai_derive",
"crates/languages/bevy_mod_scripting_rune",
"crates/bevy_mod_scripting_common",
]
resolver = "2"
exclude = ["bevy_api_gen"]

[profile.dev]
debug = 1
opt-level = 1

[profile.dev.package."*"]
debug = 0
opt-level = 3

[profile.ephemeral-build]
Expand All @@ -105,16 +111,25 @@ codegen-units = 8
incremental = false
debug = false


[[example]]
name = "console_integration_lua"
path = "examples/lua/console_integration.rs"
required-features = ["lua54", "lua_script_api", "bevy/file_watcher"]
required-features = [
"lua54",
"lua_script_api",
"bevy/file_watcher",
"bevy/multi-threaded",
]

[[example]]
name = "console_integration_rhai"
path = "examples/rhai/console_integration.rs"
required-features = ["rhai", "rhai_script_api", "bevy/file_watcher"]
required-features = [
"rhai",
"rhai_script_api",
"bevy/file_watcher",
"bevy/multi-threaded",
]

[[example]]
name = "complex_game_loop_lua"
Expand All @@ -124,12 +139,22 @@ required-features = ["lua54"]
[[example]]
name = "game_of_life_lua"
path = "examples/lua/game_of_life.rs"
required-features = ["lua54", "teal", "lua_script_api", "bevy/file_watcher"]
required-features = [
"lua54",
"lua_script_api",
"bevy/file_watcher",
"bevy/multi-threaded",
]

[[example]]
name = "game_of_life_rhai"
path = "examples/rhai/game_of_life.rs"
required-features = ["rhai", "rhai_script_api", "bevy/file_watcher"]
required-features = [
"rhai",
"rhai_script_api",
"bevy/file_watcher",
"bevy/multi-threaded",
]

[[example]]
name = "event_recipients_lua"
Expand All @@ -156,11 +181,6 @@ name = "bevy_api_rhai"
path = "examples/rhai/bevy_api.rs"
required-features = ["rhai", "rhai_script_api"]

[[example]]
name = "multiple_events_rhai"
path = "examples/rhai/multiple_events_rhai.rs"
required-features = ["rhai", "rhai_script_api"]

[[example]]
name = "wrappers"
path = "examples/wrappers.rs"
Expand Down
Loading

0 comments on commit b424fe8

Please sign in to comment.