-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
263 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: cmake ci | ||
on: [workflow_dispatch] | ||
jobs: | ||
build: | ||
runs-on: macos-14 | ||
steps: | ||
- name: Checkout last commit | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Configure build environment | ||
run: | | ||
brew install ninja rsync | ||
- name: Build | ||
run: | | ||
cmake -S. -GNinja -DCMAKE_OSX_DEPLOYMENT_TARGET=13 | ||
ninja -Cbuild |
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
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
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,95 @@ | ||
cmake_minimum_required(VERSION 3.30) | ||
project(squirrel VERSION 1.0.2 LANGUAGES CXX Swift) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | ||
|
||
# ############################################################################## | ||
# Options | ||
# ############################################################################## | ||
set(DEV_ID "UNSET" CACHE STRING "Dev ID for code-signing") | ||
set(SIGN_KEY "UNSET" CACHE STRING "Sign key for code-signing") | ||
option(FIXUP_WHEN_BUILD "Fix-up the app bundle in build time" ON) | ||
|
||
if(NOT (DEV_ID STREQUAL "UNSET") AND (SIGN_KEY STREQUAL "UNSET")) | ||
set(SIGN_KEY "Developer ID Application: ${DEV_ID}") | ||
endif() | ||
|
||
# ############################################################################## | ||
# Dependencies | ||
# ############################################################################## | ||
include(AddSparkle) | ||
include(AddRime) | ||
|
||
# ############################################################################## | ||
# Squirrel.app | ||
# ############################################################################## | ||
file(GLOB SRCS "${PROJECT_SOURCE_DIR}/Sources/*.swift") | ||
add_executable(Squirrel MACOSX_BUNDLE ${SRCS}) | ||
target_compile_options(Squirrel PRIVATE | ||
-import-objc-header "${PROJECT_SOURCE_DIR}/Sources/Squirrel-Bridging-Header.h" | ||
-enable-bare-slash-regex | ||
) | ||
target_include_directories(Squirrel PRIVATE | ||
"${PROJECT_SOURCE_DIR}/Sources" | ||
"${PROJECT_SOURCE_DIR}/librime/src" | ||
) | ||
target_link_libraries(Squirrel PRIVATE rime Sparkle) | ||
|
||
set(BUNDLE_PATH "${PROJECT_BINARY_DIR}/Squirrel.app") | ||
set(BUNDLE_CONTENTS_DIR "${BUNDLE_PATH}/Contents") | ||
set(BUNDLE_BIN_DIR "${BUNDLE_CONTENTS_DIR}/MacOS") | ||
set(BUNDLE_RESOURCES_DIR "${BUNDLE_CONTENTS_DIR}/Resources") | ||
set(BUNDLE_FRAMEWORKS_DIR "${BUNDLE_CONTENTS_DIR}/Frameworks") | ||
set(BUNDLE_SHARED_SUPPORT_DIR "${BUNDLE_CONTENTS_DIR}/SharedSupport") | ||
|
||
set_target_properties(Squirrel PROPERTIES | ||
MACOSX_BUNDLE_GUI_IDENTIFIER im.rime.inputmethod.Squirrel | ||
MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION} | ||
) | ||
|
||
# Copy additional binaries | ||
file(GLOB RIME_PROGRAMS "${CMAKE_BINARY_DIR}/librime/bin/rime_*") | ||
add_custom_command(TARGET Squirrel POST_BUILD | ||
COMMAND cp -a "${CMAKE_BINARY_DIR}/librime/bin/rime_*" ${BUNDLE_BIN_DIR}) | ||
|
||
# Copy resources | ||
add_subdirectory(resources) | ||
|
||
# Copy built-in schemas | ||
add_subdirectory(data) | ||
|
||
# Copy linked frameworks and libraries | ||
add_custom_command(TARGET Squirrel POST_BUILD | ||
COMMAND rsync -a "${CMAKE_CURRENT_BINARY_DIR}/librime/lib/" "${BUNDLE_FRAMEWORKS_DIR}" | ||
--exclude pkgconfig | ||
) | ||
add_custom_command(TARGET Squirrel POST_BUILD | ||
COMMAND rsync -a "${CMAKE_BINARY_DIR}/Sparkle.framework" | ||
"${BUNDLE_FRAMEWORKS_DIR}" | ||
--exclude=Headers --exclude=PrivateHeaders --exclude=Modules | ||
) | ||
|
||
# Fix linking so that the bundle is standalone | ||
set(FIXUP_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake) | ||
set(FIXUP_DIRS "${BUNDLE_FRAMEWORKS_DIR}") | ||
file(WRITE ${FIXUP_SCRIPT} " | ||
include(BundleUtilities) | ||
file(GLOB PLUGINS ${BUNDLE_FRAMEWORKS_DIR}/rime-plugins/*.dylib) | ||
fixup_bundle(\"${BUNDLE_PATH}\" \"\${PLUGINS}\" \"${FIXUP_DIRS}\") | ||
") | ||
if(${FIXUP_WHEN_BUILD}) | ||
add_custom_command(TARGET Squirrel POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -P ${FIXUP_SCRIPT} | ||
) | ||
endif() | ||
|
||
# Install (for development) | ||
set(CMAKE_SKIP_RPATH TRUE) # done by fixup_bundle | ||
install(SCRIPT ${FIXUP_SCRIPT}) | ||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target sign)") | ||
install(TARGETS Squirrel BUNDLE DESTINATION "/Library/Input\ Methods") | ||
|
||
# ############################################################################## | ||
# Distribution | ||
# ############################################################################## | ||
add_subdirectory(package) |
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
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,22 @@ | ||
include(ExternalProject) | ||
|
||
ExternalProject_Add(BuildRime | ||
SOURCE_DIR "${PROJECT_SOURCE_DIR}/librime" | ||
INSTALL_DIR "${PROJECT_BINARY_DIR}/librime" | ||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
-DCMAKE_BUILD_TYPE=Release | ||
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} | ||
-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} | ||
-DBUILD_MERGED_PLUGINS=OFF | ||
-DENABLE_EXTERNAL_PLUGINS=ON | ||
-DBUILD_TEST=OFF | ||
) | ||
|
||
add_library(rime INTERFACE) | ||
add_dependencies(rime BuildRime) | ||
target_include_directories(rime INTERFACE "${PROJECT_BINARY_DIR}/librime/include") | ||
target_link_directories(rime INTERFACE "${PROJECT_BINARY_DIR}/librime/lib/") | ||
target_link_libraries(rime INTERFACE -lrime) | ||
|
||
find_path(X11Keysym X11/keysym.h) | ||
target_include_directories(rime INTERFACE ${X11Keysym}) |
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,18 @@ | ||
include(ExternalProject) | ||
|
||
ExternalProject_Add(BuildSparkle | ||
SOURCE_DIR "${PROJECT_SOURCE_DIR}/Sparkle" | ||
|
||
CONFIGURE_COMMAND "" | ||
|
||
BUILD_COMMAND xcodebuild -project "<SOURCE_DIR>/Sparkle.xcodeproj" -scheme Sparkle -configuration Release | ||
BUILD_IN_SOURCE TRUE | ||
|
||
# Install Sparkle.framework | ||
INSTALL_COMMAND cp -a "<SOURCE_DIR>/build/Release/Sparkle.framework" "${CMAKE_BINARY_DIR}" | ||
) | ||
|
||
add_library(Sparkle INTERFACE) | ||
add_dependencies(Sparkle BuildSparkle) | ||
target_include_directories(Sparkle INTERFACE "${CMAKE_BINARY_DIR}/Sparkle.framework/Headers") | ||
target_link_libraries(Sparkle INTERFACE "${CMAKE_BINARY_DIR}/Sparkle.framework") |
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,10 @@ | ||
macro(process_xcstrings path outdir) | ||
get_filename_component(basename ${path} NAME_WLE) | ||
set(target ${outdir}/en.lproj/${basename}.strings) | ||
add_custom_command( | ||
OUTPUT ${target} | ||
COMMAND xcrun xcstringstool compile ${path} --output-directory ${outdir} | ||
COMMENT "Process ${basename}.xcstrings" | ||
) | ||
add_custom_target(xcstrings_${basename} ALL DEPENDS ${target}) | ||
endmacro() |
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,21 @@ | ||
set(OUTDIR "${BUNDLE_SHARED_SUPPORT_DIR}") | ||
|
||
# ############################################################################## | ||
# Plum | ||
# ############################################################################## | ||
add_custom_command( | ||
OUTPUT "${OUTDIR}/default.yaml" | ||
COMMAND make "OUTPUT=${OUTDIR}" -C "${PROJECT_SOURCE_DIR}/plum" | ||
COMMENT "plum: update default schemas") | ||
add_custom_target(plum-data ALL | ||
DEPENDS "${OUTDIR}/default.yaml") | ||
|
||
# ############################################################################## | ||
# OpenCC | ||
# ############################################################################## | ||
add_custom_command( | ||
OUTPUT "${OUTDIR}/opencc/s2t.json" | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/librime/share/opencc ${OUTDIR}/opencc | ||
COMMENT "opencc: copy data") | ||
add_custom_target(opencc-data ALL | ||
DEPENDS "${OUTDIR}/opencc/s2t.json") |
Submodule librime
updated
43 files
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,12 @@ | ||
add_custom_target(sign | ||
COMMAND codesign --deep --force --options runtime --timestamp --verbose | ||
--entitlements "${PROJECT_SOURCE_DIR}/resources/Squirrel.entitlements" | ||
--sign "${SIGN_KEY}" "${BUNDLE_PATH}" | ||
DEPENDS Squirrel | ||
) | ||
|
||
add_custom_target(package | ||
COMMAND ./make_package | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
DEPENDS sign | ||
) |
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,31 @@ | ||
# Info.plist | ||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist" INFO_PLIST) | ||
string(REPLACE "$(PRODUCT_BUNDLE_IDENTIFIER)" "@MACOSX_BUNDLE_GUI_IDENTIFIER@" INFO_PLIST "${INFO_PLIST}") | ||
string(REPLACE "$(CURRENT_PROJECT_VERSION)" "@MACOSX_BUNDLE_BUNDLE_VERSION@" INFO_PLIST "${INFO_PLIST}") | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/Info.plist" "${INFO_PLIST}") | ||
set_target_properties(Squirrel PROPERTIES | ||
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist | ||
) | ||
|
||
# Static resources | ||
set(FILES | ||
${PROJECT_SOURCE_DIR}/README.md | ||
${PROJECT_SOURCE_DIR}/LICENSE.txt | ||
rime.pdf | ||
) | ||
foreach(f ${FILES}) | ||
get_filename_component(filename ${f} NAME) | ||
configure_file(${f} ${BUNDLE_RESOURCES_DIR}/${filename} COPYONLY) | ||
endforeach() | ||
|
||
# Localization | ||
include(AppleUtils) | ||
process_xcstrings(${CMAKE_CURRENT_SOURCE_DIR}/Localizable.xcstrings ${BUNDLE_RESOURCES_DIR}) | ||
process_xcstrings(${CMAKE_CURRENT_SOURCE_DIR}/InfoPlist.xcstrings ${BUNDLE_RESOURCES_DIR}) | ||
|
||
# RimeIcon.icns | ||
add_custom_command( | ||
OUTPUT ${BUNDLE_RESOURCES_DIR}/RimeIcon.icns | ||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/Assets.xcassets/RimeIcon.appiconset ${CMAKE_BINARY_DIR}/RimeIcon.iconset && iconutil -c icns ${CMAKE_BINARY_DIR}/RimeIcon.iconset -o ${BUNDLE_RESOURCES_DIR}/RimeIcon.icns | ||
) | ||
add_custom_target(RimeIcon.icns ALL DEPENDS ${BUNDLE_RESOURCES_DIR}/RimeIcon.icns) |