Skip to content

Commit

Permalink
Update fcitx5 submodules and prebuilt
Browse files Browse the repository at this point in the history
- support addon factory v2 in AndroidSharedLibraryLoader
see fcitx/fcitx5#1185
- set VERSION_NAME and PREBUILT_DIR in NativeBaseConventionPlugin

# Conflicts:
#	lib/fcitx5-chinese-addons/src/main/cpp/fcitx5-chinese-addons
#	lib/fcitx5/src/main/cpp/fcitx5
#	lib/fcitx5/src/main/cpp/prebuilt
#	lib/libime/src/main/cpp/libime
#	plugin/anthy/src/main/cpp/fcitx5-anthy
#	plugin/rime/src/main/cpp/fcitx5-rime
#	plugin/unikey/src/main/cpp/fcitx5-unikey
  • Loading branch information
rocka authored and wxyzh committed Dec 10, 2024
1 parent 3f87783 commit 5d70f39
Show file tree
Hide file tree
Showing 49 changed files with 120 additions and 97 deletions.
2 changes: 1 addition & 1 deletion app/licenses/libraries/boost.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "boostorg/boost",
"artifactVersion": "1.83.0",
"artifactVersion": "1.86.0",
"description": "Free peer-reviewed portable C++ source libraries",
"name": "boostorg/boost",
"website": "https://www.boost.org/",
Expand Down
2 changes: 1 addition & 1 deletion app/licenses/libraries/fcitx5-chinese-addons.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "fcitx/fcitx5-chinese-addons",
"artifactVersion": "5.1.5",
"artifactVersion": "5.1.7",
"description": "Chinese related addon for fcitx5",
"name": "fcitx/fcitx5-chinese-addons",
"website": "https://github.com/fcitx/fcitx5-chinese-addons",
Expand Down
2 changes: 1 addition & 1 deletion app/licenses/libraries/fcitx5.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "fcitx/fcitx5",
"artifactVersion": "5.1.9",
"artifactVersion": "5.1.12",
"description": "Next generation of fcitx",
"name": "fcitx/fcitx5",
"website": "https://github.com/fcitx/fcitx5",
Expand Down
2 changes: 1 addition & 1 deletion app/licenses/libraries/fmt.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "fmtlib/fmt",
"artifactVersion": "9.1.0",
"artifactVersion": "11.0.2",
"description": "Open-source formatting library for C++",
"name": "fmtlib/fmt",
"website": "https://fmt.dev",
Expand Down
2 changes: 1 addition & 1 deletion app/licenses/libraries/libime.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "fcitx/libime",
"artifactVersion": "1.1.7",
"artifactVersion": "1.1.9",
"description": "library to support generic input method implementation",
"name": "fcitx/libime",
"website": "https://github.com/fcitx/libime",
Expand Down
2 changes: 1 addition & 1 deletion app/licenses/libraries/libintl-lite.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "j-jorge/libintl-lite",
"artifactVersion": "5750d92",
"artifactVersion": "ba15146",
"description": "simple (but less powerful) GNU gettext libintl replacement",
"name": "j-jorge/libintl-lite",
"website": "https://github.com/j-jorge/libintl-lite",
Expand Down
2 changes: 1 addition & 1 deletion app/licenses/libraries/libuv.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "libuv/libuv",
"artifactVersion": "1.47.0",
"artifactVersion": "1.49.2",
"description": "Cross-platform asynchronous I/O",
"name": "libuv/libuv",
"website": "https://libuv.org/",
Expand Down
2 changes: 1 addition & 1 deletion app/licenses/libraries/lua.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "lua/lua",
"artifactVersion": "5.4.6",
"artifactVersion": "5.4.7",
"description": "Powerful lightweight programming language designed for extending applications",
"name": "lua/lua",
"website": "https://www.lua.org/",
Expand Down
2 changes: 1 addition & 1 deletion app/licenses/libraries/opencc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "BYVoid/OpenCC",
"artifactVersion": "1.1.7",
"artifactVersion": "1.1.9",
"description": "opensource project for conversions between Traditional Chinese, Simplified Chinese and Japanese Kanji (Shinjitai).",
"name": "BYVoid/OpenCC",
"website": "https://opencc.byvoid.com/",
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

project(fcitx5-android VERSION 0.0.9)
project(fcitx5-android VERSION ${VERSION_NAME})

# For reproducible build
add_link_options("LINKER:--hash-style=gnu,--build-id=none")
Expand Down Expand Up @@ -31,9 +31,6 @@ add_subdirectory(androidfrontend)
add_subdirectory(androidkeyboard)
add_subdirectory(androidnotification)

