Skip to content

Commit

Permalink
Merge branch 'master' into pd-upscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Apr 1, 2024
2 parents f042c9a + 5158530 commit 7bc0105
Show file tree
Hide file tree
Showing 31 changed files with 1,541 additions and 340 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ jobs:
target: [RE2, RE2_TDB66, RE3, RE3_TDB67, RE4, RE7, RE7_TDB49, RE8, DMC5, MHRISE, SF6, DD2]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
submodules: recursive
fetch-depth: 0

- name: Configure CMake
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DDEVELOPER_MODE=ON
Expand All @@ -34,7 +35,7 @@ jobs:
7z rn ${{github.workspace}}/${{matrix.target}}.zip scripts reframework/autorun
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
with:
name: ${{matrix.target}}
path: ${{github.workspace}}/${{matrix.target}}.zip
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ src/sdk/generated
cmake-build*
.idea/
build_vs2019_devmode_DMC5.bat
src/CommitHash.autogenerated
93 changes: 90 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(ASMJIT_STATIC ON CACHE BOOL "" FORCE)
set(DYNAMIC_LOADER ON CACHE BOOL "" FORCE) # OpenXR
set(BUILD_TOOLS OFF CACHE BOOL "" FORCE) # DirectXTK
set(SAFETYHOOK_FETCH_ZYDIS ON)

if ("${CMAKE_BUILD_TYPE}" MATCHES "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT")
Expand Down Expand Up @@ -113,6 +114,16 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(directxtk12)

message(STATUS "Fetching safetyhook (44200343bf803f78862426e301e9382e5b28ea2c)...")
FetchContent_Declare(
safetyhook
GIT_REPOSITORY
https://github.com/cursey/safetyhook
GIT_TAG
44200343bf803f78862426e301e9382e5b28ea2c
)
FetchContent_MakeAvailable(safetyhook)

