inputmethod/mozc-server226: import mozc-server-2.26.4282.100nb25

Mozc is a Japanese Input Method Editor (IME) designed for multi-platform
such as Chromium OS, Windows, Mac and Linux. This open-source
project originates from Google Japanese Input.

This package is dictionary server for mozc client, such as ibus-mozc.

This package does not require deve/bazel, so you can build under
32-bit systems.
This commit is contained in:
ryoon 2024-02-10 01:20:46 +00:00
parent 28c56842c5
commit b68ce8c2af
45 changed files with 4264 additions and 0 deletions

View File

@ -0,0 +1,8 @@
Mozc is a Japanese Input Method Editor (IME) designed for multi-platform
such as Chromium OS, Windows, Mac and Linux. This open-source
project originates from Google Japanese Input.
This package is dictionary server for mozc client, such as ibus-mozc.
This package does not require deve/bazel, so you can build under
32-bit systems.

View File

@ -0,0 +1,23 @@
# $NetBSD: Makefile,v 1.1 2024/02/10 01:20:46 ryoon Exp $
PKGNAME= ${DISTNAME:S/mozc-/mozc-server-/}
PKGREVISION= 25
INSTALLATION_DIRS+= libexec
post-patch:
${RM} ${WRKSRC}/unix/uim/uim.gyp
do-build:
cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
${PYTHONBIN} build_mozc.py build \
-c ${MOZC_BUILD_MODE} \
dictionary/dictionary_base.gyp:text_dictionary_loader \
server/server.gyp:mozc_server
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/out_${OSDEST}/${MOZC_BUILD_MODE}/mozc_server \
${DESTDIR}${PREFIX}/libexec/mozc_server
.include "../../inputmethod/mozc-server226/Makefile.common"
.include "../../mk/bsd.pkg.mk"

View File

@ -0,0 +1,97 @@
# $NetBSD: Makefile.common,v 1.1 2024/02/10 01:20:46 ryoon Exp $
# used by inputmethod/ibus-mozc226/Makefile
# used by inputmethod/mozc-elisp226/Makefile
# used by inputmethod/mozc-server226/Makefile
# used by inputmethod/mozc-tool226/Makefile
# used by inputmethod/mozc-renderer226/Makefile
# used by inputmethod/uim-mozc226/Makefile
MOZC_VER= 2.26.4282.100
DISTNAME= mozc-${MOZC_VER}
CATEGORIES= inputmethod
MASTER_SITES= ${MASTER_SITE_LOCAL}
EXTRACT_SUFX= .tar.xz
MAINTAINER= ryoon@NetBSD.org
HOMEPAGE= https://github.com/google/mozc/
COMMENT= Japanese inputmethod Mozc engine
LICENSE= modified-bsd
UIM_MOZC= uim-mozc-321.3ea28b1
DISTFILES+= ${DISTNAME}${EXTRACT_SUFX} \
${UIM_MOZC}.tar.xz
SITES.${UIM_MOZC}.tar.xz= ${MASTER_SITE_SOURCEFORGE:=pnsft-aur/}
EXTRACT_USING= bsdtar
WRKSRC= ${WRKDIR}/${DISTNAME}/src
DISTINFO_FILE= ${.CURDIR}/../../inputmethod/mozc-server226/distinfo
PATCHDIR= ${.CURDIR}/../../inputmethod/mozc-server226/patches
PYTHON_VERSIONS_INCOMPATIBLE+= 27
TOOL_DEPENDS+= ${PYPKGPREFIX}-gyp>=0.1pre20200512.caa60026e223fc501e8b337fd5086ece4028b1c6:../../devel/gyp
TOOL_DEPENDS+= ${PYPKGPREFIX}-six-[0-9]*:../../lang/py-six
TOOL_DEPENDS+= ninja-build-[0-9]*:../../devel/ninja-build
USE_LANGUAGES= c c++
USE_TOOLS+= gmake pkg-config
USE_CXX_FEATURES+= c++11
CHECK_PORTABILITY_SKIP+= third_party/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh
OPENSSL_CFLAGS= -I${BUILDLINK_PREFIX.openssl}/include
OPENSSL_INC= -I${BUILDLINK_PREFIX.openssl}/include
OPENSSL_LDFLAGS= -L${BUILDLINK_PREFIX.openssl}/lib -lssl -lcrypto
OPENSSL_LIBS= -lssl -lcrypto
SUBST_CLASSES+= gyp
SUBST_STAGE.gyp= pre-configure
SUBST_MESSAGE.gyp= Fix gyp defaults
SUBST_FILES.gyp+= config.bzl
SUBST_FILES.gyp+= base/process.cc
SUBST_FILES.gyp+= gyp/directories.gypi
SUBST_FILES.gyp+= unix/ibus/ibus.gyp
SUBST_FILES.gyp+= unix/ibus/path_util.cc
SUBST_VARS.gyp+= OPENSSL_CFLAGS OPENSSL_INC OPENSSL_LDFLAGS OPENSSL_LIBS
SUBST_VARS.gyp+= PREFIX
# To disable flock(1) in link stage.
ALL_ENV+= LINK=${CXX}
.include "../../mk/bsd.prefs.mk"
OPSYSVARS+= OSDEST
OSDEST.Linux= linux
OSDEST.NetBSD= bsd
MOZC_BUILD_MODE= Release # or Debug
# In file included from src/dictionary/system/system_dictionary.h:43:0,
# from ../../dictionary/system/system_dictionary.cc:47:
# src/dictionary/system/key_expansion_table.h: In member function 'const mozc::dictionary::ExpandedKey mozc::dictionary::KeyExpansionTable::ExpandKey(char) const':
# src/dictionary/system/key_expansion_table.h:83:34: error: array subscript has type 'char' [-Werror=char-subscripts]
# return ExpandedKey(table_[key]);
# Maybe fix this later.
BUILDLINK_TRANSFORM+= rm:-Werror=char-subscripts
do-configure:
cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
${PYTHONBIN} build_mozc.py \
gyp \
--gypdir=${LOCALBASE}/bin
.include "../../devel/glib2/buildlink3.mk"
#.include "../../devel/protobuf/buildlink3.mk"
# gmock is not used yet...
#.include "../../devel/gmock/buildlink3.mk"
.include "../../inputmethod/zinnia/buildlink3.mk"
.include "../../www/curl/buildlink3.mk"
.include "../../x11/gtk2/buildlink3.mk"
.include "../../x11/qt5-qtbase/buildlink3.mk"
.include "../../lang/python/tool.mk"
.include "../../mk/atomic64.mk"

View File

@ -0,0 +1,2 @@
@comment $NetBSD: PLIST,v 1.1 2024/02/10 01:20:46 ryoon Exp $
libexec/mozc_server

View File