# prebuilt dir. at least it works.
set(PREBUILT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../lib/fcitx5/src/main/cpp/prebuilt")

# prebuilt fmt
set(fmt_DIR "${PREBUILT_DIR}/fmt/${ANDROID_ABI}/lib/cmake/fmt")
find_package(fmt)
Expand All @@ -44,7 +41,7 @@ find_package(libuv)

# prebuilt boost
list(APPEND CMAKE_FIND_ROOT_PATH "${PREBUILT_DIR}/boost/${ANDROID_ABI}/lib/cmake")
find_package(Boost 1.83.0 REQUIRED COMPONENTS headers filesystem iostreams CONFIG)
find_package(Boost 1.86.0 REQUIRED COMPONENTS headers iostreams CONFIG)

set(CHINESE_ADDONS_PINYIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../lib/fcitx5-chinese-addons/src/main/cpp/fcitx5-chinese-addons/im/pinyin")
add_library(pinyin-customphrase STATIC "${CHINESE_ADDONS_PINYIN_DIR}/customphrase.cpp")
Expand Down
17 changes: 15 additions & 2 deletions app/src/main/cpp/androidaddonloader/androidaddonloader.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* SPDX-FileCopyrightText: Copyright 2016-2016 CSSlayer <[email protected]>
* SPDX-FileCopyrightText: Copyright 2023 Fcitx5 for Android Contributors
* SPDX-FileCopyrightText: Copyright 2023-2024 Fcitx5 for Android Contributors
* SPDX-FileComment: Modified from https://github.com/fcitx/fcitx5/blob/5.1.1/src/lib/fcitx/addonloader.cpp
*/

#include <exception>
#include <memory>
#include <string>
#include <utility>
#include <fcitx-utils/flags.h>
#include <fcitx-utils/library.h>
#include <fcitx-utils/log.h>
#include <fcitx-utils/standardpath.h>
#include <fcitx-utils/stringutils.h>
#include <fcitx/addoninfo.h>
#include <fcitx/addonloader.h>
#include <fcitx/addoninstance.h>
#include "androidaddonloader.h"

#define FCITX_LIBRARY_SUFFIX ".so"
Expand Down Expand Up @@ -65,7 +78,7 @@ AddonInstance *AndroidSharedLibraryLoader::load(const AddonInfo &info,
try {
registry_.emplace(
info.uniqueName(),
std::make_unique<AndroidSharedLibraryFactory>(std::move(lib)));
std::make_unique<AndroidSharedLibraryFactory>(info, std::move(lib)));
} catch (const std::exception &e) {
}
break;
Expand Down
23 changes: 19 additions & 4 deletions app/src/main/cpp/androidaddonloader/androidaddonloader.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* SPDX-FileCopyrightText: Copyright 2016-2016 CSSlayer <[email protected]>
* SPDX-FileCopyrightText: Copyright 2023 Fcitx5 for Android Contributors
* SPDX-FileCopyrightText: Copyright 2023-2024 Fcitx5 for Android Contributors
* SPDX-FileComment: Modified from https://github.com/fcitx/fcitx5/blob/5.1.1/src/lib/fcitx/addonloader_p.h
*/

#ifndef FCITX5_ANDROID_ANDROIDADDONLOADER_H
#define FCITX5_ANDROID_ANDROIDADDONLOADER_H

#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
#include <unordered_map>
#include <utility>
#include <fcitx-utils/library.h>
#include <fcitx-utils/standardpath.h>
#include <fcitx/addonloader.h>
#include <fcitx-utils/stringutils.h>
#include <fcitx/addonfactory.h>
#include <fcitx/addoninfo.h>
#include <fcitx/addoninstance.h>
#include <fcitx/addonloader.h>

namespace fcitx {

namespace {
constexpr char FCITX_ADDON_FACTORY_ENTRY[] = "fcitx_addon_factory_instance";
}

class AndroidSharedLibraryFactory {
public:
explicit AndroidSharedLibraryFactory(Library lib) : library_(std::move(lib)) {
auto *funcPtr = library_.resolve("fcitx_addon_factory_instance");
explicit AndroidSharedLibraryFactory(const AddonInfo &info, Library lib)
: library_(std::move(lib)) {
auto v2Name = stringutils::concat(FCITX_ADDON_FACTORY_ENTRY, "_", info.uniqueName());
auto *funcPtr = library_.resolve(v2Name.data());
if (!funcPtr) {
funcPtr = library_.resolve(FCITX_ADDON_FACTORY_ENTRY);
}
if (!funcPtr) {
throw std::runtime_error(library_.error());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* SPDX-FileCopyrightText: Copyright 2021-2023 Fcitx5 for Android Contributors
* SPDX-FileCopyrightText: Copyright 2021-2024 Fcitx5 for Android Contributors
*/

import com.android.build.api.dsl.CommonExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -11,16 +12,20 @@ import org.gradle.kotlin.dsl.task
open class NativeBaseConventionPlugin : Plugin<Project> {

override fun apply(target: Project) {
@Suppress("UnstableApiUsage")
val prebuiltDir = target.rootProject.projectDir
.resolve("lib/fcitx5/src/main/cpp/prebuilt").absolutePath
target.extensions.configure(CommonExtension::class.java) {
ndkVersion = target.ndkVersion
defaultConfig {
minSdk = Versions.minSdk
@Suppress("UnstableApiUsage")
externalNativeBuild {
cmake {
arguments(
"-DANDROID_STL=c++_shared",
"-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF"
"-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF",
"-DVERSION_NAME=${Versions.baseVersionName}",
"-DPREBUILT_DIR=$prebuiltDir"
)
}
}
Expand Down
17 changes: 10 additions & 7 deletions build-logic/convention/src/main/kotlin/ProjectExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import java.io.File
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi

fun Project.runCmd(cmd: String): String = ByteArrayOutputStream().use {
project.exec {
commandLine = cmd.split(" ")
standardOutput = it
fun Project.runCmd(cmd: String, defaultValue: String = ""): String {
val stdout = ByteArrayOutputStream()
val result = stdout.use {
project.exec {
commandLine = cmd.split(" ")
standardOutput = stdout
}
}
it.toString().trim()
return if (result.exitValue == 0) stdout.toString().trim() else defaultValue
}

val Project.libs get() = the<LibrariesForLibs>()
Expand All @@ -39,12 +42,12 @@ val Project.buildToolsVersion

val Project.buildVersionName
get() = ep("BUILD_VERSION_NAME", "buildVersionName") {
runCmd("git describe --tags --long --always")
runCmd("git describe --tags --long --always", Versions.baseVersionName)
}

val Project.buildCommitHash
get() = ep("BUILD_COMMIT_HASH", "buildCommitHash") {
runCmd("git rev-parse HEAD")
runCmd("git rev-parse HEAD", "N/A")
}

val Project.buildTimestamp
Expand Down
4 changes: 3 additions & 1 deletion build-logic/convention/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
* SPDX-FileCopyrightText: Copyright 2021-2023 Fcitx5 for Android Contributors
* SPDX-FileCopyrightText: Copyright 2021-2024 Fcitx5 for Android Contributors
*/

import org.gradle.api.JavaVersion

object Versions {
Expand All @@ -17,6 +18,7 @@ object Versions {

// NOTE: increase this value to bump version code
const val baseVersionCode = 7
const val baseVersionName = "0.0.9"

val supportedABIs = setOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
const val fallbackABI = "arm64-v8a"
Expand Down
7 changes: 2 additions & 5 deletions lib/fcitx5-chinese-addons/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

project(fcitx5-android-lib-fcitx5-chinese-addons VERSION 0.0.9)
project(fcitx5-android-lib-fcitx5-chinese-addons VERSION ${VERSION_NAME})

# For reproducible build
add_link_options("LINKER:--hash-style=gnu,--build-id=none")
Expand Down Expand Up @@ -31,16 +31,13 @@ find_package(Fcitx5ModuleLuaAddonLoader MODULE)
# dummy target to export src/main/cpp/cmake
add_custom_target(cmake)

# prebuilt dir. at least it works.
set(PREBUILT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../fcitx5/src/main/cpp/prebuilt")

# prebuilt fmt
set(fmt_DIR "${PREBUILT_DIR}/fmt/${ANDROID_ABI}/lib/cmake/fmt")
find_package(fmt)

# prebuilt boost
list(APPEND CMAKE_FIND_ROOT_PATH "${PREBUILT_DIR}/boost/${ANDROID_ABI}/lib/cmake")
find_package(Boost 1.83.0 REQUIRED COMPONENTS iostreams CONFIG)
find_package(Boost 1.86.0 REQUIRED COMPONENTS iostreams CONFIG)

# prebuilt marisa-tire, OpenCC needs it
set(marisa_DIR "${PREBUILT_DIR}/marisa/${ANDROID_ABI}/lib/cmake/marisa")
Expand Down
5 changes: 1 addition & 4 deletions lib/fcitx5-lua/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

project(fcitx5-android-lib-fcitx5-lua VERSION 0.0.9)
project(fcitx5-android-lib-fcitx5-lua VERSION ${VERSION_NAME})

# For reproducible build
add_link_options("LINKER:--hash-style=gnu,--build-id=none")
Expand All @@ -17,9 +17,6 @@ find_package(Fcitx5Module MODULE)
# dummy target to export src/main/cpp/cmake
add_custom_target(cmake)

# prebuilt dir. at least it works.
set(PREBUILT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../fcitx5/src/main/cpp/prebuilt")

# prebuilt lua
set(Lua_DIR "${PREBUILT_DIR}/lua/${ANDROID_ABI}/share/cmake/Lua")
find_package(Lua CONFIG)
Expand Down
5 changes: 1 addition & 4 deletions lib/fcitx5/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

project(fcitx5-android-lib-fcitx5 VERSION 0.0.9)
project(fcitx5-android-lib-fcitx5 VERSION ${VERSION_NAME})

# For reproducible build
add_link_options("LINKER:--hash-style=gnu,--build-id=none")
Expand All @@ -15,9 +15,6 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# cmake/FindECM.cmake
find_package(ECM)

# prebuilt dir
set(PREBUILT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/prebuilt")

# prebuilt fmt
set(fmt_DIR "${PREBUILT_DIR}/fmt/${ANDROID_ABI}/lib/cmake/fmt")
find_package(fmt)
Expand Down
7 changes: 2 additions & 5 deletions lib/libime/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

project(fcitx5-android-lib-fcitx5-chinese-addons VERSION 0.0.9)
project(fcitx5-android-lib-fcitx5-chinese-addons VERSION ${VERSION_NAME})

# For reproducible build
add_link_options("LINKER:--hash-style=gnu,--build-id=none")
Expand All @@ -16,16 +16,13 @@ find_package(Fcitx5Utils MODULE)
# dummy target to export src/main/cpp/cmake
add_custom_target(cmake)

# prebuilt dir. at least it works.
set(PREBUILT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../fcitx5/src/main/cpp/prebuilt")

# prebuilt fmt
set(fmt_DIR "${PREBUILT_DIR}/fmt/${ANDROID_ABI}/lib/cmake/fmt")
find_package(fmt)

# prebuilt boost
list(APPEND CMAKE_FIND_ROOT_PATH "${PREBUILT_DIR}/boost/${ANDROID_ABI}/lib/cmake")
find_package(Boost 1.83.0 REQUIRED COMPONENTS filesystem iostreams CONFIG)
find_package(Boost 1.86.0 REQUIRED COMPONENTS iostreams CONFIG)

# prebuilt zstd
set(zstd_DIR "${PREBUILT_DIR}/zstd/${ANDROID_ABI}/lib/cmake/zstd")
Expand Down
2 changes: 1 addition & 1 deletion plugin/anthy/licenses/libraries/fcitx5-anthy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "fcitx/fcitx5-anthy",
"artifactVersion": "5.1.4",
"artifactVersion": "5.1.5",
"description": "Anthy Wrapper for Fcitx",
"name": "fcitx/fcitx5-anthy",
"website": "https://github.com/fcitx/fcitx5-anthy",
Expand Down
3 changes: 2 additions & 1 deletion plugin/anthy/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.18)

project(fcitx5-android-plugin-anthy VERSION 0.0.9)
project(fcitx5-android-plugin-anthy VERSION ${VERSION_NAME})

# For reproducible build
add_link_options("LINKER:--hash-style=gnu,--build-id=none")
Expand All @@ -14,6 +14,7 @@ find_package(ECM MODULE)
find_package(Fcitx5Core MODULE)
find_package(Fcitx5Module MODULE)

option(ENABLE_TEST "" OFF)
set(BUILD_SHARED_LIBS OFF)
# anthy have some GCC pragma that LLVM doesn't recognize
add_compile_options("-Wno-unknown-warning-option")
Expand Down
2 changes: 1 addition & 1 deletion plugin/chewing/licenses/libraries/fcitx5-chewing.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"uniqueId": "fcitx/fcitx5-chewing",
"artifactVersion": "5.1.4",
"artifactVersion": "5.1.6",
"description": "Chewing Wrapper for Fcitx",
"name": "fcitx/fcitx5-chewing",
"website": "https://github.com/fcitx/fcitx5-chewing",
Expand Down
Loading

0 comments on commit 5d70f39

Please sign in to comment.