Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

libthai #3

Merged
merged 1 commit into from
Aug 15, 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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "json"]
path = json
url = https://github.com/nlohmann/json
[submodule "libthai"]
path = libthai
url = https://github.com/tlwg/libthai
1 change: 1 addition & 0 deletions libthai
Submodule libthai added at 185a81
30 changes: 30 additions & 0 deletions patches/libthai.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 3.22.1)
project(libthai)

include(GNUInstallDirs)

set(LIBTHAI_HEADER
"include/thai/thailib.h"
"include/thai/thcell.h"
"include/thai/thinp.h"
)
set(LIBTHAI_SOURCE
src/thcell/thcell.c
src/thctype/thctype.c
src/thctype/wtt.c
src/thinp/thinp.c
)

add_library(thai STATIC ${LIBTHAI_SOURCE})
target_include_directories(thai PRIVATE include)
install(TARGETS thai)
install(FILES ${LIBTHAI_HEADER} DESTINATION include/thai)

configure_file(libthai.pc.in "${CMAKE_CURRENT_BINARY_DIR}/libthai.pc" @ONLY)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/libthai.pc"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)
10 changes: 10 additions & 0 deletions patches/libthai.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

Name: libthai
Description: Thai support library
Version: @CMAKE_PROJECT_VERSION@
Cflags: -I${includedir}
Libs: -L${libdir} -lthai
15 changes: 15 additions & 0 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ def ensure(program: str, args: list[str]):
raise Exception("Command failed")


def patch(project: str, src: str, dst: str | None = None):
src = f'patches/{src}'
if dst:
ensure('cp', [
src,
f'{project}/{dst}'
])
else:
ensure('git', [
'apply',
f'--directory={project}',
src
])


class Builder:
def __init__(self, name: str, options: list[str] | None=None):
self.name = name
Expand Down
8 changes: 8 additions & 0 deletions scripts/libthai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from common import Builder, patch

project = 'libthai'

patch(project, 'libthai.cmake', 'CMakeLists.txt')
patch(project, 'libthai.pc.in', '.')

Builder(project).exec()