Merge pull request #358 from google/fix_issue247
Use Ninja to build Mozc for OS X.
Yohei Yukawa
8 years ago
70 | 70 | - if [ $TRAVIS_OS_NAME == linux ]; then export PATH="$PATH":`pwd`/src/third_party/depot_tools; fi |
71 | 71 | - if [ $TRAVIS_OS_NAME == linux ]; then unset CC; fi |
72 | 72 | - if [ $TRAVIS_OS_NAME == linux ]; then unset CXX; fi |
73 | - if [ $TARGET_PLATFORM == Mac ]; then git -C src/third_party clone https://chromium.googlesource.com/chromium/tools/depot_tools.git; fi | |
74 | - if [ $TARGET_PLATFORM == Mac ]; then export PATH="$PATH":`pwd`/src/third_party/depot_tools; fi | |
73 | 75 | - 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 |
74 | 76 | - 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 |
75 | 77 | - if [ $TARGET_PLATFORM == Android ]; then export ANDROID_NDK_HOME=`pwd`/src/third_party/android-ndk-r10e ; fi |
9 | 9 | Building on Mac requires the following software. |
10 | 10 | |
11 | 11 | * Xcode |
12 | * [Ninja](https://github.com/ninja-build/ninja) | |
12 | 13 | |
13 | 14 | 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. |
14 | 15 |
147 | 147 | """Gets the generator name based on the platform.""" |
148 | 148 | if generator: |
149 | 149 | return generator |
150 | elif IsMac(): | |
151 | return 'xcode' | |
152 | else: | |
153 | return 'ninja' | |
150 | return 'ninja' | |
154 | 151 | |
155 | 152 | |
156 | 153 | def GetPkgConfigCommand(): |
879 | 876 | gyp_options.extend([ |
880 | 877 | '-D', 'server_dir=%s' % os.path.abspath(options.server_dir)]) |
881 | 878 | |
882 | # TODO(yukawa): Use ninja on OSX. | |
883 | 879 | if generator == 'ninja': |
884 | 880 | gyp_options.extend(['--generator-output=.']) |
885 | 881 | short_basename = GetBuildShortBaseName(options, target_platform) |
946 | 942 | return (gyp_file_name, target_name) |
947 | 943 | |
948 | 944 | |
949 | def BuildOnLinux(options, targets, unused_original_directory_name): | |
950 | """Build the targets on Linux.""" | |
945 | def BuildWithNinja(options, targets, unused_original_directory_name): | |
946 | """Build the targets with Ninja.""" | |
951 | 947 | target_names = [] |
952 | 948 | for target in targets: |
953 | 949 | (unused_gyp_file_name, target_name) = ( |
967 | 963 | RunOrDie([make_command] + build_args + target_names) |
968 | 964 | |
969 | 965 | |
970 | def BuildOnMac(options, targets, original_directory_name): | |
971 | """Build the targets on Mac.""" | |
972 | original_directory_relpath = GetRelPath(original_directory_name, os.getcwd()) | |
973 | for target in targets: | |
974 | (gyp_file_name, target_name) = CanonicalTargetToGypFileAndTargetName(target) | |
975 | gyp_file_name = os.path.join(original_directory_relpath, gyp_file_name) | |
976 | CheckFileOrDie(gyp_file_name) | |
977 | (xcode_base_name, _) = os.path.splitext(gyp_file_name) | |
978 | RunOrDie(['xcodebuild', | |
979 | '-project', '%s.xcodeproj' % xcode_base_name, | |
980 | '-configuration', options.configuration, | |
981 | '-target', target_name, | |
982 | '-parallelizeTargets', | |
983 | 'BUILD_WITH_GYP=1']) | |
984 | ||
985 | ||
986 | 966 | def BuildOnWindows(targets): |
987 | 967 | """Build the target on Windows.""" |
988 | 968 | ninja = 'ninja.exe' |
1005 | 985 | python_path = os.pathsep.join([original_python_path, mozc_root]) |
1006 | 986 | os.environ['PYTHONPATH'] = python_path |
1007 | 987 | |
1008 | if IsMac(): | |
1009 | BuildOnMac(options, targets, original_directory_name) | |
1010 | elif IsLinux(): | |
1011 | BuildOnLinux(options, targets, original_directory_name) | |
1012 | elif IsWindows(): | |
988 | if IsWindows(): | |
1013 | 989 | BuildOnWindows(targets) |
1014 | 990 | else: |
1015 | logging.error('Unsupported platform: %s', os.name) | |
1016 | return | |
991 | BuildWithNinja(options, targets, original_directory_name) | |
1017 | 992 | |
1018 | 993 | # Revert python path. |
1019 | 994 | os.environ['PYTHONPATH'] = original_python_path |
895 | 895 | 'product_name': '<(branding)Tool_lib', |
896 | 896 | 'mac_bundle': 1, |
897 | 897 | 'xcode_settings': { |
898 | # Ninja uses DYLIB_INSTALL_NAME_BASE to specify | |
899 | # where this framework is located. | |
900 | 'DYLIB_INSTALL_NAME_BASE': '@executable_path/../Frameworks', | |
898 | 901 | 'INSTALL_PATH': '@executable_path/../Frameworks', |
899 | 902 | 'INFOPLIST_FILE': '<(gen_out_dir)/mozc_tool_lib_info', |
900 | 903 | }, |
299 | 299 | '<(gen_out_dir)/English.lproj/InfoPlist.strings', |
300 | 300 | 'Japanese.lproj/Config.xib', |
301 | 301 | '<(gen_out_dir)/Japanese.lproj/InfoPlist.strings', |
302 | '<(PRODUCT_DIR)/<(branding)Converter.app', | |
303 | '<(PRODUCT_DIR)/<(branding)Prelauncher.app', | |
304 | '<(PRODUCT_DIR)/<(branding)Renderer.app', | |
305 | '<(PRODUCT_DIR)/<(branding)Tool.app', | |
306 | '<(PRODUCT_DIR)/AboutDialog.app', | |
307 | '<(PRODUCT_DIR)/CharacterPalette.app', | |
308 | '<(PRODUCT_DIR)/ConfigDialog.app', | |
309 | '<(PRODUCT_DIR)/DictionaryTool.app', | |
310 | '<(PRODUCT_DIR)/ErrorMessageDialog.app', | |
311 | '<(PRODUCT_DIR)/HandWriting.app', | |
312 | '<(PRODUCT_DIR)/WordRegisterDialog.app', | |
313 | 302 | ], |
314 | 303 | 'xcode_settings': { |
315 | 304 | 'INFOPLIST_FILE': '<(gen_out_dir)/Info.plist', |
316 | 305 | 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', |
317 | 306 | }, |
307 | # Ninja does not consider symlinks on mac_bundle_resources. | |
308 | # So 'copies' should be used to copy app directories. | |
309 | 'copies': [ | |
310 | { | |
311 | 'files': [ | |
312 | '<(PRODUCT_DIR)/<(branding)Converter.app', | |
313 | '<(PRODUCT_DIR)/<(branding)Prelauncher.app', | |
314 | '<(PRODUCT_DIR)/<(branding)Renderer.app', | |
315 | '<(PRODUCT_DIR)/<(branding)Tool.app', | |
316 | '<(PRODUCT_DIR)/AboutDialog.app', | |
317 | '<(PRODUCT_DIR)/CharacterPalette.app', | |
318 | '<(PRODUCT_DIR)/ConfigDialog.app', | |
319 | '<(PRODUCT_DIR)/DictionaryTool.app', | |
320 | '<(PRODUCT_DIR)/ErrorMessageDialog.app', | |
321 | '<(PRODUCT_DIR)/HandWriting.app', | |
322 | '<(PRODUCT_DIR)/WordRegisterDialog.app', | |
323 | ], | |
324 | 'destination': '<(PRODUCT_DIR)/<(branding).app/Contents/Resources', | |
325 | }, | |
326 | ], | |
318 | 327 | 'link_settings': { |
319 | 328 | 'libraries': [ |
320 | 329 | '$(SDKROOT)/System/Library/Frameworks/Carbon.framework', |