Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirdEyeSqueegee committed Oct 2, 2024
0 parents commit 04dc598
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/update_git_tree.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Update git-tree

on:
workflow_run:
workflows: Update vcpkg port
types: completed
workflow_dispatch:

permissions: write-all

concurrency:
group: update-git-tree
cancel-in-progress: true

jobs:
update-git-tree:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- run: python update_git_tree.py

- name: Add & Commit
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "ci: update git-tree"
33 changes: 33 additions & 0 deletions .github/workflows/update_vcpkg_port.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Update vcpkg port

on:
repository_dispatch:
types: [update-clib-port-event]
workflow_dispatch:

permissions: write-all

concurrency:
group: update-vcpkg-port
cancel-in-progress: true

jobs:
update-vcpkg-port:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12

- run: python update_vcpkg_port.py

- name: Add & Commit
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "ci: update vcpkg port"
45 changes: 45 additions & 0 deletions ports/commonlibsf/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Starfield-Reverse-Engineering/CommonLibSF
REF 0
SHA512 0
HEAD_REF main
)

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
xbyak SFSE_SUPPORT_XBYAK
)

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS ${FEATURE_OPTIONS}
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(
PACKAGE_NAME CommonLibSF
CONFIG_PATH lib/cmake
)

vcpkg_copy_pdbs()

file(GLOB CMAKE_CONFIGS ${CURRENT_PACKAGES_DIR}/share/CommonLibSF/CommonLibSF/*.cmake)

file(
INSTALL ${CMAKE_CONFIGS}
DESTINATION ${CURRENT_PACKAGES_DIR}/share/CommonLibSF
)
file(
INSTALL ${SOURCE_PATH}/cmake/CommonLibSF.cmake
DESTINATION ${CURRENT_PACKAGES_DIR}/share/CommonLibSF
)

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share/CommonLibSF/CommonLibSF)

file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})

vcpkg_install_copyright(FILE_LIST ${SOURCE_PATH}/LICENSE)
9 changes: 9 additions & 0 deletions ports/commonlibsf/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The package CommonLibSF provides CMake targets:

find_package(CommonLibSF CONFIG REQUIRED)

add_commonlibsf_plugin(
${PROJECT_NAME}
AUTHOR <your name>
SOURCES <your source files>
)
24 changes: 24 additions & 0 deletions ports/commonlibsf/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "commonlibsf",
"version-string": "latest",
"description": "CommonLibSF",
"homepage": "https://github.com/Starfield-Reverse-Engineering/CommonLibSF",
"dependencies": [
"spdlog",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"xbyak": {
"description": "xbyak support",
"dependencies": ["xbyak"]
}
}
}
18 changes: 18 additions & 0 deletions update_git_tree.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from json import dumps, load
from subprocess import run

# Update CLibNG git-tree
clib_git_tree = run(
["git", "rev-parse", "HEAD:ports/commonlibsf"], capture_output=True
).stdout.decode()

with open("./versions/c-/commonlibsf.json") as f:
version = load(f)

version["versions"][0]["git-tree"] = clib_git_tree.strip("\n")

version_str = dumps(version, indent=2)
version_str += "\n"

with open("./versions/c-/commonlibsf.json", "w", newline="\r\n") as f:
f.write(version_str)
28 changes: 28 additions & 0 deletions update_vcpkg_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from hashlib import sha512
from re import sub
from subprocess import run
from urllib.request import urlretrieve

clib_repo = "https://github.com/Starfield-Reverse-Engineering/CommonLibSF"

clib_ref = (
run(["git", "ls-remote", clib_repo], capture_output=True)
.stdout.decode()
.splitlines()[0]
.split()[0]
)

# Update CommonLibSF portfile
clib_archive, _ = urlretrieve(f"{clib_repo}/archive/{clib_ref}.tar.gz")

with open(clib_archive, "rb") as f:
clib_sha = sha512(f.read()).hexdigest()

with open("./ports/commonlibsf/portfile.cmake") as f:
portfile = f.readlines()

portfile[3] = sub(r"(REF).*", f"REF {clib_ref}", portfile[3])
portfile[4] = sub(r"(SHA512).*", f"SHA512 {clib_sha}", portfile[4])

with open("./ports/commonlibsf/portfile.cmake", "w", newline="\r\n") as f:
f.writelines(portfile)
8 changes: 8 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"default": {
"commonlibsf": {
"baseline": "latest",
"port-version": 0
}
}
}
9 changes: 9 additions & 0 deletions versions/c-/commonlibsf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "0",
"version-string": "latest",
"port-version": 0
}
]
}

0 comments on commit 04dc598

Please sign in to comment.