Skip to content

Commit 70e9214

Browse files
Rust rewrite completely (#18)
* Changes * Base providers * Switch to json conversion * Refactor animation structures and update JSON configuration for NDK compatibility * Attempt to move most of the work to Rust * Update PointDefinitionW constructor to include BaseProviderContext and refactor property access in AssignPathAnimationData * Refactor animation context constructors and update PointDefinitionW to support copy construction * Refactor TracksContext and update BeatmapAssociatedData to use shared_ptr for internal_tracks_context * Implement event queuing * Refactor Track and PointDefinition headers to improve structure and add interpolation methods for various vector types * Add operator overloads and registration methods to TrackW and PathPropertyW for improved usability * Refactor GameObjectTrackController to use std::span for track parameters and enhance property retrieval methods with optional types * Multiply scale * Refactor GameObjectTrackController to use TimeUnit for lastCheckedTime and enhance vector operations with new operator overloads * Fix PointDefinitionW, missing one thing * Enhance PointDefinitionW and Track classes with context management and const correctness; refactor point data handling in BeatmapAssociatedData * Use corrosion * Finally get tracks_rs statically linked * Optimize binaries * Remove tracks-rs dependency from qpm.json and qpm.shared.json * Add Rust setup step for nightly and aarch64-linux-android target in CI workflows * Remove canary NDK setup from build workflows * Update QPM Rust Action to use version 1 in build and publish workflows * Update to BS 1.40.3 * Install cargo-ndk * Specify toolchain for aarch64-linux-android target in build workflows * Fix GameObjectTrackController class declaration * Fix static linking libtracks_rs_link * Disable sl2 bundling in qmod * Refactor include paths and improve const correctness in Track and Property classes * Add lastCheckedTime and getter * Fix time param * Fix null context --------- Co-authored-by: Futuremappermydud <54294576+Futuremappermydud@users.noreply.github.com>
1 parent 560ae99 commit 70e9214

31 files changed

+2644
-1352
lines changed

.github/workflows/build-ndk.yml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,13 @@ jobs:
2424

2525
- uses: seanmiddleditch/gha-setup-ninja@v3
2626

27-
# Use canary NDK to avoid lesser known compile bugs
28-
- name: Setup canary NDK
29-
id: setup-ndk
30-
uses: ./.github/actions/canary-ndk
31-
32-
- name: Create ndkpath.txt
33-
run: |
34-
echo ${{ steps.setup-ndk.outputs.ndk-path }} > ${GITHUB_WORKSPACE}/ndkpath.txt
35-
cat ${GITHUB_WORKSPACE}/ndkpath.txt
36-
3727
# - name: Create ndkpath.txt
3828
# run: |
3929
# echo "$ANDROID_NDK_LATEST_HOME" > ${GITHUB_WORKSPACE}/ndkpath.txt
4030
# cat ${GITHUB_WORKSPACE}/ndkpath.txt
4131

4232
- name: QPM Rust Action
43-
uses: Fernthedev/qpm-rust-action@main
33+
uses: Fernthedev/qpm-rust-action@v1
4434
with:
4535
#required
4636
workflow_token: ${{secrets.GITHUB_TOKEN}}
@@ -55,6 +45,12 @@ jobs:
5545
run: |
5646
qpm-rust collapse
5747
48+
- name: Setup Rust
49+
run: |
50+
rustup install nightly
51+
rustup target add aarch64-linux-android --toolchain nightly
52+
cargo install --locked --git https://github.com/bbqsrc/cargo-ndk.git cargo-ndk
53+
5854
- name: Build
5955
run: |
6056
cd ${GITHUB_WORKSPACE}

.github/workflows/publish.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ jobs:
2222
lfs: true
2323

2424
- uses: seanmiddleditch/gha-setup-ninja@v3
25-
26-
# Use canary NDK to avoid lesser known compile bugs
27-
- name: Setup canary NDK
28-
id: setup-ndk
29-
uses: ./.github/actions/canary-ndk
30-
31-
- name: Create ndkpath.txt
32-
run: |
33-
echo ${{ steps.setup-ndk.outputs.ndk-path }} > ${GITHUB_WORKSPACE}/ndkpath.txt
34-
cat ${GITHUB_WORKSPACE}/ndkpath.txt
3525

3626
# - name: Create ndkpath.txt
3727
# run: |
@@ -46,15 +36,15 @@ jobs:
4636
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
4737
4838
- name: QPM Rust Action
49-
uses: Fernthedev/qpm-action@main
39+
uses: Fernthedev/qpm-action@v1
5040
with:
5141
#required
5242
workflow_token: ${{secrets.GITHUB_TOKEN}}
5343

5444
restore: true # will run restore on download
5545
cache: true #will cache dependencies
5646

57-
publish: true
47+
publish: "late"
5848
publish_token: ${{secrets.QPM_TOKEN}}
5949

6050
version: ${{ steps.get_tag_version.outputs.VERSION }}
@@ -67,6 +57,12 @@ jobs:
6757
# Name of qmod in release asset. Assumes exists, same as prior
6858
qpm_qmod: ${{env.qmodName}}.qmod
6959

60+
- name: Setup Rust
61+
run: |
62+
rustup install nightly
63+
rustup target add aarch64-linux-android --toolchain nightly
64+
cargo install --locked --git https://github.com/bbqsrc/cargo-ndk.git cargo-ndk
65+
7066
- name: Build
7167
run: |
7268
cd ${GITHUB_WORKSPACE}

CMakeLists.txt

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
cmake_minimum_required(VERSION 3.21)
2+
13
# include some defines automatically made by qpm
24
include(qpm_defines.cmake)
35

4-
cmake_minimum_required(VERSION 3.21)
56
project(${COMPILE_ID})
67

8+
79
# c++ standard
810
set(CMAKE_CXX_STANDARD 20)
911
set(CMAKE_CXX_STANDARD_REQUIRED 20)
@@ -17,9 +19,8 @@ set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
1719
# compile options used
1820
add_compile_options(-frtti -fexceptions)
1921

20-
21-
2222
add_compile_options(-O3)
23+
2324
# compile definitions used
2425
add_compile_definitions(VERSION=\"${MOD_VERSION}\")
2526
add_compile_definitions(MOD_ID=\"${MOD_ID}\")
@@ -41,18 +42,25 @@ add_library(
4142
${c_file_list}
4243
${inline_hook_c}
4344
${inline_hook_cpp}
45+
tracks_rs_link/target/aarch64-linux-android/release/libtracks_rs_link.a
4446
)
4547

4648
# add src dir as include dir
4749
target_include_directories(${COMPILE_ID} PRIVATE ${SOURCE_DIR})
50+
4851
# add include dir as include dir
4952
target_include_directories(${COMPILE_ID} PRIVATE ${INCLUDE_DIR})
53+
5054
# add shared dir as include dir
5155
target_include_directories(${COMPILE_ID} PUBLIC ${SHARED_DIR})
52-
# codegen includes
56+
57+
# codegen includes
5358
target_include_directories(${COMPILE_ID} PRIVATE ${EXTERN_DIR}/includes/${CODEGEN_ID}/include)
5459

5560
target_link_libraries(${COMPILE_ID} PRIVATE -llog)
61+
target_link_directories(${COMPILE_ID} PUBLIC tracks_rs_link/target/aarch64-linux-android/release)
62+
target_link_libraries(${COMPILE_ID} PUBLIC tracks_rs_link)
63+
5664
# add extern stuff like libs and other includes
5765
include(extern.cmake)
5866

@@ -64,14 +72,14 @@ add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
6472
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
6573
COMMAND ${CMAKE_COMMAND} -E make_directory debug
6674
COMMENT "Rename the lib to debug_ since it has debug symbols"
67-
)
75+
)
6876

6977
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
7078
COMMAND ${CMAKE_COMMAND} -E rename lib${COMPILE_ID}.so debug/lib${COMPILE_ID}.so
7179
COMMENT "Rename the lib to debug_ since it has debug symbols"
72-
)
80+
)
7381