@ -0,0 +1,48 @@
$NetBSD: distinfo,v 1.1 2024/02/10 01:20:46 ryoon Exp $
BLAKE2s (mozc-2.26.4282.100.tar.xz) = 0d6239653ece7577159c7dc23ead2e2a42239496f0b7c3d30db472634689d12e
SHA512 (mozc-2.26.4282.100.tar.xz) = 236ec8ece076aea04480cb9aee30076699a30db88356c8bd9eb0694d86716a89748a6d33d66f5ba831e95bd0d16260e3111a9c75fded9e34df35e1785980cf12
Size (mozc-2.26.4282.100.tar.xz) = 38346468 bytes
BLAKE2s (uim-mozc-321.3ea28b1.tar.xz) = 56a29c64bd2a2a309f3c7ffd248d21a404f3e00d2058da2d4b3b356d0184cad5
SHA512 (uim-mozc-321.3ea28b1.tar.xz) = b28f4d207a52c208694371dbc550ac5022a29c5870b8d856bca8052106d8be88ab8d066bdc6d895ac6fa9f350ce6be16d638603e46058f9528691f97cb86d054
Size (uim-mozc-321.3ea28b1.tar.xz) = 24400 bytes
SHA1 (patch-base_base.gyp) = d8d9abc0da196f0573ad645937812710c7c67746
SHA1 (patch-base_clock.cc) = bac420650fed0450cf82b5071703a1c60e974a93
SHA1 (patch-base_cpu__stats.cc) = 9c18fb2543f352951969822e0095f01f0e8d3bcd
SHA1 (patch-base_logging.cc) = 65938bf4f4d414a0c3bcaffe9615d976dcab2254
SHA1 (patch-base_mutex.cc) = c52761be5ef60af35685a4de18ef18a083b1d0b9
SHA1 (patch-base_password__manager.cc) = 6b669b7c2cf15b1a85e648265dfca0f34e86d00d
SHA1 (patch-base_port.h) = 73b76a61759e32dcb7edcbb70b5cff6ad091a15c
SHA1 (patch-base_process.cc) = 9b838e6178d7dd64012c94b9c55a201d096e4680
SHA1 (patch-base_run__level.cc) = b26b0c8a457b9feb9a4de0abd7d5aae5bcd9e491
SHA1 (patch-base_system__util.cc) = bdd468c5a22fe8ecc3de57168162944afd0bb20d
SHA1 (patch-base_thread.cc) = 5e62c41beedc57dec004d100753bae4c77289762
SHA1 (patch-build__mozc.py) = c0ef43010c0f048550ed4a5e9bb7b29c8a24ac77
SHA1 (patch-build__tools_mozc__version.py) = 133f6b17d9dc811284901513e4e4ae3711710082
SHA1 (patch-build__tools_util.py) = 5ca614adf2453fcc33c18cda74c0d9b2e4f6bc21
SHA1 (patch-client_client.cc) = c11341d48ce55af0aea440800da4a53a62a436c1
SHA1 (patch-config.bzl) = 5f959d46741f2f3fbf0fbbe38aa8fa1baafadb27
SHA1 (patch-config_stats__config__util__test.cc) = f1af7403f8e06faadc5c46267d2d8b26a60c8f8d
SHA1 (patch-gui_config__dialog_config__dialog.cc) = f3349d6ed2bee63f7bb92bc71f9d8a8ab1316b74
SHA1 (patch-gui_config__dialog_keybinding__editor.cc) = 09c03f57031306b5cca8f1e546719db936159e2d
SHA1 (patch-gui_dictionary__tool_dictionary__tool.cc) = cae617cc8e324b0f93adc1e76632a018530cd2c7
SHA1 (patch-gui_qt__libraries.gypi) = ceb8d5b15d4cd5b2d907406f02413290bd4ab652
SHA1 (patch-gui_qt__moc.gypi) = e3d42e61b35012cda10da13aa03cee67786e171c
SHA1 (patch-gui_qt__rcc.gypi) = d38a849fe8e81672eb441a41936f454d8e45ff5c
SHA1 (patch-gui_qt__uic.gypi) = 7dd69ee109e81f0e70f2866b77555412518b4844
SHA1 (patch-gui_word__register__dialog_word__register__dialog.cc) = 218e3706b819855814ba8871504fc7ccb4e40b23
SHA1 (patch-gyp_common.gypi) = ce27e8665b9dab4dc6d34d337a2cb8c985c9e6f4
SHA1 (patch-gyp_directories.gypi) = eea985113aac5b99bf3c12267ad754817eef5dcc
SHA1 (patch-ipc_ipc__path__manager.cc) = cd1352bd5333f1ed755dcf6221f931fcd0a936d3
SHA1 (patch-ipc_ipc__path__manager__test.cc) = 1b83b513383f184f5ab5a56cce734b7934998533
SHA1 (patch-ipc_named__event.cc) = 8be0b1e5c4675e5b238e07b63e395dbed3c2d125
SHA1 (patch-ipc_unix__ipc.cc) = d5d86910ca610015103a309bba8d6392d96f6ce6
SHA1 (patch-protobuf_protobuf.gyp) = bb1c9684881199936abb8acd73948d1cb174a1ea
SHA1 (patch-renderer_renderer.gyp) = 83493259d6b8cd9ab6871512bebc9616d72132d1
SHA1 (patch-session_session.cc) = 3ae2c8dd056aae4c92d9dbfdac53d9c45261aad2
SHA1 (patch-session_session__test.cc) = 7396e2f4931257d8a33087b1bed5418a038fefa1
SHA1 (patch-third__party_abseil-cpp_absl_base_config.h) = e996fad886e0763c7be7b79735819e668159fd82
SHA1 (patch-third__party_protobuf_post__process__dist.sh) = 8adc79d5d7eed3cbf406ebcfbd5832b7a050ced6
SHA1 (patch-uim-mozc) = 0000583d8f3f44ef2281888c7cfdb968c17ec798
SHA1 (patch-unix_ibus_ibus.gyp) = aa2077cf3c379bf9ce33e97abe478540346782ad
SHA1 (patch-unix_ibus_path__util.cc) = a6aa368d9ce8926e200602fdc370c13e35d5a8cf

View File

