diff --git a/base/cpu_stats.cc b/base/cpu_stats.cc
index ef7ee3d..59094d9 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 18b9c58..fdb210d 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 79976b2..568395c 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 6acf323..4a3e094 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 433d954..2b3b01a 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 5af82b9..07e280b 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 cf0b422..61a381f 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) || defined(OS_FREEBSD)
typedef PlainPasswordManager DefaultPasswordManager;
#endif
diff --git a/base/process.cc b/base/process.cc
index c230b31..2d5859a 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) || defined(OS_FREEBSD)
#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) || 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.
@@ -204,7 +204,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;
@@ -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) || 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 cd7a42b..b82354b 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/stopwatch.cc b/base/stopwatch.cc
index 15afad3..8ff2e29 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/thread.h b/base/thread.h
index 681c3f6..e1d9ecf 100755
--- a/base/thread.h
+++ b/base/thread.h
@@ -58,10 +58,10 @@
#endif // OS_WINDOWS
// Use GCC's keyword on Linux.
-#ifdef OS_LINUX
+#if defined(OS_LINUX) || defined(OS_GNU_KFREEBSD) || defined(OS_FREEBSD)
#define TLS_KEYWORD __thread
#define HAVE_TLS 1
-#endif // OS_LINUX
+#endif // OS_LINUX || OS_GNU_KFREEBSD || OS_FREEBSD
// OSX doesn't support Thread Local Storage.
diff --git a/base/util.cc b/base/util.cc
index 484cd63..d44e002 100755
--- a/base/util.cc
+++ b/base/util.cc
@@ -2592,7 +2592,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
}
@@ -2671,7 +2671,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 "";
@@ -3167,7 +3167,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)
@@ -3587,18 +3587,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() {
@@ -3632,7 +3633,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);
@@ -3658,7 +3659,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 a08f8c5..5adcbfa 100755
--- a/build_mozc.py
+++ b/build_mozc.py
@@ -72,6 +72,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():
@@ -87,7 +95,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')
@@ -114,6 +122,8 @@ def GetBuildBaseName(options):
# On Linux, seems there is no way to specify the build_base directory
# inside common.gypi
build_base = 'out_linux'
+ elif IsFreeBSD() or IsGNUkFreeBSD():
+ build_base = 'out_bsd'
else:
logging.error('Unsupported platform: %s', os.name)
@@ -205,7 +215,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 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.
@@ -362,6 +372,7 @@ def AddCommonOptions(parser):
help='If you want ChromeOS build, specify "ChromeOS"')
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
@@ -459,7 +470,7 @@ def ExpandMetaTarget(meta_target_name, target_platform):
targets = ['%s/unix/ibus/ibus.gyp:ibus_mozc',
'%s/server/server.gyp:mozc_server',
'%s/gui/gui.gyp:mozc_tool']
- elif IsLinux():
+ elif IsLinux() or IsFreeBSD() or IsGNUkFreeBSD():
targets = ['%s/unix/ibus/ibus.gyp:ibus_mozc',
'%s/server/server.gyp:mozc_server',
'%s/gui/gui.gyp:mozc_tool']
@@ -579,6 +590,9 @@ def GypMain(options, unused_args):
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)])
@@ -616,7 +630,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='])
@@ -714,6 +728,42 @@ def BuildOnLinux(options, targets, unused_original_directory_name):
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) = (
+ 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, '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."""
@@ -877,6 +927,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)
elif IsWindows():
BuildOnWindows(options, targets, original_directory_name)
else:
@@ -1000,7 +1052,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,
@@ -1019,6 +1071,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)
@@ -1045,7 +1101,6 @@ def ShowHelpAndExit():
print 'See also the comment in the script for typical usage.'
sys.exit(1)
-
def main():
if len(sys.argv) < 2:
ShowHelpAndExit()
diff --git a/build_tools/mozc_version.py b/build_tools/mozc_version.py
index 04d644b..b3ed870 100755
--- a/build_tools/mozc_version.py
+++ b/build_tools/mozc_version.py
@@ -58,6 +58,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, target_platform):
"""Returns the revision for the current platform."""
@@ -76,6 +83,10 @@ def CalculateRevisionForPlatform(revision, target_platform):
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/config/stats_config_util_test.cc b/config/stats_config_util_test.cc
index a49dd08..61fda2e 100755
--- a/config/stats_config_util_test.cc
+++ b/config/stats_config_util_test.cc
@@ -690,7 +690,7 @@ TEST_F(StatsConfigUtilTestWin, IsEnabled) {
#else // CHANNEL_DEV
#endif // CHANNEL_DEV
-#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/gui/base/locale_util.cc b/gui/base/locale_util.cc
index 827fd28..52c881b 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 5aee977..4df1942 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 = 6;
configDialogTabWidget->removeTab(kMiscTabIndex);
-#endif // OS_MACOSX || OS_LINUX
+#endif // OS_MACOSX || OS_LINUX || OS_GNU_KFREEBSD || OS_FREEBSD
#endif // NO_LOGGING
#if !defined(GOOGLE_JAPANESE_INPUT_BUILD)
@@ -277,7 +277,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);
@@ -364,7 +364,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 c17efc6..1239316 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 5bc096d..c3b45d3 100755
--- a/gui/config_dialog/keymap_editor.cc
+++ b/gui/config_dialog/keymap_editor.cc
@@ -94,7 +94,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
@@ -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) || 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 b66f13e..20c3461 100755
--- a/gui/dictionary_tool/dictionary_tool.cc
+++ b/gui/dictionary_tool/dictionary_tool.cc
@@ -317,7 +317,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 37e4e44..bef1334 100755
--- a/gui/gui.gyp
+++ b/gui/gui.gyp
@@ -378,7 +378,7 @@
'includes': [
'qt_libraries.gypi',
],
- 'conditions': [['use_libzinnia==1 and OS=="linux"', {
+ 'conditions': [['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 b406bc6..b564c1c 100755
--- a/gui/qt_libraries.gypi
+++ b/gui/qt_libraries.gypi
@@ -86,7 +86,7 @@
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
]
}],
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'conditions': [
['qt_dir', {
'libraries': [
diff --git a/gui/zinnia.gyp b/gui/zinnia.gyp
index b4cd01c..481b280 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 551f8bd..c0e0a5f 100755
--- a/gyp/common.gypi
+++ b/gyp/common.gypi
@@ -238,7 +238,7 @@
},
},
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'cflags': [
'<@(debug_extra_cflags)',
],
@@ -277,7 +277,7 @@
},
},
'conditions': [
- ['OS=="linux"', {
+ ['OS=="linux" or OS=="gnu-kfreebsd"', {
'cflags': [
'<@(release_extra_cflags)',
],
@@ -532,6 +532,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',
@@ -586,7 +631,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 db5b5d7..ab4091b 100755
--- a/ipc/ipc_path_manager.cc
+++ b/ipc/ipc_path_manager.cc
@@ -274,7 +274,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
@@ -367,7 +367,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];
@@ -387,7 +387,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/ipc_path_manager_test.cc b/ipc/ipc_path_manager_test.cc
index 82cea4a..4b24fb8 100755
--- a/ipc/ipc_path_manager_test.cc
+++ b/ipc/ipc_path_manager_test.cc
@@ -108,7 +108,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)
// 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 3085320..37ff133 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);
@@ -146,7 +147,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 +186,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
@@ -524,4 +525,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 38d8eef..b821e7c 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 6072864..a619ddc 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': {
@@ -196,7 +196,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 be5bf45..c6cc2d0 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) || defined(OS_FREEBSD)
// 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 ff8fece..1153dff 100755
--- a/session/session_test.cc
+++ b/session/session_test.cc
@@ -2089,7 +2089,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
@@ -2117,7 +2117,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
diff --git a/testing/testing.gyp b/testing/testing.gyp
index 58d1cf3..34a59d6 100755
--- a/testing/testing.gyp
+++ b/testing/testing.gyp
@@ -53,7 +53,7 @@
'../base/base.gyp:base',
],
'conditions': [
- ['OS!="linux"', {
+ ['OS!="linux" and OS!="gnu-kfreebsd"', {
'dependencies': [
'testing',
],