Description: Support kFreeBSD
Forwarded: None
Author: Nobuhiri Iwamatsu <iwamatsu@debian.org>
Bug-Debian: No
Last-Update: 2012-06-14
From e45c381a2a9a9a727ec4f7a2cea3b1635d951b85 Mon Sep 17 00:00:00 2001
From: Nobuhiro Iwamatsu <iwamatsu@debian.org>
Date: Fri, 15 Jun 2012 12:26:28 +0900
Subject: [PATCH] Fix kfreebsd
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@debian.org>
---
base/base.gyp | 4 +-
base/cpu_stats.cc | 6 +-
base/flags.h | 2 +-
base/iconv.cc | 4 ++
base/logging.cc | 5 --
base/mutex.cc | 3 +-
base/mutex.h | 6 +-
base/password_manager.cc | 2 +-
base/process.cc | 8 +--
base/run_level.cc | 2 +-
base/thread.h | 3 +-
base/util.cc | 17 +++--
base/util_test.cc | 2 +-
build_mozc.py | 83 +++++++++++++++++++---
build_tools/mozc_version.py | 9 +++
chrome/skk/skk.gyp | 2 +-
client/client.cc | 2 +-
config/stats_config_util_test.cc | 2 +-
gui/base/locale_util.cc | 2 +-
gui/config_dialog/config_dialog.cc | 8 +--
gui/config_dialog/keybinding_editor.cc | 8 +--
gui/config_dialog/keymap_editor.cc | 2 +-
gui/dictionary_tool/dictionary_tool.cc | 2 +-
gui/gui.gyp | 2 +-
gui/qt_libraries.gypi | 2 +-
gui/word_register_dialog/word_register_dialog.cc | 2 +-
gui/zinnia.gyp | 2 +-
gyp/common.gypi | 18 +++--
handwriting/handwriting.gyp | 2 +-
ipc/ipc_path_manager.cc | 6 +-
ipc/ipc_path_manager_test.cc | 2 +-
ipc/unix_ipc.cc | 10 +--
languages/chewing/chewing.gyp | 2 +-
languages/hangul/hangul.gyp | 2 +-
net/net.gyp | 2 +-
protobuf/genproto.gypi | 2 +-
protobuf/protobuf.gyp | 6 +-
session/session_converter_interface.h | 2 +-
session/session_test.cc | 4 +-
39 files changed, 170 insertions(+), 80 deletions(-)
diff --git a/base/base.gyp b/base/base.gyp
index eb71957..28a6a3f 100755
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -104,7 +104,7 @@
# shared among *host* binaries and *target* binaries. This means that
# you should implement *host* binaries by using limited libraries
# which are also available on NDK.
- ['OS=="linux" and target_platform!="Android" and '
+ ['OS=="gnu-kfreebsd" or (OS=="linux" and target_platform!="Android") and '
'not (target_platform=="NaCl" and _toolset=="target")', {
'defines': [
'HAVE_LIBRT=1',
@@ -235,7 +235,7 @@
],
}
}],
- ['OS=="linux" and target_platform!="Android"', {
+ ['OS=="gnu-kfreebsd" or (OS=="linux" and target_platform!="Android")', {
'cflags': [
'<!@(<(pkg_config_command) --cflags-only-other openssl)',
],
diff --git a/base/cpu_stats.cc b/base/cpu_stats.cc
index e915b35..a53141d 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)
// 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)
// 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)
// Not implemented
return 1;
#endif // OS_LINUX
diff --git a/base/flags.h b/base/flags.h
index 4b2004f..838f2e5 100755
--- a/base/flags.h
+++ b/base/flags.h
@@ -75,7 +75,7 @@ extern void InitGoogleInternal(const char *arg0,
// 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 84c6380..6785171 100755
--- a/base/iconv.cc
+++ b/base/iconv.cc
@@ -52,7 +52,11 @@ bool 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 false;
}
diff --git a/base/logging.cc b/base/logging.cc
index 10578ef..06d5b15 100755
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -75,12 +75,7 @@ string Logging::GetLogMessageHeader() {
char buf[512];
snprintf(buf, sizeof(buf),
"%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d %u "
-#if !defined(OS_LINUX) || defined(__native_client__)
-// = OS_WINDOWS or OS_MACOSX or __native_client__
- "%u",
-#else
"%lu",
-#endif
1900 + tm_time.tm_year,
1 + tm_time.tm_mon,
tm_time.tm_mday,
diff --git a/base/mutex.cc b/base/mutex.cc
index 930e24d..44d58c0 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)
+// 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 c5df9c8..7cc89b3 100755
--- a/base/mutex.h
+++ b/base/mutex.h
@@ -97,10 +97,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 aa8b6b4..42718af 100755
--- a/base/password_manager.cc
+++ b/base/password_manager.cc
@@ -363,7 +363,7 @@ class DeprecatedMacPasswordManager : 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)
typedef PlainPasswordManager DefaultPasswordManager;
#endif
diff --git a/base/process.cc b/base/process.cc
index 51eae95..7f2d89b 100755
--- a/base/process.cc
+++ b/base/process.cc
@@ -51,7 +51,7 @@
#include "base/mac_process.h"
#endif // OS_MACOSX
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
#include <fcntl.h>
#include <signal.h>
#include <spawn.h> // for posix_spawn().
@@ -120,7 +120,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)
static const char kBrowserCommand[] = "/usr/bin/xdg-open";
// xdg-open which uses kfmclient or gnome-open internally works both on KDE
// and GNOME environments.
@@ -204,7 +204,7 @@ bool Process::SpawnProcess(const string &path,
}
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// Do not call posix_spawn() for obviously bad path.
if (!S_ISREG(statbuf.st_mode)) {
LOG(ERROR) << "Not a regular file: " << path;
@@ -399,7 +399,7 @@ bool Process::LaunchErrorMessageDialog(const string &error_type) {
}
#endif // OS_WINDOWS
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
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 8b1fe47..cc4c58a 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)
#include <unistd.h>
#include <sys/types.h>
#endif
diff --git a/base/thread.h b/base/thread.h
index 0397937..c2488e9 100755
--- a/base/thread.h
+++ b/base/thread.h
@@ -61,7 +61,8 @@
// Andorid NDK and NaCl don't support TLS.
#if defined(OS_LINUX) && !defined(OS_ANDROID) && \
- !defined(__native_client__) && (defined(__GNUC__) || defined(__clang__))
+ !defined(__native_client__) && (defined(__GNUC__) || defined(__clang__)) || \
+ defined(OS_GNU_KFREEBSD)
// GCC and Clang support TLS.
#define TLS_KEYWORD __thread
#define HAVE_TLS 1
diff --git a/base/util.cc b/base/util.cc
index 3b39cb6..846fcfb 100755
--- a/base/util.cc
+++ b/base/util.cc
@@ -1414,7 +1414,7 @@ class ClockImpl : public Util::ClockInterface {
mach_timebase_info(&timebase_info);
return static_cast<uint64>(
1.0e9 * timebase_info.denom / timebase_info.numer);
-#elif defined(OS_LINUX)
+#elif defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
#if defined(HAVE_LIBRT)
return 1000000000uLL;
#else
@@ -1434,7 +1434,7 @@ class ClockImpl : public Util::ClockInterface {
return static_cast<uint64>(timestamp.QuadPart);
#elif defined(OS_MACOSX)
return static_cast<uint64>(mach_absolute_time());
-#elif defined(OS_LINUX)
+#elif defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
#if defined(HAVE_LIBRT)
struct timespec timestamp;
if (-1 == clock_gettime(CLOCK_REALTIME, ×tamp)) {
@@ -2746,7 +2746,7 @@ string Util::GetServerDirectory() {
return MacUtil::GetServerDirectory();
#endif // OS_MACOSX
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
return kMozcServerDirectory;
#endif // OS_LINUX
}
@@ -2847,7 +2847,7 @@ bool GetCurrentSessionId(DWORD *session_id) {
#endif // OS_WINDOWS
string Util::GetDesktopNameAsString() {
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
const char *display = getenv("DISPLAY");
if (display == NULL) {
return "";
@@ -3357,7 +3357,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)
// TODO(yukawa): support Linux.
return true;
#elif defined(OS_WINDOWS)
@@ -3793,6 +3793,9 @@ string Util::GetOSVersionString() {
#elif defined(OS_LINUX)
const string ret = "Linux";
return ret;
+#elif defined(OS_GNU_KFREEBSD)
+ const string ret = "GNU/kFreeBSD";
+ return ret;
#else
const string ret = "Unknown";
return ret;
@@ -3830,7 +3833,7 @@ uint64 Util::GetTotalPhysicalMemory() {
return 0;
}
return total_memory;
-#elif defined(OS_LINUX)
+#elif defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
#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);
@@ -3856,7 +3859,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)
#if defined(_SC_PAGESIZE)
const size_t page_size = sysconf(_SC_PAGESIZE);
#else
diff --git a/base/util_test.cc b/base/util_test.cc
index 11ae77f..3dc5a44 100755
--- a/base/util_test.cc
+++ b/base/util_test.cc
@@ -3626,7 +3626,7 @@ TEST(UtilTest, MacMaybeMLockTest) {
TEST(UtilTest, LinuxMaybeMLockTest) {
size_t data_len = 32;
void *addr = malloc(data_len);
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
#if defined(OS_ANDROID) || defined(__native_client__)
EXPECT_EQ(-1, Util::MaybeMLock(addr, data_len));
EXPECT_EQ(-1, Util::MaybeMUnlock(addr, data_len));
diff --git a/build_mozc.py b/build_mozc.py
index f584489..979598d 100755
--- a/build_mozc.py
+++ b/build_mozc.py
@@ -93,6 +93,14 @@ def GetMozcVersion():
# TODO(matsuzakit): Caching might be better.
return mozc_version.MozcVersion('%s/mozc_version.txt' % SRC_DIR)
+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'
def GetColoredText(text, color):
"""Gets colored text for terminal."""
@@ -183,7 +191,7 @@ def GetBuildBaseName(options, target_platform):
build_base = 'out_win'
elif target_platform == 'Mac':
build_base = 'out_mac'
- elif target_platform == 'Linux' or target_platform == 'ChromeOS':
+ elif target_platform == 'Linux' or target_platform == 'ChromeOS' or target_platform == 'GNU/kFreeBSD':
build_base = 'out_linux'
elif target_platform == 'Android':
build_base = 'out_android'
@@ -310,7 +318,7 @@ def GetGypFileNames(options):
if IsWindows():
gyp_file_names.extend(glob.glob('%s/win32/*/*.gyp' % SRC_DIR))
gyp_file_names.extend(glob.glob('third_party/breakpad/*.gyp'))
- elif IsLinux():
+ elif IsLinux() 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.
@@ -380,6 +388,7 @@ def AddCommonOptions(parser):
help='Specifies the base directory of the built binaries.')
parser.add_option('--language', dest='language', default='japanese',
help='Specify the target language to build.')
+ parser.add_option('--os', dest='os', default='linux')
return parser
@@ -394,6 +403,10 @@ def AddTargetPlatformOption(parser):
default_target = 'Windows'
elif IsMac():
default_target = 'Mac'
+ elif IsFreeBSD():
+ default_target = 'FreeBSD'
+ elif IsGNUkFreeBSD():
+ default_target = 'GNU/kFreeBSD'
parser.add_option('--target_platform', dest='target_platform',
default=default_target,
help=('Linux environment can build for Linux, Android and '
@@ -566,7 +579,7 @@ def ExpandMetaTarget(meta_target_name):
# Note that ChromeOS does not use this method.
if target_platform == 'Android':
targets = ['%s/android/android.gyp:apk']
- elif target_platform == 'Linux':
+ elif target_platform == 'Linux' or target_platform == 'Linux' :
targets = ['%s/unix/ibus/ibus.gyp:ibus_mozc',
'%s/server/server.gyp:mozc_server',
'%s/renderer/renderer.gyp:mozc_renderer',
@@ -585,7 +598,7 @@ def ParseBuildOptions(args=None, values=None):
"""Parses command line options for the build command."""
parser = optparse.OptionParser(usage='Usage: %prog build [options]')
AddCommonOptions(parser)
- if IsLinux():
+ if IsLinux() or IsGNUkFreeBSD():
default_build_concurrency = GetNumberOfProcessors() * 2
parser.add_option('--jobs', '-j', dest='jobs',
default=('%d' % default_build_concurrency),
@@ -605,7 +618,7 @@ def ParseRunTestsOptions(args=None, values=None):
parser = optparse.OptionParser(
usage='Usage: %prog runtests [options] [test_targets] [-- build options]')
AddCommonOptions(parser)
- if IsLinux():
+ if IsLinux() or IsGNUkFreeBSD():
default_build_concurrency = GetNumberOfProcessors() * 2
parser.add_option('--jobs', '-j', dest='jobs',
default=('%d' % default_build_concurrency),
@@ -734,6 +747,8 @@ def GypMain(options, unused_args):
command_line.extend(['-D', 'wix_dir=%s' % options.wix_dir])
else:
command_line.extend(['-D', 'use_wix=NO'])
+ if options.os:
+ command_line.extend(['-D', 'OS=%s' % options.os])
command_line.extend(['-D', 'build_base=%s' %
GetBuildBaseName(options, version.GetTargetPlatform())])
@@ -766,7 +781,7 @@ def GypMain(options, unused_args):
def SetCommandLineForFeature(option_name, windows=False, mac=False,
linux=False, chromeos=False, android=False,
- nacl=False):
+ nacl=False, freebsd=False, gnu_kfreebsd=False):
"""Updates an option like '--enable_foober' and add a -D argument for gyp.
This function ensures an option like '--enable_foober' exists and it has a
@@ -790,6 +805,10 @@ def GypMain(options, unused_args):
option on Android platform.
nacl: A boolean which replesents the default value of the target
option on NaCl.
+ freebsd: A boolean which replesents the default value of the target
+ option on FreeBSD platform.
+ gnu_fkreebsd: A boolean which replesents the default value of the target
+ option on GNU/kFreeBSD platform.
Raises:
ValueError: An error occurred when 'option_name' is empty.
@@ -803,6 +822,7 @@ def GypMain(options, unused_args):
'Linux': linux,
'ChromeOS': chromeos,
'Android': android,
+ 'GNU/kFreeBSD': gnu_kfreebsd,
'NaCl': nacl}[options.target_platform]
enable_option_name = 'enable_%s' % option_name
enabled = options.ensure_value(enable_option_name, default_enabled)
@@ -861,7 +881,7 @@ def GypMain(options, unused_args):
else:
command_line.extend(['-D', 'use_zinnia=NO'])
- if IsLinux():
+ if IsLinux() or IsGNUkFreeBSD():
if '%s/unix/ibus/ibus.gyp' % SRC_DIR in gyp_file_names:
command_line.extend(['-D', 'use_libibus=1'])
if '%s/unix/scim/scim.gyp' % SRC_DIR in gyp_file_names:
@@ -886,7 +906,7 @@ def GypMain(options, unused_args):
# command for pkg-config. Here we catch the environment variable
# and use the specified command instead of actual pkg-config
# command.
- if IsLinux():
+ if IsLinux() or IsFreeBSD() or IsGNUkFreeBSD():
command_line.extend(['-D', 'pkg_config_command=%s' % GetPkgConfigCommand()])
else:
command_line.extend(['-D', 'pkg_config_command='])
@@ -1020,6 +1040,44 @@ def BuildOnMac(options, targets, original_directory_name):
'-parallelizeTargets',
'BUILD_WITH_GYP=1'])
+def BuildOnBSD(options, targets, unused_original_directory_name):
+ """Build the targets on *BSD."""
+ target_names = []
+ for target in targets:
+ (unused_gyp_file_name, target_name) = (
+ CanonicalTargetToGypFileAndTargetName(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,
+ 'MAKE_JOBS=%s' % options.jobs,
+ 'BUILDTYPE=%s' % options.configuration]
+ build_args.append('builddir_name=%s' %
+ GetBuildBaseName(options,
+ GetMozcVersion().GetTargetPlatform()))
+
+ RunOrDie([make_command] + build_args + target_names)
def LocateMSBuildDir():
"""Locate the directory where msbuild.exe exists.
@@ -1171,6 +1229,8 @@ def BuildMain(options, targets, original_directory_name):
BuildOnMac(options, targets, original_directory_name)
elif IsLinux():
BuildOnLinux(options, targets, original_directory_name)
+ elif IsFreeBSD() or IsGNUkFreeBSD():
+ BuildOnBSD(options, targets, original_directory_name)
elif IsWindows():
BuildOnWindows(options, targets, original_directory_name)
else:
@@ -1323,7 +1383,7 @@ def CleanBuildFilesAndDirectories(options, unused_args):
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.extend(glob.glob(os.path.join(gyp_directory_name,
@@ -1350,6 +1410,10 @@ def CleanBuildFilesAndDirectories(options, unused_args):
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)
@@ -1376,7 +1440,6 @@ def ShowHelpAndExit():
print 'See also the comment in the script for typical usage.'
sys.exit(1)
-
def main():
logging.basicConfig(level=logging.INFO, format='%(message)s')
diff --git a/build_tools/mozc_version.py b/build_tools/mozc_version.py
index e8bbafd..6f38964 100755
--- a/build_tools/mozc_version.py
+++ b/build_tools/mozc_version.py
@@ -56,6 +56,13 @@ import os
import re
import sys
+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'
TARGET_PLATFORM_TO_DIGIT = {
'Windows': '0',
@@ -64,6 +71,8 @@ TARGET_PLATFORM_TO_DIGIT = {
'ChromeOS': '2',
'Android': '3',
'NaCl': '4',
+ 'FreeBSD': '5',
+ 'GNU/kFreeBSD': '6',
}
VERSION_PROPERTIES = [
diff --git a/chrome/skk/skk.gyp b/chrome/skk/skk.gyp
index 3b82e84..ec69cc1 100755
--- a/chrome/skk/skk.gyp
+++ b/chrome/skk/skk.gyp
@@ -42,7 +42,7 @@
'configuration_nacl_i686': '<(CONFIGURATION_NAME)_NaCl_i686',
'configuration_nacl_x86_64': '<(CONFIGURATION_NAME)_NaCl_x86-64',
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
# We need to copy binaries for NaCl i686 and x86-64 into a single skk
# directory across configurations. The following variables must be
# the same as <(PRODUCT_DIR) for each configuration.
diff --git a/client/client.cc b/client/client.cc
index 5cc62a2..5265601 100755
--- a/client/client.cc
+++ b/client/client.cc
@@ -933,7 +933,7 @@ bool Client::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)
string arg = "--mode=" + mode;
if (!extra_arg.empty()) {
arg += " ";
diff --git a/config/stats_config_util_test.cc b/config/stats_config_util_test.cc
index ed5ebd2..8be77d1 100755
--- a/config/stats_config_util_test.cc
+++ b/config/stats_config_util_test.cc
@@ -687,7 +687,7 @@ TEST_F(StatsConfigUtilTestWin, IsEnabled) {
#endif // OS_WINDOWS
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
TEST(StatsConfigUtilTestLinux, DefaultValueTest) {
EXPECT_FALSE(mozc::StatsConfigUtil::IsEnabled());
}
diff --git a/gui/base/locale_util.cc b/gui/base/locale_util.cc
index 3bc8e98..6c1ccb3 100755
--- a/gui/base/locale_util.cc
+++ b/gui/base/locale_util.cc
@@ -206,7 +206,7 @@ TranslationDataImpl::TranslationDataImpl()
qApp->installEventFilter(&window_title_modifier_);
#endif // MOZC_SHOW_BUILD_NUMBER_ON_TITLE
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// 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 d5ade5e..77b536b 100755
--- a/gui/config_dialog/config_dialog.cc
+++ b/gui/config_dialog/config_dialog.cc
@@ -81,7 +81,7 @@ ConfigDialog::ConfigDialog()
miscAdministrationWidget->setVisible(false);
#endif // OS_MACOSX
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
miscDefaultIMEWidget->setVisible(false);
miscAdministrationWidget->setVisible(false);
miscStartupWidget->setVisible(false);
@@ -91,7 +91,7 @@ ConfigDialog::ConfigDialog()
// disable logging options
miscLoggingWidget->setVisible(false);
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// The last "misc" tab has no valid configs on Linux
const int kMiscTabIndex = 6;
configDialogTabWidget->removeTab(kMiscTabIndex);
@@ -320,7 +320,7 @@ ConfigDialog::ConfigDialog()
dictionaryPreloadingAndUACLabel->setVisible(false);
#endif // OS_WINDOWS
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// On Linux, disable all fields for UsageStats
usageStatsLabel->setEnabled(false);
usageStatsLabel->setVisible(false);
@@ -436,7 +436,7 @@ bool ConfigDialog::Update() {
}
-#if defined(OS_WINDOWS) || defined(OS_LINUX)
+#if defined(OS_WINDOWS) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
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 0644079..7d7728a 100755
--- a/gui/config_dialog/keybinding_editor.cc
+++ b/gui/config_dialog/keybinding_editor.cc
@@ -33,7 +33,7 @@
#include <windows.h>
#include <imm.h>
#include <ime.h>
-#elif OS_LINUX
+#elif defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
#define XK_MISCELLANY
#include <X11/keysymdef.h>
#endif
@@ -121,7 +121,7 @@ const WinVirtualKeyEntry kWinVirtualKeyModifierNonRequiredTable[] = {
{ VK_DBE_DBCSCHAR, "Hankaku/Zenkaku" }, // Zenkaku/hankaku
// { VK_KANJI, "Kanji" }, // Do not support Kanji
};
-#elif OS_LINUX
+#elif defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
struct LinuxVirtualKeyEntry {
uint16 virtual_key;
const char *mozc_key_name;
@@ -390,7 +390,7 @@ KeyBindingFilter::KeyState KeyBindingFilter::AddKey(
return Encode(result);
}
}
-#elif OS_LINUX
+#elif defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
const uint16 virtual_key = key_event.nativeVirtualKey();
// The XKB defines three types of logical key code: "xkb::Hiragana",
@@ -500,7 +500,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)
// 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 6d33630..6285618 100755
--- a/gui/config_dialog/keymap_editor.cc
+++ b/gui/config_dialog/keymap_editor.cc
@@ -447,7 +447,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)
QMessageBox::information(
this,
tr("Mozc settings"),
diff --git a/gui/dictionary_tool/dictionary_tool.cc b/gui/dictionary_tool/dictionary_tool.cc
index d47ce0c..608f57d 100755
--- a/gui/dictionary_tool/dictionary_tool.cc
+++ b/gui/dictionary_tool/dictionary_tool.cc
@@ -327,7 +327,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/gui.gyp b/gui/gui.gyp
index fc05c5e..bc0abe1 100755
--- a/gui/gui.gyp
+++ b/gui/gui.gyp
@@ -387,7 +387,7 @@
'../session/session_base.gyp:session_protocol',
],
}],
- ['use_libzinnia==1 and OS=="linux"', {
+ ['use_libzinnia==1 and (OS=="linux" or OS=="gnu-kfreebsd")', {
'defines': [
'USE_LIBZINNIA',
],
diff --git a/gui/qt_libraries.gypi b/gui/qt_libraries.gypi
index 8b4a80a..059d844 100755
--- a/gui/qt_libraries.gypi
+++ b/gui/qt_libraries.gypi
@@ -84,7 +84,7 @@
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
]
}],
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'conditions': [
['qt_dir', {
'libraries': [
diff --git a/gui/word_register_dialog/word_register_dialog.cc b/gui/word_register_dialog/word_register_dialog.cc
index 1310118..4e170cc 100755
--- a/gui/word_register_dialog/word_register_dialog.cc
+++ b/gui/word_register_dialog/word_register_dialog.cc
@@ -74,7 +74,7 @@ QString GetEnv(const char *envname) {
}
return "";
#endif // OS_WINDOWS
-#if defined(OS_MACOSX) || defined(OS_LINUX)
+#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
return ::getenv(envname);
#endif // OS_MACOSX or OS_LINUX
// TODO(team): Support other platforms.
diff --git a/gui/zinnia.gyp b/gui/zinnia.gyp
index e4d323a..dc6d8a9 100755
--- a/gui/zinnia.gyp
+++ b/gui/zinnia.gyp
@@ -45,7 +45,7 @@
'target_name': 'zinnia',
'type': 'static_library',
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'conditions': [
['use_libzinnia==1', {
'link_settings': {
diff --git a/gyp/common.gypi b/gyp/common.gypi
index ef8fb08..d40ac35 100755
--- a/gyp/common.gypi
+++ b/gyp/common.gypi
@@ -269,12 +269,12 @@
# additional suffix except for Japanese so that multiple
# converter processes can coexist. Note that Mozc on ChromeOS does
# not use IPC so this kind of special treatment is not required.
- ['language!="japanese" and target_platform=="Linux"', {
+ ['language!="japanese" and target_platform=="Linux" or target_platform=="GNU/kFreeBSD"', {
'defines': [
'MOZC_LANGUAGE_SUFFIX_FOR_LINUX="_<(language)"',
],
}],
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'ldflags': [
'<@(linux_ldflags)',
],
@@ -416,7 +416,7 @@
},
},
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'cflags': [
'<@(debug_extra_cflags)',
],
@@ -454,7 +454,7 @@
},
},
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'cflags': [
'<@(release_extra_cflags)',
],
@@ -760,6 +760,16 @@
}],
],
}],
+ ['OS=="gnu-kfreebsd"', {
+ 'defines': [
+ 'OS_GNU_KFREEBSD',
+ ],
+ 'cflags': [
+ '<@(gcc_cflags)',
+ '-fPIC',
+ '-fno-exceptions',
+ ],
+ }],
['OS=="mac"', {
'defines': [
'OS_MACOSX',
diff --git a/handwriting/handwriting.gyp b/handwriting/handwriting.gyp
index 1538d43..b78e773 100755
--- a/handwriting/handwriting.gyp
+++ b/handwriting/handwriting.gyp
@@ -39,7 +39,7 @@
'../base/base.gyp:base',
'../gui/zinnia.gyp:zinnia',
],
- 'conditions': [['use_libzinnia==1 and OS=="linux"', {
+ 'conditions': [['use_libzinnia==1 and (OS=="linux" or OS=="gnu-kfreebsd")', {
'defines': [
'USE_LIBZINNIA',
],
diff --git a/ipc/ipc_path_manager.cc b/ipc/ipc_path_manager.cc
index 86f4a0c..b000cda 100755
--- a/ipc/ipc_path_manager.cc
+++ b/ipc/ipc_path_manager.cc
@@ -284,7 +284,7 @@ bool IPCPathManager::GetPathName(string *ipc_name) const {
*ipc_name = kIPCPrefix;
#endif // OS_WINDOWS
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// On Linux, use abstract namespace which is independent of the file system.
(*ipc_name)[0] = '\0';
#endif
@@ -377,7 +377,7 @@ bool IPCPathManager::IsValidServer(uint32 pid,
}
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// load from /proc/<pid>/exe
char proc[128];
char filename[512];
@@ -397,7 +397,7 @@ bool IPCPathManager::IsValidServer(uint32 pid,
return true;
}
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
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/ipc_path_manager_test.cc b/ipc/ipc_path_manager_test.cc
index e1e2481..7b7e5c8 100755
--- a/ipc/ipc_path_manager_test.cc
+++ b/ipc/ipc_path_manager_test.cc
@@ -102,7 +102,7 @@ TEST_F(IPCPathManagerTest, IPCPathManagerTest) {
EXPECT_FALSE(manager->GetServerProductVersion().empty());
EXPECT_GT(manager->GetServerProcessId(), 0);
EXPECT_EQ(t.path(), path);
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// On Linux, |path| should be abstract (see man unix(7) for details.)
ASSERT_FALSE(path.empty());
EXPECT_EQ('\0', path[0]);
diff --git a/ipc/unix_ipc.cc b/ipc/unix_ipc.cc
index 7b85039..4da8032 100755
--- a/ipc/unix_ipc.cc
+++ b/ipc/unix_ipc.cc
@@ -28,7 +28,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// skip all if non-Linux or Android.
-#if defined(OS_LINUX) && !defined(OS_ANDROID)
+#if (defined(OS_LINUX) && !defined(OS_ANDROID)) || defined(OS_GNU_KFREEBSD)
#include "ipc/ipc.h"
@@ -41,7 +41,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 +124,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);
@@ -146,7 +146,7 @@ bool IsPeerValid(int socket, pid_t *pid) {
*pid = 0;
#endif
-#ifdef OS_LINUX
+#if defined(OS_LINUX)
// On ARM Linux, we do nothing and just return true since the platform
// sometimes doesn't support the getsockopt(sock, SOL_SOCKET, SO_PEERCRED)
// system call.
@@ -185,7 +185,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
diff --git a/languages/chewing/chewing.gyp b/languages/chewing/chewing.gyp
index e94e8dd..a5bfb3c 100755
--- a/languages/chewing/chewing.gyp
+++ b/languages/chewing/chewing.gyp
@@ -55,7 +55,7 @@
},
],
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'targets': [
{
'target_name': 'ibus_mozc_chewing',
diff --git a/languages/hangul/hangul.gyp b/languages/hangul/hangul.gyp
index bd5ee6f..3cb36de 100755
--- a/languages/hangul/hangul.gyp
+++ b/languages/hangul/hangul.gyp
@@ -59,7 +59,7 @@
},
],
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'targets': [
{
'target_name': 'ibus_mozc_hangul',
diff --git a/net/net.gyp b/net/net.gyp
index 717bdd7..a0bcb88 100755
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -61,7 +61,7 @@
},
},
}],
- ['target_platform=="Linux"', {
+ ['target_platform=="Linux" or OS=="gnu-kfreebsd"', {
# Enable libcurl
'cflags': [
'<!@(<(pkg_config_command) --cflags libcurl)',
diff --git a/protobuf/genproto.gypi b/protobuf/genproto.gypi
index a0db8b8..d67f511 100755
--- a/protobuf/genproto.gypi
+++ b/protobuf/genproto.gypi
@@ -34,7 +34,7 @@
'build_tools_dir%': '../build_tools',
},
'conditions': [
- ['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 6998e9f..c3f66aa 100755
--- a/protobuf/protobuf.gyp
+++ b/protobuf/protobuf.gyp
@@ -117,7 +117,7 @@
'type': 'static_library',
'toolsets': ['host', 'target'],
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'conditions': [
['use_libprotobuf==1', {
'link_settings': {
@@ -162,7 +162,7 @@
'.',
],
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'conditions': [
['use_libprotobuf!=1', {
'cflags': [
@@ -199,7 +199,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_interface.h b/session/session_converter_interface.h
index 0c55421..66310be 100755
--- a/session/session_converter_interface.h
+++ b/session/session_converter_interface.h
@@ -56,7 +56,7 @@ struct OperationPreferences {
bool use_cascading_window;
string candidate_shortcuts;
OperationPreferences() {
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// TODO(komatsu): Move this logic to the client code.
use_cascading_window = false;
#else
diff --git a/session/session_test.cc b/session/session_test.cc
index 13d574f..a94f31a 100755
--- a/session/session_test.cc
+++ b/session/session_test.cc
@@ -2343,7 +2343,7 @@ TEST_F(SessionTest, OutputAllCandidateWords) {
EXPECT_EQ(0, output.all_candidate_words().focused_index());
EXPECT_EQ(commands::CONVERSION, output.all_candidate_words().category());
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// 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
@@ -2371,7 +2371,7 @@ TEST_F(SessionTest, OutputAllCandidateWords) {
EXPECT_EQ(1, output.all_candidate_words().focused_index());
EXPECT_EQ(commands::CONVERSION, output.all_candidate_words().category());
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD)
// 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
--
1.7.10