Skip to content

Commit

Permalink
tried adding rust (gone wrong)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubesicle committed Sep 20, 2024
1 parent 6eaa80e commit f740d96
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "x86_64-pc-windows-msvc"
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,19 @@ build-*/

# CLion
.idea/
/cmake-build-*/
/cmake-build-*/

# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ add_library(${PROJECT_NAME} SHARED
# Add any extra C++ source files here
)

include(FetchContent)

FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.5 # Optionally specify a commit hash, version tag or branch here
)
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)

target_link_libraries(${PROJECT_NAME} rusty)
include_directories(${CMAKE_SOURCE_DIR}/target)

if (NOT DEFINED ENV{GEODE_SDK})
message(FATAL_ERROR "Unable to find Geode SDK! Please define GEODE_SDK environment variable to point to Geode")
else()
Expand Down
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "rusty"
version = "0.1.0"
edition = "2021"

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

[dependencies]

[build-dependencies]
cbindgen = "0.27"
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
extern crate cbindgen;

use std::env;

fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let mut config: cbindgen::Config = Default::default();
config.language = cbindgen::Language::C;
cbindgen::generate_with_config(&crate_dir, config)
.unwrap()
.write_to_file("target/Rusty.h");
}
6 changes: 6 additions & 0 deletions rusty-src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use std::ffi::c_int;

#[no_mangle]
pub extern "C" fn peepeepoopoo() -> c_int {
69
}
16 changes: 15 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Include the Geode headers.
*/
#include "Geode/loader/ModEvent.hpp"
#include <Geode/Geode.hpp>

/**
Expand Down Expand Up @@ -95,6 +96,19 @@ class $modify(MyMenuLayer, MenuLayer) {
* return type `void` and taking a `CCObject*`.
*/
void onMyButton(CCObject*) {
FLAlertLayer::create("Geode", "Hello from my custom mod!", "OK")->show();
FLAlertLayer::create("Geode", "Hello from my custom fuckoff mod!", "OK")->show();
}
};

#include "Geode/modify/PlayLayer.hpp"
class $modify(PlayLayer) {
void startGame() {
log::info("fuck you lmao");
PlayLayer::startGame();
}
};

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

0 comments on commit f740d96

Please sign in to comment.