7482
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
7583
COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so
7684
COMMENT "Rename the stripped lib to regular"
77-
)
85+
)

build.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ if (($clean.IsPresent) -or (-not (Test-Path -Path "build")))
1919
$out = new-item -Path build -ItemType Directory
2020
}
2121

22-
cd build
22+
# build the rust code
23+
cd ./tracks_rs_link
24+
cargo ndk --bindgen --no-strip -t arm64-v8a -o build build --release
25+
26+
cd ../build
2327
& cmake -G "Ninja" -DCMAKE_BUILD_TYPE="RelWithDebInfo" ../
2428
& cmake --build .
2529
cd ..

include/Animation/Events.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,27 @@ void AddEventCallbacks();
1212
void UpdateCoroutines(GlobalNamespace::BeatmapCallbacksController* callbackController);
1313

1414
struct AnimateTrackContext {
15-
PointDefinition* points;
16-
Property* property;
15+
PointDefinitionW points;
16+
PropertyW property;
1717
float duration;
1818
Functions easing;
1919
float startTime;
2020
int repeat;
2121

22-
constexpr AnimateTrackContext(PointDefinition* points, Property* aProperty, float duration, float startTime,
22+
constexpr AnimateTrackContext(PointDefinitionW points, PropertyW aProperty, float duration, float startTime,
2323
Functions easing, int repeat)
2424
: points(points), property(aProperty), duration(duration), startTime(startTime), easing(easing), repeat(repeat) {}
2525

26-
constexpr AnimateTrackContext() = default;
2726
};
2827

2928
struct AssignPathAnimationContext {
30-
PathProperty* property;
29+
PathPropertyW property;
3130
float duration;
3231
Functions easing;
3332
float startTime;
3433
int repeat;
3534

36-
constexpr AssignPathAnimationContext() = default;
37-
38-
constexpr AssignPathAnimationContext(PathProperty* aProperty, float duration, float startTime, Functions easing,
35+
constexpr AssignPathAnimationContext(PathPropertyW aProperty, float duration, float startTime, Functions easing,
3936
int repeat)
4037
: property(aProperty), duration(duration), startTime(startTime), easing(easing), repeat(repeat) {}
4138
};

qpm.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"info": {
66
"name": "Tracks",
77
"id": "tracks",
8-
"version": "1.0.0",
8+
"version": "1.1.0",
99
"url": "https://github.com/StackDoubleFlow/Tracks",
1010
"additionalData": {
1111
"overrideSoName": "libtracks.so",
@@ -18,6 +18,7 @@
1818
"pwsh ./build.ps1"
1919
]
2020
},
21+
"ndk": "^27.1.12297006",
2122
"qmodIncludeDirs": [
2223
"./build",
2324
"./extern/libs"
@@ -29,11 +30,13 @@
2930
{
3031
"id": "beatsaber-hook",
3132
"versionRange": "^6.1.7",
32-
"additionalData": {}
33+
"additionalData": {
34+
"extraFiles": []
35+
}
3336
},
3437
{
3538
"id": "bs-cordl",
36-
"versionRange": "^4000.0.0",
39+
"versionRange": "^4030.0.0",
3740
"additionalData": {
3841
"includeQmod": true
3942
}
@@ -51,7 +54,9 @@
5154
{
5255
"id": "scotland2",
5356
"versionRange": "*",
54-
"additionalData": {}
57+
"additionalData": {
58+
"includeQmod": false
59+
}
5560
},
5661
{
5762
"id": "custom-types",
@@ -67,7 +72,7 @@
6772
},
6873
{
6974
"id": "paper2_scotland2",
70-
"versionRange": "^4.4.1",
75+
"versionRange": "^4.6.1",
7176
"additionalData": {}
7277
}
7378
]

0 commit comments

Comments
 (0)