Skip to content

Commit

Permalink
Merge pull request #34 from michael-r-elp/master
Browse files Browse the repository at this point in the history
Update to 1.21.0/1.22.0
  • Loading branch information
cubicgraphics committed Jun 4, 2022
2 parents af28f4e + f73f88d commit a64eee2
Show file tree
Hide file tree
Showing 16 changed files with 607 additions and 146 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -58,4 +58,6 @@ Android.mk.backup
/log_timestamp

TestBuild.ps1
TestQMOD.ps1
TestQMOD.ps1
/build
*.cmake
43 changes: 0 additions & 43 deletions Android.mk

This file was deleted.

6 changes: 0 additions & 6 deletions Application.mk

This file was deleted.

100 changes: 100 additions & 0 deletions CMakeLists.txt
@@ -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"
)
35 changes: 35 additions & 0 deletions CMakeSettings.json
@@ -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"
}
]
}
59 changes: 59 additions & 0 deletions ExampleBuild.ps1
@@ -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
98 changes: 98 additions & 0 deletions ExampleQMOD.ps1
@@ -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"
8 changes: 2 additions & 6 deletions README.md
Expand Up @@ -15,18 +15,14 @@ Want to support development and server costs? [Click Here](https://www.patreon.c

**Recommended Install:**

**PLEASE USE MANUAL INSTALL FOR NOW. THE MOD IS IN BETA AND ISN'T LISTED TILL IT IS STABLE. THIS WILL BE REMOVED WHEN ITS AVAILABLE.**

<strike>

Here is how to install the mod in headset:
- Go to the Browser section of the BMBF app.
- Click the small globe icon in the top right-hand corner and click QuestBoard
- Hit "Download Mods"
- Scroll down till you find "BeatTogether" and hit the blue download button on the right hand side.
- It will say its downloaded. Make sure to hit "Sync to Beat Saber" to apply changes</strike>

~~You are now ready to play!~~
You are now ready to play!

**Manual Install:**

Expand All @@ -39,7 +35,7 @@ On your PC, type in that web address that is shown. You will be greeted with a u
Upload the .qmod you got from the download above. To be sure it downloaded correctly, check the "mods" tab and see if its enabled and active.

## Custom Song Support
Customs in multiplayer requires [MultiQuestensions](https://github.com/Goobwabber/MultiQuestensions)
Customs in multiplayer require [MultiplayerCore](https://github.com/EnderdracheLP/MultiplayerCore.Quest)

## Special Thanks
Special thanks to [Sc2ad](https://github.com/Sc2ad) for helping me debug this.
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

0 comments on commit a64eee2

Please sign in to comment.