Skip to content

Commit

Permalink
Add build files & actions
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBrumbler committed Dec 27, 2023
1 parent 0ccea21 commit 8640758
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/actions/canary-ndk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Setup canary ndk"
description: "Sets up canary ndk"
outputs:
ndk-path:
value: ${{ steps.path.outputs.path }}
description: "Output path of the ndk"
cache-hit:
value: ${{ steps.cache.outputs.cache-hit }}
description: "Whether a cache hit occurred for the ndk"
runs:
using: "composite"
steps:
- name: NDK cache
id: cache
uses: actions/cache@v3
with:
path: ${HOME}/android-ndk-r27-canary/
key: ${{ runner.os }}-ndk-r27-canary

- name: Download canary ndk
if: ${{ !steps.cache.outputs.cache-hit }}
env:
CANARY_URL: https://github.com/QuestPackageManager/ndk-canary-archive/releases/download/27.0.1/android-ndk-10883340-linux-x86_64.zip
run: wget ${CANARY_URL} -O ${HOME}/ndk.zip
shell: bash

- name: Unzip ndk
if: ${{ !steps.cache.outputs.cache-hit }}
run: 7z x "${HOME}/ndk.zip" -o"${HOME}/"
shell: bash

- name: Set output
id: path
shell: bash
run: echo "path=${HOME}/android-ndk-r27-canary" >> ${GITHUB_OUTPUT}
97 changes: 97 additions & 0 deletions .github/workflows/build-ndk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: NDK build

