First Commit
This commit is contained in:
commit
cfa1ccd049
15 changed files with 288 additions and 0 deletions
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Godot-specific ignores
|
||||
.import/
|
||||
export.cfg
|
||||
export_presets.cfg
|
||||
|
||||
# Imported translations (automatically generated from CSV files)
|
||||
*.translation
|
||||
|
||||
# Mono-specific ignores
|
||||
.mono/
|
||||
data_*/
|
||||
|
||||
# Project-specific ignores
|
||||
exports/
|
||||
|
7
default_env.tres
Normal file
7
default_env.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
8
hello_world.gdns
Normal file
8
hello_world.gdns
Normal file
|
@ -0,0 +1,8 @@
|
|||
[gd_resource type="NativeScript" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://rust-library.gdnlib" type="GDNativeLibrary" id=1]
|
||||
|
||||
[resource]
|
||||
resource_name = "HelloWorld"
|
||||
class_name = "HelloWorld"
|
||||
library = ExtResource( 1 )
|
BIN
icon.png
Normal file
BIN
icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
35
icon.png.import
Normal file
35
icon.png.import
Normal file
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
27
project.godot
Normal file
27
project.godot
Normal file
|
@ -0,0 +1,27 @@
|
|||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
[application]
|
||||
|
||||
config/name="godot-rust-template"
|
||||
run/main_scene="res://test.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[gui]
|
||||
|
||||
common/drop_mouse_on_gui_input_disabled=true
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
||||
[rendering]
|
||||
|
||||
environment/default_environment="res://default_env.tres"
|
20
rust-library.gdnlib
Normal file
20
rust-library.gdnlib
Normal file
|
@ -0,0 +1,20 @@
|
|||
[general]
|
||||
|
||||
singleton=false
|
||||
load_once=true
|
||||
symbol_prefix="godot_"
|
||||
reloadable=true
|
||||
|
||||
[entry]
|
||||
|
||||
HTML5.wasm32="res://rust/target/wasm32-unknown-emscripten/release/rustside_godot.wasm"
|
||||
OSX.64="res://rust/target/release/librustside_godot.dylib"
|
||||
Windows.64="res://rust/target/release/rustside_godot.dll"
|
||||
X11.64="res://rust/target/release/librustside_godot.so"
|
||||
|
||||
[dependencies]
|
||||
|
||||
HTML5.wasm32=[ ]
|
||||
OSX.64=[ ]
|
||||
Windows.64=[ ]
|
||||
X11.64=[ ]
|
6
rust/.cargo/config.toml
Normal file
6
rust/.cargo/config.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[target.wasm32-unknown-emscripten]
|
||||
rustflags = [
|
||||
"-Clink-arg=-sSIDE_MODULE=2", # build a side module that Godot can load
|
||||
"-Zlink-native-libraries=no", # workaround for a wasm-ld error during linking
|
||||
"-Cpanic=abort", # workaround for a runtime error related to dyncalls
|
||||
]
|
1
rust/.envrc
Normal file
1
rust/.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
3
rust/.gitignore
vendored
Normal file
3
rust/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/target
|
||||
/Cargo.lock
|
||||
/.direnv
|
14
rust/Cargo.toml
Normal file
14
rust/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "rustside-godot"
|
||||
version = "0.1.0"
|
||||
authors = ["The godot-rust developers"]
|
||||
publish = false
|
||||
edition = "2021"
|
||||
rust-version = "1.63"
|
||||
license = "MIT"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
gdnative = "*"
|
94
rust/flake.lock
Normal file
94
rust/flake.lock
Normal file
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1659877975,
|
||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1656363765,
|
||||
"narHash": "sha256-al9eMT2a66tiQQMys40orUS7f2Wg9cBqbEd321HE/EA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ff8b619cfecb98bb94ae49ca7ceca937923a75fa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ff8b619cfecb98bb94ae49ca7ceca937923a75fa",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1665296151,
|
||||
"narHash": "sha256-uOB0oxqxN9K7XGF1hcnY+PQnlQJ+3bP2vCn/+Ru/bbc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "14ccaaedd95a488dd7ae142757884d8e125b3363",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1672712534,
|
||||
"narHash": "sha256-8S0DdMPcbITnlOu0uA81mTo3hgX84wK8S9wS34HEFY4=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "69fb7bf0a8c40e6c4c197fa1816773774c8ac59f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
29
rust/flake.nix
Normal file
29
rust/flake.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url =
|
||||
"github:NixOS/nixpkgs/ff8b619cfecb98bb94ae49ca7ceca937923a75fa";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
in with pkgs; {
|
||||
devShells.default = mkShell {
|
||||
buildInputs = [
|
||||
(rust-bin.nightly."2022-09-02".default.override {
|
||||
extensions = [ "rust-src" ];
|
||||
targets = [ "wasm32-unknown-emscripten" ];
|
||||
})
|
||||
libclang
|
||||
emscripten
|
||||
];
|
||||
C_INCLUDE_PATH = "${emscripten}/share/emscripten/cache/sysroot/include";
|
||||
LIBCLANG_PATH = "${libclang.lib}/lib";
|
||||
EM_CACHE = "/tmp/emscripten-cache";
|
||||
};
|
||||
});
|
||||
}
|
23
rust/src/lib.rs
Normal file
23
rust/src/lib.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use gdnative::prelude::*;
|
||||
|
||||
#[derive(NativeClass)]
|
||||
#[inherit(Node)]
|
||||
struct HelloWorld;
|
||||
|
||||
#[methods]
|
||||
impl HelloWorld {
|
||||
fn new(_owner: &Node) -> Self {
|
||||
HelloWorld
|
||||
}
|
||||
|
||||
#[method]
|
||||
fn _ready(&self) {
|
||||
godot_print!("Hello from Rust!")
|
||||
}
|
||||
}
|
||||
|
||||
fn init(handle: InitHandle) {
|
||||
handle.add_class::<HelloWorld>();
|
||||
}
|
||||
|
||||
godot_init!(init);
|
6
test.tscn
Normal file
6
test.tscn
Normal file
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://hello_world.gdns" type="Script" id=1]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
Loading…
Reference in a new issue