21
21
22
22
namespace rime {
23
23
24
- DictCompiler::DictCompiler (Dictionary *dictionary)
24
+ DictCompiler::DictCompiler (Dictionary *dictionary, const string& prefix )
25
25
: dict_name_(dictionary->name ()),
26
26
prism_(dictionary->prism ()),
27
- table_(dictionary->table ()) {
27
+ table_(dictionary->table ()),
28
+ prefix_(prefix) {
28
29
}
29
30
30
31
static string LocateFile (const string& file_name) {
31
32
the<ResourceResolver> resolver (
32
- Service::instance ().CreateResourceResolver ({" " , " " , " " }));
33
+ Service::instance ().CreateResourceResolver ({" build_source " , " " , " " }));
33
34
return resolver->ResolvePath (file_name).string ();
34
35
}
35
36
@@ -107,7 +108,8 @@ bool DictCompiler::Compile(const string &schema_file) {
107
108
LOG (INFO) << schema_file << " (" << schema_file_checksum << " )" ;
108
109
{
109
110
the<ResourceResolver> resolver (
110
- Service::instance ().CreateResourceResolver ({" " , " " , " .reverse.bin" }));
111
+ Service::instance ().CreateResourceResolver (
112
+ {" find_reverse_db" , prefix_, " .reverse.bin" }));
111
113
ReverseDb reverse_db (resolver->ResolvePath (dict_name_).string ());
112
114
if (!reverse_db.Exists () ||
113
115
!reverse_db.Load () ||
@@ -130,8 +132,9 @@ bool DictCompiler::Compile(const string &schema_file) {
130
132
return true ;
131
133
}
132
134
133
- static string RelocateToUserDirectory (const string& file_name) {
134
- ResourceResolver resolver (ResourceType{" " , " " , " " });
135
+ static string RelocateToUserDirectory (const string& prefix,
136
+ const string& file_name) {
137
+ ResourceResolver resolver (ResourceType{" build_target" , prefix, " " });
135
138
resolver.set_root_path (Service::instance ().deployer ().user_data_dir );
136
139
auto resource_id = boost::filesystem::path (file_name).filename ().string ();
137
140
return resolver.ResolvePath (resource_id).string ();
@@ -141,7 +144,7 @@ bool DictCompiler::BuildTable(DictSettings* settings,
141
144
const vector<string>& dict_files,
142
145
uint32_t dict_file_checksum) {
143
146
LOG (INFO) << " building table..." ;
144
- table_ = New<Table>(RelocateToUserDirectory (table_->file_name ()));
147
+ table_ = New<Table>(RelocateToUserDirectory (prefix_, table_->file_name ()));
145
148
146
149
EntryCollector collector;
147
150
collector.Configure (settings);
@@ -186,7 +189,8 @@ bool DictCompiler::BuildTable(DictSettings* settings,
186
189
}
187
190
}
188
191
// build .reverse.bin
189
- ReverseDb reverse_db (RelocateToUserDirectory (dict_name_ + " .reverse.bin" ));
192
+ ReverseDb reverse_db (RelocateToUserDirectory (prefix_,
193
+ dict_name_ + " .reverse.bin" ));
190
194
if (!reverse_db.Build (settings,
191
195
collector.syllabary ,
192
196
vocabulary,
@@ -199,9 +203,10 @@ bool DictCompiler::BuildTable(DictSettings* settings,
199
203
}
200
204
201
205
bool DictCompiler::BuildPrism (const string &schema_file,
202
- uint32_t dict_file_checksum, uint32_t schema_file_checksum) {
206
+ uint32_t dict_file_checksum,
207
+ uint32_t schema_file_checksum) {
203
208
LOG (INFO) << " building prism..." ;
204
- prism_ = New<Prism>(RelocateToUserDirectory (prism_->file_name ()));
209
+ prism_ = New<Prism>(RelocateToUserDirectory (prefix_, prism_->file_name ()));
205
210
206
211
// get syllabary from table
207
212
Syllabary syllabary;
0 commit comments