-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Hanjp-IM/develop
Migrate to GObject from C++
- Loading branch information
Showing
25 changed files
with
1,703 additions
and
701 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "libhangul"] | ||
path = libhangul | ||
url = https://github.com/libhangul/libhangul.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(libhanjp) | ||
|
||
set(hangul_USE_STATIC_LIBS OFF) | ||
set(GObject_USE_STATIC_LIBS OFF) | ||
|
||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(hangul libhangul REQUIRED) | ||
add_library(hanjp automata.cpp inputcontext.cpp keyboard.cpp) | ||
target_include_directories(hanjp PUBLIC ${hangul_INCLUDE_DIRS}) | ||
target_link_libraries(hanjp ${hangul_LIBRARIES}) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
include(GenerateExportHeader) | ||
|
||
include(FetchContent) | ||
FetchContent_Declare( | ||
googletest | ||
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(GObject REQUIRED gobject-2.0) | ||
add_library(hanjp hanjpautomata.c hanjpinputcontext.c hanjpkeyboard.c | ||
${PROJECT_SOURCE_DIR}/libhangul/hangul/hangulctype.c | ||
${PROJECT_SOURCE_DIR}/libhangul/hangul/hangulkeyboard.c | ||
) | ||
|
||
# For Windows: Prevent overriding the parent project's compiler/linker settings | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
FetchContent_MakeAvailable(googletest) | ||
|
||
enable_testing() | ||
|
||
add_executable(testing testing.cpp) | ||
target_link_libraries(testing PUBLIC hanjp gtest_main) | ||
|
||
include(GoogleTest) | ||
gtest_discover_tests(testing) | ||
target_include_directories(hanjp PUBLIC ${GObject_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/libhangul/hangul) | ||
target_link_libraries(hanjp ${GObject_LIBRARIES}) | ||
generate_export_header(hanjp) | ||
|
||
add_subdirectory(test) | ||
|
||
install(TARGETS hanjp DESTINATION lib) | ||
install(FILES | ||
hanjp.h | ||
hanjpautomata.h | ||
hanjpkeyboard.h | ||
hanjpinputcontext.h | ||
hanjpunicode.h | ||
DESTINATION include | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,26 @@ | ||
C++ Migration work for libhanjp | ||
It is a library implemented for Hanjp input method engines. | ||
It is designed on GObject type system, so that it is easily portable to many platforms. | ||
You can use GObject Introspection for cross-language interoperability. | ||
|
||
Why migrate?: because it is difficult to write OOP style code on C(It is ugly) | ||
|
||
## How can we build? | ||
``` | ||
git clone --recurse-submodules https://github.com/Hanjp-IM/libhanjp.git | ||
cd libhanjp | ||
mkdir build | ||
cd build | ||
cmake .. | ||
make | ||
``` | ||
|
||
## Dependencies | ||
Currently, the library depends on two packages. | ||
``` | ||
glib-2.0 | ||
libhangul | ||
``` | ||
How can we install above? | ||
``` | ||
# On ubuntu | ||
sudo apt update && sudo apt install libglib2.0-dev libhangul-dev | ||
``` |
Oops, something went wrong.