9 files changed
+234
No files matched your search
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [[ ! -d "/home/faumaray/Project/personal/ExampleMod" ]]; then
|
||||
echo "Cannot find source directory; Did you move it?"
|
||||
echo "(Looking for "/home/faumaray/Project/personal/ExampleMod")"
|
||||
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# rebuild the cache forcefully
|
||||
_nix_direnv_force_reload=1 direnv exec "/home/faumaray/Project/personal/ExampleMod" true
|
||||
|
||||
# Update the mtime for .envrc.
|
||||
# This will cause direnv to reload again - but without re-building.
|
||||
touch "/home/faumaray/Project/personal/ExampleMod/.envrc"
|
||||
|
||||
# Also update the timestamp of whatever profile_rc we have.
|
||||
# This makes sure that we know we are up to date.
|
||||
touch -r "/home/faumaray/Project/personal/ExampleMod/.envrc" "/home/faumaray/Project/personal/ExampleMod/.direnv"/*.rc
|
||||
@@ -7,6 +7,8 @@
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
build
|
||||
.direnv
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(VoidExampleMod LANGUAGES CXX)
|
||||
|
||||
# ============================================================
|
||||
# Project settings
|
||||
# ============================================================
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
include(FetchContent)
|
||||
|
||||
add_compile_options(-ffunction-sections -fdata-sections)
|
||||
add_link_options(-Wl,--gc-sections)
|
||||
# ============================================================
|
||||
# Source / includes
|
||||
# ============================================================
|
||||
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "src/*.cpp")
|
||||
|
||||
# ============================================================
|
||||
# Platform flags
|
||||
# ============================================================
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN -DNOMINMAX)
|
||||
else()
|
||||
add_compile_options(-fPIC)
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(
|
||||
VoidLoaderApi
|
||||
GIT_REPOSITORY https://git.faumaray.ru/VoidLoader/VoidLoaderApi.git
|
||||
GIT_TAG main # release-1.10.0
|
||||
)
|
||||
|
||||
|
||||
FetchContent_MakeAvailable(VoidLoaderApi)
|
||||
|
||||
# ============================================================
|
||||
# Build shared library
|
||||
# ============================================================
|
||||
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC VoidLoaderApiInterface)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
target_link_options(${PROJECT_NAME} PRIVATE
|
||||
-Wl,-z,defs
|
||||
-Wl,--no-undefined
|
||||
-Wl,--as-needed
|
||||
-static-libstdc++
|
||||
-static-libgcc
|
||||
-Wl,-O1
|
||||
-Wl,--gc-sections
|
||||
-Wl,--export-dynamic
|
||||
-Wl,--undefined=__start_vlmods
|
||||
-Wl,--undefined=__stop_vlmods
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
# Output name: YourAgent.dll / libYourAgent.so
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
PREFIX ""
|
||||
SUFFIX ".vlmod"
|
||||
OUTPUT_NAME "VoidExampleMod"
|
||||
)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_options(${PROJECT_NAME} PRIVATE -Wl,--enable-new-dtags -Wl,-rpath,\$ORIGIN)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES BUILD_RPATH "\$ORIGIN" INSTALL_RPATH "\$ORIGIN")
|
||||
endif()
|
||||
Generated
+61
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1760524057,
|
||||
"narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
description = "Gradle C++ cross-compile (Linux → Windows/Mac)";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "CppShell";
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
gcc15Stdenv
|
||||
gcc15
|
||||
ninja
|
||||
cmake
|
||||
clang-tools
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
];
|
||||
|
||||
shellHook = '''';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include <Mod/Mod.hpp>
|
||||
|
||||
class MyMod final : public vl::mod::Mod<MyMod> {
|
||||
public:
|
||||
std::string_view name() const noexcept override { return "Example.MyMod"; }
|
||||
std::string_view version() const noexcept override { return "1.0.0"; }
|
||||
|
||||
explicit MyMod(const vl::mod::Context& ctx) : m_ctx(ctx) {}
|
||||
MyMod() = delete;
|
||||
~MyMod() = default;
|
||||
|
||||
void onStart() override;
|
||||
void onStop() override;
|
||||
|
||||
private:
|
||||
vl::mod::Context m_ctx;
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
|
||||
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <MyMod.hpp>
|
||||
|
||||
#include <Logging/LoggerManager.hpp>
|
||||
|
||||
|
||||
void MyMod::onStart() {
|
||||
auto& api = vl::logging::LoggerManager::instance();
|
||||
auto log = api.createCombined("[MyMod]", std::string(m_ctx.logDir) + "/my_mod", 512'000, vl::logging::Level::Info);
|
||||
|
||||
log->info("onStart: gameDir={}, dataDir={}, api={}.{}.{}",
|
||||
m_ctx.gameDir, m_ctx.dataDir,
|
||||
m_ctx.apiVersion.major, m_ctx.apiVersion.minor, m_ctx.apiVersion.patch);
|
||||
}
|
||||
|
||||
void MyMod::onStop() {
|
||||
auto log = vl::logging::LoggerManager::instance().createConsole("[MyMod]");
|
||||
log->info("onStop");
|
||||
}
|
||||
Reference in new issue
Block a user