2121
2222namespace rime {
2323
24- DictCompiler::DictCompiler (Dictionary *dictionary)
24+ DictCompiler::DictCompiler (Dictionary *dictionary, const string& prefix )
2525 : dict_name_(dictionary->name ()),
2626 prism_(dictionary->prism ()),
27- table_(dictionary->table ()) {
27+ table_(dictionary->table ()),
28+ prefix_(prefix) {
2829}
2930
3031static string LocateFile (const string& file_name) {
3132 the<ResourceResolver> resolver (
32- Service::instance ().CreateResourceResolver ({" " , " " , " " }));
33+ Service::instance ().CreateResourceResolver ({" build_source " , " " , " " }));
3334 return resolver->ResolvePath (file_name).string ();
3435}
3536
@@ -107,7 +108,8 @@ bool DictCompiler::Compile(const string &schema_file) {
107108 LOG (INFO) << schema_file << " (" << schema_file_checksum << " )" ;
108109 {
109110 the<ResourceResolver> resolver (
110- Service::instance ().CreateResourceResolver ({" " , " " , " .reverse.bin" }));
111+ Service::instance ().CreateResourceResolver (
112+ {" find_reverse_db" , prefix_, " .reverse.bin" }));
111113 ReverseDb reverse_db (resolver->ResolvePath (dict_name_).string ());
112114 if (!reverse_db.Exists () ||
113115 !reverse_db.Load () ||
@@ -130,8 +132,9 @@ bool DictCompiler::Compile(const string &schema_file) {
130132 return true ;
131133}
132134
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, " " });
135138 resolver.set_root_path (Service::instance ().deployer ().user_data_dir );
136139 auto resource_id = boost::filesystem::path (file_name).filename ().string ();
137140 return resolver.ResolvePath (resource_id).string ();
@@ -141,7 +144,7 @@ bool DictCompiler::BuildTable(DictSettings* settings,
141144 const vector<string>& dict_files,
142145 uint32_t dict_file_checksum) {
143146 LOG (INFO) << " building table..." ;
144- table_ = New<Table>(RelocateToUserDirectory (table_->file_name ()));
147+ table_ = New<Table>(RelocateToUserDirectory (prefix_, table_->file_name ()));
145148
146149 EntryCollector collector;
147150 collector.Configure (settings);
@@ -186,7 +189,8 @@ bool DictCompiler::BuildTable(DictSettings* settings,
186189 }
187190 }
188191 // build .reverse.bin
189- ReverseDb reverse_db (RelocateToUserDirectory (dict_name_ + " .reverse.bin" ));
192+ ReverseDb reverse_db (RelocateToUserDirectory (prefix_,
193+ dict_name_ + " .reverse.bin" ));
190194 if (!reverse_db.Build (settings,
191195 collector.syllabary ,
192196 vocabulary,
@@ -199,9 +203,10 @@ bool DictCompiler::BuildTable(DictSettings* settings,
199203}
200204
201205bool 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) {
203208 LOG (INFO) << " building prism..." ;
204- prism_ = New<Prism>(RelocateToUserDirectory (prism_->file_name ()));
209+ prism_ = New<Prism>(RelocateToUserDirectory (prefix_, prism_->file_name ()));
205210
206211 // get syllabary from table
207212 Syllabary syllabary;
0 commit comments