diff --git a/.github/workflows/build-ndk.yml b/.github/workflows/build-ndk.yml index 1c78445..a49d61d 100644 --- a/.github/workflows/build-ndk.yml +++ b/.github/workflows/build-ndk.yml @@ -1,112 +1,112 @@ -name: NDK build - -env: - module_id: SearchFixes - qmodName: SearchFixes - cache-name: searchfixes_cache - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - name: Checkout - with: - submodules: true - lfs: true - - - uses: seanmiddleditch/gha-setup-ninja@v3 - - - 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: cargo-build.yml - name: linux-qpm-rust - path: QPM - repo: RedBrumbler/QuestPackageManager-Rust - - - 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 - env: - cache-name: cache-qpm-deps - with: - path: /home/runner/.local/share/QPM-Rust/cache - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: QPM Restore - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust restore - - name: QPM Legacy fix - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust cache legacy-fix - - name: List Post Restore - run: | - 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} - pwsh -Command ./build.ps1 -# TODO: Generate QMOD -# ./QPM/qpm-rust qmod build - - - - name: Create Qmod - run: | - pwsh -Command ./createqmod.ps1 ${{env.qmodName}} - - name: Get Library Name - id: libname - run: | - cd ./build/ - pattern="lib${module_id}*.so" - files=( $pattern ) - echo ::set-output name=NAME::"${files[0]}" - - name: Upload non-debug 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 qmod artifact - uses: actions/upload-artifact@v2 - with: - name: ${{env.qmodName}}.qmod - path: ./${{ env.qmodName }}.qmod - if-no-files-found: error - - # TODO: NEEDED? -# - name: Upload debug artifact -# uses: actions/upload-artifact@v2 -# with: -# name: debug_${{ steps.libname.outputs.NAME }} -# path: ./obj/local/arm64-v8a/${{ steps.libname.outputs.NAME }} -# if-no-files-found: error +name: NDK build + +env: + module_id: SearchFixes + qmodName: SearchFixes + cache-name: searchfixes_cache + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + name: Checkout + with: + submodules: true + lfs: true + + - uses: seanmiddleditch/gha-setup-ninja@v3 + + - 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: cargo-build.yml + name: linux-qpm-rust + path: QPM + repo: RedBrumbler/QuestPackageManager-Rust + + - 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 + env: + cache-name: cache-qpm-deps + with: + path: /home/runner/.local/share/QPM-Rust/cache + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: QPM Restore + run: | + chmod +x ./QPM/qpm-rust + ./QPM/qpm-rust restore + - name: QPM Legacy fix + run: | + chmod +x ./QPM/qpm-rust + ./QPM/qpm-rust cache legacy-fix + - name: List Post Restore + run: | + 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} + pwsh -Command ./build.ps1 +# TODO: Generate QMOD +# ./QPM/qpm-rust qmod build + + + - name: Create Qmod + run: | + pwsh -Command ./createqmod.ps1 ${{env.qmodName}} + - name: Get Library Name + id: libname + run: | + cd ./build/ + pattern="lib${module_id}*.so" + files=( $pattern ) + echo ::set-output name=NAME::"${files[0]}" + - name: Upload non-debug 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 qmod artifact + uses: actions/upload-artifact@v2 + with: + name: ${{env.qmodName}}.qmod + path: ./${{ env.qmodName }}.qmod + if-no-files-found: error + + # TODO: NEEDED? +# - name: Upload debug artifact +# uses: actions/upload-artifact@v2 +# with: +# name: debug_${{ steps.libname.outputs.NAME }} +# path: ./obj/local/arm64-v8a/${{ steps.libname.outputs.NAME }} +# if-no-files-found: error # TODO: Add auto-populating releases, auto update versions, auto publish package on release \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 180e3d2..cf85617 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,201 +1,201 @@ -# Yoinked from NoodleExtensions: https://github.com/StackDoubleFlow/NoodleExtensions/blob/master/.github/workflows/publish.yml - -name: Publish QPM Package - -env: - module_id: SearchFixes - qmodName: SearchFixes - cache-name: searchfixes_cache - -on: - push: - tags: - - 'v*' - -jobs: - publish: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - name: Checkout - with: - submodules: true - lfs: true - - - uses: seanmiddleditch/gha-setup-ninja@v3 - - - 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: cargo-build.yml - name: linux-qpm-rust - path: QPM - repo: RedBrumbler/QuestPackageManager-Rust - - - name: QPM Collapse - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust collapse - # added the cache on the off chance the qpm.json stays the same across versions - - name: QPM Dependencies Cache - id: cache-qpm-deps - uses: actions/cache@v2 - env: - cache-name: cache-qpm-deps - with: - path: /home/runner/.local/share/QPM-Rust/cache - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - name: QPM Restore - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust restore - - name: QPM Legacy fix - run: | - chmod +x ./QPM/qpm-rust - ./QPM/qpm-rust cache legacy-fix - - name: List Post Restore - run: | - 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: Get Tag Version - id: get_tag_version - run: | - echo ${GITHUB_REF#refs/tags/} - echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} - echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} - - name: QPM Edit Version - run: | - ./QPM/qpm-rust package edit --version "${{ steps.get_tag_version.outputs.VERSION }}" - - name: Build - run: | - cd ${GITHUB_WORKSPACE} - pwsh -Command ./build.ps1 -# TODO: Generate QMOD -# ./QPM/qpm-rust qmod build - - - - name: Create Qmod - run: | - pwsh -Command ./createqmod.ps1 ${{env.qmodName}} - # Commit the change to the package, .vscode/c_cpp_properties.json, and Android.mk - - name: Configure commit - run: | - git config user.name "Github Actions" - git config user.email "<>" - - name: Commit Edit Version - run: | - git add qpm.json - git commit --allow-empty -m "Update Version and post restore" - # Then, we want to use the commit we have just made, and force push our tag to that commit - - name: Get Commit ID - id: get_commit_id - run: | - echo `git rev-parse HEAD` - echo ::set-output name=ID::`git rev-parse HEAD` - - name: Force create tag - run: | - git tag --force ${{ steps.get_tag_version.outputs.TAG }} ${{ steps.get_commid_id.outputs.ID }} - # Then, push, upload our artifacts, modify the config file to have soLink and debugSoLink - - name: Create and push version specific branch - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - git branch version-${{ steps.get_tag_version.outputs.TAG }} - git push -u origin version-${{ steps.get_tag_version.outputs.TAG }} --force --tags - # Get release that was created for this tag - - name: Get Release - uses: octokit/request-action@v2.x - id: get_release - with: - route: GET /repos/:repository/releases/tags/${{ steps.get_tag_version.outputs.TAG }} - repository: ${{ github.repository }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get Release Upload URL - id: get_upload_url - run: | - url=$(echo "$response" | jq -r '.upload_url') - echo $url - echo "::set-output name=upload_url::$url" - env: - response: ${{ steps.get_release.outputs.data }} - - - name: Get Library Name - id: libname - run: | - cd ./build/ - pattern="lib${module_id}*.so" - files=( $pattern ) - echo ::set-output name=NAME::"${files[0]}" - - name: Upload Release Asset - id: upload_release_asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_upload_url.outputs.upload_url }} - asset_path: ./build/${{ steps.libname.outputs.NAME }} - asset_name: ${{ steps.libname.outputs.NAME }} - asset_content_type: application/octet-stream - - - name: Upload Qmod Asset - id: upload_qmod_asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.get_upload_url.outputs.upload_url }} - asset_path: ./${{env.qmodName}}.qmod - asset_name: ${{env.qmodName}}.qmod - asset_content_type: application/octet-stream - - - name: Upload QMod to Mod Repo - uses: BobbyShmurner/mod-uploader@v1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - repo-token: ${{ secrets.REPO_TOKEN }} - qmod-name: ${{env.qmodName}}.qmod - tag: ${{github.ref_name}} - -# - name: Change QPM Package Info -# run: | -# ./QPM/qpm-rust package edit-extra --branchName "version-${{ steps.get_tag_version.outputs.TAG }}" -# ./QPM/qpm-rust package edit-extra --soLink "${{ steps.upload_release_asset.outputs.browser_download_url }}" -# ./QPM/qpm-rust package edit-extra --modLink "${{ steps.upload_qmod_asset.outputs.browser_download_url }}" -# -# - name: Commit Changed package info -# run: | -# git add qpm.json -# git commit -m "Updated qpm.json" -# -# # Then, we want to use the commit we have just made, and force push our tag to that commit -# - name: Get Commit ID -# id: get_created_commit_id -# run: | -# echo `git rev-parse HEAD` -# echo ::set-output name=ID::`git rev-parse HEAD` -# -# - name: Push New Commit and Tag -# run: | -# git push origin HEAD:version-${{ steps.get_tag_version.outputs.TAG }} --force -# git tag --force ${{ steps.get_tag_version.outputs.TAG }} ${{ steps.get_created_commit_id.outputs.ID }} -# git push --tags --force - -# - name: QPM Publish +# Yoinked from NoodleExtensions: https://github.com/StackDoubleFlow/NoodleExtensions/blob/master/.github/workflows/publish.yml + +name: Publish QPM Package + +env: + module_id: SearchFixes + qmodName: SearchFixes + cache-name: searchfixes_cache + +on: + push: + tags: + - 'v*' + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + name: Checkout + with: + submodules: true + lfs: true + + - uses: seanmiddleditch/gha-setup-ninja@v3 + + - 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: cargo-build.yml + name: linux-qpm-rust + path: QPM + repo: RedBrumbler/QuestPackageManager-Rust + + - name: QPM Collapse + run: | + chmod +x ./QPM/qpm-rust + ./QPM/qpm-rust collapse + # added the cache on the off chance the qpm.json stays the same across versions + - name: QPM Dependencies Cache + id: cache-qpm-deps + uses: actions/cache@v2 + env: + cache-name: cache-qpm-deps + with: + path: /home/runner/.local/share/QPM-Rust/cache + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('qpm.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: QPM Restore + run: | + chmod +x ./QPM/qpm-rust + ./QPM/qpm-rust restore + - name: QPM Legacy fix + run: | + chmod +x ./QPM/qpm-rust + ./QPM/qpm-rust cache legacy-fix + - name: List Post Restore + run: | + 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: Get Tag Version + id: get_tag_version + run: | + echo ${GITHUB_REF#refs/tags/} + echo ::set-output name=TAG::${GITHUB_REF#refs/tags/} + echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} + - name: QPM Edit Version + run: | + ./QPM/qpm-rust package edit --version "${{ steps.get_tag_version.outputs.VERSION }}" + - name: Build + run: | + cd ${GITHUB_WORKSPACE} + pwsh -Command ./build.ps1 +# TODO: Generate QMOD +# ./QPM/qpm-rust qmod build + + + - name: Create Qmod + run: | + pwsh -Command ./createqmod.ps1 ${{env.qmodName}} + # Commit the change to the package, .vscode/c_cpp_properties.json, and Android.mk + - name: Configure commit + run: | + git config user.name "Github Actions" + git config user.email "<>" + - name: Commit Edit Version + run: | + git add qpm.json + git commit --allow-empty -m "Update Version and post restore" + # Then, we want to use the commit we have just made, and force push our tag to that commit + - name: Get Commit ID + id: get_commit_id + run: | + echo `git rev-parse HEAD` + echo ::set-output name=ID::`git rev-parse HEAD` + - name: Force create tag + run: | + git tag --force ${{ steps.get_tag_version.outputs.TAG }} ${{ steps.get_commid_id.outputs.ID }} + # Then, push, upload our artifacts, modify the config file to have soLink and debugSoLink + - name: Create and push version specific branch + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git branch version-${{ steps.get_tag_version.outputs.TAG }} + git push -u origin version-${{ steps.get_tag_version.outputs.TAG }} --force --tags + # Get release that was created for this tag + - name: Get Release + uses: octokit/request-action@v2.x + id: get_release + with: + route: GET /repos/:repository/releases/tags/${{ steps.get_tag_version.outputs.TAG }} + repository: ${{ github.repository }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Get Release Upload URL + id: get_upload_url + run: | + url=$(echo "$response" | jq -r '.upload_url') + echo $url + echo "::set-output name=upload_url::$url" + env: + response: ${{ steps.get_release.outputs.data }} + + - name: Get Library Name + id: libname + run: | + cd ./build/ + pattern="lib${module_id}*.so" + files=( $pattern ) + echo ::set-output name=NAME::"${files[0]}" + - name: Upload Release Asset + id: upload_release_asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_upload_url.outputs.upload_url }} + asset_path: ./build/${{ steps.libname.outputs.NAME }} + asset_name: ${{ steps.libname.outputs.NAME }} + asset_content_type: application/octet-stream + + - name: Upload Qmod Asset + id: upload_qmod_asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.get_upload_url.outputs.upload_url }} + asset_path: ./${{env.qmodName}}.qmod + asset_name: ${{env.qmodName}}.qmod + asset_content_type: application/octet-stream + + - name: Upload QMod to Mod Repo + uses: BobbyShmurner/mod-uploader@v1.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ secrets.REPO_TOKEN }} + qmod-name: ${{env.qmodName}}.qmod + tag: ${{github.ref_name}} + +# - name: Change QPM Package Info +# run: | +# ./QPM/qpm-rust package edit-extra --branchName "version-${{ steps.get_tag_version.outputs.TAG }}" +# ./QPM/qpm-rust package edit-extra --soLink "${{ steps.upload_release_asset.outputs.browser_download_url }}" +# ./QPM/qpm-rust package edit-extra --modLink "${{ steps.upload_qmod_asset.outputs.browser_download_url }}" +# +# - name: Commit Changed package info +# run: | +# git add qpm.json +# git commit -m "Updated qpm.json" +# +# # Then, we want to use the commit we have just made, and force push our tag to that commit +# - name: Get Commit ID +# id: get_created_commit_id +# run: | +# echo `git rev-parse HEAD` +# echo ::set-output name=ID::`git rev-parse HEAD` +# +# - name: Push New Commit and Tag +# run: | +# git push origin HEAD:version-${{ steps.get_tag_version.outputs.TAG }} --force +# git tag --force ${{ steps.get_tag_version.outputs.TAG }} ${{ steps.get_created_commit_id.outputs.ID }} +# git push --tags --force + +# - name: QPM Publish # run: ./QPM/qpm-rust publish \ No newline at end of file diff --git a/.gitignore b/.gitignore index c6fa94e..e99705b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,67 +1,67 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# VSCode config stuff -!.vscode/c_cpp_properties.json -!.vscode/tasks.json -!.vscode/settings.json - -# Jetbrains IDEs -.idea/ - -# NDK stuff -out/ -[Ll]ib/ -[Ll]ibs/ -[Oo]bj/ -[Oo]bjs/ -ndkpath.txt -*.zip -*.txt -*.log -Android.mk.backup - -# QPM stuff -[Ee]xtern/ -*.qmod -qpm.shared.json -qpm_defines.cmake -![Cc][Mm]ake[Ll]ists.txt - -# CMake stuff -[Bb]uild/ -cmake-build-*/ -extern.cmake - -# QMOD Schema +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# VSCode config stuff +!.vscode/c_cpp_properties.json +!.vscode/tasks.json +!.vscode/settings.json + +# Jetbrains IDEs +.idea/ + +# NDK stuff +out/ +[Ll]ib/ +[Ll]ibs/ +[Oo]bj/ +[Oo]bjs/ +ndkpath.txt +*.zip +*.txt +*.log +Android.mk.backup + +# QPM stuff +[Ee]xtern/ +*.qmod +qpm.shared.json +qpm_defines.cmake +![Cc][Mm]ake[Ll]ists.txt + +# CMake stuff +[Bb]uild/ +cmake-build-*/ +extern.cmake + +# QMOD Schema mod.json.schema \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index ce816bc..09aca46 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,117 +1,117 @@ -{ - "files.associations": { - "iosfwd": "cpp", - "__config": "cpp", - "__nullptr": "cpp", - "thread": "cpp", - "any": "cpp", - "deque": "cpp", - "list": "cpp", - "map": "cpp", - "optional": "cpp", - "queue": "cpp", - "set": "cpp", - "stack": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "variant": "cpp", - "vector": "cpp", - "__bit_reference": "cpp", - "__debug": "cpp", - "__errc": "cpp", - "__functional_base": "cpp", - "__hash_table": "cpp", - "__locale": "cpp", - "__mutex_base": "cpp", - "__node_handle": "cpp", - "__split_buffer": "cpp", - "__string": "cpp", - "__threading_support": "cpp", - "__tree": "cpp", - "__tuple": "cpp", - "algorithm": "cpp", - "array": "cpp", - "atomic": "cpp", - "bit": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "cfenv": "cpp", - "charconv": "cpp", - "chrono": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "codecvt": "cpp", - "compare": "cpp", - "complex": "cpp", - "condition_variable": "cpp", - "csetjmp": "cpp", - "csignal": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "exception": "cpp", - "coroutine": "cpp", - "propagate_const": "cpp", - "forward_list": "cpp", - "fstream": "cpp", - "functional": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "ios": "cpp", - "iostream": "cpp", - "istream": "cpp", - "iterator": "cpp", - "limits": "cpp", - "locale": "cpp", - "memory": "cpp", - "mutex": "cpp", - "new": "cpp", - "numeric": "cpp", - "ostream": "cpp", - "random": "cpp", - "ratio": "cpp", - "regex": "cpp", - "scoped_allocator": "cpp", - "span": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "string": "cpp", - "string_view": "cpp", - "strstream": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "typeindex": "cpp", - "typeinfo": "cpp", - "utility": "cpp", - "valarray": "cpp", - "xstring": "cpp", - "xlocale": "cpp", - "xlocbuf": "cpp", - "concepts": "cpp", - "filesystem": "cpp", - "shared_mutex": "cpp", - "xfacet": "cpp", - "xhash": "cpp", - "xiosbase": "cpp", - "xlocinfo": "cpp", - "xlocmes": "cpp", - "xlocmon": "cpp", - "xlocnum": "cpp", - "xloctime": "cpp", - "xmemory": "cpp", - "xstddef": "cpp", - "xtr1common": "cpp", - "xtree": "cpp", - "xutility": "cpp" - } +{ + "files.associations": { + "iosfwd": "cpp", + "__config": "cpp", + "__nullptr": "cpp", + "thread": "cpp", + "any": "cpp", + "deque": "cpp", + "list": "cpp", + "map": "cpp", + "optional": "cpp", + "queue": "cpp", + "set": "cpp", + "stack": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "variant": "cpp", + "vector": "cpp", + "__bit_reference": "cpp", + "__debug": "cpp", + "__errc": "cpp", + "__functional_base": "cpp", + "__hash_table": "cpp", + "__locale": "cpp", + "__mutex_base": "cpp", + "__node_handle": "cpp", + "__split_buffer": "cpp", + "__string": "cpp", + "__threading_support": "cpp", + "__tree": "cpp", + "__tuple": "cpp", + "algorithm": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "cfenv": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "cinttypes": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "complex": "cpp", + "condition_variable": "cpp", + "csetjmp": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "exception": "cpp", + "coroutine": "cpp", + "propagate_const": "cpp", + "forward_list": "cpp", + "fstream": "cpp", + "functional": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "locale": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "numeric": "cpp", + "ostream": "cpp", + "random": "cpp", + "ratio": "cpp", + "regex": "cpp", + "scoped_allocator": "cpp", + "span": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "string": "cpp", + "string_view": "cpp", + "strstream": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "utility": "cpp", + "valarray": "cpp", + "xstring": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "concepts": "cpp", + "filesystem": "cpp", + "shared_mutex": "cpp", + "xfacet": "cpp", + "xhash": "cpp", + "xiosbase": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xmemory": "cpp", + "xstddef": "cpp", + "xtr1common": "cpp", + "xtree": "cpp", + "xutility": "cpp" + } } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1c6ca82..633305a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,89 +1,89 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "label": "NDK Build", - "detail": "Builds the library using ndk-build.cmd", - "type": "shell", - "command": "ndk-build", - "windows": { - "command": "ndk-build.cmd" - }, - "args": ["NDK_PROJECT_PATH=.", "APP_BUILD_SCRIPT=./Android.mk", "NDK_APPLICATION_MK=./Application.mk"], - "group": "build", - "options": { - "env": {} - } - }, - { - "label": "Powershell Build", - "detail": "Builds the library using Powershell (recommended)", - "type": "shell", - "command": "./build.ps1", - "windows": { - "command": "./build.ps1" - }, - "group": { - "kind": "build", - "isDefault": true - }, - "options": { - "env": {} - } - }, - { - "label": "Powershell Build and Copy", - "detail": "Builds and copies the library to the Quest using ADB and force-quits Beat Saber", - "type": "shell", - "command": "./copy.ps1", - "windows": { - "command": "./copy.ps1" - }, - "group": "build", - "options": { - "env": {} - } - }, - { - "label": "QMOD Build", - "detail": "Builds a .qmod to be installed into BMBF or QuestPatcher", - "type": "shell", - "command": "./buildQMOD.ps1", - "windows": { - "command": "./buildQMOD.ps1" - }, - "args": [], - "group": "build", - "options": { - "env": {} - } - }, - { - "label": "Start logging", - "detail": "Begin logging from the Quest to the console", - "type": "shell", - "command": "./start-logging.ps1", - "windows": { - "command": "./start-logging.ps1" - } - }, - { - "label": "Start logging to file", - "detail": "Begin logging from the Quest to the console and saving output to a file 'logcat.log'", - "type": "shell", - "command": "./start-logging.ps1 --file", - "windows": { - "command": "./start-logging.ps1 --file" - } - }, - { - "label": "Restart Beat Saber", - "detail": "Force-quits and restarts Beat Saber on the Quest", - "type": "shell", - "command": "./start-logging.ps1", - "windows": { - "command": "./start-logging.ps1" - } - } - ] -} +{ + "version": "2.0.0", + "tasks": [ + { + "label": "NDK Build", + "detail": "Builds the library using ndk-build.cmd", + "type": "shell", + "command": "ndk-build", + "windows": { + "command": "ndk-build.cmd" + }, + "args": ["NDK_PROJECT_PATH=.", "APP_BUILD_SCRIPT=./Android.mk", "NDK_APPLICATION_MK=./Application.mk"], + "group": "build", + "options": { + "env": {} + } + }, + { + "label": "Powershell Build", + "detail": "Builds the library using Powershell (recommended)", + "type": "shell", + "command": "./build.ps1", + "windows": { + "command": "./build.ps1" + }, + "group": { + "kind": "build", + "isDefault": true + }, + "options": { + "env": {} + } + }, + { + "label": "Powershell Build and Copy", + "detail": "Builds and copies the library to the Quest using ADB and force-quits Beat Saber", + "type": "shell", + "command": "./copy.ps1", + "windows": { + "command": "./copy.ps1" + }, + "group": "build", + "options": { + "env": {} + } + }, + { + "label": "QMOD Build", + "detail": "Builds a .qmod to be installed into BMBF or QuestPatcher", + "type": "shell", + "command": "./buildQMOD.ps1", + "windows": { + "command": "./buildQMOD.ps1" + }, + "args": [], + "group": "build", + "options": { + "env": {} + } + }, + { + "label": "Start logging", + "detail": "Begin logging from the Quest to the console", + "type": "shell", + "command": "./start-logging.ps1", + "windows": { + "command": "./start-logging.ps1" + } + }, + { + "label": "Start logging to file", + "detail": "Begin logging from the Quest to the console and saving output to a file 'logcat.log'", + "type": "shell", + "command": "./start-logging.ps1 --file", + "windows": { + "command": "./start-logging.ps1 --file" + } + }, + { + "label": "Restart Beat Saber", + "detail": "Force-quits and restarts Beat Saber on the Quest", + "type": "shell", + "command": "./start-logging.ps1", + "windows": { + "command": "./start-logging.ps1" + } + } + ] +} diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d749a1..d12e8e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,80 +1,80 @@ -# include some defines automatically made by qpm -include(qpm_defines.cmake) - -# override mod id -set(MOD_ID "SearchFixes") - -# 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" - ) - +# include some defines automatically made by qpm +include(qpm_defines.cmake) + +# override mod id +set(MOD_ID "SearchFixes") + +# 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" + ) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) \ No newline at end of file diff --git a/README.md b/README.md index 7581f5c..baede3d 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# SearchFixes - -An improved search algorithm for Beat Saber - -## Credits - -* [zoller27osu](https://github.com/zoller27osu), [Sc2ad](https://github.com/Sc2ad) and [jakibaki](https://github.com/jakibaki) - [beatsaber-hook](https://github.com/sc2ad/beatsaber-hook) -* [raftario](https://github.com/raftario) -* [Lauriethefish](https://github.com/Lauriethefish), [danrouse](https://github.com/danrouse) and [Bobby Shmurner](https://github.com/BobbyShmurner) for [this template](https://github.com/Lauriethefish/quest-mod-template) +# SearchFixes + +An improved search algorithm for Beat Saber + +## Credits + +* [zoller27osu](https://github.com/zoller27osu), [Sc2ad](https://github.com/Sc2ad) and [jakibaki](https://github.com/jakibaki) - [beatsaber-hook](https://github.com/sc2ad/beatsaber-hook) +* [raftario](https://github.com/raftario) +* [Lauriethefish](https://github.com/Lauriethefish), [danrouse](https://github.com/danrouse) and [Bobby Shmurner](https://github.com/BobbyShmurner) for [this template](https://github.com/Lauriethefish/quest-mod-template) diff --git a/build.ps1 b/build.ps1 index f16df1d..8fba68e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,36 +1,36 @@ -Param( - [Parameter(Mandatory=$false)] - [Switch] $clean, - - [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 -} - -# 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 . +Param( + [Parameter(Mandatory=$false)] + [Switch] $clean, + + [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 +} + +# 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 .. \ No newline at end of file diff --git a/buildQMOD.ps1 b/buildQMOD.ps1 index 7af3e52..371a3d0 100644 --- a/buildQMOD.ps1 +++ b/buildQMOD.ps1 @@ -1,92 +1,92 @@ -Param( - [String] $qmodname="", - - [Parameter(Mandatory=$false)] - [Switch] $clean, - - [Parameter(Mandatory=$false)] - [Switch] $help -) - -if ($help -eq $true) { - echo "`"BuildQmod `" - 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" - -$schemaUrl = "https://raw.githubusercontent.com/Lauriethefish/QuestPatcher.QMod/main/QuestPatcher.QMod/Resources/qmod.schema.json" -Invoke-WebRequest $schemaUrl -OutFile ./mod.schema.json - -$mod = "./mod.json" -$schema = "./mod.schema.json" -$modJsonRaw = Get-Content $mod -Raw -$modJson = $modJsonRaw | ConvertFrom-Json -$modSchemaRaw = Get-Content $schema -Raw - -Remove-Item ./mod.schema.json - -echo "Validating mod.json..." -if(!($modJsonRaw | Test-Json -Schema $modSchemaRaw)) { - exit -} - -$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 +Param( + [String] $qmodname="", + + [Parameter(Mandatory=$false)] + [Switch] $clean, + + [Parameter(Mandatory=$false)] + [Switch] $help +) + +if ($help -eq $true) { + echo "`"BuildQmod `" - 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" + +$schemaUrl = "https://raw.githubusercontent.com/Lauriethefish/QuestPatcher.QMod/main/QuestPatcher.QMod/Resources/qmod.schema.json" +Invoke-WebRequest $schemaUrl -OutFile ./mod.schema.json + +$mod = "./mod.json" +$schema = "./mod.schema.json" +$modJsonRaw = Get-Content $mod -Raw +$modJson = $modJsonRaw | ConvertFrom-Json +$modSchemaRaw = Get-Content $schema -Raw + +Remove-Item ./mod.schema.json + +echo "Validating mod.json..." +if(!($modJsonRaw | Test-Json -Schema $modSchemaRaw)) { + exit +} + +$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 \ No newline at end of file diff --git a/copy.ps1 b/copy.ps1 index 7ad4ce8..ff30a35 100644 --- a/copy.ps1 +++ b/copy.ps1 @@ -1,59 +1,59 @@ -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)] - [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 -} - -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 - +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)] + [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 +} + +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 } \ No newline at end of file diff --git a/createqmod.ps1 b/createqmod.ps1 index bf23fc5..8584494 100644 --- a/createqmod.ps1 +++ b/createqmod.ps1 @@ -1,53 +1,53 @@ -Param( - [String]$qmodname="", - [Parameter(Mandatory=$false)] - [Switch]$clean -) - -if ($qmodName -eq "") -{ - echo "Give a proper qmod name and try again" - exit -} -$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 +Param( + [String]$qmodname="", + [Parameter(Mandatory=$false)] + [Switch]$clean +) + +if ($qmodName -eq "") +{ + echo "Give a proper qmod name and try again" + exit +} +$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 \ No newline at end of file diff --git a/include/main.hpp b/include/main.hpp index ba3f93c..575b218 100644 --- a/include/main.hpp +++ b/include/main.hpp @@ -1,15 +1,15 @@ -#pragma once - -// Include the modloader header, which allows us to tell the modloader which mod this is, and the version etc. -#include "modloader/shared/modloader.hpp" - -// beatsaber-hook is a modding framework that lets us call functions and fetch field values from in the game -// It also allows creating objects, configuration, and importantly, hooking methods to modify their values -#include "beatsaber-hook/shared/utils/logging.hpp" -#include "beatsaber-hook/shared/config/config-utils.hpp" -#include "beatsaber-hook/shared/utils/il2cpp-functions.hpp" -#include "beatsaber-hook/shared/utils/hooking.hpp" - -// Define these functions here so that we can easily read configuration and log information from other files -Configuration& getConfig(); +#pragma once + +// Include the modloader header, which allows us to tell the modloader which mod this is, and the version etc. +#include "modloader/shared/modloader.hpp" + +// beatsaber-hook is a modding framework that lets us call functions and fetch field values from in the game +// It also allows creating objects, configuration, and importantly, hooking methods to modify their values +#include "beatsaber-hook/shared/utils/logging.hpp" +#include "beatsaber-hook/shared/config/config-utils.hpp" +#include "beatsaber-hook/shared/utils/il2cpp-functions.hpp" +#include "beatsaber-hook/shared/utils/hooking.hpp" + +// Define these functions here so that we can easily read configuration and log information from other files +Configuration& getConfig(); Logger& getLogger(); \ No newline at end of file diff --git a/mod.json b/mod.json index 5f9ef84..4092e76 100644 --- a/mod.json +++ b/mod.json @@ -1,16 +1,16 @@ -{ - "_QPVersion": "0.1.1", - "name": "SearchFixes", - "id": "SearchFixes", - "author": "rui2015", - "version": "1.2.0", - "packageId": "com.beatgames.beatsaber", - "packageVersion": "1.20.0", - "description": "An improved search algorithm for Beat Saber", - "modFiles": [ - "libSearchFixes.so" - ], - "libraryFiles": [ - "libbeatsaber-hook_3_6_8.so" - ] -} +{ + "_QPVersion": "0.1.1", + "name": "SearchFixes", + "id": "SearchFixes", + "author": "rui2015", + "version": "1.2.0", + "packageId": "com.beatgames.beatsaber", + "packageVersion": "1.20.0", + "description": "An improved search algorithm for Beat Saber", + "modFiles": [ + "libSearchFixes.so" + ], + "libraryFiles": [ + "libbeatsaber-hook_3_6_8.so" + ] +} diff --git a/ndk-stack.ps1 b/ndk-stack.ps1 index 0bc1a69..ad11b08 100644 --- a/ndk-stack.ps1 +++ b/ndk-stack.ps1 @@ -1,19 +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" -} +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" +} diff --git a/restart-game.ps1 b/restart-game.ps1 index fd0196a..5fea919 100644 --- a/restart-game.ps1 +++ b/restart-game.ps1 @@ -1,2 +1,2 @@ -adb shell am force-stop com.beatgames.beatsaber -adb shell am start com.beatgames.beatsaber/com.unity3d.player.UnityPlayerActivity +adb shell am force-stop com.beatgames.beatsaber +adb shell am start com.beatgames.beatsaber/com.unity3d.player.UnityPlayerActivity diff --git a/src/main.cpp b/src/main.cpp index 132ae4a..7ca63b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,93 +1,93 @@ -#include "main.hpp" - -#include "GlobalNamespace/BeatmapLevelFilterModel.hpp" -#include "GlobalNamespace/IPreviewBeatmapLevel.hpp" -using namespace GlobalNamespace; - -#include "System/StringComparison.hpp" - -static ModInfo modInfo; // Stores the ID and version of our mod, and is sent to the modloader upon startup - -// Loads the config from disk using our modInfo, then returns it for use -Configuration& getConfig() { - static Configuration config(modInfo); - config.Load(); - return config; -} - -// Returns a logger, useful for printing debug messages -Logger& getLogger() { - static Logger* logger = new Logger(modInfo); - return *logger; -} - -void toLower(std::string& str) { - std::transform(str.begin(), str.end(), str.begin(), ::tolower); -} - -bool findSubstring(std::string str, std::string substr) { - toLower(str); - toLower(substr); - return str.find(substr) != std::string::npos; -} - -MAKE_HOOK_MATCH(BeatmapLevelFilterModel_LevelContainsText, &BeatmapLevelFilterModel::LevelContainsText, bool, IPreviewBeatmapLevel* beatmapLevel, ArrayW searchTexts) { - int words = 0; - int matches = 0; - - auto songName = beatmapLevel->get_songName(); - auto songSubName = beatmapLevel->get_songSubName(); - auto songAuthorName = beatmapLevel->get_songAuthorName(); - auto levelAuthorName = beatmapLevel->get_levelAuthorName(); - - auto arrayLen = searchTexts.Length(); - - for (int i = 0; i < arrayLen; i++) - { - - StringW searchTerm = searchTexts[i]; - - // getLogger().debug("Searching for '%s' in '%s'", static_cast(searchTerm).c_str(), static_cast(songName).c_str()); // Debugging Stuff - - if (searchTerm->get_Length() == 0) - continue; - - words++; - - bool found = findSubstring(songName, searchTerm) || - findSubstring(songSubName, searchTerm) || - findSubstring(songAuthorName, searchTerm) || - findSubstring(levelAuthorName, searchTerm); - - /* Debugging stuff - getLogger().debug("songName: '%s'; songSubName: '%s'; songAuthorName: '%s'; levelAuthorName: '%s'; searchTermString: %s", static_cast(songName).c_str(), static_cast(songSubName).c_str(), static_cast(songAuthorName).c_str(), static_cast(levelAuthorName).c_str(), searchTermString.c_str()); - getLogger().debug("Found: %s", found ? "true" : "false"); - getLogger().debug(""); - */ - - - if (found) matches++; - - } - - return matches == words; -} - -// Called at the early stages of game loading -extern "C" void setup(ModInfo& info) { - info.id = ID; - info.version = VERSION; - modInfo = info; - - getConfig().Load(); // Load the config file - getLogger().info("Completed setup!"); -} - -// Called later on in the game loading - a good time to install function hooks -extern "C" void load() { - il2cpp_functions::Init(); - - getLogger().info("Installing hooks..."); - INSTALL_HOOK(getLogger(), BeatmapLevelFilterModel_LevelContainsText); - getLogger().info("Installed all hooks!"); +#include "main.hpp" + +#include "GlobalNamespace/BeatmapLevelFilterModel.hpp" +#include "GlobalNamespace/IPreviewBeatmapLevel.hpp" +using namespace GlobalNamespace; + +#include "System/StringComparison.hpp" + +static ModInfo modInfo; // Stores the ID and version of our mod, and is sent to the modloader upon startup + +// Loads the config from disk using our modInfo, then returns it for use +Configuration& getConfig() { + static Configuration config(modInfo); + config.Load(); + return config; +} + +// Returns a logger, useful for printing debug messages +Logger& getLogger() { + static Logger* logger = new Logger(modInfo); + return *logger; +} + +void toLower(std::string& str) { + std::transform(str.begin(), str.end(), str.begin(), ::tolower); +} + +bool findSubstring(std::string str, std::string substr) { + toLower(str); + toLower(substr); + return str.find(substr) != std::string::npos; +} + +MAKE_HOOK_MATCH(BeatmapLevelFilterModel_LevelContainsText, &BeatmapLevelFilterModel::LevelContainsText, bool, IPreviewBeatmapLevel* beatmapLevel, ArrayW searchTexts) { + int words = 0; + int matches = 0; + + auto songName = beatmapLevel->get_songName(); + auto songSubName = beatmapLevel->get_songSubName(); + auto songAuthorName = beatmapLevel->get_songAuthorName(); + auto levelAuthorName = beatmapLevel->get_levelAuthorName(); + + auto arrayLen = searchTexts.Length(); + + for (int i = 0; i < arrayLen; i++) + { + + StringW searchTerm = searchTexts[i]; + + // getLogger().debug("Searching for '%s' in '%s'", static_cast(searchTerm).c_str(), static_cast(songName).c_str()); // Debugging Stuff + + if (searchTerm->get_Length() == 0) + continue; + + words++; + + bool found = findSubstring(songName, searchTerm) || + findSubstring(songSubName, searchTerm) || + findSubstring(songAuthorName, searchTerm) || + findSubstring(levelAuthorName, searchTerm); + + /* Debugging stuff + getLogger().debug("songName: '%s'; songSubName: '%s'; songAuthorName: '%s'; levelAuthorName: '%s'; searchTermString: %s", static_cast(songName).c_str(), static_cast(songSubName).c_str(), static_cast(songAuthorName).c_str(), static_cast(levelAuthorName).c_str(), searchTermString.c_str()); + getLogger().debug("Found: %s", found ? "true" : "false"); + getLogger().debug(""); + */ + + + if (found) matches++; + + } + + return matches == words; +} + +// Called at the early stages of game loading +extern "C" void setup(ModInfo& info) { + info.id = ID; + info.version = VERSION; + modInfo = info; + + getConfig().Load(); // Load the config file + getLogger().info("Completed setup!"); +} + +// Called later on in the game loading - a good time to install function hooks +extern "C" void load() { + il2cpp_functions::Init(); + + getLogger().info("Installing hooks..."); + INSTALL_HOOK(getLogger(), BeatmapLevelFilterModel_LevelContainsText); + getLogger().info("Installed all hooks!"); } \ No newline at end of file diff --git a/start-logging.ps1 b/start-logging.ps1 index d8159e7..a9cedda 100644 --- a/start-logging.ps1 +++ b/start-logging.ps1 @@ -1,64 +1,64 @@ -Param( - [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, - - [Parameter(Mandatory=$false)] - [Switch] $excludeHeader -) - -if ($help -eq $true) { - if ($excludeHeader -eq $false) { - echo "`"Start-Logging`" - Logs Beat Saber using `"adb logcat`"" - echo "`n-- Arguments --`n" - } - - echo "-Self `t`t Only Logs your mod and Crashes" - echo "-All `t`t Logs everything, including logs made by the Quest itself" - echo "-Custom `t Specify a specific logging pattern, e.g `"custom-types|questui`"" - echo "`t`t NOTE: The paterent `"AndriodRuntime|CRASH`" is always appended to a custom pattern" - echo "-File `t`t Saves the output of the log to `"logcat.log`"" - - exit -} - -$timestamp = Get-Date -Format "MM-dd HH:mm:ss.fff" -$bspid = adb shell pidof com.beatgames.beatsaber -$command = "adb logcat -T `"$timestamp`"" - -if ($all -eq $false) { - while ([string]::IsNullOrEmpty($bspid)) { - Start-Sleep -Milliseconds 100 - $bspid = adb shell pidof com.beatgames.beatsaber - } - - $command += "--pid $bspid" -} - -if ($self -eq $true) { - $command += " | Select-String -pattern `"(SearchFixes|AndroidRuntime|CRASH)`"" -} elseif ($custom -ne "") { - $pattern = "(" + $custom + "|AndriodRuntime|CRASH)" - $command += " | Select-String -pattern `"$pattern`"" -} -elseif ($all -eq $false) { - $command += " | Select-String -pattern `"(QuestHook|modloader|AndroidRuntime|CRASH)`"" -} - -if ($file -eq $true) { - $command += " | Out-File -FilePath $PSScriptRoot\logcat.log" -} - -echo "Logging using Command `"$command`"" +Param( + [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, + + [Parameter(Mandatory=$false)] + [Switch] $excludeHeader +) + +if ($help -eq $true) { + if ($excludeHeader -eq $false) { + echo "`"Start-Logging`" - Logs Beat Saber using `"adb logcat`"" + echo "`n-- Arguments --`n" + } + + echo "-Self `t`t Only Logs your mod and Crashes" + echo "-All `t`t Logs everything, including logs made by the Quest itself" + echo "-Custom `t Specify a specific logging pattern, e.g `"custom-types|questui`"" + echo "`t`t NOTE: The paterent `"AndriodRuntime|CRASH`" is always appended to a custom pattern" + echo "-File `t`t Saves the output of the log to `"logcat.log`"" + + exit +} + +$timestamp = Get-Date -Format "MM-dd HH:mm:ss.fff" +$bspid = adb shell pidof com.beatgames.beatsaber +$command = "adb logcat -T `"$timestamp`"" + +if ($all -eq $false) { + while ([string]::IsNullOrEmpty($bspid)) { + Start-Sleep -Milliseconds 100 + $bspid = adb shell pidof com.beatgames.beatsaber + } + + $command += "--pid $bspid" +} + +if ($self -eq $true) { + $command += " | Select-String -pattern `"(SearchFixes|AndroidRuntime|CRASH)`"" +} elseif ($custom -ne "") { + $pattern = "(" + $custom + "|AndriodRuntime|CRASH)" + $command += " | Select-String -pattern `"$pattern`"" +} +elseif ($all -eq $false) { + $command += " | Select-String -pattern `"(QuestHook|modloader|AndroidRuntime|CRASH)`"" +} + +if ($file -eq $true) { + $command += " | Out-File -FilePath $PSScriptRoot\logcat.log" +} + +echo "Logging using Command `"$command`"" Invoke-Expression $command \ No newline at end of file