on:
push:
tags:
- 'v*'
branches:
- main
- dev/*
- feat/*
paths-ignore:
- '**.yml'
- '!.github/workflows/build-ndk.yml'
- '!.github/actions/canary-ndk/action.yml'
- '**.md'
- '**.json'
- '!qpm.json'
- '!qpm.shared.json'
- '.gitignore'
pull_request:
branches:
- main

jobs:
# test if the pushed files compile
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
lfs: true

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

- name: Setup Canary NDK
id: setup-ndk
uses: ./.github/actions/canary-ndk

- name: Create ndkpath.txt
run: |
echo ${{ steps.setup-ndk.outputs.path }} > ${GITHUB_WORKSPACE}/ndkpath.txt
cat ${GITHUB_WORKSPACE}/ndkpath.txt
- name: Setup qpm for regular build
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
uses: Fernthedev/qpm-action@main
with:
workflow_token: ${{ secrets.GITHUB_TOKEN }}
restore: true
cache: false
publish: false

- name: Build
run: |
cd ${GITHUB_WORKSPACE}
qpm s build
publish:
runs-on: ubuntu-latest

# if build was successful and a tag was pushed, we release
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
lfs: true

- name: Extract version
id: version
run: |
echo "TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_OUTPUT}
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> ${GITHUB_OUTPUT}
- name: Setup qpm for release
uses: Fernthedev/qpm-action@main
with:
workflow_token: ${{ secrets.GITHUB_TOKEN }}
restore: true
cache: false
publish: true
publish_token: ${{ secrets.QPM_KEY }}
version: ${{ steps.version.outputs.VERSION }}
tag: ${{ steps.version.outputs.TAG }}
qpm_release_bin: false
qpm_debug_bin: false

- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/v')
with:
generate_release_notes: true
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/
extern/
ndkpath.txt
*.cmake
56 changes: 56 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
cmake_minimum_required(VERSION 3.25)

include(${CMAKE_CURRENT_LIST_DIR}/cmake/quest.cmake)

project(bs-cordl VERSION ${PACKAGE_VERSION})

set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED 20)

add_compile_options(
-frtti
-fPIE
-fPIC
-fexceptions
-fdeclspec
-O3
-fpack-struct=8
-DANDROID
-DNO_CODEGEN_USE
-DNO_CODEGEN_WRAPPERS
)

file(GLOB_RECURSE headers ${CMAKE_CURRENT_LIST_DIR}/include/*.hpp)
set(namespace_headers "")
foreach (file_path in ${headers})
cmake_path(GET file_path FILENAME file_name)
cmake_path(REMOVE_EXTENSION file_name)

cmake_path(GET file_path PARENT_PATH parent_path)
cmake_path(GET parent_path STEM directory)

# namespace includes are files that are named like ../foldername/foldername.hpp
string(COMPARE EQUAL "${file_name}" "${directory}" is_ns_include)
if (is_ns_include)
cmake_path(RELATIVE_PATH file_path BASE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/include")
list(APPEND namespace_headers "${file_path}")
endif()
endforeach()

set(${main_content} "")
string(APPEND main_content "#pragma once\n")


add_library(${CMAKE_PROJECT_NAME} SHARED)
foreach(file_path IN LISTS namespace_headers)
cmake_path(REPLACE_EXTENSION file_path "cpp" OUTPUT_VARIABLE src_file_path)

file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/include/${src_file_path}" CONTENT "#include \"beatsaber-hook/shared/utils/typedefs.h\"\n#include \"${file_path}\"\n")
target_sources(${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include/${src_file_path}")
# target_precompile_headers(${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/include/${file_path}")
endforeach()

target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/extern/includes)
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/extern/includes/libil2cpp/il2cpp/libil2cpp)
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# bs-cordl

Quest modding library representing the functions from the il2cpp metadata of the game Beat Saber

Files generated using [cordl](https://github.com/Fernthedev/cordl)

Building of this project is strictly used for checking whether the files are generated correctly
38 changes: 38 additions & 0 deletions qpm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"sharedDir": "include",
"dependenciesDir": "extern",
"info": {
"name": "bs-cordl",
"id": "bs-cordl",
"version": "0.1.0",
"url": null,
"additionalData": {
"headersOnly": true,
"compileOptions": {
"includePaths": ["include"],
"cppFeatures": [],
"cppFlags": ["-DNEED_UNSAFE_CSHARP", "-fdeclspec", "-DUNITY_2021"]
}
}
},
"dependencies": [
{
"id": "beatsaber-hook",
"versionRange": "^5.0.0",
"additionalData": {}
},
{
"id": "libil2cpp",
"versionRange": "^0.3.0",
"additionalData": {}
}
],
"workspace": {
"scripts": {
"build": [
"cmake -G \"Ninja\" -DCMAKE_BUILD_TYPE=\"RelWithDebInfo\" -B ./build -S .",
"cmake --build ./build"
]
}
}
}
73 changes: 73 additions & 0 deletions qpm.shared.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"config": {
"sharedDir": "include",
"dependenciesDir": "extern",
"info": {
"name": "bs-cordl",
"id": "bs-cordl",
"version": "0.1.0",
"url": "https://github.com/QuestPackageManager/bs-cordl",
"additionalData": {
"headersOnly": true,
"compileOptions": {
"includePaths": [
"include"
],
"cppFeatures": [],
"cppFlags": [
"-DNEED_UNSAFE_CSHARP",
"-fdeclspec",
"-DUNITY_2021"
]
}
}
},
"dependencies": [
{
"id": "beatsaber-hook",
"versionRange": "^5.0.0",
"additionalData": {}
},
{
"id": "libil2cpp",
"versionRange": "^0.3.0",
"additionalData": {}
}
],
"workspace": null
},
"restoredDependencies": [
{
"dependency": {
"id": "libil2cpp",
"versionRange": "=0.3.1",
"additionalData": {
"headersOnly": true
}
},
"version": "0.3.1"
},
{
"dependency": {
"id": "beatsaber-hook",
"versionRange": "=5.0.0",
"additionalData": {
"soLink": "https://github.com/sc2ad/beatsaber-hook/releases/download/v0.5.8/libbeatsaber-hook.so",
"debugSoLink": "https://github.com/sc2ad/beatsaber-hook/releases/download/v0.5.8/debug_libbeatsaber-hook.so",
"branchName": "master"
}
},
"version": "5.0.0"
},
{
"dependency": {
"id": "scotland2",
"versionRange": "=0.1.3",
"additionalData": {
"overrideSoName": "libsl2.so"
}
},
"version": "0.1.3"
}
]
}

0 comments on commit 8640758

Please sign in to comment.