diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..858267e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +name: ci + +on: + push: + branches: + - master + pull_request: + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - { os: macos-14, platform: OS } + - { os: macos-14, platform: SIMULATOR } + - { os: macos-13, platform: SIMULATOR } + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Build + env: + IOS_PLATFORM: ${{ matrix.platform }} + run: | + python scripts/fmt.py + python scripts/libintl.py + python scripts/libuv.py + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: artifact-${{ matrix.os }}-${{ matrix.platform }} + path: | + build/*.tar.bz2 + + - name: Setup tmate session + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 + + release: + needs: build + if: ${{ github.ref == 'refs/heads/master' }} + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + merge-multiple: true + + - name: Release + uses: 'marvinpinto/action-automatic-releases@latest' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + automatic_release_tag: latest + prerelease: true + title: "Nightly Build" + files: | + *.tar.bz2 diff --git a/patches/libintl.patch b/patches/libintl.patch new file mode 100644 index 0000000..20b763f --- /dev/null +++ b/patches/libintl.patch @@ -0,0 +1,10 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 03903b9..2231dc8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required(VERSION 3.0) ++cmake_minimum_required(VERSION 3.27) + project(LibIntl VERSION 1.0) + + include(GNUInstallDirs) diff --git a/patches/libuv.patch b/patches/libuv.patch new file mode 100644 index 0000000..70f7136 --- /dev/null +++ b/patches/libuv.patch @@ -0,0 +1,19 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 28c6df25..da5d2dd0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -759,12 +759,12 @@ set(UV_VERSION_MAJOR "${CMAKE_MATCH_1}") + set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) + set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + set(prefix ${CMAKE_INSTALL_PREFIX}) +-configure_file(libuv-static.pc.in libuv-static.pc @ONLY) ++configure_file(libuv.pc.in libuv.pc @ONLY) + + install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) + install(FILES LICENSE-extra DESTINATION ${CMAKE_INSTALL_DOCDIR}) +-install(FILES ${PROJECT_BINARY_DIR}/libuv-static.pc ++install(FILES ${PROJECT_BINARY_DIR}/libuv.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(TARGETS uv_a EXPORT libuvConfig + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/scripts/common.py b/scripts/common.py new file mode 100644 index 0000000..4b309bb --- /dev/null +++ b/scripts/common.py @@ -0,0 +1,66 @@ +import os +import platform + +INSTALL_PREFIX = '/usr' + + +def ensure(program: str, args: list[str]): + command = " ".join([program, *args]) + print(command) + if os.system(command) != 0: + raise Exception("Command failed") + + +def patch(project: str, src: str | None = None, dst: str | None = None): + if src and dst: + ensure('cp', [ + f'patches/{src}', + f'{project}/{dst}' + ]) + else: + ensure('git', [ + 'apply', + f'--directory={project}', + f'patches/{project}.patch' + ]) + + +class Builder: + def __init__(self, name: str, options: list[str] | None=None, src='.', build='build', dep=False): + self.name = name + self.root = os.getcwd() + self.destdir = f'{self.root}/build/{self.name}' + self.options = options or [] + self.src = src + self.build_ = build + + def configure(self): + os.environ['PKG_CONFIG_PATH'] = f'{self.root}/build/sysroot/usr/lib/pkgconfig' + os.chdir(f'{self.root}/{self.name}') + ensure('cmake', [ + '-B', self.build_, '-G', 'Xcode', + '-S', self.src, + '-DCMAKE_TOOLCHAIN_FILE=../ios.cmake', + f'-DIOS_PLATFORM={os.environ["IOS_PLATFORM"]}', + '-DBUILD_SHARED_LIBS=OFF', + f'-DCMAKE_INSTALL_PREFIX={INSTALL_PREFIX}', + f'-DCMAKE_FIND_ROOT_PATH={self.root}/build/sysroot/usr', + *self.options + ]) + + def build(self): + ensure('cmake', ['--build', self.build_, '--config', 'Release']) + + def install(self): + os.environ['DESTDIR'] = self.destdir + ensure('cmake', ['--install', self.build_]) + + def package(self): + os.chdir(f'{self.destdir}{INSTALL_PREFIX}') + ensure('tar', ['cjvf', f'{self.destdir}{"-" + platform.machine() if os.environ["IOS_PLATFORM"] == "SIMULATOR" else ""}.tar.bz2', '*']) + + def exec(self): + self.configure() + self.build() + self.install() + self.package() diff --git a/scripts/fmt.py b/scripts/fmt.py new file mode 100644 index 0000000..249cb4a --- /dev/null +++ b/scripts/fmt.py @@ -0,0 +1,6 @@ +from common import Builder + +Builder('fmt', [ + '-DFMT_TEST=OFF', + '-DFMT_DOC=OFF' +]).exec() diff --git a/scripts/libintl.py b/scripts/libintl.py new file mode 100644 index 0000000..62ba5b4 --- /dev/null +++ b/scripts/libintl.py @@ -0,0 +1,7 @@ +from common import Builder, patch + +project = 'libintl' + +patch(project) + +Builder(project).exec() diff --git a/scripts/libuv.py b/scripts/libuv.py new file mode 100644 index 0000000..f773ef5 --- /dev/null +++ b/scripts/libuv.py @@ -0,0 +1,10 @@ +from common import Builder, patch + +project = 'libuv' + +patch(project) + +Builder(project, [ + '-DLIBUV_BUILD_SHARED=OFF', + '-DLIBUV_BUILD_TESTS=OFF' +]).exec()