diff --git a/.github/workflows/update_git_tree.yml b/.github/workflows/update_git_tree.yml new file mode 100644 index 0000000..6a549fa --- /dev/null +++ b/.github/workflows/update_git_tree.yml @@ -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" diff --git a/.github/workflows/update_vcpkg_port.yml b/.github/workflows/update_vcpkg_port.yml new file mode 100644 index 0000000..dda2537 --- /dev/null +++ b/.github/workflows/update_vcpkg_port.yml @@ -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" diff --git a/ports/commonlibsf/portfile.cmake b/ports/commonlibsf/portfile.cmake new file mode 100644 index 0000000..524d3db --- /dev/null +++ b/ports/commonlibsf/portfile.cmake @@ -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) diff --git a/ports/commonlibsf/usage b/ports/commonlibsf/usage new file mode 100644 index 0000000..d74c6b5 --- /dev/null +++ b/ports/commonlibsf/usage @@ -0,0 +1,9 @@ +The package CommonLibSF provides CMake targets: + + find_package(CommonLibSF CONFIG REQUIRED) + + add_commonlibsf_plugin( + ${PROJECT_NAME} + AUTHOR + SOURCES + ) diff --git a/ports/commonlibsf/vcpkg.json b/ports/commonlibsf/vcpkg.json new file mode 100644 index 0000000..b6278c1 --- /dev/null +++ b/ports/commonlibsf/vcpkg.json @@ -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"] + } + } +} diff --git a/update_git_tree.py b/update_git_tree.py new file mode 100644 index 0000000..f98af2d --- /dev/null +++ b/update_git_tree.py @@ -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) diff --git a/update_vcpkg_port.py b/update_vcpkg_port.py new file mode 100644 index 0000000..ed35278 --- /dev/null +++ b/update_vcpkg_port.py @@ -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) diff --git a/versions/baseline.json b/versions/baseline.json new file mode 100644 index 0000000..6a31c1a --- /dev/null +++ b/versions/baseline.json @@ -0,0 +1,8 @@ +{ + "default": { + "commonlibsf": { + "baseline": "latest", + "port-version": 0 + } + } +} diff --git a/versions/c-/commonlibsf.json b/versions/c-/commonlibsf.json new file mode 100644 index 0000000..cb08928 --- /dev/null +++ b/versions/c-/commonlibsf.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "0", + "version-string": "latest", + "port-version": 0 + } + ] +}