From 3b7ac867fe894005bf4ac46341d1dc7114ddf630 Mon Sep 17 00:00:00 2001
From: Nobuhiro Iwamatsu <iwamatsu@debian.org>
Date: Sat, 9 Oct 2010 08:15:18 +0900
Subject: [PATCH] Add support kfreebsd
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
---
base/const.h | 2 +-
base/cpu_stats.cc | 6 +-
base/flags.h | 2 +-
base/iconv.cc | 4 ++
base/logging.cc | 2 +-
base/mutex.cc | 3 +-
base/mutex.h | 6 ++-
base/password_manager.cc | 2 +-
base/process.cc | 8 ++--
base/run_level.cc | 2 +-
base/stats_config_util.cc | 2 +-
base/stats_config_util_test.cc | 2 +-
base/stopwatch.cc | 6 +-
base/util.cc | 19 +++++----
build_mozc.py | 64 ++++++++++++++++++++++++++++++--
build_tools/mozc_version.py | 11 +++++
client/session.cc | 2 +-
dictionary/dictionary_preloader.cc | 4 +-
gui/base/locale_util.cc | 2 +-
gui/config_dialog/config_dialog.cc | 8 ++--
gui/config_dialog/keybinding_editor.cc | 2 +-
gui/config_dialog/keymap_editor.cc | 4 +-
gui/dictionary_tool/dictionary_tool.cc | 2 +-
gui/qt_common.gypi | 2 +-
gui/qt_libraries.gypi | 2 +-
gui/qt_moc.gypi | 2 +-
gui/qt_rcc.gypi | 2 +-
gui/qt_target_default.gypi | 2 +-
gui/qt_uic.gypi | 2 +-
gyp/common.gypi | 51 ++++++++++++++++++++++++-
ipc/ipc_path_manager.cc | 6 +-
ipc/unix_ipc.cc | 12 +++--
protobuf/genproto.gypi | 2 +-
protobuf/protobuf.gyp | 4 +-
session/session_converter.cc | 2 +-
testing/testing.gyp | 2 +-
36 files changed, 190 insertions(+), 66 deletions(-)
diff --git a/base/const.h b/base/const.h
index a018527..c8b8946 100755
--- a/base/const.h
+++ b/base/const.h
@@ -109,7 +109,7 @@ const char kEventPathPrefix[] = "GoogleJapaneseInput.event.";
#else
const char kEventPathPrefix[] = "Mozc.event.";
#endif // GOOGLE_JAPANESE_INPUT_BUILD
-#else // OS_LINUX
+#else // OS_LINUX || OS_GNU_KFREEBSD || OS_FREEBSD
const char kMozcServerName[] = "mozc_server";
const char kEventPathPrefix[] = "mozc.event.";
const char kMozcTool[] = "mozc_tool";
diff --git a/base/cpu_stats.cc b/base/cpu_stats.cc
index 7279ff6..3b785ca 100755
--- a/base/cpu_stats.cc
+++ b/base/cpu_stats.cc
@@ -122,7 +122,7 @@ float CPUStats::GetSystemCPULoad() {
#endif // OS_MACOSX
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// NOT IMPLEMENTED
// TODO(taku): implement Linux version
// can take the info from /proc/stats
@@ -177,7 +177,7 @@ float CPUStats::GetCurrentProcessCPULoad() {
TimeValueTToInt64(task_times_info.system_time);
#endif // OS_MACOSX
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// not implemented
const uint64 total_times = 0;
const uint64 cpu_times = 0;
@@ -209,7 +209,7 @@ size_t CPUStats::GetNumberOfProcessors() const {
return static_cast<size_t>(basic_info.avail_cpus);
#endif // OS_MACOSX
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// Not implemented
return 1;
#endif // OS_LINUX
diff --git a/base/flags.h b/base/flags.h
index 2767113..81567c4 100755
--- a/base/flags.h
+++ b/base/flags.h
@@ -76,7 +76,7 @@ namespace {
// so that CrashReportHandler() is resovled in link time
inline void InstallBreakpad() {
#ifdef GOOGLE_JAPANESE_INPUT_BUILD
-#ifndef OS_LINUX
+#if !defined(OS_LINUX) && !defined(OS_GNU_KFREEBSD) && !defined(OS_FREEBSD)
if (StatsConfigUtil::IsEnabled()) {
CrashReportHandler::Initialize(false);
}
diff --git a/base/iconv.cc b/base/iconv.cc
index e61031a..3ebd0eb 100755
--- a/base/iconv.cc
+++ b/base/iconv.cc
@@ -52,7 +52,11 @@ void IconvHelper(iconv_t ic, const string &input, string *output) {
size_t olen_org = olen;
iconv(ic, 0, &ilen, 0, &olen); // reset iconv state
while (ilen != 0) {
+#ifdef OS_FREEBSD
+ if (iconv(ic, (const char **)(&ibuf), &ilen, &obuf, &olen)
+#else
if (iconv(ic, reinterpret_cast<char **>(&ibuf), &ilen, &obuf, &olen)
+#endif
== static_cast<size_t>(-1)) {
return;
}
diff --git a/base/logging.cc b/base/logging.cc
index 3ba399b..cdba4a2 100755
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -212,7 +212,7 @@ string Logging::GetLogMessageHeader() {
char buf[512];
snprintf(buf, sizeof(buf),
"%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d %u "
-#ifndef OS_LINUX // = OS_WINDOWS or OS_MACOSX
+#if !defined(OS_LINUX) && !defined(OS_GNU_KFREEBSD) && !defined(OS_FREEBSD) // = OS_WINDOWS or OS_MACOSX
"%u",
#else
"%lu",
diff --git a/base/mutex.cc b/base/mutex.cc
index 36f4dc3..79ed9b3 100755
--- a/base/mutex.cc
+++ b/base/mutex.cc
@@ -44,7 +44,8 @@ namespace mozc {
// Wrapper for Windows InterlockedCompareExchange
namespace {
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
+// TODO(taku):
// Linux doesn't provide InterlockedCompareExchange-like function.
inline int InterlockedCompareExchange(volatile int *target,
int new_value,
diff --git a/base/mutex.h b/base/mutex.h
index 6d2d1e4..0f19a80 100755
--- a/base/mutex.h
+++ b/base/mutex.h
@@ -86,10 +86,14 @@ class Mutex {
#define PTHREAD_MUTEX_RECURSIVE_VALUE PTHREAD_MUTEX_RECURSIVE
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
#define PTHREAD_MUTEX_RECURSIVE_VALUE PTHREAD_MUTEX_RECURSIVE_NP
#endif
+#ifdef OS_FREEBSD
+#define PTHREAD_MUTEX_RECURSIVE_VALUE PTHREAD_MUTEX_RECURSIVE
+#endif
+
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_VALUE);
diff --git a/base/password_manager.cc b/base/password_manager.cc
index ce4cbdb..93f4490 100755
--- a/base/password_manager.cc
+++ b/base/password_manager.cc
@@ -358,7 +358,7 @@ class MacPasswordManager : public PasswordManagerInterface {
// 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
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
typedef PlainPasswordManager DefaultPasswordManager;
#endif
diff --git a/base/process.cc b/base/process.cc
index 445fa30..f1bf767 100755
--- a/base/process.cc
+++ b/base/process.cc
@@ -52,7 +52,7 @@
#include "base/mac_process.h"
#endif // OS_MACOSX
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
#include <fcntl.h>
#include <signal.h>
#include <spawn.h> // for posix_spawn().
@@ -194,7 +194,7 @@ bool Process::OpenBrowser(const string &url) {
return ShellExecuteInSystemDir(L"open", wurl.c_str(), NULL, SW_SHOW);
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
static const char kBrowserCommand[] = "/usr/bin/xdg-open";
// xdg-open which uses kfmclient or gnome-open internally works both on KDE
// and GNOME environments.
@@ -278,7 +278,7 @@ bool Process::SpawnProcess(const string &path,
}
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// Do not call posix_spawn() for obviously bad path.
if (!S_ISREG(statbuf.st_mode)) {
LOG(ERROR) << "Not a regular file: " << path;
@@ -574,7 +574,7 @@ bool Process::LaunchErrorMessageDialog(const string &error_type) {
}
#endif // OS_WINDOWS
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
const char kMozcTool[] = "mozc_tool";
const string arg = "--mode=error_message_dialog --error_type=" + error_type;
size_t pid = 0;
diff --git a/base/run_level.cc b/base/run_level.cc
index 87b0f0a..1578ad8 100755
--- a/base/run_level.cc
+++ b/base/run_level.cc
@@ -38,7 +38,7 @@
#include <windows.h>
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
#include <unistd.h>
#include <sys/types.h>
#endif
diff --git a/base/stats_config_util.cc b/base/stats_config_util.cc
index d6a15ab..3588905 100755
--- a/base/stats_config_util.cc
+++ b/base/stats_config_util.cc
@@ -336,7 +336,7 @@ bool MacStatsConfigUtilImpl::SetEnabled(bool val) {
}
#endif // MACOSX
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
class LinuxStatsConfigUtilImpl : public StatsConfigUtilInterface {
// TODO(toshiyuki): implement this
public:
diff --git a/base/stats_config_util_test.cc b/base/stats_config_util_test.cc
index 3052d86..fab4aa2 100755
--- a/base/stats_config_util_test.cc
+++ b/base/stats_config_util_test.cc
@@ -840,7 +840,7 @@ TEST_F(StatsConfigUtilTestWin,
} // namespace mozc
#endif // OS_WINDOWS
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
TEST(StatsConfigUtilTestLinux, DefaultValueTest) {
EXPECT_FALSE(mozc::StatsConfigUtil::IsEnabled());
}
diff --git a/base/stopwatch.cc b/base/stopwatch.cc
index 5224b36..1b512d9 100755
--- a/base/stopwatch.cc
+++ b/base/stopwatch.cc
@@ -39,7 +39,7 @@
#include <unistd.h>
#endif // OS_MACOSX
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
#include <sys/time.h>
#endif // OS_LINUX
@@ -65,7 +65,7 @@ int64 Stopwatch::GetFrequency() {
return static_cast<int64>(1.0e9 * timebase_info.denom / timebase_info.numer);
#endif // OS_MACOSX
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
return 1000000000LL;
#endif // OS_LINUX
}
@@ -83,7 +83,7 @@ int64 Stopwatch::GetTimestamp() {
return static_cast<int64>(mach_absolute_time());
#endif // OS_MACOSX
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
struct timespec timestamp;
if (-1 == clock_gettime(CLOCK_REALTIME, ×tamp)) {
return 0;
diff --git a/base/util.cc b/base/util.cc
index 8dc2f89..fddcfb0 100755
--- a/base/util.cc
+++ b/base/util.cc
@@ -1629,7 +1629,7 @@ string Util::GetServerDirectory() {
return MacUtil::GetServerDirectory();
#endif // OS_MACOSX
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
return "/usr/lib/mozc";
#endif // OS_LINUX
}
@@ -1705,7 +1705,7 @@ string GetObjectNameAsString(HANDLE handle) {
#endif
string Util::GetDesktopNameAsString() {
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
const char *display = getenv("DISPLAY");
if (display == NULL) {
return "";
@@ -2152,7 +2152,7 @@ bool Util::IsPlatformSupported() {
#if defined(OS_MACOSX)
// TODO(yukawa): support Mac.
return true;
-#elif defined(OS_LINUX)
+#elif defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// TODO(yukawa): support Linux.
return true;
#elif defined(OS_WINDOWS)
@@ -2468,18 +2468,19 @@ string Util::GetOSVersionString() {
} else {
LOG(WARNING) << "GetVersionEx failed";
}
- return ret;
#elif defined(OS_MACOSX)
const string ret = "MacOSX " + MacUtil::GetOSVersionString();
// TODO(toshiyuki): get more specific info
- return ret;
#elif defined(OS_LINUX)
const string ret = "Linux";
- return ret;
+#elif defined(OS_GNU_KFREEBSD)
+ const string ret = "GNU/kFreeBSD";
+#elif defined(OS_FREEBSD)
+ const string ret = "FreeBSD";
#else
const string ret = "Unknown";
- return ret;
#endif
+ return ret;
}
void Util::DisableIME() {
@@ -2513,7 +2514,7 @@ uint64 Util::GetTotalPhysicalMemory() {
return 0;
}
return total_memory;
-#elif defined(OS_LINUX)
+#elif defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
#if defined(_SC_PAGESIZE) && defined(_SC_PHYS_PAGES)
const long page_size = sysconf(_SC_PAGESIZE);
const long number_of_phyisical_pages = sysconf(_SC_PHYS_PAGES);
@@ -2539,7 +2540,7 @@ void Util::PreloadMappedRegion(const void *begin,
::ZeroMemory(&system_info, sizeof(system_info));
::GetSystemInfo(&system_info);
const size_t page_size = system_info.dwPageSize;
-#elif defined(OS_MACOSX) || defined(OS_LINUX)
+#elif defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
#if defined(_SC_PAGESIZE)
const size_t page_size = sysconf(_SC_PAGESIZE);
#else
diff --git a/build_mozc.py b/build_mozc.py
index 0c2991d..786b09d 100755
--- a/build_mozc.py
+++ b/build_mozc.py
@@ -71,6 +71,14 @@ def IsLinux():
"""Returns true if the platform is Linux."""
return os.name == 'posix' and os.uname()[0] == 'Linux'
+def IsFreeBSD():
+ """Returns true if the platform is FreeBSD."""
+ return os.name == 'posix' and os.uname()[0] == 'FreeBSD'
+
+def IsGNUkFreeBSD():
+ """Returns true if the platform is GNU/kFreeBSD."""
+ os.environ['GYP_DEFINES'] = 'OS=="GNU/kFreeBSD"'
+ return os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD'
# TODO(yukawa): Move this function to util.py (b/2715400)
def GetNumberOfProcessors():
@@ -86,7 +94,7 @@ def GetNumberOfProcessors():
commands = ['sysctl', '-n', 'hw.ncpu']
process = subprocess.Popen(commands, stdout=subprocess.PIPE)
return int(process.communicate()[0])
- elif IsLinux():
+ elif IsLinux() or IsFreeBSD() or IsGNUkFreeBSD():
# Count the number of 'vendor_id' in /proc/cpuinfo, assuming that
# each line corresponds to one logical CPU.
cpuinfo = open('/proc/cpuinfo', 'r')
@@ -183,7 +191,7 @@ def GetGypFileNames():
gyp_file_names.extend(glob.glob('%s/win32/*/*.gyp' % SRC_DIR))
gyp_file_names.extend(glob.glob('third_party/breakpad/*.gyp'))
gyp_file_names.append('third_party/mozc/sandbox/sandbox.gyp')
- elif IsLinux():
+ elif IsLinux() or IsFreeBSD() or IsGNUkFreeBSD():
gyp_file_names.extend(glob.glob('%s/unix/*/*.gyp' % SRC_DIR))
# Add ibus.gyp if ibus is installed.
# Ubuntu 8.04 (Hardy) does not contain ibus package.
@@ -256,7 +264,7 @@ def CleanBuildFilesAndDirectories():
elif IsMac():
directory_names.extend(glob.glob(os.path.join(gyp_directory_name,
'*.xcodeproj')))
- elif IsLinux():
+ elif IsLinux() or IsFreeBSD() or IsGNUkFreeBSD():
file_names.extend(glob.glob(os.path.join(gyp_directory_name,
'*.target.mk')))
file_names.append('%s/mozc_version.txt' % SRC_DIR)
@@ -270,6 +278,10 @@ def CleanBuildFilesAndDirectories():
file_names.append('Makefile')
elif IsWindows():
file_names.append('third_party/breakpad/breakpad.gyp')
+ directory_names.append('out_win')
+ elif IsFreeBSD() or IsGNUkFreeBSD():
+ file_names.append('Makefile')
+ directory_names.append('out_bsd')
# Remove files.
for file_name in file_names:
RemoveFile(file_name)
@@ -351,6 +363,8 @@ def GypMain(deps_file_name):
command_line.extend(['-D', 'use_qt=NO'])
if options.coverage:
command_line.extend(['-D', 'coverage=1'])
+ if options.os:
+ command_line.extend(['-D', 'OS=%s' % options.os])
command_line.extend(['-D', 'build_base=%s' % GetBuildBaseName(options)])
@@ -386,6 +400,8 @@ def RunTests(configuration, calculate_coverage):
base_path = os.path.join('out_linux', configuration)
elif IsWindows():
base_path = os.path.join('out_win', configuration)
+ elif IsFreeBSD() or IsGNUkFreeBSD():
+ base_path = os.path.join('out_bsd', configuration)
else:
logging.error('Unsupported platform: %s', os.name)
return
@@ -527,6 +543,7 @@ def ParseGypOptions():
parser.add_option('--build_base', dest='build_base',
help='specify the base directory of the built binaries.')
+ parser.add_option('--os', dest='os', default='linux')
(options, unused_args) = parser.parse_args()
return options
@@ -639,6 +656,7 @@ def BuildOnLinux(options, targets):
target_names.append(target_name)
make_command = os.getenv('BUILD_COMMAND', 'make')
+
# flags for building in Chrome OS chroot environment
envvars = [
'CFLAGS',
@@ -653,7 +671,7 @@ def BuildOnLinux(options, targets):
for envvar in envvars:
if envvar in os.environ:
os.environ[envvar] = os.getenv(envvar)
-
+
# set output directory
os.environ['builddir_name'] = 'out_linux'
@@ -663,6 +681,42 @@ def BuildOnLinux(options, targets):
RunOrDie([make_command] + build_args + target_names)
+def BuildOnBSD(options, targets):
+ """Build the targets on *BSD."""
+ target_names = []
+ for target in targets:
+ (unused_gyp_file_name, target_name) = ParseTarget(target)
+ target_names.append(target_name)
+
+ if os.uname()[0] == 'FreeBSD' :
+ make_command = os.getenv('BUILD_COMMAND', 'gmake')
+ else:
+ make_command = os.getenv('BUILD_COMMAND', 'make')
+
+ # flags for building in Chrome OS chroot environment
+ envvars = [
+ 'CFLAGS',
+ 'CXXFLAGS',
+ 'CXX',
+ 'CC',
+ 'AR',
+ 'AS',
+ 'RANLIB',
+ 'LD',
+ ]
+ for envvar in envvars:
+ if envvar in os.environ:
+ os.environ[envvar] = os.getenv(envvar)
+
+ # set output directory
+ os.environ['builddir_name'] = 'out_bsd'
+
+ build_args = ['-j%s' % options.jobs, 'BUILDTYPE=%s' % options.configuration]
+ if options.build_base:
+ build_args.append('builddir_name=%s' % options.build_base)
+
+ RunOrDie([make_command] + build_args + target_names)
+
def CheckFileOrDie(file_name):
"""Check the file exists or dies if not."""
@@ -756,6 +810,8 @@ def BuildMain(original_directory_name):
BuildOnMac(options, targets, original_directory_name)
elif IsLinux():
BuildOnLinux(options, targets)
+ elif IsFreeBSD() or IsGNUkFreeBSD():
+ BuildOnBSD(options, targets)
elif IsWindows():
BuildOnWindows(options, targets, original_directory_name)
else:
diff --git a/build_tools/mozc_version.py b/build_tools/mozc_version.py
index 42af980..700cf53 100755
--- a/build_tools/mozc_version.py
+++ b/build_tools/mozc_version.py
@@ -57,6 +57,13 @@ def IsLinux():
"""Returns true if the platform is Linux."""
return os.name == 'posix' and os.uname()[0] == 'Linux'
+def IsFreeBSD():
+ """Returns true if the platform is FreeBSD."""
+ return os.name == 'posix' and os.uname()[0] == 'FreeBSD'
+
+def IsGNUkFreeBSD():
+ """Returns true if the platform is GNU/kFreeBSD."""
+ return os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD'
def CalculateRevisionForPlatform(revision):
"""Returns the revision for the current platform."""
@@ -68,6 +75,10 @@ def CalculateRevisionForPlatform(revision):
last_digit = '1'
elif IsLinux():
last_digit = '2'
+ elif IsFreeBSD():
+ last_digit = '3'
+ elif IsGNUkFreeBSD():
+ last_digit = '4'
if last_digit:
return revision[0:-1] + last_digit
diff --git a/client/session.cc b/client/session.cc
index 4557a0a..72c10f6 100755
--- a/client/session.cc
+++ b/client/session.cc
@@ -847,7 +847,7 @@ bool Session::LaunchTool(const string &mode, const string &extra_arg) {
return false;
}
-#if defined(OS_WINDOWS) || defined(OS_LINUX)
+#if defined(OS_WINDOWS) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
string arg = "--mode=" + mode;
if (!extra_arg.empty()) {
arg += " ";
diff --git a/dictionary/dictionary_preloader.cc b/dictionary/dictionary_preloader.cc
index c9a7044..b023ffc 100755
--- a/dictionary/dictionary_preloader.cc
+++ b/dictionary/dictionary_preloader.cc
@@ -89,7 +89,7 @@ bool IsPreloadable(const char *image, size_t size) {
return available_memory > preload_size * FLAGS_preload_memory_factor;
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// TOOD(taku): implement Linux version.
// Since Linux is installed into heterogeneous environment,
// we have to check the amount of available memory.
@@ -161,7 +161,7 @@ void DictionaryPreloader::PreloadIfApplicable(const char *image, size_t size) {
// GoogleIMEJaCacheService.exe is responsible for keeping the dictionary
// on-page (or freeing the memory in low-memory condition).
// See http://b/2354549 for details.
-#if defined(OS_MACOSX) || defined(OS_LINUX)
+#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
if (!IsPreloadable(image, size)) {
return;
}
diff --git a/gui/base/locale_util.cc b/gui/base/locale_util.cc
index 2e32f21..a825086 100755
--- a/gui/base/locale_util.cc
+++ b/gui/base/locale_util.cc
@@ -198,7 +198,7 @@ TranslationDataImpl::TranslationDataImpl()
qApp->installEventFilter(&window_title_modifier_);
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// Use system default messages.
// Even if the locale is not English nor Japanese, load translation
// file to translate common messages like "OK" and "Cancel".
diff --git a/gui/config_dialog/config_dialog.cc b/gui/config_dialog/config_dialog.cc
index e748393..04e91ae 100755
--- a/gui/config_dialog/config_dialog.cc
+++ b/gui/config_dialog/config_dialog.cc
@@ -73,11 +73,11 @@ ConfigDialog::ConfigDialog()
verboseLevelLabel->setVisible(false);
verboseLevelComboBox->setVisible(false);
-#if defined(OS_MACOSX) || defined(OS_LINUX)
+#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// The last "misc" tab has no valid configs on Mac and Linux
const int kMiscTabIndex = 5;
configDialogTabWidget->removeTab(kMiscTabIndex);
-#endif // OS_MACOSX || OS_LINUX
+#endif // OS_MACOSX || OS_LINUX || OS_GNU_KFREEBSD || OS_FREEBSD)
#endif // NO_LOGGING
client_->set_restricted(true); // start with restricted mode
@@ -258,7 +258,7 @@ ConfigDialog::ConfigDialog()
dictionaryPreloadingAndUACLabel->setVisible(false);
#endif // OS_WINDOWS
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// On Linux, disable all fields for UsageStats
usageStatsLabel->setEnabled(false);
usageStatsLabel->setVisible(false);
@@ -343,7 +343,7 @@ bool ConfigDialog::Update() {
}
-#if defined(OS_WINDOWS) || defined(OS_LINUX)
+#if defined(OS_WINDOWS) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
if (initial_preedit_method_ !=
static_cast<int>(config.preedit_method()) ||
initial_use_keyboard_to_change_preedit_method_ !=
diff --git a/gui/config_dialog/keybinding_editor.cc b/gui/config_dialog/keybinding_editor.cc
index 6749dcb..17d90da 100755
--- a/gui/config_dialog/keybinding_editor.cc
+++ b/gui/config_dialog/keybinding_editor.cc
@@ -443,7 +443,7 @@ bool KeyBindingFilter::eventFilter(QObject *obj, QEvent *event) {
KeyBindingEditor::KeyBindingEditor(QWidget *parent, QWidget *trigger_parent)
: QDialog(parent), trigger_parent_(trigger_parent) {
setupUi(this);
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// Workaround for the issue http://code.google.com/p/mozc/issues/detail?id=9
// Seems that even after clicking the button for the keybinding dialog,
// the edit is not raised. This might be a bug of setFocusProxy.
diff --git a/gui/config_dialog/keymap_editor.cc b/gui/config_dialog/keymap_editor.cc
index adfe645..ebbe3f2 100755
--- a/gui/config_dialog/keymap_editor.cc
+++ b/gui/config_dialog/keymap_editor.cc
@@ -93,7 +93,7 @@ class KeyMapValidator {
invisible_commands_.insert(kReportBugCommand);
// Old command name.
invisible_commands_.insert(kEditInsertCommand);
-#if defined(OS_MACOSX) || defined(OS_LINUX)
+#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// On Mac/Linux, we cannot customize keybindings for IME ON/OFF
// So we do not show them.
// TODO(toshiyuki): remove them after implimenting IME ON/OFF for Mac
@@ -446,7 +446,7 @@ bool KeyMapEditorDialog::Update() {
*keymap_table += invisible_keymap_table_;
if (new_ime_switch_keymap != ime_switch_keymap_) {
-#if defined(OS_WINDOWS) || defined(OS_LINUX)
+#if defined(OS_WINDOWS) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
QMessageBox::information(
this,
tr("Mozc settings"),
diff --git a/gui/dictionary_tool/dictionary_tool.cc b/gui/dictionary_tool/dictionary_tool.cc
index 44fe65c..14edad4 100755
--- a/gui/dictionary_tool/dictionary_tool.cc
+++ b/gui/dictionary_tool/dictionary_tool.cc
@@ -303,7 +303,7 @@ DictionaryTool::DictionaryTool(QWidget *parent)
}
// main window
-#ifndef OS_LINUX
+#if !defined(OS_LINUX) && !defined(OS_GNU_KFREEBSD) && !defined(OS_FREEBSD)
// For some reason setCentralWidget crashes the dictionary_tool on Linux
// TODO(taku): investigate the cause of the crashes
setCentralWidget(splitter_);
diff --git a/gui/qt_common.gypi b/gui/qt_common.gypi
index 66112ed..6d82f54 100755
--- a/gui/qt_common.gypi
+++ b/gui/qt_common.gypi
@@ -33,7 +33,7 @@
'variables': {
'qt_basepath': '$(QTDIR)',
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'qt_cflags': ' <!@(pkg-config --cflags QtCore QtGui)',
},{ # OS!="linux"
'qt_cflags': '<(qt_basepath)/include',
diff --git a/gui/qt_libraries.gypi b/gui/qt_libraries.gypi
index c1b905a..597daa1 100755
--- a/gui/qt_libraries.gypi
+++ b/gui/qt_libraries.gypi
@@ -44,7 +44,7 @@
],
},
}],
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'link_settings': {
'libraries': [
' <!@(pkg-config --libs QtCore QtGui)',
diff --git a/gui/qt_moc.gypi b/gui/qt_moc.gypi
index f0992a2..bef23fe 100755
--- a/gui/qt_moc.gypi
+++ b/gui/qt_moc.gypi
@@ -31,7 +31,7 @@
{
'variables': {
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'moc_path': '<!(pkg-config --variable=moc_location QtGui)',
},{ # OS!="linux"
'moc_path': '<(qt_basepath)/bin/moc<(EXECUTABLE_SUFFIX)',
diff --git a/gui/qt_rcc.gypi b/gui/qt_rcc.gypi
index 2dd06c6..d163695 100755
--- a/gui/qt_rcc.gypi
+++ b/gui/qt_rcc.gypi
@@ -31,7 +31,7 @@
{
'variables': {
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
# seems that --variable=rcc_location is not supported
'rcc_path': '<!(pkg-config --variable=exec_prefix QtGui)/bin/rcc',
},{ # OS!="linux"
diff --git a/gui/qt_target_default.gypi b/gui/qt_target_default.gypi
index c168f75..b1aa629 100755
--- a/gui/qt_target_default.gypi
+++ b/gui/qt_target_default.gypi
@@ -91,7 +91,7 @@
},
},
}],
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'target_defaults': {
'configurations': {
'Common_Base': {
diff --git a/gui/qt_uic.gypi b/gui/qt_uic.gypi
index cfaa397..1157c0e 100755
--- a/gui/qt_uic.gypi
+++ b/gui/qt_uic.gypi
@@ -31,7 +31,7 @@
{
'variables': {
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'uic_path': '<!(pkg-config --variable=uic_location QtGui)',
},{ # OS!="linux"
'uic_path': '<(qt_basepath)/bin/uic<(EXECUTABLE_SUFFIX)',
diff --git a/gyp/common.gypi b/gyp/common.gypi
index 051284e..8b305ed 100755
--- a/gyp/common.gypi
+++ b/gyp/common.gypi
@@ -203,7 +203,7 @@
},
},
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'cflags': [
'<@(debug_extra_cflags)',
],
@@ -242,7 +242,7 @@
},
},
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'cflags': [
'<@(release_extra_cflags)',
],
@@ -455,6 +455,51 @@
}],
],
}],
+ ['OS=="freebsd"', {
+ 'defines': [
+ 'OS_FREEBSD',
+ ],
+ 'cflags': [
+ '<@(gcc_cflags)',
+ '-fPIC',
+ '-fno-exceptions',
+ ],
+ 'libraries': [
+ '-lcurl',
+ '-lcrypto',
+ '-lpthread',
+ '-lrt',
+ '-lssl',
+ '-lz',
+ '<@(extra_linux_libs)',
+ ],
+ 'conditions': [
+ ['chromeos==1', {
+ 'defines': [
+ 'OS_CHROMEOS',
+ ],
+ }],
+ ],
+ }],
+ ['OS=="gnu-kfreebsd"', {
+ 'defines': [
+ 'OS_GNU_KFREEBSD',
+ ],
+ 'cflags': [
+ '<@(gcc_cflags)',
+ '-fPIC',
+ '-fno-exceptions',
+ ],
+ 'libraries': [
+ '-lcurl',
+ '-lcrypto',
+ '-lpthread',
+ '-lrt',
+ '-lssl',
+ '-lz',
+ '<@(extra_linux_libs)',
+ ],
+ }],
['OS=="mac"', {
'defines': [
'OS_MACOSX',
@@ -509,7 +554,7 @@
# Linux gyp (into scons) doesn't like target_conditions?
# TODO(team): track down why 'target_conditions' doesn't work
# on Linux gyp into scons like it does on Mac gyp into xcodeproj.
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'cflags': [ '-ftest-coverage',
'-fprofile-arcs' ],
'link_settings': { 'libraries': [ '-lgcov' ] },
diff --git a/ipc/ipc_path_manager.cc b/ipc/ipc_path_manager.cc
index 392ee0d..60924cb 100755
--- a/ipc/ipc_path_manager.cc
+++ b/ipc/ipc_path_manager.cc
@@ -265,7 +265,7 @@ bool IPCPathManager::GetPathName(string *ipc_name) {
*ipc_name = kIPCPrefix;
#endif // OS_WINDOWS
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// On Linux, use abstract namespace which is independent of the file system.
(*ipc_name)[0] = '\0';
#endif
@@ -358,7 +358,7 @@ bool IPCPathManager::IsValidServer(uint32 pid,
}
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// load from /proc/<pid>/exe
char proc[128];
char filename[512];
@@ -378,7 +378,7 @@ bool IPCPathManager::IsValidServer(uint32 pid,
return true;
}
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
if ((server_path + " (deleted)") == server_path_) {
LOG(WARNING) << server_path << " on disk is modified";
// If a user updates the server binary on disk during the server is running,
diff --git a/ipc/unix_ipc.cc b/ipc/unix_ipc.cc
index 66eb90c..69373f1 100755
--- a/ipc/unix_ipc.cc
+++ b/ipc/unix_ipc.cc
@@ -28,7 +28,8 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// skip all if Windows
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_MACOSX) ||\
+ defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD)
#include "ipc/ipc.h"
@@ -41,7 +42,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/un.h>
-#ifdef OS_MACOSX
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
#include <sys/ucred.h>
#endif
#include <sys/wait.h>
@@ -124,7 +125,7 @@ bool IsWriteTimeout(int socket, int timeout) {
bool IsPeerValid(int socket, pid_t *pid) {
*pid = 0;
-#ifdef OS_MACOSX
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
// If the OS is MAC, we should validate the peer by using LOCAL_PEERCRED.
struct xucred peer_cred;
socklen_t peer_cred_len = sizeof(struct xucred);
@@ -179,7 +180,7 @@ bool SendMessage(int socket,
return false;
}
const ssize_t l = ::send(socket, buf, buf_length_left,
-#ifdef OS_MACOSX
+#if defined(OS_MACOSX) || defined(OS_FREEBSD)
SO_NOSIGPIPE
#else
MSG_NOSIGNAL
@@ -518,4 +519,5 @@ void IPCServer::Loop() {
}; // namespace mozc
-#endif // OS_LINUX
+#endif // defined(OS_LINUX) || defined(OS_MACOSX) ||\
+ // defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD)
diff --git a/protobuf/genproto.gypi b/protobuf/genproto.gypi
index b5aba7f..8f209cb 100755
--- a/protobuf/genproto.gypi
+++ b/protobuf/genproto.gypi
@@ -39,7 +39,7 @@
'<(protobuf_dir)/protobuf.gyp:install_protoc',
],
}],
- ['OS!="linux"', {
+ ['OS!="linux" and OS!="gnu-kfreebsd"', {
'variables': {
'protoc_command%': '<(relative_dir)/<(mozc_build_tools_dir)/protoc<(EXECUTABLE_SUFFIX)',
},
diff --git a/protobuf/protobuf.gyp b/protobuf/protobuf.gyp
index 0b8ca63..449167c 100755
--- a/protobuf/protobuf.gyp
+++ b/protobuf/protobuf.gyp
@@ -116,7 +116,7 @@
'target_name': 'protobuf',
'type': 'static_library',
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'conditions': [
['use_libprotobuf==1', {
'link_settings': {
@@ -193,7 +193,7 @@
},
'conditions': [
# use system-installed protoc on Linux
- ['OS!="linux"', {
+ ['OS!="linux" and OS!="gnu-kfreebsd"', {
'includes' : [
'../gyp/install_build_tool.gypi',
],
diff --git a/session/session_converter.cc b/session/session_converter.cc
index a9a0be3..b23a407 100755
--- a/session/session_converter.cc
+++ b/session/session_converter.cc
@@ -90,7 +90,7 @@ void SessionConverter::UpdateConfig(const config::Config &config) {
}
// Cascading Window.
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
// TODO(komatsu): Move this logic to the client code.
operation_preferences_.use_cascading_window = false;
#else
diff --git a/testing/testing.gyp b/testing/testing.gyp
index 22a659c..1dd505c 100755
--- a/testing/testing.gyp
+++ b/testing/testing.gyp
@@ -49,7 +49,7 @@
'base/internal/gtest_main.cc',
],
'conditions': [
- ['OS!="linux"', {
+ ['OS!="linux" and OS!="gnu-kfreebsd"', {
'dependencies': [
'testing',
],
--
1.7.2.3