Skip to content

Commit

Permalink
feat: CI for auto updating vcpkg port (#20)
Browse files Browse the repository at this point in the history
This is for
https://github.com/Starfield-Reverse-Engineering/Starfield-RE-vcpkg/pull/1
Also made the Maintenance script manually dispatchable.

closes #13

---------

Co-authored-by: maintenance <[email protected]>
  • Loading branch information
gottyduke and gottyduke authored Sep 8, 2023
1 parent c4ab3bc commit b3235bf
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup MSVC Environment
uses: ilammy/msvc-dev-cmd@v1.10.0
uses: ilammy/msvc-dev-cmd@v1.12.1

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: main
paths:
- "CommonLibSF/**"
workflow_dispatch:

jobs:
maintenance:
Expand All @@ -17,7 +18,7 @@ jobs:
shell: pwsh
run: "& ${{ github.workspace }}/.github/make-directives.ps1 ${{ github.workspace }}/CommonLibSF"

- name: Run clang-format
- name: Apply Clang-Format
uses: DoozyX/[email protected]
with:
source: "."
Expand All @@ -26,16 +27,16 @@ jobs:
clangFormatVersion: 16
inplace: True

- name: Update vcpkg version-date
- name: Update VCPKG Version
id: versioning
shell: pwsh
run: "& ${{ github.workspace }}/.github/update-registry.ps1 ${{ github.workspace }}"

- name: Check for success
- name: Check Failure
run: exit 1
if: ${{ steps.versioning.outputs.VCPKG_SUCCESS == 'false' }}

- name: Check for commit
- name: Check for Commit
uses: EndBug/add-and-commit@v9
with:
author_name: maintenance
Expand All @@ -47,6 +48,5 @@ jobs:
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.VCPKG_HELPER_TOKEN }}
repository: Starfield-Reverse-Engineering/Starfield-RE-vcpkg
repository: ${{ github.repository_owner }}/Starfield-RE-vcpkg
event-type: update-event
client-payload: '{"sha": "${{ github.sha }}"}'
15 changes: 2 additions & 13 deletions CommonLibSF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ if(TARGET CommonLibSF)
return()
endif()

# options if not defined
option(SFSE_SUPPORT_XBYAK "Enables trampoline support for Xbyak." ON)

# standards & flags
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand All @@ -32,6 +29,7 @@ endif()

# dependencies
find_package(spdlog CONFIG REQUIRED)
find_package(xbyak CONFIG REQUIRED)

# source files
execute_process(COMMAND powershell -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_SOURCE_DIR}/cmake/make-sourcelist.ps1" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}")
Expand Down Expand Up @@ -116,18 +114,9 @@ target_link_libraries(
${PROJECT_NAME}
PUBLIC
spdlog::spdlog
Version.lib
)

if (SFSE_SUPPORT_XBYAK)
find_package(xbyak CONFIG REQUIRED)

target_link_libraries(
${PROJECT_NAME}
PUBLIC
xbyak::xbyak
Version.lib
)
endif()

target_precompile_headers(
${PROJECT_NAME}
Expand Down
2 changes: 1 addition & 1 deletion CommonLibSF/cmake/config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
include(CMakeFindDependencyMacro)

find_dependency(spdlog CONFIG)
find_dependency(xbyak CONFIG)
11 changes: 0 additions & 11 deletions CommonLibSF/include/REL/Relocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,17 +638,6 @@ namespace REL
return write_vfunc(a_idx, stl::unrestricted_cast<std::uintptr_t>(a_newFunc));
}

/**
template <class F, std::size_t idx, class T>
void write_vfunc()
{
REL::Relocation<std::uintptr_t> vtbl{ F::VTABLE[0]
* * };
T::func = vtbl.write_vfunc(idx, T::thunk);
}
**/

private:
[[nodiscard]] static std::uintptr_t base()
{
Expand Down
4 changes: 4 additions & 0 deletions CommonLibSF/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"license": "GPL-3.0-or-later",
"supports": "windows & x64",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
Expand Down
32 changes: 6 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,7 @@

#### vcpkg

Add the following to your `vcpkg-configuration`:

```json
"registries": [
{
"kind": "git",
"repository": "https://github.com/Starfield-Reverse-Engineering/Starfield-RE-vcpkg",
"baseline": "<SHA of latest commit to the above repository>",
"packages": [
"commonlibsf"
]
}
]
```

And the following to your `CMakeLists.txt`:

```cmake
find_package(CommonLibSF CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME}
PRIVATE
CommonLibSF::CommonLibSF)
```
[See how to use CommonLibSF with vcpkg in your project.](https://github.com/Starfield-Reverse-Engineering/Starfield-RE-vcpkg)

---

Expand All @@ -67,9 +45,11 @@ Then add the following to your `CMakeLists.txt`:

```cmake
add_subdirectory(extern/CommonLibSF)
target_link_libraries(${PROJECT_NAME}
PRIVATE
CommonLibSF::CommonLibSF)
target_link_libraries(
${PROJECT_NAME}
PRIVATE
CommonLibSF::CommonLibSF
)
```

## End-User Dependencies
Expand Down

0 comments on commit b3235bf

Please sign in to comment.