Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# include some defines automatically made by qpm
include(qpm_defines.cmake)

# 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)
set(CMAKE_CXX_STANDARD 26)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand All @@ -22,8 +20,38 @@ 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)
add_link_options(-Wl,--exclude-libs,ALL)
add_compile_options(-frtti -fPIE -fPIC -fexceptions -fvisibility=hidden)

if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
add_compile_options(-O3 -flto)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
add_compile_options(-O0 -g)
endif()

# get git info
execute_process(COMMAND git config user.name OUTPUT_VARIABLE GIT_USER)
execute_process(COMMAND git branch --show-current OUTPUT_VARIABLE GIT_BRANCH)
execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_COMMIT)
execute_process(COMMAND git diff-index --quiet HEAD RESULT_VARIABLE GIT_MODIFIED)

string(STRIP "${GIT_USER}" GIT_USER)
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
string(STRIP "${GIT_COMMIT}" GIT_COMMIT)
string(STRIP "${GIT_MODIFIED}" GIT_MODIFIED)

message(STATUS "GIT_USER: ${GIT_USER}")
message(STATUS "GIT_BRANCH: ${GIT_BRANCH}")
message(STATUS "GIT_COMMIT: 0x${GIT_COMMIT}")
message(STATUS "GIT_MODIFIED: ${GIT_MODIFIED}")

# set git defines
add_compile_definitions(GIT_USER=\"${GIT_USER}\")
add_compile_definitions(GIT_BRANCH=\"${GIT_BRANCH}\")
add_compile_definitions(GIT_COMMIT=0x${GIT_COMMIT})
add_compile_definitions(GIT_MODIFIED=${GIT_MODIFIED})

# compile definitions used
add_compile_definitions(VERSION=\"${MOD_VERSION}\")
add_compile_definitions(MOD_ID=\"${MOD_ID}\")
Expand Down
9 changes: 9 additions & 0 deletions include/_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#define BSS_EXPORT __attribute__((visibility("default")))

#ifdef __cplusplus
#define EXPORT_FUNC extern "C" BSS_EXPORT
#else
#define EXPORT_FUNC BSS_EXPORT
#endif
8 changes: 8 additions & 0 deletions include/logging.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "paper2_scotland2/shared/logger.hpp"

static constexpr auto Logger = Paper::ConstLoggerContext(MOD_ID);

#define LOG_INFO(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::INF>(str, MOD_ID __VA_OPT__(, __VA_ARGS__))
#define LOG_ERROR(str, ...) Paper::Logger::fmtLogTag<Paper::LogLevel::ERR>(str, MOD_ID __VA_OPT__(, __VA_ARGS__))
9 changes: 4 additions & 5 deletions include/main.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#pragma once

#include "beatsaber-hook/shared/utils/logging.hpp"
#include "_config.h"
#include "scotland2/shared/loader.hpp"
#include "beatsaber-hook/shared/hooking.hpp"

#define LOG_INFO(...) logger.info(__VA_ARGS__)
#define LOG_ERROR(...) logger.error(__VA_ARGS__)

constexpr auto logger = Paper::ConstLoggerContext(MOD_ID);
static inline modloader::ModInfo modInfo = {MOD_ID, VERSION, GIT_COMMIT};
2 changes: 1 addition & 1 deletion mod.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "${version}",
"modloader": "Scotland2",
"packageId": "com.beatgames.beatsaber",
"packageVersion": "1.40.8_7379",
"packageVersion": "1.45.0_26420",
"description": "Speed up or remove boring transitions in the game",
"coverImage": "cover.png",
"dependencies": [],
Expand Down
40 changes: 30 additions & 10 deletions qpm.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"pwsh ./scripts/build.ps1 $0?"
],
"copy": [
"pwsh ./scripts/copy.ps1 $0:?",
"pwsh ./scripts/restart-game.ps1"
"pwsh ./scripts/copy.ps1 $0:?"
],
"log": [
"pwsh ./scripts/start-logging.ps1 $0:"
Expand All @@ -39,7 +38,7 @@
"pwsh ./scripts/pull-tombstone.ps1 -analyze"
]
},
"ndk": "^27.2.12479018",
"ndk": "^29.0.14206865",
"qmodIncludeDirs": [
"build",
"extern/libs"
Expand All @@ -50,39 +49,60 @@
"dependencies": [
{
"id": "beatsaber-hook",
"versionRange": "^6.4.2",
"versionRange": "^8.2.1",
"additionalData": {}
},
{
"id": "bs-cordl",
"versionRange": "^4008.0.0",
"versionRange": "^4500.0.0",
"additionalData": {}
},
{
"id": "bsml",
"versionRange": "^0.4.53",
"versionRange": "^0.5.8",
"additionalData": {}
},
{
"id": "config-utils",
"versionRange": "^2.0.3",
"versionRange": "^3.0.0",
"additionalData": {}
},
{
"id": "custom-types",
"versionRange": "^0.18.3",
"versionRange": "^0.20.0",
"additionalData": {}
},
{
"id": "fmt",
"versionRange": "^11.0.2",
"additionalData": {}
},
{
"id": "flamingo",
"versionRange": "^1.1.2",
"additionalData": {}
},
{
"id": "paper2_scotland2",
"versionRange": "^4.6.4",
"versionRange": "^4.7.0",
"additionalData": {}
},
{
"id": "reflectcpp",
"versionRange": "^0.25.0",
"additionalData": {}
},
{
"id": "rapidjson-macros",
"versionRange": "^3.0.0",
"additionalData": {}
},
{
"id": "scotland2",
"versionRange": "^0.1.6",
"additionalData": {
"includeQmod": false
"includeQmod": false,
"private": true
}
}
]
Expand Down
Loading
Loading