-
Notifications
You must be signed in to change notification settings - Fork 33
/
librime_patch
127 lines (116 loc) · 3.99 KB
/
librime_patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e167e228..9df29c9d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.12)
project(rime)
set(CMAKE_CXX_STANDARD 17)
-set(rime_version 1.11.2)
+set(rime_version 1.8.5) # keep 1.8.5 so no need to rehash schemas
set(rime_soversion 1)
add_definitions(-DRIME_VERSION="${rime_version}")
@@ -46,6 +46,9 @@ if (ENABLE_ASAN)
set(CMAKE_SHARED_LINKER_FLAGS "${asan_lflags} ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
+# Reproducible build
+set(CMAKE_CXX_FLAGS "-DBOOST_DISABLE_CURRENT_LOCATION ${CMAKE_CXX_FLAGS}")
+
set(Boost_USE_STATIC_LIBS ${BUILD_STATIC})
set(Gflags_STATIC ${BUILD_STATIC})
set(Glog_STATIC ${BUILD_STATIC})
diff --git a/include/darts.h b/include/darts.h
index 18bf988b..4b9bb5d2 100644
--- a/include/darts.h
+++ b/include/darts.h
@@ -16,7 +16,7 @@
#define DARTS_LINE_TO_STR(line) DARTS_INT_TO_STR(line)
#define DARTS_LINE_STR DARTS_LINE_TO_STR(__LINE__)
#define DARTS_THROW(msg) throw Darts::Details::Exception( \
- __FILE__ ":" DARTS_LINE_STR ": exception: " msg)
+ __FILE_NAME__ ":" DARTS_LINE_STR ": exception: " msg)
namespace Darts {
diff --git a/src/rime/schema.cc b/src/rime/schema.cc
index 8f60625c..c3397559 100644
--- a/src/rime/schema.cc
+++ b/src/rime/schema.cc
@@ -4,9 +4,17 @@
//
// 2011-05-08 GONG Chen <[email protected]>
//
+#include <string>
#include <boost/algorithm/string.hpp>
#include <rime/schema.h>
+#ifdef __EMSCRIPTEN__
+namespace my_rime {
+extern bool deployed;
+extern std::string get_schema_name(std::string);
+} // namespace my_rime
+#endif
+
namespace rime {
Schema::Schema() : schema_id_(".default") {
@@ -26,7 +34,12 @@ void Schema::FetchUsefulConfigItems() {
schema_name_ = schema_id_ + "?";
return;
}
- if (!config_->GetString("schema/name", &schema_name_)) {
+#ifdef __EMSCRIPTEN__
+ if (!my_rime::deployed) {
+ schema_name_ = my_rime::get_schema_name(schema_id_);
+ } else
+#endif
+ if (!config_->GetString("schema/name", &schema_name_)) {
schema_name_ = schema_id_;
}
config_->GetInt("menu/page_size", &page_size_);
diff --git a/src/rime/schema.h b/src/rime/schema.h
index bb68bcdb..4ef84beb 100644
--- a/src/rime/schema.h
+++ b/src/rime/schema.h
@@ -10,6 +10,12 @@
#include <rime/common.h>
#include <rime/config.h> // for convenience
+#ifdef __EMSCRIPTEN__
+namespace my_rime {
+extern int page_size;
+} // namespace my_rime
+#endif
+
namespace rime {
class Schema {
@@ -25,7 +31,13 @@ class Schema {
Config* config() const { return config_.get(); }
void set_config(Config* config) { config_.reset(config); }
- int page_size() const { return page_size_; }
+ int page_size() const {
+#ifdef __EMSCRIPTEN__
+ return my_rime::page_size ? my_rime::page_size : page_size_;
+#else
+ return page_size_;
+#endif
+ }
bool page_down_cycle() const { return page_down_cycle_; }
const string& select_keys() const { return select_keys_; }
void set_select_keys(const string& keys) { select_keys_ = keys; }
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 090a0fc0..a24cd51f 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -52,18 +52,3 @@ if(NOT WIN32 OR NOT BUILD_SHARED_LIBS)
install(TARGETS rime_table_decompiler DESTINATION ${BIN_INSTALL_DIR})
endif()
-
-file(COPY ${PROJECT_SOURCE_DIR}/data/minimal/default.yaml
- DESTINATION ${EXECUTABLE_OUTPUT_PATH})
-file(COPY ${PROJECT_SOURCE_DIR}/data/minimal/symbols.yaml
- DESTINATION ${EXECUTABLE_OUTPUT_PATH})
-file(COPY ${PROJECT_SOURCE_DIR}/data/minimal/essay.txt
- DESTINATION ${EXECUTABLE_OUTPUT_PATH})
-file(COPY ${PROJECT_SOURCE_DIR}/data/minimal/luna_pinyin.dict.yaml
- DESTINATION ${EXECUTABLE_OUTPUT_PATH})
-file(COPY ${PROJECT_SOURCE_DIR}/data/minimal/luna_pinyin.schema.yaml
- DESTINATION ${EXECUTABLE_OUTPUT_PATH})
-file(COPY ${PROJECT_SOURCE_DIR}/data/minimal/cangjie5.dict.yaml
- DESTINATION ${EXECUTABLE_OUTPUT_PATH})
-file(COPY ${PROJECT_SOURCE_DIR}/data/minimal/cangjie5.schema.yaml
- DESTINATION ${EXECUTABLE_OUTPUT_PATH})