Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fcitx
Browse files Browse the repository at this point in the history
  • Loading branch information
Fcitx Bot committed Dec 26, 2024
2 parents bab5c6a + 6dadef1 commit 8fc360d
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: build
working-directory: ./src
env:
USE_BAZEL_VERSION: "7.4.1"
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_android package --config release_build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: bazel build
working-directory: ./src
env:
USE_BAZEL_VERSION: "7.4.1"
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_linux package --config release_build
Expand Down Expand Up @@ -67,6 +67,6 @@ jobs:
- name: bazel test
working-directory: ./src
env:
USE_BAZEL_VERSION: "7.4.1"
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel test ... --config oss_linux --build_tests_only -c dbg
8 changes: 4 additions & 4 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: bazel build
working-directory: ./src
env:
USE_BAZEL_VERSION: "7.4.1"
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_macos package --macos_cpus=arm64 --config release_build
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
- name: bazel build
working-directory: ./src
env:
USE_BAZEL_VERSION: "7.4.1"
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_macos package --macos_cpus=x86_64 --config release_build
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:
- name: bazel build
working-directory: ./src
env:
USE_BAZEL_VERSION: "7.4.1"
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel build --config oss_macos package --macos_cpus=x86_64,arm64 --config release_build
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
- name: bazel test
working-directory: ./src
env:
USE_BAZEL_VERSION: "7.4.1"
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel test ... --config oss_macos --build_tests_only -c dbg
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
working-directory: .\src
env:
ANDROID_NDK_HOME: ""
USE_BAZEL_VERSION: "7.4.1"
USE_BAZEL_VERSION: "8.0.0"
run: |
bazel --bazelrc=windows.bazelrc build --config oss_windows --config release_build package
Expand Down
5 changes: 2 additions & 3 deletions docker/ubuntu22.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ WORKDIR /home/mozc_builder/work
ENV PKG_CONFIG_PATH="/home/mozc_builder/work/mozc/docker/ubuntu22.04/qt6-core-pkgconfig:${PKG_CONFIG_PATH}"

## Set up bazelisk as bazel
RUN curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.22.0/bazelisk-linux-amd64 \
RUN curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /home/mozc_builder/bin/bazel \
&& chmod u+x /home/mozc_builder/bin/bazel
### TODO(https://github.com/google/mozc/issues/1118): Support Bazel 8.0
ENV USE_BAZEL_VERSION 7.4.1
ENV USE_BAZEL_VERSION 8.0.0

## Set up Android SDK and NDK
ENV ANDROID_HOME /home/mozc_builder/Android/Sdk
Expand Down
5 changes: 2 additions & 3 deletions docker/ubuntu24.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ RUN mkdir -p /home/mozc_builder/work
WORKDIR /home/mozc_builder/work

## Set up bazelisk as bazel
RUN curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.22.0/bazelisk-linux-amd64 \
RUN curl -LO https://github.com/bazelbuild/bazelisk/releases/download/v1.25.0/bazelisk-linux-amd64 \
&& mv bazelisk-linux-amd64 /home/mozc_builder/bin/bazel \
&& chmod u+x /home/mozc_builder/bin/bazel
### TODO(https://github.com/google/mozc/issues/1118): Support Bazel 8.0
ENV USE_BAZEL_VERSION 7.4.1
ENV USE_BAZEL_VERSION 8.0.0

