Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt, libintl, libuv #1

Merged
merged 1 commit into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions patches/libintl.patch
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions patches/libuv.patch
Original file line number Diff line number Diff line change
@@ -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})
66 changes: 66 additions & 0 deletions scripts/common.py
Original file line number Diff line number Diff line change
@@ -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()
6 changes: 6 additions & 0 deletions scripts/fmt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from common import Builder

Builder('fmt', [
'-DFMT_TEST=OFF',
'-DFMT_DOC=OFF'
]).exec()
7 changes: 7 additions & 0 deletions scripts/libintl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from common import Builder, patch

project = 'libintl'

patch(project)

Builder(project).exec()
10 changes: 10 additions & 0 deletions scripts/libuv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from common import Builder, patch

project = 'libuv'

patch(project)

Builder(project, [
'-DLIBUV_BUILD_SHARED=OFF',
'-DLIBUV_BUILD_TESTS=OFF'
]).exec()