Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from michael-r-elp/master
Update to 1.21.0/1.22.0
- Loading branch information
Showing
16 changed files
with
607 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,4 +58,6 @@ Android.mk.backup | |
/log_timestamp | ||
|
||
TestBuild.ps1 | ||
TestQMOD.ps1 | ||
TestQMOD.ps1 | ||
/build | ||
*.cmake |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# include some defines automatically made by qpm | ||
include(qpm_defines.cmake) | ||
|
||
# override mod id | ||
# set(MOD_ID "QuestSounds") | ||
|
||
# Enable link time optimization | ||
# In my experience, this can be highly unstable but it nets a huge size optimization and likely performance | ||
# However, the instability was seen using Android.mk/ndk-build builds. With Ninja + CMake, this problem seems to have been solved. | ||
# As always, test thoroughly | ||
# - Fern | ||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) | ||
|
||
cmake_minimum_required(VERSION 3.21) | ||
project(${COMPILE_ID}) | ||
|
||
# c++ standard | ||
set(CMAKE_CXX_STANDARD 20) | ||
set(CMAKE_CXX_STANDARD_REQUIRED 20) | ||
|
||
# define that stores the actual source directory | ||
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
# compile options used | ||
add_compile_options(-frtti -fexceptions) | ||
add_compile_options(-Ofast) | ||
# compile definitions used | ||
add_compile_definitions(VERSION=\"${MOD_VERSION}\") | ||
add_compile_definitions(ID=\"${MOD_ID}\") | ||
add_compile_definitions(MOD_ID=\"${MOD_ID}\") | ||
add_compile_definitions(USE_CODEGEN_FIELDS) | ||
|
||
# BeatTogether compile definitions | ||
if (NOT DEFINED HOST_NAME OR NOT DEFINED STATUS_URL) | ||
add_compile_definitions(HOST_NAME=\"master.beattogether.systems\") | ||
add_compile_definitions(PORT=2328) | ||
add_compile_definitions(STATUS_URL=\"http://master.beattogether.systems/status\") | ||
message(STATUS "Using Server master.beattogether.systems:2328 with StatusUrl \"http://master.beattogether.systems/status\"") | ||
elseif (NOT DEFINED ${PORT}) | ||
add_compile_definitions(HOST_NAME=\"${HOST_NAME}\") | ||
add_compile_definitions(STATUS_URL=\"${STATUS_URL}\") | ||
add_compile_definitions(PORT=2328) | ||
message(AUTHOR_WARNING "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nOverriding default Server to ${HOST_NAME}:2328 with StatusUrl ${STATUS_URL}\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n") | ||
else() | ||
add_compile_definitions(HOST_NAME=\"${HOST_NAME}\") | ||
add_compile_definitions(STATUS_URL=\"${STATUS_URL}\") | ||
add_compile_definitions(PORT=${PORT}) | ||
message(AUTHOR_WARNING "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nOverriding default Server to ${HOST_NAME}:${PORT} with StatusUrl ${STATUS_URL}\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n") | ||
endif() | ||
|
||
|
||
# recursively get all src files | ||
RECURSE_FILES(cpp_file_list ${SOURCE_DIR}/*.cpp) | ||
RECURSE_FILES(c_file_list ${SOURCE_DIR}/*.c) | ||
|
||
# add all src files to compile | ||
add_library( | ||
${COMPILE_ID} | ||
SHARED | ||
${cpp_file_list} | ||
${c_file_list} | ||
) | ||
|
||
target_include_directories(${COMPILE_ID} PRIVATE .) | ||
|
||
target_include_directories(${COMPILE_ID} PRIVATE extern/includes/questui_components) | ||
|
||
# add src dir as include dir | ||
target_include_directories(${COMPILE_ID} PRIVATE ${SOURCE_DIR}) | ||
# add include dir as include dir | ||
target_include_directories(${COMPILE_ID} PRIVATE ${INCLUDE_DIR}) | ||
# add shared dir as include dir | ||
target_include_directories(${COMPILE_ID} PUBLIC ${SHARED_DIR}) | ||
# codegen includes | ||
target_include_directories(${COMPILE_ID} PRIVATE ${EXTERN_DIR}/includes/${CODEGEN_ID}/include) | ||
|
||
target_link_libraries(${COMPILE_ID} PRIVATE -llog) | ||
# add extern stuff like libs and other includes | ||
include(extern.cmake) | ||
|
||
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD | ||
COMMAND ${CMAKE_STRIP} -d --strip-all | ||
"lib${COMPILE_ID}.so" -o "stripped_lib${COMPILE_ID}.so" | ||
COMMENT "Strip debug symbols done on final binary.") | ||
|
||
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E make_directory debug | ||
COMMENT "Make directory for debug symbols" | ||
) | ||
|
||
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E rename lib${COMPILE_ID}.so debug/lib${COMPILE_ID}.so | ||
COMMENT "Rename the lib to debug_ since it has debug symbols" | ||
) | ||
|
||
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so | ||
COMMENT "Rename the stripped lib to regular" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "arm64-v8a-Debug", | ||
"generator": "Ninja", | ||
"configurationType": "RelWithDebInfo", | ||
"inheritEnvironments": [ "linux_arm" ], | ||
"buildRoot": "${projectDir}\\build", | ||
"installRoot": "${projectDir}\\out\\install\\${name}", | ||
"cmakeExecutable": "C:\\Program Files\\CMake\\bin\\cmake.exe", | ||
"cmakeCommandArgs": "", | ||
"buildCommandArgs": "", | ||
"ctestCommandArgs": "", | ||
"cmakeToolchain": "F:/BS-Modding/android-ndk-r24-beta1/build/cmake/android.toolchain.cmake", | ||
"variables": [ | ||
{ | ||
"name": "CMAKE_MAKE_PROGRAM", | ||
"value": "C:\\Program Files\\Meson\\ninja.EXE", | ||
"type": "FILEPATH" | ||
}, | ||
{ | ||
"name": "CMAKE_C_COMPILER", | ||
"value": "F:\\BS-Modding\\android-ndk-r24-beta1\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\clang.exe", | ||
"type": "FILEPATH" | ||
}, | ||
{ | ||
"name": "CMAKE_CXX_COMPILER", | ||
"value": "F:\\BS-Modding\\android-ndk-r24-beta1\\toolchains\\llvm\\prebuilt\\windows-x86_64\\bin\\clang++.exe", | ||
"type": "FILEPATH" | ||
} | ||
], | ||
"intelliSenseMode": "android-clang-arm64" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Param ( | ||
[Parameter(Mandatory=$false, HelpMessage="The version the mod should be compiled with")][Alias("ver")][string]$Version, | ||
[Parameter(Mandatory=$false, HelpMessage="Switch to create a clean compilation")][Alias("rebuild")][Switch]$clean, | ||
[Parameter(Mandatory=$false, HelpMessage="To create a release build")][Alias("publish")][Switch]$release, | ||
[Parameter(Mandatory=$false, HelpMessage="To create a github actions build, assumes specific Environment variables are set")][Alias("github-build")][Switch]$actions | ||
) | ||
|
||
# The following is an example build file that overwrites the default hostname and status url | ||
|
||
$NDKPath = Get-Content $PSScriptRoot/ndkpath.txt | ||
$QPMpackage = "./qpm.json" | ||
$qpmjson = Get-Content $QPMpackage -Raw | ConvertFrom-Json | ||
$ModID = $qpmjson.info.id | ||
$VERSION = $qpmjson.info.version | ||
if (-not $VERSION.Contains("-Test")) { | ||
$VERSION += "-Test" | ||
} | ||
& qpm-rust package edit --version $VERSION | ||
|
||
|
||
if ((Test-Path "./extern/includes/beatsaber-hook/src/inline-hook/And64InlineHook.cpp", "./extern/includes/beatsaber-hook/src/inline-hook/inlineHook.c", "./extern/includes/beatsaber-hook/src/inline-hook/relocate.c") -contains $false) { | ||
Write-Host "Critical: Missing inline-hook" | ||
if (!(Test-Path "./extern/includes/beatsaber-hook/src/inline-hook/And64InlineHook.cpp")) { | ||
Write-Host "./extern/includes/beatsaber-hook/src/inline-hook/And64InlineHook.cpp" | ||
} | ||
if (!(Test-Path "./extern/includes/beatsaber-hook/src/inline-hook/inlineHook.c")) { | ||
Write-Host "./extern/includes/beatsaber-hook/src/inline-hook/inlineHook.c" | ||
} | ||
if (!(Test-Path "./extern/includes/beatsaber-hook/inline-hook/src/relocate.c")) { | ||
Write-Host "./extern/includes/beatsaber-hook/src/inline-hook/relocate.c" | ||
} | ||
Write-Host "Task Failed, see output above" | ||
exit 1; | ||
} | ||
echo "Building mod $ModID version $VERSION" | ||
|
||
if ($clean.IsPresent) | ||
{ | ||
if (Test-Path -Path "build") | ||
{ | ||
remove-item build -R | ||
} | ||
} | ||
|
||
if (($clean.IsPresent) -or (-not (Test-Path -Path "build"))) | ||
{ | ||
$out = new-item -Path build -ItemType Directory | ||
} | ||
|
||
cd build | ||
# For overwriting the hostname and status url | ||
& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DHOST_NAME="YOUR_SERVER_HOSTNAME" -DSTATUS_URL="http://YOUR_STATUS_URL" ../ | ||
# If you also need to overwrite the port use the following line instead | ||
# & cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DHOST_NAME="YOUR_SERVER_HOSTNAME" -DSTATUS_URL="http://YOUR_STATUS_URL" -DPORT=2328 ../ | ||
& cmake --build . -j 6 | ||
$ExitCode = $LastExitCode | ||
cd .. | ||
exit $ExitCode | ||
echo Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
Param( | ||
[Parameter(Mandatory=$false, HelpMessage="The name the output qmod file should have")][String] $qmodname="", | ||
|
||
[Parameter(Mandatory=$false, HelpMessage="Switch to create a clean compilation")] | ||
[Alias("rebuild")] | ||
[Switch] $clean, | ||
|
||
[Parameter(Mandatory=$false, HelpMessage="Prints the help instructions")] | ||
[Switch] $help, | ||
|
||
[Parameter(Mandatory=$false, HelpMessage="Tells the script to not compile and only package the existing files")] | ||
[Alias("actions", "pack")] | ||
[Switch] $package | ||
) | ||
|
||
# Builds a .qmod file for loading with QP or BMBF | ||
|
||
# This is an example qmod script that will build a qmod using our ExampleBuild.ps1 script | ||
# Replace line 37 with the name of the script you want to use | ||
|
||
if ($help -eq $true) { | ||
echo "`"BuildQmod <qmodName>`" - Copiles your mod into a `".so`" or a `".a`" library" | ||
echo "`n-- Parameters --`n" | ||
echo "qmodName `t The file name of your qmod" | ||
|
||
echo "`n-- Arguments --`n" | ||
|
||
echo "-clean `t`t Performs a clean build on both your library and the qmod" | ||
echo "-help `t`t Prints this" | ||
echo "-package `t Only packages existing files, without recompiling`n" | ||
|
||
exit | ||
} | ||
|
||
echo "Creating QMod" | ||
# Replace ExampleBuild.ps1 with the name of your build script | ||
& $PSScriptRoot/ExampleBuild.ps1 -clean:$clean | ||
|
||
if ($LASTEXITCODE -ne 0) { | ||
echo "Failed to build, exiting..." | ||
exit $LASTEXITCODE | ||
} | ||
|
||
qpm-rust qmod build | ||
|
||
echo "Creating qmod from mod.json" | ||
|
||
$mod = "./mod.json" | ||
$modJson = Get-Content $mod -Raw | ConvertFrom-Json | ||
|
||
if ($qmodName -eq "") | ||
{ | ||
$qmodName = "$($modJson.name)_$($modJson.version)" | ||
} | ||
|
||
$filelist = @($mod) | ||
|
||
$cover = "./" + $modJson.coverImage | ||
if ((-not ($cover -eq "./")) -and (Test-Path $cover)) | ||
{ | ||
$filelist += ,$cover | ||
} else { | ||
echo "No cover Image found" | ||
} | ||
|
||
foreach ($mod in $modJson.modFiles) | ||
{ | ||
$path = "./build/" + $mod | ||
if (-not (Test-Path $path)) | ||
{ | ||
$path = "./extern/libs/" + $mod | ||
} | ||
$filelist += $path | ||
} | ||
|
||
foreach ($lib in $modJson.libraryFiles) | ||
{ | ||
$path = "./extern/libs/" + $lib | ||
if (-not (Test-Path $path)) | ||
{ | ||
$path = "./build/" + $lib | ||
} | ||
$filelist += $path | ||
} | ||
|
||
$zip = $qmodName + ".zip" | ||
$qmod = $qmodName + ".qmod" | ||
|
||
if ((-not ($clean.IsPresent)) -and (Test-Path $qmod)) | ||
{ | ||
echo "Making Clean Qmod" | ||
Move-Item $qmod $zip -Force | ||
} | ||
|
||
Compress-Archive -Path $filelist -DestinationPath $zip -Update | ||
Move-Item $zip $qmod -Force | ||
|
||
echo "Task Completed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.