## Set up Android SDK and NDK
ENV ANDROID_HOME /home/mozc_builder/Android/Sdk
Expand Down
2 changes: 1 addition & 1 deletion docs/build_mozc_in_osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Building on Mac requires the following software.
* Xcode 13 (macOS 13 SDK) or later
* ⚠️Xcode Command Line Tools aren't sufficient.
* [Bazel](https://docs.bazel.build/versions/master/install-os-x.html) for Bazel build
* ⚠️ Bazel 8.x is not yet supported ([#1118](https://github.com/google/mozc/issues/1118))
* check [src/.bazelversion](../src/.bazelversion) for the supported Bazel version.
* Python 3.9 or later with the following pip module.
* `requests`
* CMake 3.18.4 or later (to build Qt6)
Expand Down
2 changes: 1 addition & 1 deletion docs/build_mozc_in_windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Note that you can specify `--qtdir=` option instead of `--noqt` in GYP phase sin
Additional requirements:

* [Bazel](https://bazel.build/)
* ⚠️ Bazel 8.x is not yet supported ([#1118](https://github.com/google/mozc/issues/1118))
* check [src/.bazelversion](../src/.bazelversion) for the supported Bazel version.
* [MSYS2](https://github.com/msys2/msys2)

After running `build_tools/update_deps.py` and `build_tools/build_qt.py`, run the following command instead of `build_mozc.py`:
Expand Down
4 changes: 2 additions & 2 deletions src/.bazelversion
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

7.4.1
8.0.0
# The first liine is intentionally empty to allow any Bazel versions.
# We have checked the build and tests with Bazel 7.4.1.
# We have checked the build and tests with Bazel 8.0.0.
# Remove the first line and use Bazelisk to use the confirmed version.
12 changes: 4 additions & 8 deletions src/engine/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ mozc_cc_library(
deps = [
":data_loader",
":engine_interface",
":minimal_engine",
":minimal_converter",
":modules",
":supplemental_model_interface",
"//base:vlog",
Expand Down Expand Up @@ -358,19 +358,15 @@ mozc_cc_library(
)

mozc_cc_library(
name = "minimal_engine",
srcs = ["minimal_engine.cc"],
hdrs = ["minimal_engine.h"],
name = "minimal_converter",
srcs = ["minimal_converter.cc"],
hdrs = ["minimal_converter.h"],
deps = [
":engine_interface",
":modules",
"//base/strings:assign",
"//composer",
"//converter:converter_interface",
"//converter:segments",
"//request:conversion_request",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
],
Expand Down
3 changes: 3 additions & 0 deletions src/engine/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "converter/immutable_converter_interface.h"
#include "data_manager/data_manager.h"
#include "engine/data_loader.h"
#include "engine/minimal_converter.h"
#include "engine/modules.h"
#include "engine/supplemental_model_interface.h"
#include "prediction/dictionary_predictor.h"
Expand Down Expand Up @@ -96,6 +97,8 @@ std::unique_ptr<Engine> Engine::CreateEngine() {
return absl::WrapUnique(new Engine());
}

Engine::Engine() : minimal_converter_(CreateMinimalConverter()) {}

absl::Status Engine::ReloadModules(std::unique_ptr<engine::Modules> modules,
bool is_mobile) {
ReloadAndWait();
Expand Down
4 changes: 2 additions & 2 deletions src/engine/engine.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@
],
},
{
'target_name': 'minimal_engine',
'target_name': 'minimal_converter',
'type': 'static_library',
'sources': [
'<(gen_out_dir)/../dictionary/pos_matcher_impl.inc',
'minimal_engine.cc',
'minimal_converter.cc',
],
'dependencies': [
'<(mozc_oss_src_dir)/composer/composer.gyp:composer',
Expand Down
21 changes: 12 additions & 9 deletions src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include "data_manager/data_manager.h"
#include "engine/data_loader.h"
#include "engine/engine_interface.h"
#include "engine/minimal_engine.h"
#include "engine/minimal_converter.h"
#include "engine/modules.h"
#include "engine/supplemental_model_interface.h"
#include "prediction/predictor_interface.h"
Expand Down Expand Up @@ -86,12 +86,13 @@ class Engine : public EngineInterface {
// TODO(taku): Avoid returning pointer, as converter_ may be updated
// dynamically and return value will become a dangling pointer.
ConverterInterface *GetConverter() const override {
return converter_ ? converter_.get() : minimal_engine_.GetConverter();
return converter_ ? converter_.get() : minimal_converter_.get();
}

absl::string_view GetPredictorName() const override {
static absl::string_view kDefaultPredictorName = "MinimalPredictor";
return converter_ ? converter_->predictor()->GetPredictorName()
: minimal_engine_.GetPredictorName();
: kDefaultPredictorName;
}

// Functions for Reload, Sync, Wait return true if successfully operated
Expand All @@ -109,18 +110,20 @@ class Engine : public EngineInterface {
bool is_mobile);

absl::string_view GetDataVersion() const override {
static absl::string_view kDefaultDataVersion = "0.0.0";
return converter_ ? converter_->modules()->GetDataManager().GetDataVersion()
: minimal_engine_.GetDataVersion();
: kDefaultDataVersion;
}

// Returns a list of part-of-speech (e.g. "名詞", "動詞一段") to be used for
// the user dictionary GUI tool.
// Since the POS set may differ per LM, this function returns
// available POS items. In practice, the POS items are rarely changed.
std::vector<std::string> GetPosList() const override {
return converter_ && converter_->modules()->GetUserDictionary()
? converter_->modules()->GetUserDictionary()->GetPosList()
: minimal_engine_.GetPosList();
if (converter_ && converter_->modules()->GetUserDictionary()) {
return converter_->modules()->GetUserDictionary()->GetPosList();
}
return {};
}

// For testing only.
Expand All @@ -137,17 +140,17 @@ class Engine : public EngineInterface {
void SetAlwaysWaitForTesting(bool value) { always_wait_for_testing_ = value; }

private:
Engine() = default;
Engine();

// Initializes the engine object by the given modules and is_mobile flag.
// The is_mobile flag is used to select DefaultPredictor and MobilePredictor.
absl::Status Init(std::unique_ptr<engine::Modules> modules, bool is_mobile);

MinimalEngine minimal_engine_;
DataLoader loader_;

std::unique_ptr<engine::SupplementalModelInterface> supplemental_model_;
std::unique_ptr<Converter> converter_;
std::unique_ptr<ConverterInterface> minimal_converter_;
std::unique_ptr<DataLoader::Response> loader_response_;
bool always_wait_for_testing_ = false;
};
Expand Down
10 changes: 3 additions & 7 deletions src/engine/minimal_engine.cc → src/engine/minimal_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "engine/minimal_engine.h"
#include "engine/minimal_converter.h"

#include <cstddef>
#include <cstdint>
Expand All @@ -39,7 +39,6 @@
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "base/strings/assign.h"
#include "composer/composer.h"
#include "converter/converter_interface.h"
#include "converter/segments.h"
#include "request/conversion_request.h"
Expand Down Expand Up @@ -152,11 +151,8 @@ class MinimalConverter : public ConverterInterface {
};
} // namespace

MinimalEngine::MinimalEngine()
: converter_(std::make_unique<MinimalConverter>()) {}

ConverterInterface *MinimalEngine::GetConverter() const {
return converter_.get();
std::unique_ptr<ConverterInterface> CreateMinimalConverter() {
return std::make_unique<MinimalConverter>();
}

} // namespace mozc
35 changes: 4 additions & 31 deletions src/engine/minimal_engine.h → src/engine/minimal_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,17 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef MOZC_ENGINE_MINIMAL_ENGINE_H_
#define MOZC_ENGINE_MINIMAL_ENGINE_H_
#ifndef MOZC_ENGINE_MINIMAL_CONVERTER_H_
#define MOZC_ENGINE_MINIMAL_CONVERTER_H_

#include <memory>
#include <string>
#include <vector>

#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "converter/converter_interface.h"
#include "engine/engine_interface.h"
#include "engine/modules.h"

namespace mozc {

// A minimal implementation of EngineInterface, which copies input key to the
// first candidate.
class MinimalEngine : public EngineInterface {
public:
MinimalEngine();
MinimalEngine(const MinimalEngine &) = delete;
MinimalEngine &operator=(const MinimalEngine &) = delete;

ConverterInterface *GetConverter() const override;
absl::string_view GetPredictorName() const override {
return "MinimalPredictor";
}
absl::string_view GetDataVersion() const override { return "0.0.0"; }

absl::Status ReloadModules(std::unique_ptr<engine::Modules> modules,
bool is_mobile) {
return absl::OkStatus();
}

private:
std::unique_ptr<ConverterInterface> converter_;
};
std::unique_ptr<ConverterInterface> CreateMinimalConverter();

} // namespace mozc

#endif // MOZC_ENGINE_MINIMAL_ENGINE_H_
#endif // MOZC_ENGINE_MINIMAL_CONVERTER_H_
1 change: 0 additions & 1 deletion src/ios/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ mozc_cc_library(
"//data_manager",
"//engine",
"//engine:engine_interface",
"//engine:minimal_engine",
"//protocol:commands_cc_proto",
"//protocol:config_cc_proto",
"//protocol:user_dictionary_storage_cc_proto",
Expand Down

0 comments on commit 8fc360d

Please sign in to comment.