Skip to content

Commit

Permalink
Use Ninja to build Mozc for OS X.
Browse files Browse the repository at this point in the history
With this CL, Mozc for OS X is built with Ninja rather than xcodebuild.
No user-visible behavior change is intended.

Closes #247.

BUG=#247
TEST=unittest
REF_BUG=22545802
REF_CL=112438793,112444215
  • Loading branch information
hiroyuki-komatsu authored and yukawa committed Jan 23, 2016
1 parent 80c7fb8 commit da34e1e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ install:
- if [ $TRAVIS_OS_NAME == linux ]; then export PATH="$PATH":`pwd`/src/third_party/depot_tools; fi
- if [ $TRAVIS_OS_NAME == linux ]; then unset CC; fi
- if [ $TRAVIS_OS_NAME == linux ]; then unset CXX; fi
- if [ $TARGET_PLATFORM == Mac ]; then git -C src/third_party clone https://chromium.googlesource.com/chromium/tools/depot_tools.git; fi
- if [ $TARGET_PLATFORM == Mac ]; then export PATH="$PATH":`pwd`/src/third_party/depot_tools; fi
- if [ $TARGET_PLATFORM == NaCl ]; then cd src/third_party && curl -LO http://storage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk/nacl_sdk.zip && unzip nacl_sdk.zip && rm nacl_sdk.zip && cd nacl_sdk && ./naclsdk install pepper_45 && cd ../../../; fi
- if [ $TARGET_PLATFORM == Android ]; then cd src/third_party && curl -L http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin -O && chmod u+x android-ndk-r10e-linux-x86_64.bin && ./android-ndk-r10e-linux-x86_64.bin > /dev/null && rm android-ndk-r10e-linux-x86_64.bin && curl -L http://dl.google.com/android/android-sdk_r24.1.2-linux.tgz | tar -zx && cd ../../; fi
- if [ $TARGET_PLATFORM == Android ]; then export ANDROID_NDK_HOME=`pwd`/src/third_party/android-ndk-r10e ; fi
Expand Down
1 change: 1 addition & 0 deletions doc/build_mozc_in_osx.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ We only support OS X 10.7 or later intel only.
Building on Mac requires the following software.

