diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 19efd44..0000000 --- a/.gitattributes +++ /dev/null @@ -1,27 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -*.sln merge=binary -*.csproj merge=binary -*.vbproj merge=binary -*.vcxproj merge=binary -*.vcproj merge=binary -*.dbproj merge=binary -*.fsproj merge=binary -*.lsproj merge=binary -*.wixproj merge=binary -*.modelproj merge=binary -*.sqlproj merge=binary -*.wwaproj merge=binary diff --git a/.github/workflows/BuildMod.yml b/.github/workflows/BuildMod.yml index 334620e..b204bd9 100644 --- a/.github/workflows/BuildMod.yml +++ b/.github/workflows/BuildMod.yml @@ -1,27 +1,18 @@ +# Credit to darknight1050 https://github.com/darknight1050/CrashReporter/blob/master/.github/workflows/build-ndk.yml + name: NDK build +env: + module_id: Streamer-Tools + qmodName: Streamer Tools + on: workflow_dispatch: push: - branches: [ master, dev ] - paths-ignore: - - '**.yml' - - '!.github/workflows/BuildMod.yml' - - '**.json' - - '!qpm.json' - - '**.ps1' - - '!buildQMOD.ps1' - - '**.md' - - '.gitignore' + branches-ignore: + - 'version-v*' pull_request: - branches: [ master, dev ] -env: - module_id: Streamer-Tools - BSVersion: 1.17.1 - version: 0.2.2-Dev.${{ github.run_number }} - ndkname: android-ndk-r24 - jobs: build: runs-on: ubuntu-latest @@ -32,50 +23,13 @@ jobs: with: submodules: true lfs: true - + - uses: seanmiddleditch/gha-setup-ninja@v3 - #- name: Install Powershell - # run: sudo apt-get install -y powershell - - #- name: Cache Android NDK - # id: cache-ndk - # uses: actions/cache@v2 - # env: - # cache-name: cache-ndk - # with: - # path: ndk - # key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} - # restore-keys: | - # ${{ runner.os }}-${{ env.cache-name }}-${{ env.ndkname }} - - #- name: Install Android NDK - # if: steps.cache-ndk.outputs.cache-hit != 'true' - # run: | - # wget -q -O ndk.zip https://dl.google.com/android/repository/${ndkname}-linux.zip - # unzip -q ndk.zip - # mv ${ndkname} ndk - - #- name: Create ndkpath.txt - # run: | - # cd ndk - # pwd > ${GITHUB_WORKSPACE}/ndkpath.txt - - name: Create ndkpath.txt run: | echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt cat ${GITHUB_WORKSPACE}/ndkpath.txt - - #- name: Get QPM - # if: steps.cache-qpm.outputs.cache-hit != 'true' - # uses: dawidd6/action-download-artifact@v2 - # with: - # github_token: ${{secrets.GITHUB_TOKEN}} - # workflow: main.yml - # name: QPM-ubuntu-x64 - # path: QPM - # repo: sc2ad/QuestPackageManager - - name: Get QPM if: steps.cache-qpm.outputs.cache-hit != 'true' uses: dawidd6/action-download-artifact@v2 @@ -84,13 +38,13 @@ jobs: workflow: cargo-build.yml name: linux-qpm-rust path: QPM - repo: RedBrumbler/QuestPackageManager-Rust + repo: QuestPackageManager/QPM.CLI - name: QPM Collapse run: | chmod +x ./QPM/qpm-rust ./QPM/qpm-rust collapse - + - name: QPM Dependencies Cache id: cache-qpm-deps uses: actions/cache@v2 @@ -98,34 +52,31 @@ jobs: cache-name: cache-qpm-deps with: path: /home/runner/.local/share/QPM-Rust/cache - key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('qpm.json', '.github/BuildMod.yml') }} + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} restore-keys: | - ${{ runner.os }}-${{ env.cache-name }}- - ${{ runner.os }}-${{ env.cache-name }} - + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - name: QPM Restore run: | ./QPM/qpm-rust restore - - - name: Check dependency Folders + - name: List Post Restore run: | - echo "Checking extern includes" - ls -lh ${GITHUB_WORKSPACE}/extern/includes - echo "" - echo "Checking libs" - ls -lh ${GITHUB_WORKSPACE}/extern/libs - echo "" - echo "Checking QPM-Rust/cache Folder" - ls -lh $HOME/.local/share/QPM-Rust/cache - echo "" - + echo includes: + ls -la ${GITHUB_WORKSPACE}/extern/includes + echo libs: + ls -la ${GITHUB_WORKSPACE}/extern/libs + echo cache: + ls -la $HOME/.local/share/QPM-Rust/cache + - name: Build run: | cd ${GITHUB_WORKSPACE} - ./QPM/qpm-rust package edit --version ${{ env.version }} ./QPM/qpm-rust qmod build - pwsh -Command ./build.ps1 -actions - + pwsh -Command ./build.ps1 + - name: Create Qmod + run: | + pwsh -Command ./createqmod.ps1 - name: Get Library Name id: libname run: | @@ -133,31 +84,17 @@ jobs: pattern="lib${module_id}*.so" files=( $pattern ) echo ::set-output name=NAME::"${files[0]}" - - - name: Package QMOD - run: | - cd ${GITHUB_WORKSPACE} - pwsh -Command ./buildQMOD.ps1 -package - - - name: Upload non-debug artifact + + - name: Upload so artifact uses: actions/upload-artifact@v2 with: name: ${{ steps.libname.outputs.NAME }} path: ./build/${{ steps.libname.outputs.NAME }} if-no-files-found: error - - - name: Upload debug artifact - uses: actions/upload-artifact@v2 - with: - name: debug_${{ steps.libname.outputs.NAME }} - path: ./build/debug/${{ steps.libname.outputs.NAME }} - if-no-files-found: error - - - - name: Upload QMOD + - name: Upload qmod artifact uses: actions/upload-artifact@v2 with: - name: ${{ env.module_id }}-(UNZIP-for-QMOD).qmod - path: ./${{ env.module_id }}_${{ env.version }}.qmod - if-no-files-found: warn \ No newline at end of file + name: ${{env.qmodName}}.qmod + path: ./${{ env.qmodName }}.qmod + if-no-files-found: error \ No newline at end of file diff --git a/.gitignore b/.gitignore index 82ddaad..2f8ceae 100644 --- a/.gitignore +++ b/.gitignore @@ -71,4 +71,5 @@ Android.mk.backup /log_timestamp /build *.cmake +mod.json /CMakeSettings.json diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 576c408..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "extern/config-utils"] - path = extern/config-utils - url = https://github.com/darknight1050/config-utils - branch = version-v0.6.0 diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index e548f57..7a2aad4 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -5,8 +5,8 @@ "cStandard": "c11", "defines": [ "BS__1_16=1", - "ID=\"streamer-tools\"", - "VERSION=\"0.1.0\"", + "ID=\"#{id}\"", + "VERSION=\"#{version}\"", "__GNUC__", "__aarch64__" ], diff --git a/Android.mk b/Android.mk deleted file mode 100644 index 715c709..0000000 --- a/Android.mk +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH := $(call my-dir) -TARGET_ARCH_ABI := $(APP_ABI) - -rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) - -# Creating prebuilt for dependency: beatsaber-hook - version: 2.2.5 -include $(CLEAR_VARS) -LOCAL_MODULE := beatsaber-hook_2_3_0 -LOCAL_EXPORT_C_INCLUDES := extern/beatsaber-hook -LOCAL_SRC_FILES := extern/libbeatsaber-hook_2_3_0.so -LOCAL_CPP_FEATURES += exceptions -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: codegen - version: 0.14.0 -include $(CLEAR_VARS) -LOCAL_MODULE := codegen -LOCAL_EXPORT_C_INCLUDES := extern/codegen -LOCAL_SRC_FILES := extern/libcodegen.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: questui - version: 0.11.1 -include $(CLEAR_VARS) -LOCAL_MODULE := questui -LOCAL_EXPORT_C_INCLUDES := extern/questui -LOCAL_SRC_FILES := extern/libquestui.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: modloader - version: 1.2.3 -include $(CLEAR_VARS) -LOCAL_MODULE := modloader -LOCAL_EXPORT_C_INCLUDES := extern/modloader -LOCAL_SRC_FILES := extern/libmodloader.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: custom-types - version: 0.12.7 -include $(CLEAR_VARS) -LOCAL_MODULE := custom-types -LOCAL_EXPORT_C_INCLUDES := extern/custom-types -LOCAL_SRC_FILES := extern/libcustom-types.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := streamer-tools -LOCAL_SRC_FILES += $(call rwildcard,src/,*.cpp) -LOCAL_SRC_FILES += $(call rwildcard,extern/beatsaber-hook/src/inline-hook,*.cpp) -LOCAL_SRC_FILES += $(call rwildcard,extern/beatsaber-hook/src/inline-hook,*.c) -LOCAL_SHARED_LIBRARIES += beatsaber-hook_2_3_0 -LOCAL_SHARED_LIBRARIES += codegen -LOCAL_SHARED_LIBRARIES += questui -LOCAL_SHARED_LIBRARIES += modloader -LOCAL_SHARED_LIBRARIES += custom-types -LOCAL_LDLIBS += -llog -LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -I'extern/codegen/include' -DID='"streamer-tools"' -DVERSION='"$(VERSION)"' -DBS__1_17=0 -I'./shared' -I'./extern' -Ofast -LOCAL_CPPFLAGS += -std=c++2a -Ofast -LOCAL_C_INCLUDES += ./include ./src -include $(BUILD_SHARED_LIBRARY) diff --git a/Android_Template.mk b/Android_Template.mk deleted file mode 100644 index 14a225a..0000000 --- a/Android_Template.mk +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (C) 2009 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -LOCAL_PATH := $(call my-dir) -TARGET_ARCH_ABI := $(APP_ABI) - -rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) - -# Creating prebuilt -include $(CLEAR_VARS) -# Creating prebuilt for dependency: beatsaber-hook - version: 2.2.5 -include $(CLEAR_VARS) -LOCAL_MODULE := beatsaber-hook_{BS_Hook} -LOCAL_EXPORT_C_INCLUDES := extern/beatsaber-hook -LOCAL_SRC_FILES := extern/libbeatsaber-hook_{BS_Hook}.so -LOCAL_CPP_FEATURES += exceptions -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: codegen - version: 0.14.0 -include $(CLEAR_VARS) -LOCAL_MODULE := codegen -LOCAL_EXPORT_C_INCLUDES := extern/codegen -LOCAL_SRC_FILES := extern/libcodegen.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: custom types -include $(CLEAR_VARS) -LOCAL_MODULE := customtypes -LOCAL_EXPORT_C_INCLUDES := extern/custom-types -LOCAL_SRC_FILES := extern/libcustom-types.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: questui -include $(CLEAR_VARS) -LOCAL_MODULE := questui -LOCAL_EXPORT_C_INCLUDES := extern/questui -LOCAL_SRC_FILES := extern/libquestui.so -include $(PREBUILT_SHARED_LIBRARY) -# Creating prebuilt for dependency: modloader - version: 1.1.0 -include $(CLEAR_VARS) -LOCAL_MODULE := modloader -LOCAL_EXPORT_C_INCLUDES := extern/modloader -LOCAL_SRC_FILES := extern/libmodloader.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := streamer-tools -LOCAL_SRC_FILES += $(call rwildcard,src/,*.cpp) -LOCAL_SRC_FILES += $(call rwildcard,extern/beatsaber-hook/src/inline-hook,*.cpp) -LOCAL_SRC_FILES += $(call rwildcard,extern/beatsaber-hook/src/inline-hook,*.c) -LOCAL_SHARED_LIBRARIES += beatsaber-hook_{BS_Hook} -LOCAL_SHARED_LIBRARIES += codegen -LOCAL_SHARED_LIBRARIES += questui -LOCAL_SHARED_LIBRARIES += customtypes -LOCAL_SHARED_LIBRARIES += modloader -LOCAL_LDLIBS += -llog -LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -I'extern/codegen/include' -DID='"streamer-tools"' -DVERSION='"$(VERSION)"' {DEBUG_PARAMS} -I'./shared' -I'./extern' -Ofast -LOCAL_CPPFLAGS += -std=c++2a -Ofast -LOCAL_C_INCLUDES += ./include ./src -include $(BUILD_SHARED_LIBRARY) diff --git a/Application.mk b/Application.mk deleted file mode 100644 index e06107a..0000000 --- a/Application.mk +++ /dev/null @@ -1,6 +0,0 @@ -APP_ABI := arm64-v8a -APP_PLATFORM := 25 -APP_PIE:= true -APP_STL := c++_static -APP_CFLAGS := -std=gnu17 -APP_CPPFLAGS := -std=gnu++2a -frtti diff --git a/CppProperties.json b/CppProperties.json deleted file mode 100644 index f0d8752..0000000 --- a/CppProperties.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "configurations": [ - { - "compilers": { "cpp": { "path": "${workspaceRoot}/../android-ndk-r22" } }, - "compilerSwitches": "-target aarch64-none-linux-android24 -fdata-sections -ffunction-sections -fstack-protector-strong -funwind-tables -no-canonical-prefixes --sysroot F:/BS-Modding/android-ndk-r22/build//../toolchains/llvm/prebuilt/windows-x86_64/sysroot -g -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -D_FORTIFY_SOURCE=2 -fno-exceptions -fno-rtti -fpic -O2 -DNDEBUG -I./include -I./src", - //"compilerSwitches": "/target aarch64-none-linux-android24 /fdata-sections /ffunction-sections /fstack-protector-strong /funwind-tables /no-canonical-prefixes /Wall /std:c++2a /llog /std:gnu17 /std:gnu++2a /Wno-invalid-command-line-argument /Wno-unused-command-line-argument /D_FORTIFY_SOURCE=2 /fno-exceptions /fno-rtti /fpic /O2 /DNDEBUG /I./include /I./src", - "cppStandard": "c++20", - "cStandard": "c11", - "defines": [ - "BS__1_16=4", - "ID=\"streamer-tools\"", - "VERSION=\"0.1.0\"", - "__GNUC__", - "__aarch64__", - "HAS_CODEGEN" - ], - "includePath": [ - "${workspaceRoot}/**", - "${workspaceRoot}/shared/", - "${workspaceRoot}/include/", - "${workspaceRoot}/extern/**", - "${workspaceRoot}/extern/libil2cpp/il2cpp/libil2cpp", - "${workspaceRoot}/../android-ndk-r22/**" - ], - //"inheritEnvironments": [ "clang-arm64" ], - "intelliSenseMode": "android-clang-arm64" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/build.ps1 b/build.ps1 index 0a2686f..fe746c3 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,59 +1,31 @@ -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 +Param( + [Parameter(Mandatory=$false)] + [Switch] $clean, + + [Parameter(Mandatory=$false)] + [Switch] $help ) -$NDKPath = Get-Content $PSScriptRoot/ndkpath.txt -$QPMpackage = "./qpm.json" -$qpmjson = Get-Content $QPMpackage -Raw | ConvertFrom-Json -$ModID = $qpmjson.info.id -if (-not $Version) { - $VERSION = $qpmjson.info.version -} else { - $VERSION = $Version -} -if ($release -ne $true -and -not $VERSION.Contains('-Dev')) { - $VERSION += "-Dev" -} -if ($env:version -eq "") { - & qpm-rust package edit --version $VERSION -} +if ($help -eq $true) { + Write-Output "`"Build`" - Copiles your mod into a `".so`" or a `".a`" library" + Write-Output "`n-- Arguments --`n" -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; + Write-Output "-Clean `t`t Deletes the `"build`" folder, so that the entire library is rebuilt" + + exit } -echo "Building mod with ModID: $ModID version: $VERSION" -if ($clean.IsPresent) -{ - if (Test-Path -Path "build") - { +# 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 . -j 6 -$ExitCode = $LastExitCode -cd .. -exit $ExitCode -echo Done \ No newline at end of file +if (($clean.IsPresent) -or (-not (Test-Path -Path "build"))) { + new-item -Path build -ItemType Directory +} + +& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -B build +& cmake --build ./build diff --git a/buildQMOD.ps1 b/buildQMOD.ps1 deleted file mode 100644 index af2f005..0000000 --- a/buildQMOD.ps1 +++ /dev/null @@ -1,102 +0,0 @@ -Param( - [Parameter(Mandatory=$false, HelpMessage="The name the output qmod file should have")][String] $qmodname="Streamer-Tools", - - [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 - - -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 -} - -if ($qmodName -eq "") -{ - echo "Give a proper qmod name and try again" - exit -} - -if ($package -eq $true) { - $qmodName = "$($env:module_id)_$($env:version)" - echo "Actions: Packaging QMod $qmodName" -} -if (($args.Count -eq 0) -And $package -eq $false) { -echo "Creating QMod $qmodName" - & $PSScriptRoot/build.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 - -$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" \ No newline at end of file diff --git a/copy.ps1 b/copy.ps1 index ce68df2..95a0db5 100644 --- a/copy.ps1 +++ b/copy.ps1 @@ -1,21 +1,70 @@ -if ($args[0] -eq "--debug" -or $args[1] -eq "--debug") { -& $PSScriptRoot/build.ps1 --debug -} else { -& $PSScriptRoot/build.ps1 +Param( + [Parameter(Mandatory=$false)] + [Switch] $clean, + + [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)] + [String] $file="", + + [Parameter(Mandatory=$false)] + [Switch] $help +) + +if ($help -eq $true) { + Write-Output "`"Copy`" - Builds and copies your mod to your quest, and also starts Beat Saber with optional logging" + Write-Output "`n-- Arguments --`n" + + Write-Output "-Clean `t`t Performs a clean build (equvilant to running `"build -clean`")" + Write-Output "-UseDebug `t Copies the debug version of the mod to your quest" + Write-Output "-Log `t`t Logs Beat Saber using the `"Start-Logging`" command" + + Write-Output "`n-- Logging Arguments --`n" + + & $PSScriptRoot/start-logging.ps1 -help -excludeHeader + + exit } -if ($?) { - adb push build/libStreamer-Tools.so /sdcard/Android/data/com.beatgames.beatsaber/files/mods/libStreamer-Tools.so - if ($?) { - adb shell am force-stop com.beatgames.beatsaber - adb shell am start com.beatgames.beatsaber/com.unity3d.player.UnityPlayerActivity - if ($args[0] -eq "--log" -or $args[1] -eq "--log") { - $timestamp = Get-Date -Format "MM-dd HH:mm:ss.fff" - Start-Process PowerShell -ArgumentList "./logging.ps1 --file" - } - if ($args[0] -eq "--debug-log" -or $args[1] -eq "--debug-log") { - $timestamp = Get-Date -Format "MM-dd HH:mm:ss.fff" - adb logcat -T "$timestamp" main-modloader:W QuestHook[streamer-tools`|v0.1.0]:* AndroidRuntime:E *:S QuestHook[UtilsLogger`|v1.2.4]:* - } + +& $PSScriptRoot/build.ps1 -clean:$clean + +if ($LASTEXITCODE -ne 0) { + Write-Output "Failed to build, exiting..." + exit $LASTEXITCODE +} + +# & $PSScriptRoot/validate-modjson.ps1 +# if ($LASTEXITCODE -ne 0) { +# exit $LASTEXITCODE +# } +$modJson = Get-Content "./mod.json" -Raw | ConvertFrom-Json + +$modFiles = $modJson.modFiles + +foreach ($fileName in $modFiles) { + if ($useDebug -eq $true) { + & adb push build/debug/$fileName /sdcard/Android/data/com.beatgames.beatsaber/files/mods/$fileName + } else { + & adb push build/$fileName /sdcard/Android/data/com.beatgames.beatsaber/files/mods/$fileName } } -echo "Exiting Copy.ps1" \ No newline at end of file + +& $PSScriptRoot/restart-game.ps1 + +if ($log -eq $true) { + & adb logcat -c + & $PSScriptRoot/start-logging.ps1 -self:$self -all:$all -custom:$custom -file:$file +} diff --git a/cpp.hint b/cpp.hint deleted file mode 100644 index 37f1187..0000000 --- a/cpp.hint +++ /dev/null @@ -1,5 +0,0 @@ -// Hint files help the Visual Studio IDE interpret Visual C++ identifiers -// such as names of functions and macros. -// For more information see https://go.microsoft.com/fwlink/?linkid=865984 -#define DECLARE_CLASS_CODEGEN(namespaze, name, baseT, __VA_ARGS__) ___DECLARE_TYPE_WRAPPER_INHERITANCE(namespaze, name, Il2CppTypeEnum::IL2CPP_TYPE_CLASS, baseT, {}, 0, nullptr, __VA_ARGS__) -#define ROUTE_GET(URI) ROUTE("GET", URI) diff --git a/createqmod.ps1 b/createqmod.ps1 new file mode 100644 index 0000000..191c31d --- /dev/null +++ b/createqmod.ps1 @@ -0,0 +1,61 @@ +Param( + [Parameter(Mandatory=$false)] + [String] $qmodName="", + + [Parameter(Mandatory=$false)] + [Switch] $help +) + +if ($help -eq $true) { + Write-Output "`"createqmod`" - Creates a .qmod file with your compiled libraries and mod.json." + Write-Output "`n-- Arguments --`n" + + Write-Output "-QmodName `t The file name of your qmod" + + exit +} + +$mod = "./mod.json" + +$modJson = Get-Content $mod -Raw | ConvertFrom-Json + +if ($qmodName -eq "") { + $qmodName = $modJson.name +} + +$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 + } + if (-not (Test-Path $path)) { + Write-Output "Error: could not find dependency: $path" + exit 1 + } + $filelist += $path +} + +foreach ($lib in $modJson.libraryFiles) { + $path = "./build/" + $lib + if (-not (Test-Path $path)) { + $path = "./extern/libs/" + $lib + } + if (-not (Test-Path $path)) { + Write-Output "Error: could not find dependency: $path" + exit 1 + } + $filelist += $path +} + +$zip = $qmodName + ".zip" +$qmod = $qmodName + ".qmod" + +Compress-Archive -Path $filelist -DestinationPath $zip -Update +Move-Item $zip $qmod -Force diff --git a/mod.json b/mod.json deleted file mode 100644 index 4b12de9..0000000 --- a/mod.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "_QPVersion": "0.1.1", - "name": "Streamer Tools", - "id": "Streamer-Tools", - "author": "EnderdracheLP, ComputerElite, Lauriethefish, Phaze", - "version": "0.9.0", - "packageId": "com.beatgames.beatsaber", - "packageVersion": "1.27.0_3631150051", - "description": "Allows applications to get information from the game like, currently played song.", - "coverImage": "cover.png", - "dependencies": [ - { - "version": "^0.15.22", - "id": "custom-types", - "downloadIfMissing": "https://github.com/sc2ad/Il2CppQuestTypePatching/releases/download/v0.15.22/CustomTypes.qmod" - }, - { - "version": "^0.32.0", - "id": "codegen", - "downloadIfMissing": "https://github.com/sc2ad/BeatSaber-Quest-Codegen/releases/download/v0.32.0/Codegen.qmod" - }, - { - "version": "^0.17.10", - "id": "questui", - "downloadIfMissing": "https://github.com/darknight1050/QuestUI/releases/download/v0.17.10/QuestUI.qmod" - } - ], - "modFiles": [ - "libStreamer-Tools.so" - ], - "libraryFiles": [ - "libbeatsaber-hook_3_14_0.so" - ], - "fileCopies": [], - "copyExtensions": [] -} \ No newline at end of file diff --git a/mod.template.json b/mod.template.json index f84fc8e..b09379d 100644 --- a/mod.template.json +++ b/mod.template.json @@ -1,12 +1,12 @@ { "_QPVersion": "0.1.1", - "name": "Streamer Tools", - "id": "Streamer-Tools", + "name": "${mod_name}", + "id": "${mod_id}", "author": "EnderdracheLP, ComputerElite, Lauriethefish, Phaze", - "version": "0.9.0", + "version": "${version}", "packageId": "com.beatgames.beatsaber", - "packageVersion": "1.27.0_3631150051", + "packageVersion": "1.28.0_4124311467", "description": "Allows applications to get information from the game like, currently played song.", "coverImage": "cover.png", "dependencies": [], diff --git a/qpm.json b/qpm.json index ee69e23..345b716 100644 --- a/qpm.json +++ b/qpm.json @@ -4,7 +4,7 @@ "info": { "name": "Streamer Tools", "id": "Streamer-Tools", - "version": "0.9.0", + "version": "0.10.0", "url": null, "additionalData": { "overrideSoName": "libStreamer-Tools.so" @@ -27,7 +27,7 @@ }, { "id": "custom-types", - "versionRange": "^0.15.22", + "versionRange": "^0.15.23", "additionalData": {} }, { @@ -37,12 +37,12 @@ }, { "id": "questui", - "versionRange": "^0.17.10", + "versionRange": "^0.17.11", "additionalData": {} }, { "id": "codegen", - "versionRange": "^0.32.0", + "versionRange": "^0.33.0", "additionalData": {} } ], diff --git a/start-logging.ps1 b/start-logging.ps1 new file mode 100644 index 0000000..d30984f --- /dev/null +++ b/start-logging.ps1 @@ -0,0 +1,76 @@ +Param( + [Parameter(Mandatory=$false)] + [Switch] $self, + + [Parameter(Mandatory=$false)] + [Switch] $all, + + [Parameter(Mandatory=$false)] + [String] $custom="", + + [Parameter(Mandatory=$false)] + [String] $file="", + + [Parameter(Mandatory=$false)] + [Switch] $help, + + [Parameter(Mandatory=$false)] + [Switch] $excludeHeader +) + +if ($help -eq $true) { + if ($excludeHeader -eq $false) { + Write-Output "`"Start-Logging`" - Logs Beat Saber using `"adb logcat`"" + Write-Output "`n-- Arguments --`n" + } + + Write-Output "-Self `t`t Only Logs your mod and Crashes" + Write-Output "-All `t`t Logs everything, including logs made by the Quest itself" + Write-Output "-Custom `t Specify a specific logging pattern, e.g `"custom-types|questui`"" + Write-Output "`t`t NOTE: The paterent `"AndriodRuntime|CRASH`" is always appended to a custom pattern" + Write-Output "-File `t`t Saves the output of the log to the file name given" + + exit +} + +$bspid = adb shell pidof com.beatgames.beatsaber +$command = "adb logcat " + +if ($all -eq $false) { + $loops = 0 + while ([string]::IsNullOrEmpty($bspid) -and $loops -lt 3) { + Start-Sleep -Milliseconds 100 + $bspid = adb shell pidof com.beatgames.beatsaber + $loops += 1 + } + + if ([string]::IsNullOrEmpty($bspid)) { + Write-Output "Could not connect to adb, exiting..." + exit 1 + } + + $command += "--pid $bspid" +} + +if ($all -eq $false) { + $pattern = "(" + if ($self -eq $true) { + $modID = (Get-Content "./mod.json" -Raw | ConvertFrom-Json).id + $pattern += "$modID|" + } + if (![string]::IsNullOrEmpty($custom)) { + $pattern += "$custom|" + } + if ($pattern -eq "(") { + $pattern = "(QuestHook|modloader|" + } + $pattern += "AndroidRuntime|CRASH)" + $command += " | Select-String -pattern `"$pattern`"" +} + +if (![string]::IsNullOrEmpty($file)) { + $command += " | Out-File -FilePath $PSScriptRoot\$file" +} + +Write-Output "Logging using Command `"$command`"" +Invoke-Expression $command diff --git a/startlogging.bat b/startlogging.bat deleted file mode 100644 index 652e342..0000000 --- a/startlogging.bat +++ /dev/null @@ -1,2 +0,0 @@ -@ECHO OFF -adb logcat > log.txt \ No newline at end of file