Skip to content

Commit

Permalink
idk
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubesicle committed Sep 27, 2024
1 parent b6c2827 commit 724b296
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 38 deletions.
42 changes: 33 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ set(GEODE_TARGET_PLATFORM "Win64")

project(test VERSION 1.0.0)

# Set up the mod binary
add_library(${PROJECT_NAME} SHARED
src/main.cpp
# Add any extra C++ source files here
)

include(FetchContent)

FetchContent_Declare(
Expand All @@ -23,10 +17,40 @@ FetchContent_Declare(
FetchContent_MakeAvailable(Corrosion)

# Import targets defined in a package or workspace manifest `Cargo.toml` file
corrosion_import_crate(MANIFEST_PATH ${CMAKE_SOURCE_DIR}/Cargo.toml)
corrosion_import_crate(
MANIFEST_PATH Cargo.toml
)

#corrosion_experimental_cbindgen(
# TARGET rusty
# HEADER_NAME Rusty.h
#)

corrosion_add_cxxbridge(
cxxbridge-cpp
CRATE rusty
FILES lib.rs
)

# Set up the mod binary
add_library(${PROJECT_NAME} SHARED
src/main.cpp
# Add any extra C++ source files here
)

target_include_directories(cxxbridge-cpp PRIVATE "$ENV{GEODE_SDK}/loader/include")
target_include_directories(cxxbridge-cpp PRIVATE "$ENV{GEODE_SDK}/loader/include/Geode/cocos/include")
target_include_directories(cxxbridge-cpp PRIVATE "$ENV{GEODE_SDK}/loader/include/Geode/cocos/extensions")
target_include_directories(cxxbridge-cpp PRIVATE "build/bindings/bindings")
target_include_directories(cxxbridge-cpp PRIVATE "build/_deps/bindings-src/bindings/include")
target_include_directories(cxxbridge-cpp PRIVATE "build/_deps/fmt-src/include")
target_include_directories(cxxbridge-cpp PRIVATE "build/_deps/json-src/include")
target_link_libraries(${PROJECT_NAME} cxxbridge-cpp)

target_link_libraries(${PROJECT_NAME} rusty)
include_directories(${CMAKE_SOURCE_DIR}/target)
#if(MSVC)
# # Note: This is required because we use `cxx` which uses `cc` to compile and link C++ code.
# corrosion_set_env_vars(geode "CFLAGS=-MDd" "CXXFLAGS=-MDd")
#endif()

if (NOT DEFINED ENV{GEODE_SDK})
message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode")
Expand Down
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ version = "0.1.0"
edition = "2021"

[lib]
path = "rusty-src/lib.rs"
crate-type = ["staticlib"]

[dependencies]

[build-dependencies]
cbindgen = "0.27"
cxx = "1.0"
12 changes: 0 additions & 12 deletions build.rs

This file was deleted.

Empty file modified build.sh
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"geode": "3.7.0",
"geode": "3.7.1",
"gd": {
"win": "2.206",
"android": "2.206",
Expand Down
6 changes: 0 additions & 6 deletions rusty-src/lib.rs

This file was deleted.

23 changes: 23 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//#[no_mangle]
//pub extern "C" fn peepeepoopoo(callback: fn()) {
// println!("Hello from rust!! >:)");
// callback();
//}

#[cxx::bridge]
mod ffi {
extern "Rust" {
fn bingus();
}
}

#[cxx::bridge(namespace = "geode::log")]
mod ffi2 {
unsafe extern "C++" {
include!("Geode/loader/Log.hpp");
fn info(str: &str);
}
}

pub fn bingus() {
}
9 changes: 3 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,11 @@ class $modify(MyMenuLayer, MenuLayer) {
};

#include "Geode/modify/PlayLayer.hpp"
#include "cxxbridge-cpp/lib.h"
class $modify(PlayLayer) {
void startGame() {
log::info("fuck you lmao");
bingus();
log::info("all good");
PlayLayer::startGame();
}
};

#include "Rusty.h"
$on_mod(Loaded) {
peepeepoopoo();
};

0 comments on commit 724b296

Please sign in to comment.