message(STATUS "Fetching bddisasm (v1.34.10)...")
FetchContent_Declare(
bddisasm
Expand Down Expand Up @@ -525,12 +536,15 @@ set(CMKR_TARGET utility)
set(utility_SOURCES "")

list(APPEND utility_SOURCES
"shared/utility/Exceptions.cpp"
"shared/utility/FunctionHook.cpp"
"shared/utility/FunctionHookMinHook.cpp"
"shared/utility/Relocate.cpp"
"shared/utility/Exceptions.hpp"
"shared/utility/FunctionHook.hpp"
"shared/utility/Profiler.hpp"
"shared/utility/Relocate.hpp"
"shared/utility/ScopeGuard.hpp"
"shared/utility/Profiler.hpp"
)

list(APPEND utility_SOURCES
Expand All @@ -557,6 +571,7 @@ target_compile_options(utility PUBLIC
target_link_libraries(utility PUBLIC
spdlog
minhook
safetyhook
kananlib
)

Expand Down Expand Up @@ -2454,6 +2469,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -2658,6 +2679,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -4553,6 +4580,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -4757,6 +4790,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -4961,6 +5000,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -7703,6 +7748,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -7907,6 +7958,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -8958,6 +9015,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -10007,6 +10070,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -11058,6 +11127,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -12109,6 +12184,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -13160,6 +13241,12 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
"${CMAKE_BINARY_DIR}/lib/${CMKR_TARGET}"
)

add_custom_command(
TARGET ${CMKR_TARGET} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Generating commit hash..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/MakeCommitHash.bat
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)
endif()
Expand Down Expand Up @@ -13201,7 +13288,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${example_plugin_SOURCES})

target_compile_features(example_plugin PUBLIC
cxx_std_20
cxx_std_23
)

target_include_directories(example_plugin PUBLIC
Expand Down Expand Up @@ -13256,7 +13343,7 @@ if(REF_BUILD_FRAMEWORK AND CMAKE_SIZEOF_VOID_P EQUAL 8) # build-framework
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${weapon_stay_big_plugin_SOURCES})

target_compile_features(weapon_stay_big_plugin PUBLIC
cxx_std_20
cxx_std_23
)

target_include_directories(weapon_stay_big_plugin PUBLIC
Expand Down
26 changes: 0 additions & 26 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
{
"version": 2,
"configurePresets": [
{
"name": "vs2019",
"displayName": "Visual Studio 2019 - amd64",
"description": "Using compilers for Visual Studio 16 2019 (x64 architecture)",
"generator": "Visual Studio 16 2019",
"toolset": "host=x64",
"architecture": "x64",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/"
}
},
{
"name": "vs2022",
"displayName": "Visual Studio 2022 - amd64",
Expand All @@ -27,20 +15,6 @@
}
],
"buildPresets": [
{
"name": "Release 2019",
"description": "",
"displayName": "Release",
"configuration": "Release",
"configurePreset": "vs2019"
},
{
"name": "RelWithDebInfo 2019",
"description": "",
"displayName": "RelWithDebInfo",
"configuration": "RelWithDebInfo",
"configurePreset": "vs2019"
},
{
"name": "Release 2022",
"description": "",
Expand Down
58 changes: 58 additions & 0 deletions COMPILING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Compiling REFramework

## Necessary prerequisites

A C++23 compatible compiler is required. Visual Studio 2022 is recommended. Compilers other than MSVC have not been tested.

CMake is required.

## Compiling

### Clone the repository

#### SSH
```
git clone [email protected]:praydog/REFramework.git
```

#### HTTPS
```
git clone https://github.com/praydog/REFramework
```

### Initialize the submodules

```
git submodule update --init --recursive
```

### Set up CMake

#### Command line

```
cmake -S . -B build ./build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
cmake --build ./build --config Release
```

Keep in mind that not supplying a target will build multiple targets, when you may only need one of them.

For example, to build only the RE2 target, you can use the following command:

```
cmake --build ./build --config Release --target RE2
```

#### VSCode

1. Install the [CMake Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools) extension
2. Open the REFramework folder in VSCode
3. Press `Ctrl+Shift+P` and select `CMake: Configure`
4. When "Select a kit" appears, select `Visual Studio Community 2022 Release - amd64`
5. Select the desired build config (usually `Release` or `RelWithDebInfo`) near the bottom of the window
6. Select the desired build target near the bottom of the window, otherwise all targets will be built
6. You should now be able to compile REFramework by pressing `Ctrl+Shift+P` and selecting `CMake: Build` or by pressing `F7`

#### Batch script

In the root of the repository there is a `build_vs2022.bat` script that will build all targets in Release mode.
41 changes: 41 additions & 0 deletions MakeCommitHash.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@echo off

IF EXIST "src/CommitHash.autogenerated" (
echo The file "src/CommitHash.autogenerated" already exists.
exit /b 0
)

FOR /F "tokens=*" %%g IN ('git rev-parse HEAD') DO (SET REF_COMMIT_HASH=%%g)

FOR /F "tokens=*" %%t IN ('git describe --tags --abbrev^=0') DO (SET REF_TAG=%%t)

FOR /F "tokens=*" %%c IN ('git describe --tags --long') DO (
FOR /F "tokens=1,2 delims=-" %%a IN ("%%c") DO (
SET REF_TAG_LONG=%%a
SET REF_COMMITS_PAST_TAG=%%b
)
)

FOR /F "tokens=*" %%b IN ('git rev-parse --abbrev-ref HEAD') DO (SET REF_BRANCH=%%b)

FOR /F "tokens=*" %%n IN ('git rev-list --count HEAD') DO (SET REF_TOTAL_COMMITS=%%n)

FOR /F "tokens=2 delims==" %%a IN ('wmic OS get localdatetime /value') DO (
SET datetime=%%a
)

SET year=%datetime:~0,4%
SET month=%datetime:~4,2%
SET day=%datetime:~6,2%
SET hour=%datetime:~8,2%
SET minute=%datetime:~10,2%

echo #pragma once > src/CommitHash.autogenerated
echo #define REF_COMMIT_HASH "%REF_COMMIT_HASH%" >> src/CommitHash.autogenerated
echo #define REF_TAG "%REF_TAG%" >> src/CommitHash.autogenerated
echo #define REF_TAG_LONG "%REF_TAG_LONG%" >> src/CommitHash.autogenerated
echo #define REF_COMMITS_PAST_TAG %REF_COMMITS_PAST_TAG% >> src/CommitHash.autogenerated
echo #define REF_BRANCH "%REF_BRANCH%" >> src/CommitHash.autogenerated
echo #define REF_TOTAL_COMMITS %REF_TOTAL_COMMITS% >> src/CommitHash.autogenerated
echo #define REF_BUILD_DATE "%day%.%month%.%year%" >> src/CommitHash.autogenerated
echo #define REF_BUILD_TIME "%hour%:%minute%" >> src/CommitHash.autogenerated
Loading

0 comments on commit 7bc0105

Please sign in to comment.