Skip to content

Commit 51e3151

Browse files
authored
Update for 1.40.4 (#4)
1 parent 6d5bfab commit 51e3151

File tree

183 files changed

+556
-570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+556
-570
lines changed

.github/actions/canary-ndk/action.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/build-ndk.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
push:
66
branches:
77
- 'master'
8+
- 'dev'
89
paths-ignore:
910
- '**.yml'
1011
- '!.github/workflows/build-ndk.yml'
@@ -38,14 +39,9 @@ jobs:
3839

3940
- uses: seanmiddleditch/gha-setup-ninja@v3
4041

41-
# Use canary NDK to avoid lesser known compile bugs
42-
- name: Setup canary NDK
43-
id: setup-ndk
44-
uses: ./.github/actions/canary-ndk
45-
4642
- name: Create ndkpath.txt
4743
run: |
48-
echo ${{ steps.setup-ndk.outputs.ndk-path }} > ${GITHUB_WORKSPACE}/ndkpath.txt
44+
echo $ANDROID_NDK_HOME > ${GITHUB_WORKSPACE}/ndkpath.txt
4945
cat ${GITHUB_WORKSPACE}/ndkpath.txt
5046
5147
# get version from pushed tag
@@ -79,21 +75,21 @@ jobs:
7975
echo "NAME=${files[0]}" >> $GITHUB_OUTPUT
8076
8177
- name: Upload non-debug artifact
82-
uses: actions/upload-artifact@v2
78+
uses: actions/upload-artifact@v4
8379
with:
8480
name: ${{ steps.libname.outputs.NAME }}
8581
path: ./build/${{ steps.libname.outputs.NAME }}
8682
if-no-files-found: error
8783

8884
- name: Upload debug artifact
89-
uses: actions/upload-artifact@v2
85+
uses: actions/upload-artifact@v4
9086
with:
9187
name: debug_${{ steps.libname.outputs.NAME }}
9288
path: ./build/debug/${{ steps.libname.outputs.NAME }}
9389
if-no-files-found: error
9490

9591
- name: Upload qmod artifact
96-
uses: actions/upload-artifact@v2
92+
uses: actions/upload-artifact@v4
9793
with:
9894
name: ${{env.qmodName}}.qmod
9995
path: ./${{ env.qmodName }}.qmod

.github/workflows/publish.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@ jobs:
2222

2323
- uses: seanmiddleditch/gha-setup-ninja@v3
2424

25-
# Use canary NDK to avoid lesser known compile bugs
26-
- name: Setup canary NDK
27-
id: setup-ndk
28-
uses: ./.github/actions/canary-ndk
29-
3025
- name: Create ndkpath.txt
3126
run: |
32-
echo ${{ steps.setup-ndk.outputs.ndk-path }} > ${GITHUB_WORKSPACE}/ndkpath.txt
27+
echo $ANDROID_NDK_HOME > ${GITHUB_WORKSPACE}/ndkpath.txt
3328
cat ${GITHUB_WORKSPACE}/ndkpath.txt
3429
3530
# get version from pushed tag

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vs/
2+
.cache/
23

34
# Prerequisites
45
*.d
@@ -67,4 +68,4 @@ extern.cmake
6768
# QMOD Schema
6869
mod.json.schema
6970

70-
doxygen-build/
71+
doxygen-build/

CMakeLists.txt

Lines changed: 73 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
11
# include some defines automatically made by qpm
22
include(qpm_defines.cmake)
3-
include(${EXTERN_DIR}/includes/kaleb/shared/cmake/assets.cmake)
43

5-
add_definitions(-DCP_SDK_BMBF)
6-
add_definitions(-DDEBUG_SCENES)
4+
cmake_minimum_required(VERSION 3.22)
5+
project(${COMPILE_ID})
6+
include(${EXTERN_DIR}/includes/kaleb/shared/cmake/assets.cmake)
77

8-
# override mod id
9-
set(MOD_ID "ChatPlexSDK-BS")
8+
# c++ standard
9+
set(CMAKE_CXX_STANDARD 20)
10+
set(CMAKE_CXX_STANDARD_REQUIRED 20)
1011

1112
# Enable link time optimization
1213
# In my experience, this can be highly unstable but it nets a huge size optimization and likely performance
1314
# However, the instability was seen using Android.mk/ndk-build builds. With Ninja + CMake, this problem seems to have been solved.
1415
# As always, test thoroughly
1516
# - Fern
1617
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
17-
18-
cmake_minimum_required(VERSION 3.21)
19-
project(${COMPILE_ID})
20-
2118
# export compile commands for significantly better intellisense
2219
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2320

24-
# c++ standard
25-
set(CMAKE_CXX_STANDARD 20)
26-
set(CMAKE_CXX_STANDARD_REQUIRED 20)
27-
2821
# define that stores the actual source directory
2922
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
3023
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
3124
set(SHARED_DIR ${CMAKE_CURRENT_SOURCE_DIR}/shared)
3225

3326
# compile options used
34-
add_compile_options(-frtti -fexceptions)
35-
add_compile_options(-O3)
27+
add_compile_options(-frtti -fPIE -fPIC -fexceptions -fdeclspec -fvisibility=hidden -Wno-extra-qualification -O3)
3628

3729
# get git info
3830
execute_process(COMMAND git config user.name OUTPUT_VARIABLE GIT_USER)
@@ -50,103 +42,107 @@ message(STATUS "GIT_BRANCH: ${GIT_BRANCH}")
5042
message(STATUS "GIT_COMMIT: 0x${GIT_COMMIT}")
5143
message(STATUS "GIT_MODIFIED: ${GIT_MODIFIED}")
5244

53-
# set git defines
54-
add_compile_definitions(GIT_USER=\"${GIT_USER}\")
55-
add_compile_definitions(GIT_BRANCH=\"${GIT_BRANCH}\")
56-
add_compile_definitions(GIT_COMMIT=0x${GIT_COMMIT})
57-
add_compile_definitions(GIT_MODIFIED=${GIT_MODIFIED})
45+
46+
# Check for file presence and read current contents
47+
set(GIT_INFO_H_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include/git_info.h")
48+
if(EXISTS "${GIT_INFO_H_PATH}")
49+
file(READ "${GIT_INFO_H_PATH}" GIT_INFO_H_CURRENT)
50+
else()
51+
set(GIT_INFO_H_CURRENT "")
52+
endif()
53+
54+
# Define new git info content
55+
set(GIT_INFO_H "#pragma once
56+
#define GIT_USER \"${GIT_USER}\"
57+
#define GIT_BRANCH \"${GIT_BRANCH}\"
58+
#define GIT_COMMIT 0x${GIT_COMMIT}
59+
#define GIT_MODIFIED ${GIT_MODIFIED}
60+
")
61+
62+
# Write git info to file if the contents have changed
63+
if(NOT "${GIT_INFO_H}" STREQUAL "${GIT_INFO_H_CURRENT}")
64+
file(WRITE "${GIT_INFO_H_PATH}" "${GIT_INFO_H}")
65+
endif()
66+
5867

5968
# compile definitions used
6069
add_compile_definitions(VERSION=\"${MOD_VERSION}\")
6170
add_compile_definitions(MOD_ID=\"${MOD_ID}\")
71+
add_compile_definitions(UNITY_2021)
72+
add_compile_definitions(CORDL_RUNTIME_FIELD_NULL_CHECKS)
6273
add_compile_definitions(__USE_LARGEFILE64)
63-
add_compile_definitions(BEATSABER_1_29_4_OR_NEWER)
74+
75+
# compile options used
76+
add_compile_definitions(CP_SDK_BMBF)
77+
add_compile_definitions(DEBUG_SCENES)
78+
79+
string(LENGTH "${CMAKE_CURRENT_LIST_DIR}/" FOLDER_LENGTH)
80+
add_compile_definitions("PAPER_ROOT_FOLDER_LENGTH=${FOLDER_LENGTH}")
6481

6582
# recursively get all src files
66-
RECURSE_FILES(h_file_lista ${INCLUDE_DIR}/*.hpp)
67-
RECURSE_FILES(h_file_listb ${SHARED_DIR}/*.hpp)
68-
RECURSE_FILES(hpp_file_lista ${INCLUDE_DIR}/*.hpp)
69-
RECURSE_FILES(hpp_file_listb ${SHARED_DIR}/*.hpp)
70-
RECURSE_FILES(cpp_file_list ${SOURCE_DIR}/*.cpp)
71-
RECURSE_FILES(c_file_list ${SOURCE_DIR}/*.c)
83+
recurse_files(cpp_file_list ${SOURCE_DIR}/*.cpp)
84+
recurse_files(c_file_list ${SOURCE_DIR}/*.c)
7285
list(APPEND c_file_list ${INCLUDE_DIR}/zip/src/zip.c)
7386

87+
recurse_files(inline_hook_c ${EXTERN_DIR}/includes/beatsaber-hook/shared/inline-hook/*.c)
88+
recurse_files(inline_hook_cpp ${EXTERN_DIR}/includes/beatsaber-hook/shared/inline-hook/*.cpp)
89+
7490
# add all src files to compile
7591
add_library(
76-
${COMPILE_ID}
77-
SHARED
78-
${h_file_lista}
79-
${h_file_listb}
80-
${hpp_file_lista}
81-
${hpp_file_listb}
82-
${cpp_file_list}
83-
${c_file_list}
92+
${COMPILE_ID} SHARED ${cpp_file_list} ${c_file_list} ${inline_hook_c} ${inline_hook_cpp}
8493
)
8594

86-
# Add any assets
87-
add_assets(assets_${COMPILE_ID} STATIC ${CMAKE_CURRENT_LIST_DIR}/assets ${INCLUDE_DIR}/assets.hpp)
88-
89-
# get the vcpkg dir from env variables
90-
if(EXISTS $ENV{VCPKG_ROOT})
91-
set(VCPKG_ROOT $ENV{VCPKG_ROOT})
92-
else()
93-
MESSAGE(ERROR "Please define the environment variable VCPKG_ROOT with the root to your vcpkg install!")
94-
endif()
95-
96-
target_include_directories(${COMPILE_ID} PRIVATE .)
97-
9895
# add src dir as include dir
9996
target_include_directories(${COMPILE_ID} PRIVATE ${SOURCE_DIR})
10097
# add include dir as include dir
10198
target_include_directories(${COMPILE_ID} PRIVATE ${INCLUDE_DIR})
10299
# add shared dir as include dir
103100
target_include_directories(${COMPILE_ID} PUBLIC ${SHARED_DIR})
104-
# codegen includes
105-
target_include_directories(${COMPILE_ID} PRIVATE ${EXTERN_DIR}/includes/${CODEGEN_ID}/include)
106101

107-
target_link_libraries(${COMPILE_ID} PRIVATE -llog)
108-
target_link_libraries(${COMPILE_ID} PRIVATE assets_${COMPILE_ID})
102+
# Add any assets
103+
add_assets(${COMPILE_ID}-assets STATIC ${CMAKE_CURRENT_LIST_DIR}/assets ${INCLUDE_DIR}/assets.hpp)
104+
target_link_libraries(${COMPILE_ID} PRIVATE -llog -lz ${COMPILE_ID}-assets)
109105

110106
# add extern stuff like libs and other includes
111107
include(extern.cmake)
112108

113109
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
114-
COMMAND ${CMAKE_STRIP} -d --strip-all
115-
"lib${COMPILE_ID}.so" -o "stripped_lib${COMPILE_ID}.so"
116-
COMMENT "Strip debug symbols done on final binary.")
110+
COMMAND ${CMAKE_STRIP} -g -S -d --strip-all
111+
"lib${COMPILE_ID}.so" -o "stripped_lib${COMPILE_ID}.so"
112+
COMMENT "Strip debug symbols done on final binary.")
117113

118114
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
119115
COMMAND ${CMAKE_COMMAND} -E make_directory debug
120116
COMMENT "Make directory for debug symbols"
121117
)
122118

123119
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
124-
COMMAND ${CMAKE_COMMAND} -E rename lib${COMPILE_ID}.so debug/lib${COMPILE_ID}.so
125-
COMMENT "Rename the lib to debug_ since it has debug symbols"
126-
)
120+
COMMAND ${CMAKE_COMMAND} -E rename lib${COMPILE_ID}.so debug/lib${COMPILE_ID}.so
121+
COMMENT "Rename the lib to debug_ since it has debug symbols"
122+
)
127123

128-
# strip debug symbols from the .so and all dependencies
129124
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
130-
COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so
131-
COMMENT "Rename the stripped lib to regular"
132-
)
133-
foreach(so_file ${so_list})
134-
cmake_path(GET so_file FILENAME file)
125+
COMMAND ${CMAKE_COMMAND} -E rename stripped_lib${COMPILE_ID}.so lib${COMPILE_ID}.so
126+
COMMENT "Rename the stripped lib to regular"
127+
)
135128

136-
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
137-
COMMAND ${CMAKE_COMMAND} -E copy ${so_file} debug/${file}
138-
COMMENT "Copy so files for ndk stack"
139-
)
129+
foreach(so_file ${so_list})
130+
cmake_path(GET so_file FILENAME file)
140131

141-
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
142-
COMMAND ${CMAKE_STRIP} -g -S -d --strip-all ${so_file} -o ${file}
143-
COMMENT "Strip debug symbols from the dependencies")
144-
endforeach()
132+
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
133+
COMMAND ${CMAKE_COMMAND} -E copy ${so_file} debug/${file}
134+
COMMENT "Copy so files for ndk stack"
135+
)
145136

146-
foreach(a_file ${a_list})
147-
cmake_path(GET a_file FILENAME file)
137+
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
138+
COMMAND ${CMAKE_STRIP} -g -S -d --strip-all ${so_file} -o ${file}
139+
COMMENT "Strip debug symbols from the dependencies")
140+
endforeach()
148141

149-
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
150-
COMMAND ${CMAKE_COMMAND} -E copy ${a_file} debug/${file}
151-
COMMENT "Copy a files for ndk stack")
152-
endforeach()
142+
foreach(a_file ${a_list})
143+
cmake_path(GET a_file FILENAME file)
144+
145+
add_custom_command(TARGET ${COMPILE_ID} POST_BUILD
146+
COMMAND ${CMAKE_COMMAND} -E copy ${a_file} debug/${file}
147+
COMMENT "Copy a files for ndk stack")
148+
endforeach()

include/git_info.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#pragma once
2+
#define GIT_USER "HardCPP"
3+
#define GIT_BRANCH "dev"
4+
#define GIT_COMMIT 0xc20158d
5+
#define GIT_MODIFIED 1

0 commit comments

Comments
 (0)