-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5a31e5
commit 16e7250
Showing
10 changed files
with
391 additions
and
61 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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# include some defines automatically made by qpm | ||
include(qpm_defines.cmake) | ||
|
||
# override mod id | ||
set(MOD_ID "Play3rdPer") | ||
|
||
# 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(-O3) | ||
# compile definitions used | ||
add_compile_definitions(VERSION=\"${MOD_VERSION}\") | ||
add_compile_definitions(ID=\"${MOD_ID}\") | ||
add_compile_definitions(MOD_ID=\"${MOD_ID}\") | ||
|
||
# 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 .) | ||
|
||
# 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 |
---|---|---|
@@ -1,8 +1,36 @@ | ||
$NDKPath = Get-Content $PSScriptRoot/ndkpath.txt | ||
Param( | ||
[Parameter(Mandatory=$false)] | ||
[Switch] $clean, | ||
|
||
$buildScript = "$NDKPath/build/ndk-build" | ||
if (-not ($PSVersionTable.PSEdition -eq "Core")) { | ||
$buildScript += ".cmd" | ||
[Parameter(Mandatory=$false)] | ||
[Switch] $help | ||
) | ||
|
||
if ($help -eq $true) { | ||
echo "`"Build`" - Copiles your mod into a `".so`" or a `".a`" library" | ||
echo "`n-- Arguments --`n" | ||
|
||
echo "-Clean `t`t Deletes the `"build`" folder, so that the entire library is rebuilt" | ||
|
||
exit | ||
} | ||
|
||
& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk | ||
# if user specified clean, remove all build files | ||
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 | ||
& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" ../ | ||
& cmake --build . | ||
cd .. |
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,79 @@ | ||
Param( | ||
[String] $qmodname="Play3rdPer", | ||
|
||
[Parameter(Mandatory=$false)] | ||
[Switch] $clean, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[Switch] $help | ||
) | ||
|
||
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" | ||
|
||
exit | ||
} | ||
|
||
if ($qmodName -eq "") | ||
{ | ||
echo "Give a proper qmod name and try again" | ||
exit | ||
} | ||
|
||
& $PSScriptRoot/build.ps1 -clean:$clean | ||
|
||
if ($LASTEXITCODE -ne 0) { | ||
echo "Failed to build, exiting..." | ||
exit $LASTEXITCODE | ||
} | ||
|
||
echo "Creating qmod from mod.json" | ||
|
||
$mod = "./mod.json" | ||
$modJson = Get-Content $mod -Raw | ConvertFrom-Json | ||
|
||
$filelist = @($mod) | ||
|
||
$cover = "./" + $modJson.coverImage | ||
if ((-not ($cover -eq "./")) -and (Test-Path $cover)) | ||
{ | ||
$filelist += ,$cover | ||
} | ||
|
||
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 |
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 |
---|---|---|
@@ -1,10 +1,59 @@ | ||
$NDKPath = Get-Content $PSScriptRoot/ndkpath.txt | ||
Param( | ||
[Parameter(Mandatory=$false)] | ||
[Switch] $clean, | ||
|
||
$buildScript = "$NDKPath/build/ndk-build" | ||
if (-not ($PSVersionTable.PSEdition -eq "Core")) { | ||
$buildScript += ".cmd" | ||
[Parameter(Mandatory=$false)] | ||
[Switch] $log, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[Switch] $useDebug, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[Switch] $self, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[Switch] $all, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[String] $custom="", | ||
|
||
[Parameter(Mandatory=$false)] | ||
[Switch] $file, | ||
|
||
[Parameter(Mandatory=$false)] | ||
[Switch] $help | ||
) | ||
|
||
if ($help -eq $true) { | ||
echo "`"Copy`" - Builds and copies your mod to your quest, and also starts Beat Saber with optional logging" | ||
echo "`n-- Arguments --`n" | ||
|
||
echo "-Clean `t`t Performs a clean build (equvilant to running `"Build -clean`")" | ||
echo "-UseDebug `t Copied the debug version of the mod to your quest" | ||
echo "-Log `t`t Logs Beat Saber using the `"Start-Logging`" command" | ||
|
||
echo "`n-- Logging Arguments --`n" | ||
|
||
& $PSScriptRoot/start-logging.ps1 -help -excludeHeader | ||
|
||
exit | ||
} | ||
|
||
& $PSScriptRoot/build.ps1 -clean:$clean | ||
|
||
if ($LASTEXITCODE -ne 0) { | ||
echo "Failed to build, exiting..." | ||
exit $LASTEXITCODE | ||
} | ||
|
||
& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk | ||
& adb push libs/arm64-v8a/libPlay3rdPer_0_1_0.so /sdcard/Android/data/com.beatgames.beatsaber/files/mods/libPlay3rdPer_0_1_0.so | ||
& adb shell am force-stop com.beatgames.beatsaber | ||
if ($useDebug -eq $true) { | ||
$fileName = Get-ChildItem lib*.so -Path "build/debug" -Name | ||
} else { | ||
$fileName = Get-ChildItem lib*.so -Path "build/" -Name | ||
} | ||
|
||
& adb push build/$fileName /sdcard/Android/data/com.beatgames.beatsaber/files/mods/$fileName | ||
|
||
& $PSScriptRoot/restart-game.ps1 | ||
|
||
if ($log -eq $true) { & $PSScriptRoot/start-logging.ps1 -self:$self -all:$all -custom:$custom -file:$file } |
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
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,19 @@ | ||
if (Test-Path "./ndkpath.txt") | ||
{ | ||
$NDKPath = Get-Content ./ndkpath.txt | ||
} else { | ||
$NDKPath = $ENV:ANDROID_NDK_HOME | ||
} | ||
|
||
|
||
|
||
$stackScript = "$NDKPath/ndk-stack" | ||
if (-not ($PSVersionTable.PSEdition -eq "Core")) { | ||
$stackScript += ".cmd" | ||
} | ||
|
||
if ($args.Count -eq 0) { | ||
Get-Content ./log.txt | & $stackScript -sym ./build/debug/ > log_unstripped.log | ||
} else { | ||
Get-Content $args[0] | & $stackScript -sym ./build/debug/ > "$($args[0])_unstripped.txt" | ||
} |
Oops, something went wrong.