mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-18 22:53:16 +00:00
Figure out how to make that extension module work.
This commit is contained in:
parent
ab8ed5c77a
commit
63643a3f32
8 changed files with 1838 additions and 14 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -2,4 +2,5 @@ target
|
|||
mat_data.txt
|
||||
save_state
|
||||
*png~
|
||||
/quant.ew/files/system/player/tmp/
|
||||
/quant.ew/files/system/player/tmp/
|
||||
/quant.ew/ewext.dll
|
35
Justfile
35
Justfile
|
@ -13,26 +13,35 @@ build:
|
|||
cd noita-proxy && cargo build
|
||||
cd noita-proxy && cargo build --release
|
||||
|
||||
run-rel: add_dylib_release
|
||||
cd noita-proxy && NP_APPID=480 NP_SKIP_MOD_CHECK=1 cargo run --release
|
||||
## ewext stuff
|
||||
build_luajit:
|
||||
mkdir target/ -p
|
||||
cd target && git clone https://luajit.org/git/luajit.git || true
|
||||
cd target/luajit && git checkout v2.0.4 && make HOST_CC="gcc -m32" CROSS=i686-w64-mingw32- TARGET_SYS=Windows
|
||||
cp target/luajit/src/
|
||||
bindgen ../target/luajit/src/lua.h -o src/lua_bindings.rs --dynamic-loading Lua51 --no-layout-tests
|
||||
|
||||
run-rel-alt: add_dylib_release
|
||||
# `rustup target add i686-pc-windows-gnu` first
|
||||
build_ext:
|
||||
cd ewext && cargo build --release --target=i686-pc-windows-gnu
|
||||
cp ewext/target/i686-pc-windows-gnu/release/ewext.dll quant.ew/ewext.dll
|
||||
|
||||
##
|
||||
|
||||
run-rel: add_dylib_release
|
||||
cd noita-proxy && NP_SKIP_MOD_CHECK=1 cargo run --release
|
||||
|
||||
flamegraph: add_dylib_debug
|
||||
cd noita-proxy && NP_APPID=480 NP_SKIP_MOD_CHECK=1 cargo flamegraph
|
||||
|
||||
run: add_dylib_debug
|
||||
cd noita-proxy && NP_APPID=480 NP_SKIP_MOD_CHECK=1 cargo run
|
||||
run: add_dylib_debug build_ext
|
||||
cd noita-proxy && NP_SKIP_MOD_CHECK=1 cargo run
|
||||
|
||||
run2: add_dylib_debug
|
||||
cd noita-proxy && NP_APPID=480 NP_SKIP_MOD_CHECK=1 NP_NOITA_ADDR=127.0.0.1:21252 cargo run -- --launch-cmd "wine noita.exe -gamemode 0"
|
||||
run2: add_dylib_debug build_ext
|
||||
cd noita-proxy && NP_SKIP_MOD_CHECK=1 NP_NOITA_ADDR=127.0.0.1:21252 cargo run -- --launch-cmd "wine noita.exe -gamemode 0"
|
||||
|
||||
run2-alt: add_dylib_debug
|
||||
cd noita-proxy && NP_APPID=480 NP_SKIP_MOD_CHECK=1 NP_NOITA_ADDR=127.0.0.1:21252 cargo run
|
||||
run3: add_dylib_debug build_ext
|
||||
cd noita-proxy && NP_SKIP_MOD_CHECK=1 NP_NOITA_ADDR=127.0.0.1:21253 cargo run -- --launch-cmd "wine noita.exe -gamemode 0"
|
||||
|
||||
run3: add_dylib_debug
|
||||
cd noita-proxy && NP_APPID=480 NP_SKIP_MOD_CHECK=1 NP_NOITA_ADDR=127.0.0.1:21253 cargo run -- --launch-cmd "wine noita.exe -gamemode 0"
|
||||
|
||||
release: build add_dylib_release
|
||||
release: build_ext
|
||||
python scripts/prepare_release.py
|
||||
|
|
90
ewext/Cargo.lock
generated
Normal file
90
ewext/Cargo.lock
generated
Normal file
|
@ -0,0 +1,90 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "ewext"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
14
ewext/Cargo.toml
Normal file
14
ewext/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "ewext"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
|
||||
[profile.release]
|
||||
#lto = "thin"
|
||||
|
||||
[dependencies]
|
||||
libloading = "0.8.5"
|
3
ewext/build.rs
Normal file
3
ewext/build.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
// println!("cargo::rustc-link-lib=raw-dylib=lua");
|
||||
}
|
28
ewext/src/lib.rs
Normal file
28
ewext/src/lib.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use std::{ffi::c_int, sync::LazyLock};
|
||||
|
||||
use lua_bindings::{lua_State, Lua51, LUA_GLOBALSINDEX};
|
||||
|
||||
mod lua_bindings;
|
||||
|
||||
static LUA: LazyLock<Lua51> = LazyLock::new(|| unsafe {
|
||||
let lib = libloading::Library::new("./lua51.dll").expect("library to exist");
|
||||
Lua51::from_library(lib).expect("library to be lua")
|
||||
});
|
||||
|
||||
// const EWEXT: [(&'static str, Function); 1] = [("testfn", None)];
|
||||
|
||||
extern "C" fn test_fn(lua: *mut lua_State) -> c_int {
|
||||
0
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn luaopen_ewext(lua: *mut lua_State) -> c_int {
|
||||
println!("Initializing ewext");
|
||||
unsafe {
|
||||
LUA.lua_pushcclosure(lua, Some(test_fn), 0);
|
||||
LUA.lua_setfield(lua, LUA_GLOBALSINDEX, c"ewext".as_ptr())
|
||||
}
|
||||
// let mut luastate = unsafe { State::from_ptr(luastateptr) };
|
||||
// luastate.new_lib(&EWEXT);
|
||||
1
|
||||
}
|
1674
ewext/src/lua_bindings.rs
Normal file
1674
ewext/src/lua_bindings.rs
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,11 @@
|
|||
dofile_once("mods/quant.ew/NoitaPatcher/load.lua")
|
||||
np = require("noitapatcher")
|
||||
|
||||
package.cpath = package.cpath .. ";./mods/quant.ew/?.dll"
|
||||
package.path = package.path .. ";./mods/quant.ew/?.lua"
|
||||
print(package.cpath)
|
||||
require("ewext")
|
||||
|
||||
dofile_once( "data/scripts/lib/utilities.lua" )
|
||||
|
||||
dofile_once("mods/quant.ew/files/system/player/player_cosmetics.lua")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue