Skip to content

Commit

Permalink
Update librime and glog; add librime-predict (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: Rocka <i@rocka.me>
  • Loading branch information
eagleoflqj and rocka authored Apr 9, 2024
1 parent 1b4b3db commit 1ea929e
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
[submodule "libime-jyutping"]
path = libime-jyutping
url = https://github.com/fcitx/libime-jyutping
[submodule "librime-predict"]
path = librime-predict
url = https://github.com/rime/librime-predict
2 changes: 1 addition & 1 deletion glog
Submodule glog updated 92 files
+6 −2 .bazelci/presubmit.yml
+3 −3 .clang-format
+1 −1 .clang-tidy
+10 −0 .github/dependabot.yml
+31 −13 .github/workflows/android.yml
+26 −0 .github/workflows/cifuzz.yml
+57 −0 .github/workflows/emscripten.yml
+22 −30 .github/workflows/linux.yml
+22 −29 .github/workflows/macos.yml
+47 −36 .github/workflows/windows.yml
+1 −0 AUTHORS
+485 −512 CMakeLists.txt
+2 −0 CONTRIBUTORS
+1 −38 COPYING
+5 −0 ChangeLog
+6 −0 MODULE.bazel
+319 −187 README.rst
+7 −0 WORKSPACE
+125 −117 bazel/glog.bzl
+1 −1 cmake/GetCacheVariables.cmake
+12 −8 cmake/RunCleanerTest1.cmake
+12 −8 cmake/RunCleanerTest2.cmake
+12 −8 cmake/RunCleanerTest3.cmake
+4 −14 cmake/TestPackageConfig.cmake
+11 −0 codecov.yml
+8 −0 gcovr.cfg
+2 −0 glog-config.cmake.in
+55 −53 src/base/commandlineflags.h
+10 −12 src/base/googleinit.h
+0 −333 src/base/mutex.h
+14 −14 src/cleanup_immediately_unittest.cc
+14 −14 src/cleanup_with_absolute_prefix_unittest.cc
+14 −14 src/cleanup_with_relative_prefix_unittest.cc
+39 −128 src/config.h.cmake.in
+7 −0 src/dcheck_unittest/CMakeLists.txt
+53 −0 src/dcheck_unittest/glog_dcheck.cc
+342 −343 src/demangle.cc
+17 −8 src/demangle.h
+26 −28 src/demangle_unittest.cc
+7 −0 src/demangle_unittest.txt
+158 −0 src/flags.cc
+32 −0 src/fuzz_demangle.cc
+191 −0 src/glog/flags.h
+42 −14 src/glog/log_severity.h
+1,744 −0 src/glog/logging.h
+0 −2,002 src/glog/logging.h.in
+15 −11 src/glog/platform.h
+75 −78 src/glog/raw_logging.h
+44 −96 src/glog/stl_logging.h
+81 −0 src/glog/types.h
+38 −20 src/glog/vlog_is_on.h
+220 −274 src/googletest.h
+16 −0 src/includes_unittest/CMakeLists.txt
+39 −0 src/includes_unittest/glog_includes_logging.cc
+39 −0 src/includes_unittest/glog_includes_raw_logging.cc
+4 −5 src/includes_unittest/glog_includes_stl_logging.cc
+4 −5 src/includes_unittest/glog_includes_vlog_is_on.cc
+10 −0 src/log_severity_unittest/CMakeLists.txt
+40 −0 src/log_severity_unittest/glog_log_severity_constants.cc
+42 −0 src/log_severity_unittest/glog_log_severity_conversion.cc
+1,132 −988 src/logging.cc
+0 −1,384 src/logging_custom_prefix_unittest.cc
+0 −308 src/logging_custom_prefix_unittest.err
+11 −10 src/logging_striplog_test.sh
+477 −366 src/logging_unittest.cc
+17 −19 src/mock-log.h
+11 −16 src/mock-log_unittest.cc
+2 −5 src/package_config_unittest/working_config/glog_package_config.cc
+85 −53 src/raw_logging.cc
+106 −113 src/signalhandler.cc
+33 −37 src/signalhandler_unittest.cc
+38 −0 src/stacktrace.cc
+45 −9 src/stacktrace.h
+8 −4 src/stacktrace_generic-inl.h
+9 −7 src/stacktrace_libunwind-inl.h
+28 −22 src/stacktrace_powerpc-inl.h
+73 −61 src/stacktrace_unittest.cc
+20 −20 src/stacktrace_unwind-inl.h
+9 −6 src/stacktrace_windows-inl.h
+44 −31 src/stacktrace_x86-inl.h
+8 −101 src/stl_logging_unittest.cc
+23 −9 src/striplog_unittest.cc
+283 −270 src/symbolize.cc
+102 −55 src/symbolize.h
+159 −121 src/symbolize_unittest.cc
+138 −211 src/utilities.cc
+175 −109 src/utilities.h
+6 −12 src/utilities_unittest.cc
+46 −61 src/vlog_is_on.cc
+625 −744 src/windows/dirent.h
+17 −26 src/windows/port.cc
+63 −102 src/windows/port.h
2 changes: 1 addition & 1 deletion librime
Submodule librime updated 127 files
2 changes: 1 addition & 1 deletion librime-octagram
1 change: 1 addition & 0 deletions librime-predict
Submodule librime-predict added at 72e4d7
36 changes: 36 additions & 0 deletions patches/glog.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b787631..1fc8cf4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -402,6 +402,7 @@ add_custom_command (
COMMAND ${CMAKE_COMMAND} -E touch ${_glog_EMPTY_SOURCE}
)

+target_compile_options(glog_internal PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
add_library (glog
$<TARGET_OBJECTS:glog_internal>
${_glog_EMPTY_SOURCE}
diff --git a/src/glog/platform.h b/src/glog/platform.h
index 4aaf5b0..f118ca8 100644
--- a/src/glog/platform.h
+++ b/src/glog/platform.h
@@ -42,6 +42,9 @@
# ifndef GLOG_OS_LINUX
# define GLOG_OS_LINUX
# endif
+# if defined(__ANDROID__)
+# define GLOG_OS_ANDROID
+# endif
#elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
# define GLOG_OS_MACOSX
#elif defined(__FreeBSD__)
@@ -52,9 +55,6 @@
# define GLOG_OS_OPENBSD
#elif defined(__EMSCRIPTEN__)
# define GLOG_OS_EMSCRIPTEN
-#elif defined(__ANDROID__)
-# define GLOG_OS_ANDROID
-#else
// TODO(hamaji): Add other platforms.
#error Platform not supported by glog. Please consider to contribute platform information by submitting a pull request on Github.
#endif
18 changes: 18 additions & 0 deletions patches/librime-predict.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 07703bf..5ab6d3b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.10)
aux_source_directory(src predict_src)

add_library(rime-predict-objs OBJECT ${predict_src})
+target_compile_options(rime-predict-objs PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
if(BUILD_SHARED_LIBS)
set_target_properties(rime-predict-objs
PROPERTIES
@@ -15,4 +16,4 @@ set(plugin_objs $<TARGET_OBJECTS:rime-predict-objs> PARENT_SCOPE)
set(plugin_deps ${rime_library} PARENT_SCOPE)
set(plugin_modules "predict" PARENT_SCOPE)

-add_subdirectory(tools)
+# add_subdirectory(tools)
20 changes: 10 additions & 10 deletions patches/librime.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6364e1c8..347107f0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -143,6 +143,8 @@ if(BUILD_SHARED_LIBS)
@@ -162,6 +162,8 @@ if(BUILD_SHARED_LIBS)
else()
add_library(rime-static STATIC ${rime_src})
target_link_libraries(rime-static ${rime_deps})
+ target_compile_options(rime-static PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.")
+ target_compile_definitions(rime-static PRIVATE BOOST_DISABLE_CURRENT_LOCATION)
set_target_properties(rime-static PROPERTIES OUTPUT_NAME "rime" PREFIX "lib")
install(TARGETS rime-static DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
endif()
set_target_properties(rime-static PROPERTIES
OUTPUT_NAME "rime" PREFIX "lib"
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
--
2.43.0

Expand All @@ -40,11 +40,11 @@ diff --git a/src/rime/engine.cc b/src/rime/engine.cc
index 64c0fb68..549a8112 100644
--- a/src/rime/engine.cc
+++ b/src/rime/engine.cc
@@ -54,7 +54,6 @@ class ConcreteEngine : public Engine {
@@ -52,7 +52,6 @@ class ConcreteEngine : public Engine {
vector<of<Filter>> filters_;
vector<of<Formatter>> formatters_;
vector<of<Processor>> post_processors_;
// To make sure dumping user.yaml when processors_.clear(),
// switcher is owned by processors_[0]
- weak<Switcher> switcher_;
- an<Switcher> switcher_;
};

// implementations
Expand All @@ -64,7 +64,7 @@ index 2e1c8b81..47c39544 100644
void set_active_engine(Engine* engine = nullptr) { active_engine_ = engine; }

RIME_API static Engine* Create();
+ weak<Switcher> switcher_;
+ an<Switcher> switcher_;

protected:
Engine();
Expand Down Expand Up @@ -106,7 +106,7 @@ index 678169c0..1085fe5c 100644
return;
ctx->set_option(option, !!value);
+ auto engine = session->engine_.get();
+ auto switcher = engine->switcher_.lock();
+ auto switcher = engine->switcher_;
+ if (switcher->IsAutoSave(option)) {
+ if (Config* user_config = switcher->user_config()) {
+ user_config->SetBool("var/option/" + std::string(option), value);
Expand Down
6 changes: 4 additions & 2 deletions src/Rules/GLog.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ glogRule = do
useCMake $
(cmakeBuilder "glog")
{ cmakeFlags = const ["-DBUILD_SHARED_LIBS=OFF", "-DWITH_GFLAGS=OFF", "-DWITH_UNWIND=OFF", "-DBUILD_TESTING=OFF"],
-- remove absolute path by __FILE__ macro
preBuild = BuildAction $ \_ src -> cmd_ (Cwd src) Shell "sed -i '618s|\\(^add_library (glog.*\\)|target_compile_options\\(glogbase PRIVATE \"-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.\"\\)\\n\\1|' CMakeLists.txt"
-- disable logging to cwd; remove absolute path by __FILE__ macro
preBuild = BuildAction $ \_ src -> do
cmd_ (Cwd src) "git checkout ."
cmd_ (Cwd src) "git apply ../patches/glog.patch"
}
"glog" ~> buildWithAndroidEnv buildGlog GLog
7 changes: 7 additions & 0 deletions src/Rules/LibRime.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,31 @@ librimeRule = do
-- canocialize for symlink
librimeLuaSrc <- liftIO $ canonicalizePath "librime-lua"
librimeOctagramSrc <- liftIO $ canonicalizePath "librime-octagram"
librimePredictSrc <- liftIO $ canonicalizePath "librime-predict"
liftIO $ do
removePathForcibly (src </> "plugins" </> "lua")
createDirectoryLink librimeLuaSrc (src </> "plugins" </> "lua")
removePathForcibly (src </> "plugins" </> "octagram")
createDirectoryLink librimeOctagramSrc (src </> "plugins" </> "octagram")
removePathForcibly (src </> "plugins" </> "predict")
createDirectoryLink librimePredictSrc (src </> "plugins" </> "predict")
-- find lua with find_package; remove absolute path by __FILE__ macro
cmd_ (Cwd librimeLuaSrc) "git checkout ."
cmd_ (Cwd librimeLuaSrc) "git apply ../patches/librime-lua.patch"
-- disable tools; remove absolute path by __FILE__ macro
cmd_ (Cwd librimeOctagramSrc) "git checkout ."
cmd_ (Cwd librimeOctagramSrc) "git apply ../patches/librime-octagram.patch"
-- disable tools; remove absolute path by __FILE__ macro
cmd_ (Cwd librimePredictSrc) "git checkout ."
cmd_ (Cwd librimePredictSrc) "git apply ../patches/librime-predict.patch"
-- remove absolute path by __FILE__ macro
cmd_ (Cwd src) "git checkout ."
cmd_ (Cwd src) "git apply ../patches/librime.patch",
cmakeFlags = \BuildEnv {..} ->
[ "-DBUILD_SHARED_LIBS=OFF",
"-DBUILD_STATIC=ON",
"-DBUILD_TEST=OFF",
"-DALSO_LOG_TO_STDERR=ON",
"-DCMAKE_FIND_ROOT_PATH="
<> intercalate
";"
Expand Down

0 comments on commit 1ea929e

Please sign in to comment.