Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support mingw-w64 build on windows #700

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,39 @@ jobs:
path: |
rime-${{ env.git_ref_name }}-${{ runner.os }}.7z
rime-deps-${{ env.git_ref_name }}-${{ runner.os }}.7z

build-mingw:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}

steps:
- name: Setup MSYS2
uses: msys2/setup-msys2@v2

- name: Checkout last commit
uses: actions/checkout@v3

- name: Install dependencies
run: |
pacman -S --noconfirm base-devel mingw-w64-x86_64-toolchain ninja \
mingw64/mingw-w64-x86_64-cmake \
mingw-w64-x86_64-boost \
mingw-w64-x86_64-glog \
mingw-w64-x86_64-gtest \
mingw-w64-x86_64-yaml-cpp \
mingw-w64-x86_64-leveldb \
mingw-w64-x86_64-marisa \
mingw-w64-x86_64-opencc

- name: Build with mingw-w64
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DENABLE_LOGGING:BOOL=ON \
-DBUILD_TEST:BOOL=ON \
-DBUILD_STATIC:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=ON
cmake --build build
cd build/test && cp ../lib/librime.dll . && ./rime_test
3 changes: 1 addition & 2 deletions build-clang.bat
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ if %build_deps% == 1 (
echo building opencc.
pushd deps\opencc
cmake . %deps_cmake_flags%^
-DCMAKE_CXX_FLAGS:PATH="-I %RIME_ROOT%\include -L %RIME_ROOT%\lib"^
-DCMAKE_CXX_FLAGS:STRING="-I %RIME_ROOT%\include -L %RIME_ROOT%\lib"^
-DUSE_SYSTEM_MARISA:BOOL=ON || exit
cmake --build build || exit
cmake --install build || exit
Expand All @@ -141,7 +141,6 @@ set rime_cmake_flags=%common_cmake_flags%^

if %build_librime% == 1 (
echo building librime.
echo %rime_cmake_flags%
cmake . %rime_cmake_flags% || exit
cmake --build build || exit
cmake --install build || exit
Expand Down
12 changes: 6 additions & 6 deletions src/rime/algo/encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ struct TableEncodingRule {
};

// for rule-based phrase encoding
class TableEncoder : public Encoder {
class RIME_API TableEncoder : public Encoder {
public:
RIME_API TableEncoder(PhraseCollector* collector = NULL);
TableEncoder(PhraseCollector* collector = NULL);

RIME_API bool LoadSettings(Config* config);
bool LoadSettings(Config* config);

RIME_API bool Encode(const RawCode& code, string* result);
RIME_API bool EncodePhrase(const string& phrase, const string& value);
bool Encode(const RawCode& code, string* result);
bool EncodePhrase(const string& phrase, const string& value);

RIME_API bool IsCodeExcluded(const string& code);
bool IsCodeExcluded(const string& code);

bool loaded() const { return loaded_; }
const vector<TableEncodingRule>& encoding_rules() const {
Expand Down
2 changes: 1 addition & 1 deletion src/rime/composition.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Composition : public Segmentation {
string GetPrompt() const;
string GetCommitText() const;
string GetScriptText() const;
string GetDebugText() const;
RIME_API string GetDebugText() const;
// Returns text of the last segment before the given position.
string GetTextBefore(size_t pos) const;
};
Expand Down
6 changes: 3 additions & 3 deletions src/rime/config/config_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class ConfigValue : public ConfigItem {
ConfigValue() : ConfigItem(kScalar) {}
RIME_API ConfigValue(bool value);
RIME_API ConfigValue(int value);
ConfigValue(double value);
RIME_API ConfigValue(double value);
RIME_API ConfigValue(const char* value);
ConfigValue(const string& value);
RIME_API ConfigValue(const string& value);

// schalar value accessors
bool GetBool(bool* value) const;
Expand Down Expand Up @@ -155,7 +155,7 @@ class ConfigItemRef {
RIME_API bool Append(an<ConfigItem> item);
RIME_API size_t size() const;
// map
bool HasKey(const string& key) const;
RIME_API bool HasKey(const string& key) const;

RIME_API bool modified() const;
RIME_API void set_modified();
Expand Down
4 changes: 2 additions & 2 deletions src/rime/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ class Context {
Context() = default;
~Context() = default;

bool Commit();
RIME_API bool Commit();
string GetCommitText() const;
string GetScriptText() const;
Preedit GetPreedit() const;
bool IsComposing() const;
RIME_API bool IsComposing() const;
bool HasMenu() const;
an<Candidate> GetSelectedCandidate() const;

Expand Down
4 changes: 2 additions & 2 deletions src/rime/deployer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class Deployer : public Messenger {
string distribution_version;
// }

Deployer();
~Deployer();
RIME_API Deployer();
RIME_API ~Deployer();

bool RunTask(const string& task_name,
TaskInitializer arg = TaskInitializer());
Expand Down
10 changes: 5 additions & 5 deletions src/rime/dict/corrector.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ class EditDistanceCorrector : public Corrector, public Prism {
corrector::Distance threshold);
};

class NearSearchCorrector : public Corrector {
class RIME_API NearSearchCorrector : public Corrector {
public:
NearSearchCorrector() = default;
~NearSearchCorrector() override = default;
RIME_API void ToleranceSearch(const Prism& prism,
const string& key,
corrector::Corrections* results,
size_t tolerance) override;
void ToleranceSearch(const Prism& prism,
const string& key,
corrector::Corrections* results,
size_t tolerance) override;
};

template <class... Cs>
Expand Down
2 changes: 1 addition & 1 deletion src/rime/dict/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Recoverable {

class ResourceResolver;

class DbComponentBase {
class RIME_API DbComponentBase {
public:
DbComponentBase();
virtual ~DbComponentBase();
Expand Down
12 changes: 6 additions & 6 deletions src/rime/dict/dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ struct QueryResult;

} // namespace dictionary

class DictEntryIterator : public DictEntryFilterBinder {
class RIME_API DictEntryIterator : public DictEntryFilterBinder {
public:
RIME_API DictEntryIterator();
DictEntryIterator();
virtual ~DictEntryIterator() = default;
DictEntryIterator(const DictEntryIterator& other) = default;
DictEntryIterator& operator=(const DictEntryIterator& other) = default;
Expand All @@ -34,11 +34,11 @@ class DictEntryIterator : public DictEntryFilterBinder {

void AddChunk(dictionary::Chunk&& chunk);
void Sort();
RIME_API void AddFilter(DictEntryFilter filter) override;
RIME_API an<DictEntry> Peek();
RIME_API bool Next();
void AddFilter(DictEntryFilter filter) override;
an<DictEntry> Peek();
bool Next();
bool Skip(size_t num_entries);
RIME_API bool exhausted() const;
bool exhausted() const;
size_t entry_count() const { return entry_count_; }

protected:
Expand Down
6 changes: 3 additions & 3 deletions src/rime/dict/level_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ bool LevelDb::CommitTransaction() {
}

template <>
string UserDbComponent<LevelDb>::extension() const {
RIME_API string UserDbComponent<LevelDb>::extension() const {
return ".userdb";
}

template <>
UserDbWrapper<LevelDb>::UserDbWrapper(const string& file_name,
const string& db_name)
RIME_API UserDbWrapper<LevelDb>::UserDbWrapper(const string& file_name,
const string& db_name)
: LevelDb(file_name, db_name, "userdb") {}

} // namespace rime
16 changes: 8 additions & 8 deletions src/rime/dict/text_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ class TextDb : public Db {
RIME_API virtual ~TextDb();

RIME_API virtual bool Open();
virtual bool OpenReadOnly();
RIME_API virtual bool OpenReadOnly();
RIME_API virtual bool Close();

virtual bool Backup(const string& snapshot_file);
virtual bool Restore(const string& snapshot_file);
RIME_API virtual bool Backup(const string& snapshot_file);
RIME_API virtual bool Restore(const string& snapshot_file);

virtual bool CreateMetadata();
virtual bool MetaFetch(const string& key, string* value);
virtual bool MetaUpdate(const string& key, const string& value);
RIME_API virtual bool CreateMetadata();
RIME_API virtual bool MetaFetch(const string& key, string* value);
RIME_API virtual bool MetaUpdate(const string& key, const string& value);

virtual an<DbAccessor> QueryMetadata();
virtual an<DbAccessor> QueryAll();
RIME_API virtual an<DbAccessor> QueryMetadata();
RIME_API virtual an<DbAccessor> QueryAll();
RIME_API virtual an<DbAccessor> Query(const string& key);
RIME_API virtual bool Fetch(const string& key, string* value);
RIME_API virtual bool Update(const string& key, const string& value);
Expand Down
4 changes: 2 additions & 2 deletions src/rime/dict/user_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ static TextFormat plain_userdb_format = {
};

template <>
UserDbWrapper<TextDb>::UserDbWrapper(const string& file_name,
const string& db_name)
RIME_API UserDbWrapper<TextDb>::UserDbWrapper(const string& file_name,
const string& db_name)
: TextDb(file_name, db_name, "userdb", plain_userdb_format) {}

bool UserDbHelper::UpdateUserInfo() {
Expand Down
8 changes: 4 additions & 4 deletions src/rime/dict/user_db.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class UserDbHelper {
UserDbHelper(const the<Db>& db) : db_(db.get()) {}
UserDbHelper(const an<Db>& db) : db_(db.get()) {}

bool UpdateUserInfo();
static bool IsUniformFormat(const string& name);
bool UniformBackup(const string& snapshot_file);
bool UniformRestore(const string& snapshot_file);
RIME_API bool UpdateUserInfo();
RIME_API static bool IsUniformFormat(const string& name);
RIME_API bool UniformBackup(const string& snapshot_file);
RIME_API bool UniformRestore(const string& snapshot_file);

bool IsUserDb();
string GetDbName();
Expand Down
4 changes: 2 additions & 2 deletions src/rime/dict/vocabulary.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class DictEntryList : public vector<of<DictEntry>> {

using DictEntryFilter = function<bool(an<DictEntry> entry)>;

class DictEntryFilterBinder {
class RIME_API DictEntryFilterBinder {
public:
virtual ~DictEntryFilterBinder() = default;
RIME_API virtual void AddFilter(DictEntryFilter filter);
virtual void AddFilter(DictEntryFilter filter);

protected:
DictEntryFilter filter_;
Expand Down
6 changes: 3 additions & 3 deletions src/rime/gear/simplifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <opencc/Dict.hpp>
#include <opencc/DictEntry.hpp>

#ifdef WIN32
#ifdef _MSC_VER
#include <opencc/UTF8Util.hpp>
namespace fs = boost::filesystem;
#endif
Expand All @@ -42,13 +42,13 @@ class Opencc {
opencc::Config config;
try {
// windows config_path in CP_ACP, convert it to UTF-8
#ifdef WIN32
#ifdef _MSC_VER
fs::path path{config_path};
converter_ =
config.NewFromFile(opencc::UTF8Util::U16ToU8(path.wstring()));
#else
converter_ = config.NewFromFile(config_path);
#endif /* WIN32 */
#endif /* _MSC_VER */
const list<opencc::ConversionPtr> conversions =
converter_->GetConversionChain()->GetConversions();
dict_ = conversions.front()->GetDict();
Expand Down
6 changes: 3 additions & 3 deletions src/rime/lever/deployment_tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class DetectModifications : public DeploymentTask {
};

// initialize/update installation.yaml
class InstallationUpdate : public DeploymentTask {
class RIME_API InstallationUpdate : public DeploymentTask {
public:
InstallationUpdate(TaskInitializer arg = TaskInitializer()) {}
bool Run(Deployer* deployer);
};

// update distributed config files and preset schemas
class WorkspaceUpdate : public DeploymentTask {
class RIME_API WorkspaceUpdate : public DeploymentTask {
public:
WorkspaceUpdate(TaskInitializer arg = TaskInitializer()) {}
bool Run(Deployer* deployer);
Expand All @@ -44,7 +44,7 @@ class WorkspaceUpdate : public DeploymentTask {
};

// update a specific schema, build corresponding dictionary
class SchemaUpdate : public DeploymentTask {
class RIME_API SchemaUpdate : public DeploymentTask {
public:
explicit SchemaUpdate(const string& schema_file)
: schema_file_(schema_file) {}
Expand Down
2 changes: 1 addition & 1 deletion src/rime/lever/user_dict_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Deployer;

using UserDictList = vector<string>;

class UserDictManager {
class RIME_API UserDictManager {
public:
UserDictManager(Deployer* deployer);

Expand Down
10 changes: 4 additions & 6 deletions src/rime/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ struct ResourceType {
string suffix;
};

class ResourceResolver {
class RIME_API ResourceResolver {
public:
explicit ResourceResolver(const ResourceType type) : type_(type) {}
virtual ~ResourceResolver() {}
RIME_API virtual boost::filesystem::path ResolvePath(
const string& resource_id);
virtual boost::filesystem::path ResolvePath(const string& resource_id);
string ToResourceId(const string& file_path) const;
string ToFilePath(const string& resource_id) const;
void set_root_path(boost::filesystem::path root_path) {
Expand All @@ -39,12 +38,11 @@ class ResourceResolver {
};

// try fallback path if target file doesn't exist in root path
class FallbackResourceResolver : public ResourceResolver {
class RIME_API FallbackResourceResolver : public ResourceResolver {
public:
explicit FallbackResourceResolver(const ResourceType& type)
: ResourceResolver(type) {}
RIME_API boost::filesystem::path ResolvePath(
const string& resource_id) override;
boost::filesystem::path ResolvePath(const string& resource_id) override;
void set_fallback_root_path(boost::filesystem::path fallback_root_path) {
fallback_root_path_ = fallback_root_path;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rime/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class Service {
Deployer& deployer() { return deployer_; }
bool disabled() { return !started_ || deployer_.IsMaintenanceMode(); }

static Service& instance();
RIME_API static Service& instance();

private:
Service();
Expand Down
2 changes: 1 addition & 1 deletion src/rime/setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace rime {
#define Q(x) #x
RIME_API RIME_MODULE_LIST(kDefaultModules, "default" RIME_EXTRA_MODULES);
#undef Q
RIME_MODULE_LIST(kDeployerModules, "deployer");
RIME_API RIME_MODULE_LIST(kDeployerModules, "deployer");
RIME_MODULE_LIST(kLegacyModules, "legacy");

RIME_REGISTER_MODULE_GROUP(default, "core", "dict", "gears")
Expand Down
2 changes: 1 addition & 1 deletion src/rime/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace rime {

RIME_API extern const char* kDefaultModules[];
extern const char* kDeployerModules[];
RIME_API extern const char* kDeployerModules[];
extern const char* kLegacyModules[];

RIME_API void LoadModules(const char* module_names[]);
Expand Down
Loading