Skip to content

Commit eb5dc5e

Browse files
Update to 1.19.1
1 parent 418bbf3 commit eb5dc5e

File tree

10 files changed

+392
-64
lines changed

10 files changed

+392
-64
lines changed

CMakeLists.txt

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# include some defines automatically made by qpm
2+
include(qpm_defines.cmake)
3+
4+
# override mod id
5+
set(MOD_ID "CrashMod")
6+
7+
# Enable link time optimization
8+
# In my experience, this can be highly unstable but it nets a huge size optimization and likely performance
9+
# However, the instability was seen using Android.mk/ndk-build builds. With Ninja + CMake, this problem seems to have been solved.
10+
# As always, test thoroughly
11+
# - Fern
12+
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
13+
14+
cmake_minimum_required(VERSION 3.21)
15+
project(${COMPILE_ID})
16+
17+
# c++ standard
18+
set(CMAKE_CXX_STANDARD 20)
19+
set(CMAKE_CXX_STANDARD_REQUIRED 20)
20+
21+
# define that stores the actual source directory
22+
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
23+
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
24+
25+
# compile options used
26+
add_compile_options(-frtti -fexceptions)
27+
add_compile_options(-O3)
28+
# compile definitions used
29+
add_compile_definitions(VERSION=\"${MOD_VERSION}\")
30+
add_compile_definitions(ID=\"${MOD_ID}\")
31+
add_compile_definitions(MOD_ID=\"${MOD_ID}\")
32+
33+
# recursively get all src files
34+
RECURSE_FILES(cpp_file_list ${SOURCE_DIR}/*.cpp)
35+
RECURSE_FILES(c_file_list ${SOURCE_DIR}/*.c)
36+
37+
# add all src files to compile
38+
add_library(
39+
${COMPILE_ID}
40+
SHARED
41+
${cpp_file_list}
42+
${c_file_list}
43+
)
44+
45+
target_include_directories(${COMPILE_ID} PRIVATE .)
46+
47+
# add src dir as include dir
48+
target_include_directories(${COMPILE_ID} PRIVATE ${SOURCE_DIR})
49+
# add include dir as include dir
50+
target_include_directories(${COMPILE_ID} PRIVATE ${INCLUDE_DIR})
51+
# add shared dir as include dir
52+
target_include_directories(${COMPILE_ID} PUBLIC ${SHARED_DIR})
53+
# codegen includes
54+
target_include_directories(${COMPILE_ID} PRIVATE ${EXTERN_DIR}/includes/${CODEGEN_ID}/include)
55+
56+
target_link_libraries(${COMPILE_ID} PRIVATE -llog)
57+
# add extern stuff like libs and other includes
58+
include(extern.cmake)
59+
60+
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
61+
COMMAND ${CMAKE_STRIP} -d --strip-all
62+
"lib${COMPILE_ID}.so" -o "stripped_lib${COMPILE_ID}.so"
63+
COMMENT "Strip debug symbols done on final binary.")
64+
65+
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
66+
COMMAND ${CMAKE_COMMAND} -E make_directory debug
67+
COMMENT "Make directory for debug symbols"
68+
)
69+
70+
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
71+
COMMAND ${CMAKE_COMMAND} -E rename lib${COMPILE_ID}.so debug/lib${COMPILE_ID}.so
72+
COMMENT "Rename the lib to debug_ since it has debug symbols"
73+
)
74+
75+
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
76+
COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so
77+
COMMENT "Rename the stripped lib to regular"
78+
)

build.ps1

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
1-
$NDKPath = Get-Content $PSScriptRoot/ndkpath.txt
1+
Param(
2+
[Parameter(Mandatory=$false)]
3+
[Switch] $clean,
24

3-
$buildScript = "$NDKPath/build/ndk-build"
4-
if (-not ($PSVersionTable.PSEdition -eq "Core")) {
5-
$buildScript += ".cmd"
5+
[Parameter(Mandatory=$false)]
6+
[Switch] $help
7+
)
8+
9+
if ($help -eq $true) {
10+
echo "`"Build`" - Copiles your mod into a `".so`" or a `".a`" library"
11+
echo "`n-- Arguments --`n"
12+
13+
echo "-Clean `t`t Deletes the `"build`" folder, so that the entire library is rebuilt"
14+
15+
exit
616
}
717

8-
& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk
18+
# if user specified clean, remove all build files
19+
if ($clean.IsPresent)
20+
{
21+
if (Test-Path -Path "build")
22+
{
23+
remove-item build -R
24+
}
25+
}
26+
27+
28+
if (($clean.IsPresent) -or (-not (Test-Path -Path "build")))
29+
{
30+
$out = new-item -Path build -ItemType Directory
31+
}
32+
33+
cd build
34+
& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" ../
35+
& cmake --build .
36+
cd ..

buildQMOD.ps1

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
Param(
2+
[String] $qmodname="CrashMod",
3+
4+
[Parameter(Mandatory=$false)]
5+
[Switch] $clean,
6+
7+
[Parameter(Mandatory=$false)]
8+
[Switch] $help
9+
)
10+
11+
if ($help -eq $true) {
12+
echo "`"BuildQmod <qmodName>`" - Copiles your mod into a `".so`" or a `".a`" library"
13+
echo "`n-- Parameters --`n"
14+
echo "qmodName `t The file name of your qmod"
15+
16+
echo "`n-- Arguments --`n"
17+
18+
echo "-Clean `t`t Performs a clean build on both your library and the qmod"
19+
20+
exit
21+
}
22+
23+
if ($qmodName -eq "")
24+
{
25+
echo "Give a proper qmod name and try again"
26+
exit
27+
}
28+
29+
& $PSScriptRoot/build.ps1 -clean:$clean
30+
31+
if ($LASTEXITCODE -ne 0) {
32+
echo "Failed to build, exiting..."
33+
exit $LASTEXITCODE
34+
}
35+
36+
echo "Creating qmod from mod.json"
37+
38+
$mod = "./mod.json"
39+
$modJson = Get-Content $mod -Raw | ConvertFrom-Json
40+
41+
$filelist = @($mod)
42+
43+
$cover = "./" + $modJson.coverImage
44+
if ((-not ($cover -eq "./")) -and (Test-Path $cover))
45+
{
46+
$filelist += ,$cover
47+
}
48+
49+
foreach ($mod in $modJson.modFiles)
50+
{
51+
$path = "./build/" + $mod
52+
if (-not (Test-Path $path))
53+
{
54+
$path = "./extern/libs/" + $mod
55+
}
56+
$filelist += $path
57+
}
58+
59+
foreach ($lib in $modJson.libraryFiles)
60+
{
61+
$path = "./extern/libs/" + $lib
62+
if (-not (Test-Path $path))
63+
{
64+
$path = "./build/" + $lib
65+
}
66+
$filelist += $path
67+
}
68+
69+
$zip = $qmodName + ".zip"
70+
$qmod = $qmodName + ".qmod"
71+
72+
if ((-not ($clean.IsPresent)) -and (Test-Path $qmod))
73+
{
74+
echo "Making Clean Qmod"
75+
Move-Item $qmod $zip -Force
76+
}
77+
78+
Compress-Archive -Path $filelist -DestinationPath $zip -Update
79+
Move-Item $zip $qmod -Force

copy.ps1

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,59 @@
1-
$NDKPath = Get-Content $PSScriptRoot/ndkpath.txt
1+
Param(
2+
[Parameter(Mandatory=$false)]
3+
[Switch] $clean,
24

3-
$buildScript = "$NDKPath/build/ndk-build"
4-
if (-not ($PSVersionTable.PSEdition -eq "Core")) {
5-
$buildScript += ".cmd"
5+
[Parameter(Mandatory=$false)]
6+
[Switch] $log,
7+
8+
[Parameter(Mandatory=$false)]
9+
[Switch] $useDebug,
10+
11+
[Parameter(Mandatory=$false)]
12+
[Switch] $self,
13+
14+
[Parameter(Mandatory=$false)]
15+
[Switch] $all,
16+
17+
[Parameter(Mandatory=$false)]
18+
[String] $custom="",
19+
20+
[Parameter(Mandatory=$false)]
21+
[Switch] $file,
22+
23+
[Parameter(Mandatory=$false)]
24+
[Switch] $help
25+
)
26+
27+
if ($help -eq $true) {
28+
echo "`"Copy`" - Builds and copies your mod to your quest, and also starts Beat Saber with optional logging"
29+
echo "`n-- Arguments --`n"
30+
31+
echo "-Clean `t`t Performs a clean build (equvilant to running `"Build -clean`")"
32+
echo "-UseDebug `t Copied the debug version of the mod to your quest"
33+
echo "-Log `t`t Logs Beat Saber using the `"Start-Logging`" command"
34+
35+
echo "`n-- Logging Arguments --`n"
36+
37+
& $PSScriptRoot/start-logging.ps1 -help -excludeHeader
38+
39+
exit
40+
}
41+
42+
& $PSScriptRoot/build.ps1 -clean:$clean
43+
44+
if ($LASTEXITCODE -ne 0) {
45+
echo "Failed to build, exiting..."
46+
exit $LASTEXITCODE
647
}
748

8-
& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk
9-
& adb push libs/arm64-v8a/libCrashMod_0_1_0.so /sdcard/Android/data/com.beatgames.beatsaber/files/mods/libCrashMod_0_1_0.so
10-
& adb shell am force-stop com.beatgames.beatsaber
49+
if ($useDebug -eq $true) {
50+
$fileName = Get-ChildItem lib*.so -Path "build/debug" -Name
51+
} else {
52+
$fileName = Get-ChildItem lib*.so -Path "build/" -Name
53+
}
54+
55+
& adb push build/$fileName /sdcard/Android/data/com.beatgames.beatsaber/files/mods/$fileName
56+
57+
& $PSScriptRoot/restart-game.ps1
58+
59+
if ($log -eq $true) { & $PSScriptRoot/start-logging.ps1 -self:$self -all:$all -custom:$custom -file:$file }

mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"version": "0.5.0",
66
"author": "ComputerElite",
77
"packageId": "com.beatgames.beatsaber",
8-
"packageVersion": "1.18.0",
8+
"packageVersion": "1.19.1",
99
"modFiles": [
1010
"libCrashMod.so"
1111
],
1212
"libraryFiles": [
13-
"libbeatsaber-hook_2_3_0.so"
13+
"libbeatsaber-hook_3_6_8.so"
1414
],
1515
"dependencies": [],
1616
"fileCopies": []

qpm.json

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,54 @@
11
{
2-
"sharedDir": "shared",
3-
"dependenciesDir": "extern",
4-
"info": {
5-
"name": "Crash Mod",
6-
"id": "CrashMod",
7-
"version": "0.2.1",
8-
"url": null,
9-
"additionalData": {}
10-
},
11-
"dependencies": [
12-
{
13-
"id": "beatsaber-hook",
14-
"versionRange": "*",
15-
"additionalData": {
16-
"extraFiles": [
17-
"src/inline-hook"
18-
]
19-
}
20-
},
21-
{
22-
"id": "codegen",
23-
"versionRange": "*",
24-
"additionalData": {}
25-
},
26-
{
27-
"id": "questui",
28-
"versionRange": "*",
29-
"additionalData": {}
30-
},
31-
{
32-
"id": "custom-types",
33-
"versionRange": "*",
34-
"additionalData": {}
35-
},
36-
{
37-
"id": "config-utils",
38-
"versionRange": "*",
39-
"additionalData": {}
40-
}
41-
],
42-
"additionalData": {}
2+
"sharedDir": "shared",
3+
"dependenciesDir": "extern",
4+
"info": {
5+
"name": "Crash Mod",
6+
"id": "CrashMod",
7+
"version": "0.5.0",
8+
"url": null,
9+
"additionalData": {
10+
"overrideSoName": "libCrashMod.so"
11+
}
12+
},
13+
"dependencies": [
14+
{
15+
"id": "beatsaber-hook",
16+
"versionRange": "=3.6.8",
17+
"additionalData": {
18+
"extraFiles": [
19+
"src/inline-hook"
20+
]
21+
}
22+
},
23+
{
24+
"id": "modloader",
25+
"versionRange": "=1.2.3",
26+
"additionalData": {
27+
28+
}
29+
},
30+
{
31+
"id": "codegen",
32+
"versionRange": "=0.20.0",
33+
"additionalData": {}
34+
},
35+
{
36+
"id": "questui",
37+
"versionRange": "=0.13.2",
38+
"additionalData": {}
39+
},
40+
{
41+
"id": "custom-types",
42+
"versionRange": "=0.15.7",
43+
"additionalData": {}
44+
},
45+
{
46+
"id": "config-utils",
47+
"versionRange": "*",
48+
"additionalData": {}
49+
}
50+
],
51+
"additionalData": {
52+
53+
}
4354
}

restart-game.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
adb shell am force-stop com.beatgames.beatsaber
2+
adb shell am start com.beatgames.beatsaber/com.unity3d.player.UnityPlayerActivity

0 commit comments

Comments
 (0)