@ -0,0 +1,15 @@
$NetBSD: patch-base_base.gyp,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- base/base.gyp.orig 2017-11-02 13:32:45.000000000 +0000
+++ base/base.gyp
@@ -141,7 +141,7 @@
},
},
}],
- ['target_platform=="Linux" and server_dir!=""', {
+ ['(target_platform=="Linux" or target_platform=="NetBSD") and server_dir!=""', {
'defines': [
'MOZC_SERVER_DIRECTORY="<(server_dir)"',
],

View File

@ -0,0 +1,24 @@
$NetBSD: patch-base_clock.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- base/clock.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ base/clock.cc
@@ -116,7 +116,7 @@ class ClockImpl : public ClockInterface
mach_timebase_info(&timebase_info);
return static_cast<uint64>(1.0e9 * timebase_info.denom /
timebase_info.numer);
-#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
return 1000000uLL;
#else // platforms (OS_WIN, __APPLE__, OS_LINUX, ...)
#error "Not supported platform"
@@ -133,7 +133,7 @@ class ClockImpl : public ClockInterface
return static_cast<uint64>(timestamp.QuadPart);
#elif defined(__APPLE__)
return static_cast<uint64>(mach_absolute_time());
-#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#elif defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
uint64 sec;
uint32 usec;
GetTimeOfDay(&sec, &usec);

View File

@ -0,0 +1,48 @@
$NetBSD: patch-base_cpu__stats.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- base/cpu_stats.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ base/cpu_stats.cc
@@ -122,13 +122,13 @@ float CPUStats::GetSystemCPULoad() {
#endif // __APPLE__
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
// NOT IMPLEMENTED
// TODO(taku): implement Linux version
// can take the info from /proc/stats
const uint64 total_times = 0;
const uint64 cpu_times = 0;
-#endif // OS_LINUX || OS_ANDROID || OS_WASM
+#endif // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
return UpdateCPULoad(total_times, cpu_times, &prev_system_total_times_,
&prev_system_cpu_times_);
@@ -175,11 +175,11 @@ float CPUStats::GetCurrentProcessCPULoad
TimeValueTToInt64(task_times_info.system_time);
#endif // __APPLE__
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
// not implemented
const uint64 total_times = 0;
const uint64 cpu_times = 0;
-#endif // OS_LINUX || OS_ANDROID || OS_WASM
+#endif // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
return UpdateCPULoad(total_times, cpu_times,
&prev_current_process_total_times_,
@@ -206,9 +206,9 @@ size_t CPUStats::GetNumberOfProcessors()
return static_cast<size_t>(basic_info.avail_cpus);
#endif // __APPLE__
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
// Not implemented
return 1;
-#endif // OS_LINUX
+#endif // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
}
} // namespace mozc

View File

@ -0,0 +1,27 @@
$NetBSD: patch-base_logging.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- base/logging.cc.orig 2021-02-15 05:04:33.000000000 +0000
+++ base/logging.cc
@@ -62,6 +62,10 @@
#include "absl/flags/flag.h"
#include "absl/strings/str_cat.h"
+#if defined(OS_NETBSD)
+#include <lwp.h>
+#endif
+
ABSL_FLAG(bool, colored_log, true,
"Enables colored log messages on tty devices");
ABSL_FLAG(bool, logtostderr, false,
@@ -112,6 +116,9 @@ string Logging::GetLogMessageHeader() {
return absl::StrCat(timestamp, ::getpid(), " ",
// It returns unsigned long.
pthread_self());
+# elif defined(OS_NETBSD)
+ return absl::StrCat(timestamp, ::getpid(), " ",
+ (unsigned long)_lwp_self());
# elif defined(__APPLE__)
# ifdef __LP64__
return absl::StrCat(timestamp, ::getpid(), " ",

View File

@ -0,0 +1,15 @@
$NetBSD: patch-base_mutex.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- base/mutex.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ base/mutex.cc
@@ -148,7 +148,7 @@ Mutex::Mutex() {
// PTHREAD_MUTEX_RECURSIVE_NP but Mac OS X 10.5 does not
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
-#if defined(__APPLE__) || defined(OS_WASM)
+#if defined(__APPLE__) || defined(OS_WASM) || defined(OS_NETBSD)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
#elif defined(OS_LINUX) || defined(OS_ANDROID)
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);

View File

@ -0,0 +1,15 @@
$NetBSD: patch-base_password__manager.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- base/password_manager.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ base/password_manager.cc
@@ -264,7 +264,7 @@ bool WinMacPasswordManager::RemovePasswo
// We use plain text file for password storage on Linux. If you port this module
// to other Linux distro, you might want to implement a new password manager
// which adopts some secure mechanism such like gnome-keyring.
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
typedef PlainPasswordManager DefaultPasswordManager;
#endif // OS_LINUX || OS_ANDROID || OS_WASM

View File

@ -0,0 +1,15 @@
$NetBSD: patch-base_port.h,v 1.1 2024/02/10 01:20:46 ryoon Exp $
--- base/port.h.orig 2021-02-15 05:04:33.000000000 +0000
+++ base/port.h
@@ -69,6 +69,10 @@ using std::string;
#define MOZC_OS_DEFINED
#endif // OS_WASM
+#ifdef OS_NETBSD
+#define MOZC_OS_DEFINED
+#endif // OS_NETBSD
+
#ifndef MOZC_OS_DEFINED
#error "OS_XXX (e.g., OS_WIN) must be defined."
#endif // !MOZC_OS_DEFINED

View File

@ -0,0 +1,73 @@
$NetBSD: patch-base_process.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- base/process.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ base/process.cc
@@ -46,12 +46,12 @@
#include "base/mac_process.h"
#endif // __APPLE__
-#if defined(OS_LINUX) || defined(OS_ANDROID)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
#include <fcntl.h>
#include <signal.h>
#include <spawn.h> // for posix_spawn().
#include <sys/types.h>
-#endif // OS_LINUX || OS_ANDROID
+#endif // OS_LINUX || OS_ANDROID || OS_NETBSD
#include <cstdlib>
#include <memory>
@@ -98,12 +98,12 @@ bool Process::OpenBrowser(const std::str
return WinUtil::ShellExecuteInSystemDir(L"open", wurl.c_str(), nullptr);
#endif
-#if defined(OS_LINUX) || defined(OS_ANDROID)
- static const char kBrowserCommand[] = "/usr/bin/xdg-open";
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
+ static const char kBrowserCommand[] = "@PREFIX@/bin/xdg-open";
// xdg-open which uses kfmclient or gnome-open internally works both on KDE
// and GNOME environments.
return SpawnProcess(kBrowserCommand, url);
-#endif // OS_LINUX || OS_ANDROID
+#endif // OS_LINUX || OS_ANDROID || OS_NETBSD
#ifdef __APPLE__
return MacProcess::OpenBrowserForMac(url);
@@ -185,7 +185,7 @@ bool Process::SpawnProcess(const std::st
}
#endif
-#if defined(OS_LINUX) || defined(OS_ANDROID)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
// Do not call posix_spawn() for obviously bad path.
if (!S_ISREG(statbuf.st_mode)) {
LOG(ERROR) << "Not a regular file: " << path;
@@ -208,7 +208,7 @@ bool Process::SpawnProcess(const std::st
// (www.gnu.org/software/libc/manual/html_node/Heap-Consistency-Checking.html)
const int kOverwrite = 0; // Do not overwrite.
::setenv("MALLOC_CHECK_", "2", kOverwrite);
-#endif // OS_LINUX || OS_ANDROID
+#endif // OS_LINUX || OS_ANDROID || OS_NETBSD
pid_t tmp_pid = 0;
// Spawn new process.
@@ -383,7 +383,7 @@ bool Process::LaunchErrorMessageDialog(c
}
#endif // OS_WIN
-#if defined(OS_LINUX) || defined(OS_ANDROID)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
const char kMozcTool[] = "mozc_tool";
const std::string arg =
"--mode=error_message_dialog --error_type=" + error_type;
@@ -392,7 +392,7 @@ bool Process::LaunchErrorMessageDialog(c
LOG(ERROR) << "cannot launch " << kMozcTool;
return false;
}
-#endif // OS_LINUX || OS_ANDROID
+#endif // OS_LINUX || OS_ANDROID || OS_NETBSD
return true;
}

View File

@ -0,0 +1,19 @@
$NetBSD: patch-base_run__level.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- base/run_level.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ base/run_level.cc
@@ -38,10 +38,10 @@
#include <unistd.h>
#endif // __APPLE__
-#if defined(OS_LINUX) || defined(OS_ANDROID)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
#include <sys/types.h>
#include <unistd.h>
-#endif // OS_LINUX || OS_ANDROID
+#endif // OS_LINUX || OS_ANDROID || OS_NETBSD
#include "base/const.h"
#include "base/logging.h"

View File

@ -0,0 +1,87 @@
$NetBSD: patch-base_system__util.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
--- base/system_util.cc.orig 2021-02-15 05:04:33.000000000 +0000
+++ base/system_util.cc
@@ -275,7 +275,7 @@ std::string UserProfileDirectoryImpl::Ge
# endif // GOOGLE_JAPANESE_INPUT_BUILD
-#elif defined(OS_LINUX)
+#elif defined(OS_LINUX) || defined(OS_NETBSD)
// 1. If "$HOME/.mozc" already exists,
// use "$HOME/.mozc" for backward compatibility.
// 2. If $XDG_CONFIG_HOME is defined
@@ -422,7 +422,7 @@ std::string SystemUtil::GetServerDirecto
return MacUtil::GetServerDirectory();
#endif // __APPLE__
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
# if defined(MOZC_SERVER_DIRECTORY)
return MOZC_SERVER_DIRECTORY;
# else
@@ -499,12 +499,12 @@ std::string SystemUtil::GetUserNameAsStr
return ppw->pw_name;
#endif // OS_ANDROID
-#if defined(__APPLE__) || defined(OS_LINUX) || defined(OS_WASM)
+#if defined(__APPLE__) || defined(OS_LINUX) || defined(OS_WASM) || defined(OS_NETBSD)
struct passwd pw, *ppw;
char buf[1024];
CHECK_EQ(0, getpwuid_r(geteuid(), &pw, buf, sizeof(buf), &ppw));
return pw.pw_name;
-#endif // __APPLE__ || OS_LINUX || OS_WASM
+#endif // __APPLE__ || OS_LINUX || OS_WASM || OS_NETBSD
// If none of the above platforms is specified, the compiler raises an error
// because of no return value.
@@ -662,13 +662,13 @@ string GetSessionIdString() {
#endif // OS_WIN
std::string SystemUtil::GetDesktopNameAsString() {
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
const char *display = Environ::GetEnv("DISPLAY");
if (display == nullptr) {
return "";
}
return display;
-#endif // OS_LINUX || OS_ANDROID || OS_WASM
+#endif // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
#if defined(__APPLE__)
return "";
@@ -862,10 +862,13 @@ std::string SystemUtil::GetOSVersionStri
#elif defined(OS_LINUX)
const std::string ret = "Linux";
return ret;
-#else // !OS_WIN && !__APPLE__ && !OS_LINUX
+#elif defined(OS_NETBSD)
+ const std::string ret = "NetBSD";
+ return ret;
+#else // !OS_WIN && !__APPLE__ && !OS_LINUX && !OS_NETBSD
const string ret = "Unknown";
return ret;
-#endif // OS_WIN, __APPLE__, OS_LINUX
+#endif // OS_WIN, __APPLE__, OS_LINUX, OS_NETBSD
}
void SystemUtil::DisableIME() {
@@ -901,7 +904,7 @@ uint64 SystemUtil::GetTotalPhysicalMemor
return total_memory;
#endif // __APPLE__
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
# if defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
const int32 page_size = sysconf(_SC_PAGESIZE);
const int32 number_of_phyisical_pages = sysconf(_SC_PHYS_PAGES);
@@ -914,7 +917,7 @@ uint64 SystemUtil::GetTotalPhysicalMemor
# else // defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
return 0;
# endif // defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
-#endif // OS_LINUX || OS_ANDROID || OS_WASM
+#endif // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
// If none of the above platforms is specified, the compiler raises an error
// because of no return value.

View File

@ -0,0 +1,20 @@
$NetBSD: patch-base_thread.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* tweak for NetBSD pthread_setname_np(3)
--- base/thread.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ base/thread.cc
@@ -145,9 +145,11 @@ void Thread::Start(const std::string &th
// WASM doesn't support setname?
#elif defined(__APPLE__) // !OS_WASM
pthread_setname_np(thread_name.c_str());
-#else // !(OS_WASM | __APPLE__)
+#elif defined(OS_NETBSD)
+ pthread_setname_np(*state_->handle, "%s", (void *)thread_name.c_str());
+#else // !(OS_WASM | __APPLE__ | OS_NETBSD)
pthread_setname_np(*state_->handle, thread_name.c_str());
-#endif // !(OS_WASM | __APPLE__)
+#endif // !(OS_WASM | __APPLE__ | OS_NETBSD)
}
}

View File

@ -0,0 +1,73 @@
$NetBSD: patch-build__mozc.py,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- build_mozc.py.orig 2021-02-15 03:48:53.000000000 +0000
+++ build_mozc.py
@@ -55,6 +55,7 @@ from build_tools.util import CopyFile
from build_tools.util import GetNumberOfProcessors
from build_tools.util import IsLinux
from build_tools.util import IsMac
+from build_tools.util import IsNetBSD
from build_tools.util import IsWindows
from build_tools.util import PrintErrorAndExit
from build_tools.util import RemoveDirectoryRecursively
@@ -96,6 +97,7 @@ def GetBuildShortBaseName(target_platfor
'Windows': 'out_win',
'Mac': 'out_mac',
'Linux': 'out_linux',
+ 'NetBSD': 'out_bsd',
'iOS': 'out_ios',
}
@@ -155,7 +157,7 @@ def GetGypFileNames(options):
# Include subdirectory of win32 and breakpad for Windows
if options.target_platform == 'Windows':
gyp_file_names.extend(glob.glob('%s/win32/*/*.gyp' % SRC_DIR))
- elif options.target_platform == 'Linux':
+ elif options.target_platform == 'Linux' or options.target_platform == 'NetBSD':
gyp_file_names.extend(glob.glob('%s/unix/*/*.gyp' % SRC_DIR))
# Add ibus.gyp if ibus version is >=1.4.1.
if not PkgExists('ibus-1.0 >= 1.4.1'):
@@ -182,6 +184,8 @@ def ParseVerbose(unused_option, unused_o
def AddTargetPlatformOption(parser):
if IsLinux():
default_target = 'Linux'
+ if IsNetBSD():
+ default_target = 'NetBSD'
elif IsWindows():
default_target = 'Windows'
elif IsMac():
@@ -269,6 +273,12 @@ def ExpandMetaTarget(options, meta_targe
SRC_DIR + '/gui/gui.gyp:mozc_tool']
if PkgExists('ibus-1.0 >= 1.4.1'):
targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc')
+ elif target_platform == 'NetBSD':
+ targets = [SRC_DIR + '/server/server.gyp:mozc_server',
+ SRC_DIR + '/renderer/renderer.gyp:mozc_renderer',
+ SRC_DIR + '/gui/gui.gyp:mozc_tool']
+ if PkgExists('ibus-1.0 >= 1.4.1'):
+ targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc')
elif target_platform == 'Mac':
targets = [SRC_DIR + '/mac/mac.gyp:codesign_DiskImage']
elif target_platform == 'Windows':
@@ -441,7 +451,8 @@ def GypMain(options, unused_args):
if options.noqt:
gyp_options.extend(['-D', 'use_qt=NO'])
gyp_options.extend(['-D', 'qt_dir='])
- elif target_platform == 'Linux':
+ elif (target_platform == 'Linux' or
+ target_platform == 'NetBSD'):
gyp_options.extend(['-D', 'use_qt=YES'])
gyp_options.extend(['-D', 'qt_dir='])
@@ -482,7 +493,8 @@ def GypMain(options, unused_args):
if IsWindows():
gyp_options.extend(['-G', 'msvs_version=2017'])
- if (target_platform == 'Linux' and
+ if ((target_platform == 'Linux' or
+ target_platform == 'NetBSD') and
'%s/unix/ibus/ibus.gyp' % SRC_DIR in gyp_file_names):
gyp_options.extend(['-D', 'use_libibus=1'])

View File

@ -0,0 +1,14 @@
$NetBSD: patch-build__tools_mozc__version.py,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- build_tools/mozc_version.py.orig 2021-02-15 03:48:53.000000000 +0000
+++ build_tools/mozc_version.py
@@ -69,6 +69,7 @@ TARGET_PLATFORM_TO_DIGIT = {
'iOS': '6',
'iOS_sim': '6',
'Wasm': '7',
+ 'NetBSD': '8',
}
VERSION_PROPERTIES = [

View File

@ -0,0 +1,18 @@
$NetBSD: patch-build__tools_util.py,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- build_tools/util.py.orig 2016-05-15 08:11:10.000000000 +0000
+++ build_tools/util.py
@@ -59,6 +59,11 @@ def IsLinux():
return os.name == 'posix' and os.uname()[0] == 'Linux'
+def IsNetBSD():
+ """Returns true if the platform is NetBSD."""
+ return os.name == 'posix' and os.uname()[0] == 'NetBSD'
+
+
def GetNumberOfProcessors():
"""Returns the number of CPU cores available.

View File

@ -0,0 +1,24 @@
$NetBSD: patch-client_client.cc,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* NetBSD support
--- client/client.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ client/client.cc
@@ -867,7 +867,7 @@ bool Client::LaunchTool(const std::strin
return false;
}
-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID)
+#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_NETBSD)
std::string arg = "--mode=" + mode;
if (!extra_arg.empty()) {
arg += " ";
@@ -877,7 +877,7 @@ bool Client::LaunchTool(const std::strin
LOG(ERROR) << "Cannot execute: " << kMozcTool << " " << arg;
return false;
}
-#endif // OS_WIN || OS_LINUX || OS_ANDROID
+#endif // OS_WIN || OS_LINUX || OS_ANDROID || OS_NETBSD
// TODO(taku): move MacProcess inside SpawnMozcProcess.
// TODO(taku): support extra_arg.

View File

@ -0,0 +1,19 @@
$NetBSD: patch-config.bzl,v 1.1 2024/02/10 01:20:46 ryoon Exp $
* For pkgsrc layout.
--- config.bzl.orig 2021-02-15 05:04:34.000000000 +0000
+++ config.bzl
@@ -30,9 +30,9 @@
BRANDING = "Mozc"
-LINUX_MOZC_SERVER_DIRECTORY = "/usr/lib/mozc"
-IBUS_MOZC_ICON_PATH = "/usr/share/ibus-mozc/product_icon.png"
-IBUS_MOZC_PATH = "/usr/lib/ibus-mozc/ibus-engine-mozc"
+LINUX_MOZC_SERVER_DIRECTORY = "@PREFIX@/libexec"
+IBUS_MOZC_ICON_PATH = "@PREFIX@/share/ibus-mozc/product_icon.png"
+IBUS_MOZC_PATH = "@PREFIX@/libexec/ibus-engine-mozc"
MACOS_BUNDLE_ID_PREFIX = "org.mozc.inputmethod.Japanese"
MACOS_MIN_OS_VER = "10.12"

View File

@ -0,0 +1,20 @@
$NetBSD: patch-config_stats__config__util__test.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- config/stats_config_util_test.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ config/stats_config_util_test.cc
@@ -685,11 +685,11 @@ TEST(StatsConfigUtilTestAndroid, Default
}
#endif // OS_ANDROID
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_NETBSD)
TEST(StatsConfigUtilTestLinux, DefaultValueTest) {
EXPECT_FALSE(StatsConfigUtil::IsEnabled());
}
-#endif // OS_LINUX
+#endif // OS_LINUX || OS_NETBSD
#else // !GOOGLE_JAPANESE_INPUT_BUILD
TEST(StatsConfigUtilTestNonOfficialBuild, DefaultValueTest) {

View File

@ -0,0 +1,50 @@
$NetBSD: patch-gui_config__dialog_config__dialog.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- gui/config_dialog/config_dialog.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ gui/config_dialog/config_dialog.cc
@@ -104,21 +104,21 @@ ConfigDialog::ConfigDialog()
setWindowTitle(tr("%1 Preferences").arg(GuiUtil::ProductName()));
#endif // __APPLE__
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_NETBSD)
miscDefaultIMEWidget->setVisible(false);
miscAdministrationWidget->setVisible(false);
miscStartupWidget->setVisible(false);
-#endif // OS_LINUX
+#endif // OS_LINUX || OS_NETBSD
#ifdef MOZC_NO_LOGGING
// disable logging options
miscLoggingWidget->setVisible(false);
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_NETBSD)
// The last "misc" tab has no valid configs on Linux
const int kMiscTabIndex = 6;
configDialogTabWidget->removeTab(kMiscTabIndex);
-#endif // OS_LINUX
+#endif // OS_LINUX || OS_NETBSD
#endif // MOZC_NO_LOGGING
suggestionsSizeSpinBox->setRange(1, 9);
@@ -280,7 +280,7 @@ ConfigDialog::ConfigDialog()
dictionaryPreloadingAndUACLabel->setVisible(false);
#endif // OS_WIN
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_NETBSD)
// On Linux, disable all fields for UsageStats
usageStatsLabel->setEnabled(false);
usageStatsLabel->setVisible(false);
@@ -290,7 +290,7 @@ ConfigDialog::ConfigDialog()
usageStatsMessage->setVisible(false);
usageStatsCheckBox->setEnabled(false);
usageStatsCheckBox->setVisible(false);
-#endif // OS_LINUX
+#endif // OS_LINUX || OS_NETBSD
GuiUtil::ReplaceWidgetLabels(this);

View File

@ -0,0 +1,24 @@
$NetBSD: patch-gui_config__dialog_keybinding__editor.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- gui/config_dialog/keybinding_editor.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ gui/config_dialog/keybinding_editor.cc
@@ -381,7 +381,7 @@ KeyBindingFilter::KeyState KeyBindingFil
return Encode(result);
}
}
-#elif OS_LINUX
+#elif defined(OS_LINUX) || defined(OS_NETBSD)
// The XKB defines three types of logical key code: "xkb::Hiragana",
// "xkb::Katakana" and "xkb::Hiragana_Katakana".
// On most of Linux distributions, any key event against physical
@@ -478,7 +478,7 @@ bool KeyBindingFilter::eventFilter(QObje
KeyBindingEditor::KeyBindingEditor(QWidget *parent, QWidget *trigger_parent)
: QDialog(parent), trigger_parent_(trigger_parent) {
setupUi(this);
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_NETBSD)
// Workaround for the issue https://github.com/google/mozc/issues/9
// Seems that even after clicking the button for the keybinding dialog,
// the edit is not raised. This might be a bug of setFocusProxy.

View File

@ -0,0 +1,15 @@
$NetBSD: patch-gui_dictionary__tool_dictionary__tool.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- gui/dictionary_tool/dictionary_tool.cc.orig 2014-05-21 10:51:22.000000000 +0000
+++ gui/dictionary_tool/dictionary_tool.cc
@@ -347,7 +347,7 @@ DictionaryTool::DictionaryTool(QWidget *
#endif // !ENABLE_CLOUD_SYNC
// main window
-#ifndef OS_LINUX
+#if !defined(OS_LINUX) && !defined(OS_NETBSD)
// For some reason setCentralWidget crashes the dictionary_tool on Linux
// TODO(taku): investigate the cause of the crashes
setCentralWidget(splitter_);

View File

@ -0,0 +1,15 @@
$NetBSD: patch-gui_qt__libraries.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- gui/qt_libraries.gypi.orig 2017-11-02 13:32:47.000000000 +0000
+++ gui/qt_libraries.gypi
@@ -98,7 +98,7 @@
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
]
}],
- ['target_platform=="Linux"', {
+ ['target_platform=="Linux" or target_platform=="NetBSD"', {
'cflags': ['<!@(pkg-config --cflags Qt5Widgets Qt5Gui Qt5Core)'],
'libraries': ['<!@(pkg-config --libs Qt5Widgets Qt5Gui Qt5Core)'],
}],

View File

@ -0,0 +1,15 @@
$NetBSD: patch-gui_qt__moc.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- gui/qt_moc.gypi.orig 2017-11-02 13:32:47.000000000 +0000
+++ gui/qt_moc.gypi
@@ -33,7 +33,7 @@
'variables': {
'conditions': [
- ['target_platform=="Linux"', {
+ ['target_platform=="Linux" or target_platform=="NetBSD"', {
'moc_path': '<!(pkg-config --variable=host_bins Qt5Core)/moc',
}, 'qt_dir', {
'moc_path': '<(qt_dir)/bin/moc<(EXECUTABLE_SUFFIX)',

View File

@ -0,0 +1,15 @@
$NetBSD: patch-gui_qt__rcc.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- gui/qt_rcc.gypi.orig 2017-11-02 13:32:47.000000000 +0000
+++ gui/qt_rcc.gypi
@@ -33,7 +33,7 @@
'variables': {
'conditions': [
- ['target_platform=="Linux"', {
+ ['target_platform=="Linux" or target_platform=="NetBSD"', {
'rcc_path': '<!(pkg-config --variable=host_bins Qt5Core)/rcc',
}, 'qt_dir', {
'rcc_path': '<(qt_dir)/bin/rcc<(EXECUTABLE_SUFFIX)',

View File

@ -0,0 +1,15 @@
$NetBSD: patch-gui_qt__uic.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- gui/qt_uic.gypi.orig 2017-11-02 13:32:47.000000000 +0000
+++ gui/qt_uic.gypi
@@ -33,7 +33,7 @@
'variables': {
'conditions': [
- ['target_platform=="Linux"', {
+ ['target_platform=="Linux" or target_platform=="NetBSD"', {
'uic_path': '<!(pkg-config --variable=host_bins Qt5Core)/uic',
}, 'qt_dir', {
'uic_path': '<(qt_dir)/bin/uic<(EXECUTABLE_SUFFIX)',

View File

@ -0,0 +1,19 @@
$NetBSD: patch-gui_word__register__dialog_word__register__dialog.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
* Fix from https://github.com/google/mozc/issues/460
--- gui/word_register_dialog/word_register_dialog.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ gui/word_register_dialog/word_register_dialog.cc
@@ -97,9 +97,9 @@ QString GetEnv(const char *envname) {
}
return QLatin1String("");
#endif // OS_WIN
-#if defined(__APPLE__) || defined(OS_LINUX)
+#if defined(__APPLE__) || defined(OS_LINUX) || defined(OS_NETBSD)
return QString::fromUtf8(::getenv(envname));
-#endif // __APPLE__ or OS_LINUX
+#endif // __APPLE__ or OS_LINUX or OS_NETBSD
// TODO(team): Support other platforms.
return QLatin1String("");
}

View File

@ -0,0 +1,68 @@
$NetBSD: patch-gyp_common.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- gyp/common.gypi.orig 2021-02-15 05:04:33.000000000 +0000
+++ gyp/common.gypi
@@ -93,6 +93,14 @@
'-fstack-protector',
'--param=ssp-buffer-size=4',
],
+ # netbsd_cflags will be used for NetBSD.
+ 'netbsd_cflags': [
+ '<@(gcc_cflags)',
+ '-fPIC',
+ '-D_NETBSD_SOURCE',
+ '-fno-exceptions',
+ '<!(echo $CFLAGS)',
+ ],
# mac_cflags will be used in Mac.
# Xcode 4.5 which we are currently using does not support ssp-buffer-size.
# TODO(horo): When we can use Xcode 4.6 which supports ssp-buffer-size,
@@ -128,6 +136,12 @@
'compiler_host': 'clang',
'compiler_host_version_int': 304, # Clang 3.4 or higher
}],
+ ['target_platform=="NetBSD"', {
+ 'compiler_target': 'gcc',
+ 'compiler_target_version_int': 409, # GCC 4.9 or higher
+ 'compiler_host': 'gcc',
+ 'compiler_host_version_int': 409, # GCC 4.9 or higher
+ }],
],
},
'target_defaults': {
@@ -318,6 +332,24 @@
}],
],
}],
+ ['OS=="netbsd"', {
+ 'defines': [
+ 'OS_NETBSD',
+ ],
+ 'cflags': [
+ '<@(netbsd_cflags)',
+ '-fPIC',
+ '-fno-exceptions',
+ ],
+ 'cflags_cc': [
+ # We use deprecated <hash_map> and <hash_set> instead of upcoming
+ # <unordered_map> and <unordered_set>.
+ '-Wno-deprecated',
+ ],
+ 'ldflags': [
+ '-pthread',
+ ],
+ }],
['OS=="mac"', {
'defines': [
'__APPLE__',
@@ -410,7 +442,7 @@
],
},
'conditions': [
- ['target_platform=="Linux"', {
+ ['target_platform=="Linux" or target_platform=="NetBSD"', {
'make_global_settings': [
['AR', '<!(which ar)'],
['CC', '<!(which clang)'],

View File

@ -0,0 +1,13 @@
$NetBSD: patch-gyp_directories.gypi,v 1.1 2024/02/10 01:20:47 ryoon Exp $
--- gyp/directories.gypi.orig 2021-02-15 05:04:33.000000000 +0000
+++ gyp/directories.gypi
@@ -43,7 +43,7 @@
# server_dir represents the directory where mozc_server is
# installed. This option is only for Linux.
- 'server_dir%': '/usr/lib/mozc',
+ 'server_dir%': '@PREFIX@/libexec',
# Represents the directory where the source code of protobuf is
# extracted. This value is ignored when 'use_libprotobuf' is 1.

View File

@ -0,0 +1,42 @@
$NetBSD: patch-ipc_ipc__path__manager.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- ipc/ipc_path_manager.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ ipc/ipc_path_manager.cc
@@ -53,6 +53,11 @@
#endif // __APPLE__
#endif // OS_WIN
+#if defined(OS_NETBSD)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
+
#include <cstdlib>
#include <map>
#ifdef OS_WIN
@@ -425,6 +430,23 @@ bool IPCPathManager::IsValidServer(uint3
return true;
}
+#if defined(OS_NETBSD)
+ int name[] = { CTL_KERN, KERN_PROC_ARGS, static_cast<int>(pid) };
+ size_t data_len = 0;
+ if (sysctl(name, arraysize(name), NULL,
+ &data_len, NULL, 0) < 0) {
+ LOG(ERROR) << "sysctl KERN_PROC_ARGS failed";
+ return false;
+ }
+
+ server_path_.resize(data_len);
+ if (sysctl(name, arraysize(name), &server_path_[0],
+ &data_len, NULL, 0) < 0) {
+ LOG(ERROR) << "sysctl KERN_PROC_ARGS failed";
+ return false;
+ }
+#endif // OS_NETBSD
+
#ifdef OS_LINUX
if ((server_path + " (deleted)") == server_path_) {
LOG(WARNING) << server_path << " on disk is modified";

View File

@ -0,0 +1,15 @@
$NetBSD: patch-ipc_ipc__path__manager__test.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- ipc/ipc_path_manager_test.cc.orig 2013-07-17 02:37:50.000000000 +0000
+++ ipc/ipc_path_manager_test.cc
@@ -103,7 +103,7 @@ TEST_F(IPCPathManagerTest, IPCPathManage
EXPECT_FALSE(manager->GetServerProductVersion().empty());
EXPECT_GT(manager->GetServerProcessId(), 0);
EXPECT_EQ(t.path(), path);
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_NETBSD)
// On Linux, |path| should be abstract (see man unix(7) for details.)
ASSERT_FALSE(path.empty());
EXPECT_EQ('\0', path[0]);

View File

@ -0,0 +1,15 @@
$NetBSD: patch-ipc_named__event.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* sem_open(..., 0) is not supported for NetBSD at least.
--- ipc/named_event.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ ipc/named_event.cc
@@ -325,7 +325,7 @@ int NamedEventListener::WaitEventOrProce
NamedEventNotifier::NamedEventNotifier(const char *name) : sem_(SEM_FAILED) {
const std::string key_filename = NamedEventUtil::GetEventPath(name);
- sem_ = ::sem_open(key_filename.c_str(), 0);
+ sem_ = ::sem_open(key_filename.c_str(), O_CREAT);
if (sem_ == SEM_FAILED) {
LOG(ERROR) << "sem_open failed: " << ::strerror(errno);
}

View File

@ -0,0 +1,55 @@
$NetBSD: patch-ipc_unix__ipc.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- ipc/unix_ipc.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ ipc/unix_ipc.cc
@@ -28,7 +28,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// OS_LINUX only. Note that OS_ANDROID/OS_WASM don't reach here.
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_NETBSD)
#include <arpa/inet.h>
#include <fcntl.h>
@@ -125,7 +125,7 @@ bool IsPeerValid(int socket, pid_t *pid)
// sometimes doesn't support the getsockopt(sock, SOL_SOCKET, SO_PEERCRED)
// system call.
// TODO(yusukes): Add implementation for ARM Linux.
-#ifndef __arm__
+#if !defined(__arm__) && !defined(OS_NETBSD)
struct ucred peer_cred;
int peer_cred_len = sizeof(peer_cred);
if (getsockopt(socket, SOL_SOCKET, SO_PEERCRED,
@@ -141,7 +141,23 @@ bool IsPeerValid(int socket, pid_t *pid)
}
*pid = peer_cred.pid;
-#endif // __arm__
+#endif // __arm__ || OS_NETBSD
+
+#if defined(OS_NETBSD)
+ struct unpcbid peer_cred;
+ int peer_cred_len = sizeof(peer_cred);
+ if (getsockopt(socket, 0, LOCAL_PEEREID,
+ reinterpret_cast<void *>(&peer_cred),
+ reinterpret_cast<socklen_t *>(&peer_cred_len)) < 0) {
+ LOG(ERROR) << "cannot get peer credential. Not a Unix socket?";
+ return false;
+ }
+
+ if (peer_cred.unp_euid!= ::geteuid()) {
+ LOG(WARNING) << "uid mismatch." << peer_cred.unp_euid << "!=" << ::geteuid();
+ return false;
+ }
+#endif
return true;
}
@@ -468,4 +484,4 @@ void IPCServer::Terminate() { server_thr
} // namespace mozc
-#endif // OS_LINUX
+#endif // OS_LINUX || OS_NETBSD

View File

@ -0,0 +1,17 @@
$NetBSD: patch-protobuf_protobuf.gyp,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* Pass LDFLAGS from pkgsrc.
Fix -lprotobuf is not found error.
--- protobuf/protobuf.gyp.orig 2021-02-15 05:04:33.000000000 +0000
+++ protobuf/protobuf.gyp
@@ -156,6 +156,9 @@
'libraries': [
'-lprotobuf',
],
+ 'ldflags': [
+ '<!(echo $LDFLAGS)',
+ ],
},
},
{ # else

View File

@ -0,0 +1,24 @@
$NetBSD: patch-renderer_renderer.gyp,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* Support NetBSD.
--- renderer/renderer.gyp.orig 2021-02-15 05:04:33.000000000 +0000
+++ renderer/renderer.gyp
@@ -193,7 +193,7 @@
'win32_renderer_core_test',
],
}],
- ['target_platform=="Linux" and enable_gtk_renderer==1', {
+ ['(target_platform=="Linux" or target_platform=="NetBSD") and enable_gtk_renderer==1', {
'dependencies': [
'gtk_renderer_test',
],
@@ -518,7 +518,7 @@
},
],
}],
- ['target_platform=="Linux" and enable_gtk_renderer==1', {
+ ['(target_platform=="Linux" or target_platform=="NetBSD") and enable_gtk_renderer==1', {
'targets': [
{
# Meta target to set up build environment for gtk+-2.0.

View File

@ -0,0 +1,36 @@
$NetBSD: patch-session_session.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- session/session.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ session/session.cc
@@ -230,9 +230,9 @@ void Session::InitContext(ImeContext *co
context->SetConfig(&context->GetConfig());
#if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_LINUX) || \
- defined(OS_WASM)
+ defined(OS_WASM) || defined(OS_NETBSD)
context->mutable_converter()->set_use_cascading_window(false);
-#endif // OS_ANDROID || OS_IOS || OS_LINUX || OS_WASM
+#endif // OS_ANDROID || OS_IOS || OS_LINUX || OS_WASM || OS_NETBSD
}
void Session::PushUndoContext() {
@@ -964,14 +964,14 @@ void Session::UpdatePreferences(commands
}
#if defined(OS_ANDROID) || defined(OS_IOS) || defined(OS_LINUX) || \
- defined(OS_WASM)
+ defined(OS_WASM) || defined(OS_NETBSD)
context_->mutable_converter()->set_use_cascading_window(false);
-#else // OS_LINUX || OS_ANDROID || OS_WASM
+#else // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
if (config.has_use_cascading_window()) {
context_->mutable_converter()->set_use_cascading_window(
config.use_cascading_window());
}
-#endif // OS_ANDROID || OS_IOS || OS_LINUX || OS_WASM
+#endif // OS_ANDROID || OS_IOS || OS_LINUX || OS_WASM || OS_NETBSD
}
bool Session::IMEOn(commands::Command *command) {

View File

@ -0,0 +1,71 @@
$NetBSD: patch-session_session__test.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* NetBSD support
--- session/session_test.cc.orig 2021-02-15 03:48:53.000000000 +0000
+++ session/session_test.cc
@@ -1974,11 +1974,11 @@ TEST_F(SessionTest, UpdatePreferences) {
const size_t cascading_cand_size =
command.output().candidates().candidate_size();
-#if defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM
+#if defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM || defined(OS_NETBSD)
EXPECT_EQ(no_cascading_cand_size, cascading_cand_size);
-#else // defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM
+#else // defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM || defined(OS_NETBSD)
EXPECT_GT(no_cascading_cand_size, cascading_cand_size);
-#endif // defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM
+#endif // defined(OS_LINUX) || defined(OS_ANDROID) || OS_WASM || defined(OS_NETBSD)
command.Clear();
session->ConvertCancel(&command);
@@ -2149,7 +2149,7 @@ TEST_F(SessionTest, OutputAllCandidateWo
EXPECT_EQ(0, output.all_candidate_words().focused_index());
EXPECT_EQ(commands::CONVERSION, output.all_candidate_words().category());
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
// Cascading window is not supported on Linux, so the size of
// candidate words is different from other platform.
// TODO(komatsu): Modify the client for Linux to explicitly change
@@ -2159,13 +2159,13 @@ TEST_F(SessionTest, OutputAllCandidateWo
// "" (t13n), "" (t13n), "" (t13n),
// "アイウエオ" (t13n) ]
EXPECT_EQ(9, output.all_candidate_words().candidates_size());
-#else // OS_LINUX || OS_ANDROID || OS_WASM
+#else // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
// [ "あいうえお", "アイウエオ", "アイウエオ" (t13n), "あいうえお" (t13n),
// "aiueo" (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
// "" (t13n), "" (t13n), "" (t13n),
// "アイウエオ" (t13n) ]
EXPECT_EQ(11, output.all_candidate_words().candidates_size());
-#endif // OS_LINUX || OS_ANDROID || OS_WASM
+#endif // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
}
command.Clear();
@@ -2177,7 +2177,7 @@ TEST_F(SessionTest, OutputAllCandidateWo
EXPECT_EQ(1, output.all_candidate_words().focused_index());
EXPECT_EQ(commands::CONVERSION, output.all_candidate_words().category());
-#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM)
+#if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_WASM) || defined(OS_NETBSD)
// Cascading window is not supported on Linux, so the size of
// candidate words is different from other platform.
// TODO(komatsu): Modify the client for Linux to explicitly change
@@ -2187,13 +2187,13 @@ TEST_F(SessionTest, OutputAllCandidateWo
// "" (t13n), "" (t13n), "" (t13n),
// "アイウエオ" (t13n) ]
EXPECT_EQ(9, output.all_candidate_words().candidates_size());
-#else // OS_LINUX || OS_ANDROID || OS_WASM
+#else // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
// [ "あいうえお", "アイウエオ",
// "aiueo" (t13n), "AIUEO" (t13n), "Aieuo" (t13n),
// "" (t13n), "" (t13n), "" (t13n),
// "アイウエオ" (t13n) ]
EXPECT_EQ(11, output.all_candidate_words().candidates_size());
-#endif // OS_LINUX || OS_ANDROID || OS_WASM
+#endif // OS_LINUX || OS_ANDROID || OS_WASM || OS_NETBSD
}
}

View File

@ -0,0 +1,15 @@
$NetBSD: patch-third__party_abseil-cpp_absl_base_config.h,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* Support NetBSD.
--- third_party/abseil-cpp/absl/base/config.h.orig 2021-02-15 05:04:34.000000000 +0000
+++ third_party/abseil-cpp/absl/base/config.h
@@ -364,7 +364,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMES
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \
defined(__wasm__) || defined(__Fuchsia__) || defined(__sun) || \
- defined(__ASYLO__)
+ defined(__ASYLO__) || defined(__NetBSD__)
#define ABSL_HAVE_MMAP 1
#endif

View File

@ -0,0 +1,15 @@
$NetBSD: patch-third__party_protobuf_post__process__dist.sh,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* appease pkglint
--- third_party/protobuf/post_process_dist.sh.orig 2017-11-02 13:35:43.000000000 +0000
+++ third_party/protobuf/post_process_dist.sh
@@ -15,7 +15,7 @@
# non-testdata .txt files are converted to Windows-style line endings.
# 5) Cleans up after itself.
-if [ "$1" == "" ]; then
+if [ "$1" = "" ]; then
echo "USAGE: $0 DISTFILE" >&2
exit 1
fi

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
$NetBSD: patch-unix_ibus_ibus.gyp,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* use ${PREFIX} paths
--- unix/ibus/ibus.gyp.orig 2017-11-02 13:32:47.000000000 +0000
+++ unix/ibus/ibus.gyp
@@ -31,8 +31,8 @@
'variables': {
'relative_dir': 'unix/ibus',
'gen_out_dir': '<(SHARED_INTERMEDIATE_DIR)/<(relative_dir)',
- 'ibus_mozc_icon_path%': '/usr/share/ibus-mozc/product_icon.png',
- 'ibus_mozc_path%': '/usr/lib/ibus-mozc/ibus-engine-mozc',
+ 'ibus_mozc_icon_path%': '@PREFIX@/share/ibus-mozc/product_icon.png',
+ 'ibus_mozc_path%': '@PREFIX@/libexec/ibus-engine-mozc',
# enable_x11_selection_monitor represents if ibus_mozc uses X11 selection
# monitor or not.
'enable_x11_selection_monitor%': 1,

View File

@ -0,0 +1,15 @@
$NetBSD: patch-unix_ibus_path__util.cc,v 1.1 2024/02/10 01:20:47 ryoon Exp $
* use ${PREFIX} path
--- unix/ibus/path_util.cc.orig 2017-11-02 13:32:47.000000000 +0000
+++ unix/ibus/path_util.cc
@@ -30,7 +30,7 @@
#include "unix/ibus/path_util.h"
namespace {
-const char kInstalledDirectory[] = "/usr/share/ibus-mozc";
+const char kInstalledDirectory[] = "@PREFIX@/share/ibus-mozc";
}
namespace mozc {