* Xcode
* [Ninja](https://github.com/ninja-build/ninja)

If you don't need to run gui tools like about dialog, config dialog, or dictionary tool, you can omit installing Qt. Candidate window still shows without Qt. See below for the detailed information.

Expand Down
35 changes: 5 additions & 30 deletions src/build_mozc.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,7 @@ def GetGeneratorName(generator):
"""Gets the generator name based on the platform."""
if generator:
return generator
elif IsMac():
return 'xcode'
else:
return 'ninja'
return 'ninja'


def GetPkgConfigCommand():
Expand Down Expand Up @@ -880,7 +877,6 @@ def SetCommandLineForFeature(option_name, windows=False, mac=False,
gyp_options.extend([
'-D', 'server_dir=%s' % os.path.abspath(options.server_dir)])

# TODO(yukawa): Use ninja on OSX.
if generator == 'ninja':
gyp_options.extend(['--generator-output=.'])
short_basename = GetBuildShortBaseName(options, target_platform)
Expand Down Expand Up @@ -947,8 +943,8 @@ def CanonicalTargetToGypFileAndTargetName(target):
return (gyp_file_name, target_name)


def BuildOnLinux(options, targets, unused_original_directory_name):
"""Build the targets on Linux."""
def BuildWithNinja(options, targets, unused_original_directory_name):
"""Build the targets with Ninja."""
target_names = []
for target in targets:
(unused_gyp_file_name, target_name) = (
Expand All @@ -968,22 +964,6 @@ def BuildOnLinux(options, targets, unused_original_directory_name):
RunOrDie([make_command] + build_args + target_names)


def BuildOnMac(options, targets, original_directory_name):
"""Build the targets on Mac."""
original_directory_relpath = GetRelPath(original_directory_name, os.getcwd())
for target in targets:
(gyp_file_name, target_name) = CanonicalTargetToGypFileAndTargetName(target)
gyp_file_name = os.path.join(original_directory_relpath, gyp_file_name)
CheckFileOrDie(gyp_file_name)
(xcode_base_name, _) = os.path.splitext(gyp_file_name)
RunOrDie(['xcodebuild',
'-project', '%s.xcodeproj' % xcode_base_name,
'-configuration', options.configuration,
'-target', target_name,
'-parallelizeTargets',
'BUILD_WITH_GYP=1'])


def BuildOnWindows(targets):
"""Build the target on Windows."""
ninja = 'ninja.exe'
Expand All @@ -1006,15 +986,10 @@ def BuildMain(options, targets, original_directory_name):
python_path = os.pathsep.join([original_python_path, mozc_root])
os.environ['PYTHONPATH'] = python_path

if IsMac():
BuildOnMac(options, targets, original_directory_name)
elif IsLinux():
BuildOnLinux(options, targets, original_directory_name)
elif IsWindows():
if IsWindows():
BuildOnWindows(targets)
else:
logging.error('Unsupported platform: %s', os.name)
return
BuildWithNinja(options, targets, original_directory_name)

# Revert python path.
os.environ['PYTHONPATH'] = original_python_path
Expand Down
3 changes: 3 additions & 0 deletions src/gui/gui.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,9 @@
'product_name': '<(branding)Tool_lib',
'mac_bundle': 1,
'xcode_settings': {
# Ninja uses DYLIB_INSTALL_NAME_BASE to specify
# where this framework is located.
'DYLIB_INSTALL_NAME_BASE': '@executable_path/../Frameworks',
'INSTALL_PATH': '@executable_path/../Frameworks',
'INFOPLIST_FILE': '<(gen_out_dir)/mozc_tool_lib_info',
},
Expand Down
31 changes: 20 additions & 11 deletions src/mac/mac.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -300,22 +300,31 @@
'<(gen_out_dir)/English.lproj/InfoPlist.strings',
'Japanese.lproj/Config.xib',
'<(gen_out_dir)/Japanese.lproj/InfoPlist.strings',
'<(PRODUCT_DIR)/<(branding)Converter.app',
'<(PRODUCT_DIR)/<(branding)Prelauncher.app',
'<(PRODUCT_DIR)/<(branding)Renderer.app',
'<(PRODUCT_DIR)/<(branding)Tool.app',
'<(PRODUCT_DIR)/AboutDialog.app',
'<(PRODUCT_DIR)/CharacterPalette.app',
'<(PRODUCT_DIR)/ConfigDialog.app',
'<(PRODUCT_DIR)/DictionaryTool.app',
'<(PRODUCT_DIR)/ErrorMessageDialog.app',
'<(PRODUCT_DIR)/HandWriting.app',
'<(PRODUCT_DIR)/WordRegisterDialog.app',
],
'xcode_settings': {
'INFOPLIST_FILE': '<(gen_out_dir)/Info.plist',
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
},
# Ninja does not consider symlinks on mac_bundle_resources.
# So 'copies' should be used to copy app directories.
'copies': [
{
'files': [
'<(PRODUCT_DIR)/<(branding)Converter.app',
'<(PRODUCT_DIR)/<(branding)Prelauncher.app',
'<(PRODUCT_DIR)/<(branding)Renderer.app',
'<(PRODUCT_DIR)/<(branding)Tool.app',
'<(PRODUCT_DIR)/AboutDialog.app',
'<(PRODUCT_DIR)/CharacterPalette.app',
'<(PRODUCT_DIR)/ConfigDialog.app',
'<(PRODUCT_DIR)/DictionaryTool.app',
'<(PRODUCT_DIR)/ErrorMessageDialog.app',
'<(PRODUCT_DIR)/HandWriting.app',
'<(PRODUCT_DIR)/WordRegisterDialog.app',
],
'destination': '<(PRODUCT_DIR)/<(branding).app/Contents/Resources',
},
],
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
Expand Down
2 changes: 1 addition & 1 deletion src/mozc_version_template.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=17
BUILD=2315
BUILD=2316
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.
Expand Down

0 comments on commit da34e1e

Please sign in to comment.