From bd987ae5868fc5e314d290ad8e6089f2b1969d45 Mon Sep 17 00:00:00 2001 From: Buckminsterfullerene02 Date: Thu, 29 Feb 2024 17:50:24 +0000 Subject: [PATCH 01/11] xmake template --- .gitignore | 4 +- .gitmodules | 5 -- CMakeLists.txt | 7 --- MyCPPMods/CMakeLists.txt | 1 - MyCPPMods/MyExampleMod/CMakeLists.txt | 9 ---- MyCPPMods/MyExampleMod/src/dllmain.cpp | 66 -------------------------- RE-UE4SS | 1 - README.md | 21 +++++++- build_and_install_mod.bat | 50 +++++++++++++++++++ build_mods_shipping.bat | 5 -- dllmain_template.cpp | 48 +++++++++++++++++++ generate_project_files.bat | 4 -- new_mod_setup.bat | 63 ++++++++++++++++++++++++ xmake_template.lua | 27 +++++++++++ 14 files changed, 211 insertions(+), 100 deletions(-) delete mode 100644 .gitmodules delete mode 100644 CMakeLists.txt delete mode 100644 MyCPPMods/CMakeLists.txt delete mode 100644 MyCPPMods/MyExampleMod/CMakeLists.txt delete mode 100644 MyCPPMods/MyExampleMod/src/dllmain.cpp delete mode 160000 RE-UE4SS create mode 100644 build_and_install_mod.bat delete mode 100644 build_mods_shipping.bat create mode 100644 dllmain_template.cpp delete mode 100644 generate_project_files.bat create mode 100644 new_mod_setup.bat create mode 100644 xmake_template.lua diff --git a/.gitignore b/.gitignore index 53f5ec2..f23fd7c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,6 @@ *.app BuildFiles/ -Output/ \ No newline at end of file +Output/ +build/ +.xmake/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e7734f3..0000000 --- a/.gitmodules +++ /dev/null @@ -1,5 +0,0 @@ -[submodule "RE-UE4SS"] - path = RE-UE4SS - url = https://github.com/UE4SS-RE/RE-UE4SS.git - branch = main - ignore = dirty diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index a678b51..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_minimum_required(VERSION 3.18) - -project(MyCPPMods) - -# requirements -add_subdirectory(RE-UE4SS) -add_subdirectory(MyCPPMods) diff --git a/MyCPPMods/CMakeLists.txt b/MyCPPMods/CMakeLists.txt deleted file mode 100644 index 5026b83..0000000 --- a/MyCPPMods/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(MyExampleMod) diff --git a/MyCPPMods/MyExampleMod/CMakeLists.txt b/MyCPPMods/MyExampleMod/CMakeLists.txt deleted file mode 100644 index a6f6564..0000000 --- a/MyCPPMods/MyExampleMod/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -cmake_minimum_required(VERSION 3.18) - -set(TARGET MyExampleMod) -project(${TARGET}) - -add_library(${TARGET} SHARED "src/dllmain.cpp") -target_include_directories(${TARGET} PRIVATE .) - -target_link_libraries(${TARGET} PRIVATE UE4SS) diff --git a/MyCPPMods/MyExampleMod/src/dllmain.cpp b/MyCPPMods/MyExampleMod/src/dllmain.cpp deleted file mode 100644 index 0739745..0000000 --- a/MyCPPMods/MyExampleMod/src/dllmain.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include -#include - -namespace MyMods -{ - using namespace RC; - using namespace Unreal; - - /** - * MyExampleMod: UE4SS c++ mod class defintion - */ - class MyExampleMod : public RC::CppUserModBase { - public: - - // constructor - MyExampleMod() { - ModVersion = STR("0.1"); - ModName = STR("MyExampleMod"); - ModAuthors = STR("UE4SS"); - ModDescription = STR("A basic template C++ mod"); - // Do not change this unless you want to target a UE4SS version - // other than the one you're currently building with somehow. - //ModIntendedSDKVersion = STR("2.6"); - - Output::send(STR("[MyExampleMod]: Init.\n")); - } - - // destructor - ~MyExampleMod() override { - // fill when required - } - - auto on_program_start() -> void override - { - } - - auto on_dll_load(std::wstring_view dll_name) -> void override - { - } - - auto on_unreal_init() -> void override - { - // You are allowed to use the 'Unreal' namespace in this function and anywhere else after this function has fired. - auto Object = UObjectGlobals::StaticFindObject(nullptr, nullptr, STR("/Script/CoreUObject.Object")); - Output::send(STR("Object Name: {}\n"), Object->GetFullName()); - } - - };//class -} - -/** -* export the start_mod() and uninstall_mod() functions to -* be used by the core ue4ss system to load in our dll mod -*/ -#define MOD_EXPORT __declspec(dllexport) -extern "C" { - MOD_EXPORT RC::CppUserModBase* start_mod(){ return new MyMods::MyExampleMod(); } - MOD_EXPORT void uninstall_mod(RC::CppUserModBase* mod) { delete mod; } -} - - - - - diff --git a/RE-UE4SS b/RE-UE4SS deleted file mode 160000 index ce074a9..0000000 --- a/RE-UE4SS +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ce074a9b8c411733cefa19fc00b0562d400e1914 diff --git a/README.md b/README.md index a03e1ce..352685a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,21 @@ # UE4SSCPPTemplate - + +To setup your project, run the following command in this directory, replacing "YourModName" with the name of your mod (no spaces or special characters, please!): + +```bash +.\new_mod_setup.bat YourModName +``` + +This will create a directory vsxmake2022 with a `.sln` file that you can open. + +Then, when you are ready to build and install your mod into your game, run the following command in this directory: + +```bash +.\build_and_install_mod.bat YourModName "Path\To\Your\Game\UE4SS\Install\Directory" Build__Configuration +``` + +For example: + +```bash +.\build_and_install_mod.bat MyAwesomeMod "C:\Program Files (x86)\Steam\steamapps\common\Deep Rock Galactic\FSD\Binaries\Win64" Game__Shipping__Win64 +``` \ No newline at end of file diff --git a/build_and_install_mod.bat b/build_and_install_mod.bat new file mode 100644 index 0000000..c5ee324 --- /dev/null +++ b/build_and_install_mod.bat @@ -0,0 +1,50 @@ +@echo off +setlocal + +:: Check for required arguments +if "%~1"=="" ( + echo Please provide the name of your mod as the first argument. + exit /b 1 +) +if "%~2"=="" ( + echo Please provide the path to the game's executable folder as the second argument. + exit /b 1 +) +if "%~3"=="" ( + echo Please provide the configuration. Example: Game__Shipping__Win64 + exit /b 1 +) + +:: Set variables +set MOD_NAME=%~1 +set GAME_EXECUTABLE_FOLDER=%~2 +set MODS_FOLDER=%GAME_EXECUTABLE_FOLDER%\Mods +set CONFIGURATION=%~3 + +:: Step 1: Build xmake +echo Running xmake... +xmake f -m "%CONFIGURATION%" --runtimes="MD" -y +xmake + +:: Step 2: Check if the build was successful +if not exist Output\%CONFIGURATION%\%MOD_NAME%\%MOD_NAME%.dll ( + echo Failed to build the mod. Please check the build output for errors. + exit /b 1 +) + +:: Step 3: Create mod directory structure in the game's Mods folder and move the DLL +echo Deploying the mod... +if not exist "%MODS_FOLDER%\%MOD_NAME%\dlls\" ( + mkdir "%MODS_FOLDER%\%MOD_NAME%\dlls\" +) +copy /Y "Output\%CONFIGURATION%\%MOD_NAME%\%MOD_NAME%.dll" "%MODS_FOLDER%\%MOD_NAME%\dlls\main.dll" + +:: Step 4: Create an enabled.txt file inside the mod folder +set ENABLED_TXT=%MODS_FOLDER%\%MOD_NAME%\enabled.txt +echo Creating enabled.txt... +echo.> "%ENABLED_TXT%" + +echo Mod deployment complete! Please launch your game to test the mod. + +:end +endlocal \ No newline at end of file diff --git a/build_mods_shipping.bat b/build_mods_shipping.bat deleted file mode 100644 index 6bc00c9..0000000 --- a/build_mods_shipping.bat +++ /dev/null @@ -1,5 +0,0 @@ -if not exist "BuildFiles" mkdir BuildFiles -cd BuildFiles -cmake -B Output -G"Visual Studio 17 2022" .. -cmake --build . --config Game__Shipping__Win64 -pause \ No newline at end of file diff --git a/dllmain_template.cpp b/dllmain_template.cpp new file mode 100644 index 0000000..bc84b1f --- /dev/null +++ b/dllmain_template.cpp @@ -0,0 +1,48 @@ +#include +#include +#include +#include + +using namespace RC; +using namespace RC::Unreal; + +class MyAwesomeMod : public CppUserModBase +{ +public: + MyAwesomeMod() : CppUserModBase() + { + ModName = STR("MyAwesomeMod"); + ModVersion = STR("1.0"); + ModDescription = STR("This is my awesome mod"); + ModAuthors = STR("UE4SS Team"); + // Do not change this unless you want to target a UE4SS version + // other than the one you're currently building with somehow. + //ModIntendedSDKVersion = STR("2.6"); + + Output::send(STR("MyAwesomeMod says hello\n")); + } + + ~MyAwesomeMod() override {} + + auto on_update() -> void override {} + + auto on_unreal_init() -> void override + { + auto Object = UObjectGlobals::StaticFindObject(nullptr, nullptr, STR("/Script/CoreUObject.Object")); + Output::send(STR("Object Name: {}\n"), Object->GetFullName()); + } +}; + +#define MY_AWESOME_MOD_API __declspec(dllexport) +extern "C" +{ + MY_AWESOME_MOD_API CppUserModBase* start_mod() + { + return new MyAwesomeMod(); + } + + MY_AWESOME_MOD_API void uninstall_mod(CppUserModBase* mod) + { + delete mod; + } +} diff --git a/generate_project_files.bat b/generate_project_files.bat deleted file mode 100644 index af7a471..0000000 --- a/generate_project_files.bat +++ /dev/null @@ -1,4 +0,0 @@ -if not exist "BuildFiles" mkdir BuildFiles -cd BuildFiles -cmake -G"Visual Studio 17 2022" .. -pause \ No newline at end of file diff --git a/new_mod_setup.bat b/new_mod_setup.bat new file mode 100644 index 0000000..46254e2 --- /dev/null +++ b/new_mod_setup.bat @@ -0,0 +1,63 @@ +@echo off +setlocal + +:: Check for required arguments +if "%~1"=="" ( + echo Please provide the name of your mod as the first argument. + exit /b 1 +) + +:: Set variables +set MOD_NAME=%~1 +set MOD_NAME_UPPER=%MOD_NAME% +call :ToUpper MOD_NAME_UPPER + +:ToUpper +if not defined %~1 EXIT /b +for %%a in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I" + "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R" + "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z" "ä=Ä" + "ö=Ö" "ü=Ü") do ( + call set %~1=%%%~1:%%~a%% +) + +:: Step 1: Clone the RE-UE4SS repository +echo Cloning RE-UE4SS repository... +git clone https://github.com/UE4SS-RE/RE-UE4SS.git +cd RE-UE4SS +echo Initializing submodules... +git submodule update --init --recursive +cd .. + +:: Step 2: Create mod directory and files +echo Creating mod directory and files... +mkdir %MOD_NAME% +cd %MOD_NAME% + +:: Create xmake.lua +echo Creating xmake.lua... +copy ..\xmake_template.lua xmake.lua +powershell -Command "(Get-Content xmake.lua) -replace 'MyAwesomeMod', '%MOD_NAME%' | Set-Content xmake.lua" + +:: Create dllmain.cpp +echo Creating dllmain.cpp... +copy ..\dllmain_template.cpp dllmain.cpp +powershell -Command "(Get-Content dllmain.cpp) -replace 'MyAwesomeMod', '%MOD_NAME%' | Set-Content dllmain.cpp" +powershell -Command "(Get-Content dllmain.cpp) -replace 'MY_AWESOME_MOD_API', '%MOD_NAME_UPPER%_API' | Set-Content dllmain.cpp" + +:: Return to MyMods directory +cd .. + +:: Step 3: Update the main xmake.lua +echo Updating the main xmake.lua... +echo includes("RE-UE4SS")> xmake.lua +echo includes("%MOD_NAME%")>> xmake.lua + +:: Step 4: Create VS solution +echo Creating VS solution... +xmake project -k vsxmake2022 -y + +echo Mod setup complete! + +:end +endlocal diff --git a/xmake_template.lua b/xmake_template.lua new file mode 100644 index 0000000..a127b24 --- /dev/null +++ b/xmake_template.lua @@ -0,0 +1,27 @@ +local projectName = "MyAwesomeMod" + +target(projectName) + set_kind("shared") + set_languages("cxx20") + set_exceptions("cxx") + + add_includedirs(".") + + add_files("dllmain.cpp") + + add_deps("UE4SS") + + on_load(function (target) + import("build_configs.build_configs", { rootdir = get_config("ue4ssRoot") }) + build_configs:set_output_dir(target) + end) + + on_config(function (target) + import("build_configs.build_configs", { rootdir = get_config("ue4ssRoot") }) + build_configs:config(target) + end) + + after_clean(function (target) + import("build_configs.build_configs", { rootdir = get_config("ue4ssRoot") }) + build_configs:clean_output_dir(target) + end) From 544e911eb0427eba58e1aab1d38aa52565f12017 Mon Sep 17 00:00:00 2001 From: Buckminsterfullerene02 Date: Thu, 29 Feb 2024 18:17:58 +0000 Subject: [PATCH 02/11] ignore re-ue4ss --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f23fd7c..94d3a89 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,5 @@ BuildFiles/ Output/ build/ -.xmake/ \ No newline at end of file +.xmake/ +RE-UE4SS/ \ No newline at end of file From 8f2236aa92392d5437ff2205eb4b53e3239fea6e Mon Sep 17 00:00:00 2001 From: Buckminsterfullerene02 Date: Thu, 29 Feb 2024 19:19:11 +0000 Subject: [PATCH 03/11] base xmake.lua, don't re-clone if already there only checkout latest release tag of main repo --- new_mod_setup.bat | 18 +++++++++++------- xmake.lua | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 xmake.lua diff --git a/new_mod_setup.bat b/new_mod_setup.bat index 46254e2..4616f74 100644 --- a/new_mod_setup.bat +++ b/new_mod_setup.bat @@ -21,12 +21,17 @@ for %%a in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I" call set %~1=%%%~1:%%~a%% ) -:: Step 1: Clone the RE-UE4SS repository -echo Cloning RE-UE4SS repository... -git clone https://github.com/UE4SS-RE/RE-UE4SS.git +:: Step 1: Initialise or update RE-UE4SS repository on the latest release tag +if not exist RE-UE4SS ( + echo Cloning RE-UE4SS repository... + git clone https://github.com/UE4SS-RE/RE-UE4SS.git +) + cd RE-UE4SS -echo Initializing submodules... -git submodule update --init --recursive +git fetch --tags +for /f "delims=" %%a in ('git tag -l --sort=-v:refname ^| head -n 1') do set LATEST_TAG=%%a +git checkout %LATEST_TAG% +git submodule update --init --recursive cd .. :: Step 2: Create mod directory and files @@ -49,8 +54,7 @@ powershell -Command "(Get-Content dllmain.cpp) -replace 'MY_AWESOME_MOD_API', '% cd .. :: Step 3: Update the main xmake.lua -echo Updating the main xmake.lua... -echo includes("RE-UE4SS")> xmake.lua +echo Adding mod to main xmake.lua... echo includes("%MOD_NAME%")>> xmake.lua :: Step 4: Create VS solution diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 0000000..7d1bc14 --- /dev/null +++ b/xmake.lua @@ -0,0 +1 @@ +includes("RE-UE4SS") From efc312b8915d49d9685a1ba7951e90f38c9eef4c Mon Sep 17 00:00:00 2001 From: Buckminsterfullerene02 Date: Thu, 29 Feb 2024 19:26:23 +0000 Subject: [PATCH 04/11] oops head isnt provided by default on windows --- new_mod_setup.bat | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/new_mod_setup.bat b/new_mod_setup.bat index 4616f74..6c15d46 100644 --- a/new_mod_setup.bat +++ b/new_mod_setup.bat @@ -29,7 +29,12 @@ if not exist RE-UE4SS ( cd RE-UE4SS git fetch --tags -for /f "delims=" %%a in ('git tag -l --sort=-v:refname ^| head -n 1') do set LATEST_TAG=%%a +for /f "delims=" %%a in ('git tag -l --sort=-v:refname') do ( + set LATEST_TAG=%%a + goto :checkout +) + +:checkout git checkout %LATEST_TAG% git submodule update --init --recursive cd .. From 68ebcc107d7a125bd8524f3a89d7dcbaed1d99ca Mon Sep 17 00:00:00 2001 From: Buckminsterfullerene02 Date: Sat, 6 Apr 2024 09:01:09 +0100 Subject: [PATCH 05/11] update for xmake branch changes --- README.md | 4 +++- build_and_install_mod.bat | 6 +++--- xmake_template.lua | 10 +++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 352685a..41acf6c 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,6 @@ For example: ```bash .\build_and_install_mod.bat MyAwesomeMod "C:\Program Files (x86)\Steam\steamapps\common\Deep Rock Galactic\FSD\Binaries\Win64" Game__Shipping__Win64 -``` \ No newline at end of file +``` + +If you want to delete a mod from your project, you can just delete the mod's folder and its entry in the root xmake.lua file. \ No newline at end of file diff --git a/build_and_install_mod.bat b/build_and_install_mod.bat index c5ee324..f6d1e95 100644 --- a/build_and_install_mod.bat +++ b/build_and_install_mod.bat @@ -23,11 +23,11 @@ set CONFIGURATION=%~3 :: Step 1: Build xmake echo Running xmake... -xmake f -m "%CONFIGURATION%" --runtimes="MD" -y +xmake f -m "%CONFIGURATION%" -y xmake :: Step 2: Check if the build was successful -if not exist Output\%CONFIGURATION%\%MOD_NAME%\%MOD_NAME%.dll ( +if not exist Binaries\%CONFIGURATION%\%MOD_NAME%\%MOD_NAME%.dll ( echo Failed to build the mod. Please check the build output for errors. exit /b 1 ) @@ -37,7 +37,7 @@ echo Deploying the mod... if not exist "%MODS_FOLDER%\%MOD_NAME%\dlls\" ( mkdir "%MODS_FOLDER%\%MOD_NAME%\dlls\" ) -copy /Y "Output\%CONFIGURATION%\%MOD_NAME%\%MOD_NAME%.dll" "%MODS_FOLDER%\%MOD_NAME%\dlls\main.dll" +copy /Y "Binaries\%CONFIGURATION%\%MOD_NAME%\%MOD_NAME%.dll" "%MODS_FOLDER%\%MOD_NAME%\dlls\main.dll" :: Step 4: Create an enabled.txt file inside the mod folder set ENABLED_TXT=%MODS_FOLDER%\%MOD_NAME%\enabled.txt diff --git a/xmake_template.lua b/xmake_template.lua index a127b24..743b3b3 100644 --- a/xmake_template.lua +++ b/xmake_template.lua @@ -12,16 +12,16 @@ target(projectName) add_deps("UE4SS") on_load(function (target) - import("build_configs.build_configs", { rootdir = get_config("ue4ssRoot") }) + import("build_configs", { rootdir = get_config("scriptsRoot") }) build_configs:set_output_dir(target) end) - + on_config(function (target) - import("build_configs.build_configs", { rootdir = get_config("ue4ssRoot") }) + import("build_configs", { rootdir = get_config("scriptsRoot") }) build_configs:config(target) end) - + after_clean(function (target) - import("build_configs.build_configs", { rootdir = get_config("ue4ssRoot") }) + import("build_configs", { rootdir = get_config("scriptsRoot") }) build_configs:clean_output_dir(target) end) From c8069ec5d4bce6105aa5da46c4958f5394e0a44f Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Fri, 12 Apr 2024 16:51:59 -0700 Subject: [PATCH 06/11] xmake lua helper scripts --- .gitignore | 7 +++- Mods/xmake.lua | 1 + Scripts/build_and_install.lua | 7 ++++ Scripts/install_mod.lua | 49 ++++++++++++++++++++++ Scripts/new_mod.lua | 63 ++++++++++++++++++++++++++++ Scripts/ue4ss_git.lua | 79 +++++++++++++++++++++++++++++++++++ Scripts/xmake.lua | 47 +++++++++++++++++++++ xmake.lua | 2 + 8 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 Mods/xmake.lua create mode 100644 Scripts/build_and_install.lua create mode 100644 Scripts/install_mod.lua create mode 100644 Scripts/new_mod.lua create mode 100644 Scripts/ue4ss_git.lua create mode 100644 Scripts/xmake.lua diff --git a/.gitignore b/.gitignore index 94d3a89..d65c822 100644 --- a/.gitignore +++ b/.gitignore @@ -31,8 +31,13 @@ *.out *.app +Binaries/ +Intermediates/ BuildFiles/ +vsxmake2022/ Output/ build/ .xmake/ -RE-UE4SS/ \ No newline at end of file +RE-UE4SS/ +Mods/* +!xmake.lua \ No newline at end of file diff --git a/Mods/xmake.lua b/Mods/xmake.lua new file mode 100644 index 0000000..c7becde --- /dev/null +++ b/Mods/xmake.lua @@ -0,0 +1 @@ +includes("*/xmake.lua") \ No newline at end of file diff --git a/Scripts/build_and_install.lua b/Scripts/build_and_install.lua new file mode 100644 index 0000000..f464264 --- /dev/null +++ b/Scripts/build_and_install.lua @@ -0,0 +1,7 @@ +import("core.base.option") +import("core.base.task") + +function main() + task.run("build", option.get("name"), "-y") + task.run("installmod", {exedir=option.get("exedir"), name=option.get("name")}) +end diff --git a/Scripts/install_mod.lua b/Scripts/install_mod.lua new file mode 100644 index 0000000..33b6077 --- /dev/null +++ b/Scripts/install_mod.lua @@ -0,0 +1,49 @@ +import("core.base.option") +import("core.base.task") +import("core.project.config") +import("core.project.project") + +function main() + -- validate? + local mod_name = option.get("name") + local mod_dir = path.join(option.get("exedir"), "Mods", mod_name) + + -- Get the current build mode. ex: Game__Shipping__Win64 + config.load() + local mode = config.get("mode") + print("Using the mode from xmake config: %s", mode) + + -- Load the dll location from the xmake target for the mod. + local target = project.target(mod_name) + + if not target then + print("Target %s not found.", mod_name) + os.exit() + end + + -- Step 1: Check if we have build output. + if not os.exists(target:targetfile()) then + print("Build output not detected at %s", target:targetfile()) + os.exit() + end + + -- Step 2: Copy to the mods folder. + local dll_dir = path.join(mod_dir, "dlls") + if not os.exists(dll_dir) then + print("%s not found. Creating...", dll_dir) + os.mkdir(dll_dir) + end + + os.cp(target:targetfile(), path.join(dll_dir, "main.dll")) + + if os.exists(target:symbolfile()) then + print("Symbol file detected. Copying to mod directory...") + os.cp(target:symbolfile(), path.join(dll_dir, "main.pdb")) + end + + -- Step 3: Create the enabled.txt in the mods folder. + if not os.exists(path.join(mod_dir, "enabled.txt")) then + print("enabled.txt not found. Creating...") + io.writefile(path.join(mod_dir, "enabled.txt")) + end +end \ No newline at end of file diff --git a/Scripts/new_mod.lua b/Scripts/new_mod.lua new file mode 100644 index 0000000..4772038 --- /dev/null +++ b/Scripts/new_mod.lua @@ -0,0 +1,63 @@ +import("core.base.option") +import("devel.git") +import("devel.git.submodule") +import("core.base.task") +import("detect.sdks.find_vstudio") +import("core.base.task") +import("core.base.semver") + +function main() + + -- validate? + local mod_name = option.get("name") + + if not mod_name then + print("Please specify a mod name.") + os.exit() + end + + -- Step 1: Initialise or update RE-UE4SS repository on the latest release tag. + if not os.exists(path.join("$(projectdir)", "RE-UE4SS")) then + print("UE4SS repository not yet cloned. Automatically cloning...") + task.run("ue4ss", {remote="latest"}) + end + + -- Step 2: Create mod directory and files. + local mods_dir = path.join("$(projectdir)", "Mods") + + if os.exists(mod_name) then + if option.get("regen") then + print("Regenerating mod directory and files.") + CreateModFiles(mod_name, mods_dir) + else + print("Mod directory already exists. Run with the --regen flag to regenerate mod files.") + os.exit() + end + else + CreateModFiles(mod_name, mods_dir) + end + + -- Step 3: Generate VS project if VS2022 is installed + local vs_versions = find_vstudio() + if(vs_versions and vs_versions["2022"]) then + -- Equivalent to xmake project -k vsxmake2022 -y + task.run("project", {kind="vsxmake2022", yes={nil}}) + end +end + +function CreateModFiles(mod_name, mods_dir) + print("Creating mod directory and files...") + local mod_dir = path.join(mods_dir, mod_name) + os.mkdir(mod_dir) + + local mod_xmake = path.join(mod_dir, "xmake.lua") + os.cp(path.join("$(projectdir)", "xmake_template.lua"), mod_xmake) + + io.replace(mod_xmake, "MyAwesomeMod", mod_name) + + local mod_cpp = path.join(mod_dir, "dllmain.cpp") + os.cp(path.join("$(projectdir)", "dllmain_template.cpp"), mod_cpp) + io.replace(mod_cpp, "MyAwesomeMod", mod_name) + io.replace(mod_cpp, "MY_AWESOME_MOD_API", string.upper(mod_name).."_API") +end + diff --git a/Scripts/ue4ss_git.lua b/Scripts/ue4ss_git.lua new file mode 100644 index 0000000..aa5822e --- /dev/null +++ b/Scripts/ue4ss_git.lua @@ -0,0 +1,79 @@ +import("core.base.option") +import("devel.git") +import("devel.git.submodule") +import("core.base.semver") + +local ue4ss_url = "https://github.com/UE4SS-RE/RE-UE4SS.git" +local ue4ss_dir = "RE-UE4SS" + +function main() + local remote = option.get("remote") + local update = option.get("update") + + if not (remote and update) then + print("No arguments. Run 'xmake ue4ss --help'") + os.exit() + end + + try_clone_ue4ss() + + -- Special handling if the user wants to find the 'latest' release tag. + if remote == "latest" then + print("Attempting to find latest release tag...") + local tags = git.tags(ue4ss_url) + local latest_tag + for _,tag in ipairs(tags) do + if semver.is_valid(tag) then + if not latest_tag then + latest_tag = tag + end + + if semver.compare(tag, latest_tag) == 1 then + latest_tag = tag + end + end + end + + -- Special logic to ensure we don't check out a tag that doesn't have xmake. + -- This would put the user's local repo into an unrecoverable state. + if latest_tag then + if not semver.satisfies(latest_tag, ">3.0.1") then + print("The latest tag %s is not compatible with xmake. Using 'main' branch instead of a tag.", latest_tag) + latest_tag = "main" + end + + print("Using latest tag: %s", latest_tag) + end + + remote = latest_tag + end + + -- Returns a matching version/tag/branch based on the provided "remote" string. + -- Uses semantic versioning or branch naming. + local remote, type = semver.select(remote, nil, git.tags(ue4ss_url), git.branches(ue4ss_url)) + if not remote then + print("%s was not found as a valid git remote.") + os.exit() + end + + git.checkout(remote,{repodir=ue4ss_dir}) + + if update then + -- If the user specifies a tag, then we don't need to pull/update. + local cur_branch = git.branch({repodir = ue4ss_dir}) + if cur_branch then + git.pull({remote = "origin", tags = true, repodir = ue4ss_dir}) + submodule.update({repodir = ue4ss_dir, recursive = true}) + else + print("UE4SS is not currently a branch. Update has no effect") + end + end +end + +function try_clone_ue4ss() + local ue4ss_dir = path.join("$(projectdir)", "RE-UE4SS") + if not os.exists(ue4ss_dir) then + print("Cloning UE4SS Repository...") + git.clone(ue4ss_url) + end +end \ No newline at end of file diff --git a/Scripts/xmake.lua b/Scripts/xmake.lua new file mode 100644 index 0000000..9041f4b --- /dev/null +++ b/Scripts/xmake.lua @@ -0,0 +1,47 @@ +task("ue4ss") + on_run("ue4ss_git") + set_menu { + usage = "xmake ue4ss [options]", + description = "Change the version of ue4ss that is fetched from github.", + options = + { + {'r', 'remote', "v", "main", "Tag/branch of UE4SS to use. Ex: 'latest', 'v3.0.1', 'experimental', 'main'"}, + {'u', 'update', "k", nil, "Fetches and downloads any remote changes. Only works when the --remote arg is a git branch."}, + } + } + +task("newmod") + on_run("new_mod") + set_menu { + usage = "xmake newmod [options] [modname]", + description = "Bootstrap a new mod", + options = + { + {'r', 'regen', "k", nil, "Forcibly regenerate the mod."}, + {nil, 'name', "v", nil, "Name of the new mod to create."}, + } + } + +task("installmod") + on_run("install_mod") + set_menu { + usage = "xmake installmod [options] [modname]", + description = "Installs a mod into the specified game directory.", + options = + { + {'d', 'exedir', "v", nil, "Path of the game's executable folder"}, + {nil, 'name', "v", nil, "Name of the mod to install."}, + } + } + +task("bi") + on_run("build_and_install") + set_menu { + usage = "xmake bi [options] [modname]", + description = "Build and install a mod. Equivalent to 'xmake build' followed by 'xmake installmod'", + options = + { + {'d', 'exedir', "v", nil, "Path of the game's executable folder"}, + {nil, 'name', "v", nil, "Name of the mod to build and install."}, + } + } \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index 7d1bc14..dbc9741 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1 +1,3 @@ includes("RE-UE4SS") +includes("Mods") +includes("Scripts") From 78fa654067cd68da3fe24ec5a6c867219684f262 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Fri, 12 Apr 2024 17:11:56 -0700 Subject: [PATCH 07/11] Updated readme --- README.md | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 41acf6c..a337ad0 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,42 @@ # UE4SSCPPTemplate -To setup your project, run the following command in this directory, replacing "YourModName" with the name of your mod (no spaces or special characters, please!): +This repository includes some custom `xmake` tasks to assist in your mod development. -```bash -.\new_mod_setup.bat YourModName -``` +- `xmake newmod` +- `xmake installmod` +- `xmake bi` +- `xmake ue4ss` -This will create a directory vsxmake2022 with a `.sln` file that you can open. +## `xmake newmod [-r, --regen] name` -Then, when you are ready to build and install your mod into your game, run the following command in this directory: +The `newmod` command will ensure you have the UE4SS repository cloned and then bootstrap new mod creation. -```bash -.\build_and_install_mod.bat YourModName "Path\To\Your\Game\UE4SS\Install\Directory" Build__Configuration -``` +Running `xmake newmod CoolMod` will generate `/Mods/CoolMod/...` in your repository and automatically link it with the xmake system. If you have VS2022 installed then the `newmod` command will also automatically generate a VS project which can be located at `/vsxmake2022/UE4SSCppTemplate.sln`. -For example: +## `xmake installmod [-d, --exedir] name` -```bash -.\build_and_install_mod.bat MyAwesomeMod "C:\Program Files (x86)\Steam\steamapps\common\Deep Rock Galactic\FSD\Binaries\Win64" Game__Shipping__Win64 -``` +The `installmod` command will copy your build output to a specific game directory. The configuration of the build you want to install is derived from the current xmake configuration. If you want to specify a specific configuration to install, then you can change the xmake configuration by running `xmake f -m "Game__Debug__Win64"`. -If you want to delete a mod from your project, you can just delete the mod's folder and its entry in the root xmake.lua file. \ No newline at end of file +Running `xmake installmod --exedir="Path\To\Your\Game\Dir" CoolMod` will copy the build output and install `CoolMod` in the correct subdir in the game's mod folder. + +Note that running `xmake installmod` does not automatically build your mod. You have to manually build it with `xmake build` or use the `xmake bi` task to build and install your mod. + +## `xmake bi [-d, --exedir] name` + +This is a shorthand task that will run `xmake build` followed by the `xmake installmod` command. This one-liner command facilitates rapid testing/iterating of your mod. + +## `xmake ue4ss [-r, --remote] [-u, --update]` + +By default, the `xmake newmod` command will attempt to checkout the latest release tag of UE4SS to build your mods against. If you want to build your mods against a different remote then you can specify a branch or tag as the `--remote=` parameter. + +`xmake ue4ss --remote="v3.0.1"` will attempt to use tag "v3.0.1" as the checked out UE4SS version. + +You can use the latest release tag by specifying `xmake ue4ss --remote="latest"`. + +You can also specify branches instead of tags to use. `xmake ue4ss --remote=main` will checkout the `main` branch of UE4SS. + +If you want to get upstream changes from remote branches then you can use the `--update` arg to pull remote changes. + +`xmake ue4ss --remote=main --update` will pull the latest remote changes from the `main` branch locally. + +You can also run `xmake ue4ss --update` and xmake will try to pull changes from whatever branch your local UE4SS is currently on. \ No newline at end of file From 1cba2c2f6d4ecce73e6a17de4fbb3abb36ae8bc1 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Sat, 13 Apr 2024 17:36:56 -0700 Subject: [PATCH 08/11] Small fixes --- README.md | 6 +-- Scripts/build_and_install.lua | 2 +- Scripts/ue4ss_git.lua | 43 +++++++++------------ Scripts/xmake.lua | 2 +- build_and_install_mod.bat | 50 ------------------------ new_mod_setup.bat | 72 ----------------------------------- 6 files changed, 24 insertions(+), 151 deletions(-) delete mode 100644 build_and_install_mod.bat delete mode 100644 new_mod_setup.bat diff --git a/README.md b/README.md index a337ad0..ae9610e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Running `xmake newmod CoolMod` will generate `/Mods/CoolMod/...` in your reposit ## `xmake installmod [-d, --exedir] name` -The `installmod` command will copy your build output to a specific game directory. The configuration of the build you want to install is derived from the current xmake configuration. If you want to specify a specific configuration to install, then you can change the xmake configuration by running `xmake f -m "Game__Debug__Win64"`. +The `installmod` command will copy your build output to a specific game directory. The configuration of the build you want to install is derived from the currently configured xmake mode (`xmake f -m `). This configured mode is global to the `RE-UE4SS` repo and all the mods in the `Mods` folder. If you want to specify a specific configuration to install, then you can change the xmake configuration by running `xmake f -m "Game__Debug__Win64"`. Running `xmake installmod --exedir="Path\To\Your\Game\Dir" CoolMod` will copy the build output and install `CoolMod` in the correct subdir in the game's mod folder. @@ -23,13 +23,13 @@ Note that running `xmake installmod` does not automatically build your mod. You ## `xmake bi [-d, --exedir] name` -This is a shorthand task that will run `xmake build` followed by the `xmake installmod` command. This one-liner command facilitates rapid testing/iterating of your mod. +This is a shorthand task that will run `xmake build -y ` followed by the `xmake installmod` command. This one-liner command facilitates rapid testing/iterating of your mod. ## `xmake ue4ss [-r, --remote] [-u, --update]` By default, the `xmake newmod` command will attempt to checkout the latest release tag of UE4SS to build your mods against. If you want to build your mods against a different remote then you can specify a branch or tag as the `--remote=` parameter. -`xmake ue4ss --remote="v3.0.1"` will attempt to use tag "v3.0.1" as the checked out UE4SS version. +`xmake ue4ss --remote="v3.1.0"` will attempt to use tag "v3.1.0" as the checked out UE4SS version. You can use the latest release tag by specifying `xmake ue4ss --remote="latest"`. diff --git a/Scripts/build_and_install.lua b/Scripts/build_and_install.lua index f464264..55c5c78 100644 --- a/Scripts/build_and_install.lua +++ b/Scripts/build_and_install.lua @@ -2,6 +2,6 @@ import("core.base.option") import("core.base.task") function main() - task.run("build", option.get("name"), "-y") + task.run("build", {yes=nil}, option.get("name")) task.run("installmod", {exedir=option.get("exedir"), name=option.get("name")}) end diff --git a/Scripts/ue4ss_git.lua b/Scripts/ue4ss_git.lua index aa5822e..1665cb1 100644 --- a/Scripts/ue4ss_git.lua +++ b/Scripts/ue4ss_git.lua @@ -10,12 +10,16 @@ function main() local remote = option.get("remote") local update = option.get("update") - if not (remote and update) then + if (remote == nil and update == nil) then print("No arguments. Run 'xmake ue4ss --help'") os.exit() end - - try_clone_ue4ss() + + local ue4ss_repo = path.join("$(projectdir)", ue4ss_dir) + if not os.exists(ue4ss_repo) then + print("Cloning UE4SS Repository...") + git.clone(ue4ss_url) + end -- Special handling if the user wants to find the 'latest' release tag. if remote == "latest" then @@ -33,18 +37,6 @@ function main() end end end - - -- Special logic to ensure we don't check out a tag that doesn't have xmake. - -- This would put the user's local repo into an unrecoverable state. - if latest_tag then - if not semver.satisfies(latest_tag, ">3.0.1") then - print("The latest tag %s is not compatible with xmake. Using 'main' branch instead of a tag.", latest_tag) - latest_tag = "main" - end - - print("Using latest tag: %s", latest_tag) - end - remote = latest_tag end @@ -55,7 +47,18 @@ function main() print("%s was not found as a valid git remote.") os.exit() end - + + if type == "tag" then + -- Special logic to ensure we don't check out a tag that doesn't have xmake. + -- This would put the user's local repo into an unrecoverable state. + if not semver.satisfies(remote, ">3.0.1") then + print("The latest tag %s is not compatible with xmake. Using 'main' branch instead of a tag.", remote) + remote = "main" + type = "branch" + end + end + + print("Checking out %s %s...", type, remote) git.checkout(remote,{repodir=ue4ss_dir}) if update then @@ -68,12 +71,4 @@ function main() print("UE4SS is not currently a branch. Update has no effect") end end -end - -function try_clone_ue4ss() - local ue4ss_dir = path.join("$(projectdir)", "RE-UE4SS") - if not os.exists(ue4ss_dir) then - print("Cloning UE4SS Repository...") - git.clone(ue4ss_url) - end end \ No newline at end of file diff --git a/Scripts/xmake.lua b/Scripts/xmake.lua index 9041f4b..90816d8 100644 --- a/Scripts/xmake.lua +++ b/Scripts/xmake.lua @@ -5,7 +5,7 @@ task("ue4ss") description = "Change the version of ue4ss that is fetched from github.", options = { - {'r', 'remote', "v", "main", "Tag/branch of UE4SS to use. Ex: 'latest', 'v3.0.1', 'experimental', 'main'"}, + {'r', 'remote', "v", "latest", "Tag/branch of UE4SS to use. Ex: 'latest', 'v3.0.1', 'experimental', 'main'"}, {'u', 'update', "k", nil, "Fetches and downloads any remote changes. Only works when the --remote arg is a git branch."}, } } diff --git a/build_and_install_mod.bat b/build_and_install_mod.bat deleted file mode 100644 index f6d1e95..0000000 --- a/build_and_install_mod.bat +++ /dev/null @@ -1,50 +0,0 @@ -@echo off -setlocal - -:: Check for required arguments -if "%~1"=="" ( - echo Please provide the name of your mod as the first argument. - exit /b 1 -) -if "%~2"=="" ( - echo Please provide the path to the game's executable folder as the second argument. - exit /b 1 -) -if "%~3"=="" ( - echo Please provide the configuration. Example: Game__Shipping__Win64 - exit /b 1 -) - -:: Set variables -set MOD_NAME=%~1 -set GAME_EXECUTABLE_FOLDER=%~2 -set MODS_FOLDER=%GAME_EXECUTABLE_FOLDER%\Mods -set CONFIGURATION=%~3 - -:: Step 1: Build xmake -echo Running xmake... -xmake f -m "%CONFIGURATION%" -y -xmake - -:: Step 2: Check if the build was successful -if not exist Binaries\%CONFIGURATION%\%MOD_NAME%\%MOD_NAME%.dll ( - echo Failed to build the mod. Please check the build output for errors. - exit /b 1 -) - -:: Step 3: Create mod directory structure in the game's Mods folder and move the DLL -echo Deploying the mod... -if not exist "%MODS_FOLDER%\%MOD_NAME%\dlls\" ( - mkdir "%MODS_FOLDER%\%MOD_NAME%\dlls\" -) -copy /Y "Binaries\%CONFIGURATION%\%MOD_NAME%\%MOD_NAME%.dll" "%MODS_FOLDER%\%MOD_NAME%\dlls\main.dll" - -:: Step 4: Create an enabled.txt file inside the mod folder -set ENABLED_TXT=%MODS_FOLDER%\%MOD_NAME%\enabled.txt -echo Creating enabled.txt... -echo.> "%ENABLED_TXT%" - -echo Mod deployment complete! Please launch your game to test the mod. - -:end -endlocal \ No newline at end of file diff --git a/new_mod_setup.bat b/new_mod_setup.bat deleted file mode 100644 index 6c15d46..0000000 --- a/new_mod_setup.bat +++ /dev/null @@ -1,72 +0,0 @@ -@echo off -setlocal - -:: Check for required arguments -if "%~1"=="" ( - echo Please provide the name of your mod as the first argument. - exit /b 1 -) - -:: Set variables -set MOD_NAME=%~1 -set MOD_NAME_UPPER=%MOD_NAME% -call :ToUpper MOD_NAME_UPPER - -:ToUpper -if not defined %~1 EXIT /b -for %%a in ("a=A" "b=B" "c=C" "d=D" "e=E" "f=F" "g=G" "h=H" "i=I" - "j=J" "k=K" "l=L" "m=M" "n=N" "o=O" "p=P" "q=Q" "r=R" - "s=S" "t=T" "u=U" "v=V" "w=W" "x=X" "y=Y" "z=Z" "ä=Ä" - "ö=Ö" "ü=Ü") do ( - call set %~1=%%%~1:%%~a%% -) - -:: Step 1: Initialise or update RE-UE4SS repository on the latest release tag -if not exist RE-UE4SS ( - echo Cloning RE-UE4SS repository... - git clone https://github.com/UE4SS-RE/RE-UE4SS.git -) - -cd RE-UE4SS -git fetch --tags -for /f "delims=" %%a in ('git tag -l --sort=-v:refname') do ( - set LATEST_TAG=%%a - goto :checkout -) - -:checkout -git checkout %LATEST_TAG% -git submodule update --init --recursive -cd .. - -:: Step 2: Create mod directory and files -echo Creating mod directory and files... -mkdir %MOD_NAME% -cd %MOD_NAME% - -:: Create xmake.lua -echo Creating xmake.lua... -copy ..\xmake_template.lua xmake.lua -powershell -Command "(Get-Content xmake.lua) -replace 'MyAwesomeMod', '%MOD_NAME%' | Set-Content xmake.lua" - -:: Create dllmain.cpp -echo Creating dllmain.cpp... -copy ..\dllmain_template.cpp dllmain.cpp -powershell -Command "(Get-Content dllmain.cpp) -replace 'MyAwesomeMod', '%MOD_NAME%' | Set-Content dllmain.cpp" -powershell -Command "(Get-Content dllmain.cpp) -replace 'MY_AWESOME_MOD_API', '%MOD_NAME_UPPER%_API' | Set-Content dllmain.cpp" - -:: Return to MyMods directory -cd .. - -:: Step 3: Update the main xmake.lua -echo Adding mod to main xmake.lua... -echo includes("%MOD_NAME%")>> xmake.lua - -:: Step 4: Create VS solution -echo Creating VS solution... -xmake project -k vsxmake2022 -y - -echo Mod setup complete! - -:end -endlocal From 395f5980be1a58d56c299c0a68ff7f39489bc2c2 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Sat, 13 Apr 2024 17:44:15 -0700 Subject: [PATCH 09/11] Allow for submod update for first time run --- Scripts/ue4ss_git.lua | 69 ++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/Scripts/ue4ss_git.lua b/Scripts/ue4ss_git.lua index 1665cb1..c59e1b3 100644 --- a/Scripts/ue4ss_git.lua +++ b/Scripts/ue4ss_git.lua @@ -21,54 +21,57 @@ function main() git.clone(ue4ss_url) end - -- Special handling if the user wants to find the 'latest' release tag. - if remote == "latest" then - print("Attempting to find latest release tag...") - local tags = git.tags(ue4ss_url) - local latest_tag - for _,tag in ipairs(tags) do - if semver.is_valid(tag) then - if not latest_tag then - latest_tag = tag - end + if remote then + -- Special handling if the user wants to find the 'latest' release tag. + if remote == "latest" then + print("Attempting to find latest release tag...") + local tags = git.tags(ue4ss_url) + local latest_tag + for _,tag in ipairs(tags) do + if semver.is_valid(tag) then + if not latest_tag then + latest_tag = tag + end - if semver.compare(tag, latest_tag) == 1 then - latest_tag = tag + if semver.compare(tag, latest_tag) == 1 then + latest_tag = tag + end end end + remote = latest_tag end - remote = latest_tag - end - -- Returns a matching version/tag/branch based on the provided "remote" string. - -- Uses semantic versioning or branch naming. - local remote, type = semver.select(remote, nil, git.tags(ue4ss_url), git.branches(ue4ss_url)) - if not remote then - print("%s was not found as a valid git remote.") - os.exit() - end + -- Returns a matching version/tag/branch based on the provided "remote" string. + -- Uses semantic versioning or branch naming. + local remote, type = semver.select(remote, nil, git.tags(ue4ss_url), git.branches(ue4ss_url)) + if not remote then + print("%s was not found as a valid git remote.") + os.exit() + end - if type == "tag" then - -- Special logic to ensure we don't check out a tag that doesn't have xmake. - -- This would put the user's local repo into an unrecoverable state. - if not semver.satisfies(remote, ">3.0.1") then - print("The latest tag %s is not compatible with xmake. Using 'main' branch instead of a tag.", remote) - remote = "main" - type = "branch" + if type == "tag" then + -- Special logic to ensure we don't check out a tag that doesn't have xmake. + -- This would put the user's local repo into an unrecoverable state. + if not semver.satisfies(remote, ">3.0.1") then + print("The latest tag %s is not compatible with xmake. Using 'main' branch instead of a tag.", remote) + remote = "main" + type = "branch" + end end - end - print("Checking out %s %s...", type, remote) - git.checkout(remote,{repodir=ue4ss_dir}) + print("Checking out %s %s...", type, remote) + git.checkout(remote,{repodir=ue4ss_dir}) + end if update then -- If the user specifies a tag, then we don't need to pull/update. local cur_branch = git.branch({repodir = ue4ss_dir}) if cur_branch then git.pull({remote = "origin", tags = true, repodir = ue4ss_dir}) - submodule.update({repodir = ue4ss_dir, recursive = true}) else - print("UE4SS is not currently a branch. Update has no effect") + print("UE4SS is not currently a branch. No remote changes to pull.") end + + submodule.update({repodir = ue4ss_dir, recursive = true}) end end \ No newline at end of file From d07d24bc9523a2288671a84f43efeb985cdea576 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Sat, 13 Apr 2024 17:46:17 -0700 Subject: [PATCH 10/11] Specify update flag for first time run --- Scripts/new_mod.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/new_mod.lua b/Scripts/new_mod.lua index 4772038..0657132 100644 --- a/Scripts/new_mod.lua +++ b/Scripts/new_mod.lua @@ -19,7 +19,7 @@ function main() -- Step 1: Initialise or update RE-UE4SS repository on the latest release tag. if not os.exists(path.join("$(projectdir)", "RE-UE4SS")) then print("UE4SS repository not yet cloned. Automatically cloning...") - task.run("ue4ss", {remote="latest"}) + task.run("ue4ss", {remote="latest", update=nil}) end -- Step 2: Create mod directory and files. From 0c3af4b0bdaaafaf70f56da28bfb8b2a59992158 Mon Sep 17 00:00:00 2001 From: George Higashiyama Date: Sat, 13 Apr 2024 18:10:52 -0700 Subject: [PATCH 11/11] Pass the xmake task bool args correctly --- Scripts/build_and_install.lua | 2 +- Scripts/new_mod.lua | 4 ++-- Scripts/ue4ss_git.lua | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Scripts/build_and_install.lua b/Scripts/build_and_install.lua index 55c5c78..09d6b05 100644 --- a/Scripts/build_and_install.lua +++ b/Scripts/build_and_install.lua @@ -2,6 +2,6 @@ import("core.base.option") import("core.base.task") function main() - task.run("build", {yes=nil}, option.get("name")) + task.run("build", {yes={}}, option.get("name")) task.run("installmod", {exedir=option.get("exedir"), name=option.get("name")}) end diff --git a/Scripts/new_mod.lua b/Scripts/new_mod.lua index 0657132..5695fd3 100644 --- a/Scripts/new_mod.lua +++ b/Scripts/new_mod.lua @@ -19,7 +19,7 @@ function main() -- Step 1: Initialise or update RE-UE4SS repository on the latest release tag. if not os.exists(path.join("$(projectdir)", "RE-UE4SS")) then print("UE4SS repository not yet cloned. Automatically cloning...") - task.run("ue4ss", {remote="latest", update=nil}) + task.run("ue4ss", {update={}, remote="latest"}) end -- Step 2: Create mod directory and files. @@ -41,7 +41,7 @@ function main() local vs_versions = find_vstudio() if(vs_versions and vs_versions["2022"]) then -- Equivalent to xmake project -k vsxmake2022 -y - task.run("project", {kind="vsxmake2022", yes={nil}}) + task.run("project", {kind="vsxmake2022", yes={}}) end end diff --git a/Scripts/ue4ss_git.lua b/Scripts/ue4ss_git.lua index c59e1b3..90447f6 100644 --- a/Scripts/ue4ss_git.lua +++ b/Scripts/ue4ss_git.lua @@ -72,6 +72,7 @@ function main() print("UE4SS is not currently a branch. No remote changes to pull.") end - submodule.update({repodir = ue4ss_dir, recursive = true}) + print("Updating submodule") + submodule.update({repodir = ue4ss_dir, recursive = true, init=true}) end end \ No newline at end of file