Пример #1
0
def CleanMain(options, unused_args):
  """The main function for the 'clean' command."""

  # File and directory names to be removed.
  file_names = []
  directory_names = []

  # Collect stuff in the gyp directories.
  gyp_directory_names = [os.path.dirname(f) for f in GetGypFileNames(options)]
  for gyp_directory_name in gyp_directory_names:
    if IsWindows():
      for pattern in ['*.ncb', '*.rules', '*.props', '*.sdf', '*.sln', '*.suo',
                      '*.targets', '*.vcproj', '*.vcproj.*.user', '*.vcxproj',
                      '*.vcxproj.filters', '*.vcxproj.user', 'gen_*_files.xml']:
        file_names.extend(glob.glob(os.path.join(gyp_directory_name,
                                                 pattern)))
      for build_type in ['Debug', 'Release']:
        directory_names.append(os.path.join(gyp_directory_name,
                                            build_type))
    elif IsMac():
      directory_names.extend(glob.glob(os.path.join(gyp_directory_name,
                                                    '*.xcodeproj')))

  # mozc_version.txt does not always exist.
  version_file = '%s/mozc_version.txt' % SRC_DIR
  if os.path.exists(version_file):
    file_names.append(version_file)
    build_base = GetBuildBaseName(GetMozcVersion().GetTargetPlatform())
    if build_base:
      directory_names.append(build_base)

  if IsLinux():
    # Remove auto-generated files.
    file_names.append(os.path.join(SRC_DIR, 'android', 'AndroidManifest.xml'))
    file_names.append(os.path.join(
        SRC_DIR, 'android', 'tests', 'AndroidManifest.xml'))
    # Remove a symbolic link to android/resources/res
    file_names.append(os.path.join(SRC_DIR, 'android', 'resources', 'res'))
    directory_names.append(os.path.join(SRC_DIR, 'android', 'assets'))
    # Delete files/dirs generated by Android SDK/NDK.
    android_library_projects = [
        '',
        'resources',
        'tests',
        ]
    android_generated_dirs = ['bin', 'gen', 'obj', 'libs', 'gen_for_adt']
    for project in android_library_projects:
      for directory in android_generated_dirs:
        directory_names.append(
            os.path.join(SRC_DIR, 'android', project, directory))

  # Remove files.
  for file_name in file_names:
    RemoveFile(file_name)
  # Remove directories.
  for directory_name in directory_names:
    RemoveDirectoryRecursively(directory_name)
Пример #2
0
def ParseGypOptions(args):
    """Parses command line options for the gyp command."""
    parser = optparse.OptionParser(usage='Usage: %prog gyp [options]')
    AddCommonOptions(parser)
    default_branding = 'Mozc'
    parser.add_option('--branding',
                      dest='branding',
                      default=default_branding,
                      help='Specifies the branding. [default: %default]')
    parser.add_option('--gypdir',
                      dest='gypdir',
                      help='Specifies the location of GYP to be used.')
    parser.add_option('--gyp_python_path',
                      dest='gyp_python_path',
                      help='File path to Python to execute GYP.')
    parser.add_option('--noqt',
                      action='store_true',
                      dest='noqt',
                      default=False)
    parser.add_option('--version_file',
                      dest='version_file',
                      help='use the specified version template file',
                      default='data/version/mozc_version_template.bzl')
    AddTargetPlatformOption(parser)

    # Mac and Linux
    parser.add_option(
        '--warn_as_error',
        action='store_true',
        dest='warn_as_error',
        default=(default_branding != 'Mozc'),
        help='Treat compiler warning as error. This option is used '
        'on Mac and Linux.')

    # Linux
    parser.add_option(
        '--server_dir',
        dest='server_dir',
        default='',
        help='A path to the directory where the server executable'
        'is installed. This option is used only on Linux.')

    if IsWindows():
        parser.add_option('--wix_dir',
                          dest='wix_dir',
                          default=GetDefaultWixPath(),
                          help='A path to the binary directory of wix.')

    if IsWindows() or IsMac():
        parser.add_option('--qtdir',
                          dest='qtdir',
                          default=os.getenv('QTDIR', None),
                          help='Qt base directory to be used.')

    return parser.parse_args(args)
Пример #3
0
def AddTargetPlatformOption(parser):
  if IsLinux():
    default_target = 'Linux'
  elif IsWindows():
    default_target = 'Windows'
  elif IsMac():
    default_target = 'Mac'
  parser.add_option('--target_platform', dest='target_platform',
                    default=default_target,
                    help=('This option enables this script to know which build'
                          'should be done.'))
Пример #4
0
def AddTargetPlatformOption(parser):
  # Linux environment can build for Linux, Android and NaCl.
  # --target_platform option enables this script to know which build
  # should be done. If you want NaCl build, specify "NaCl".
  # If you want Android build, specify "Android".
  if IsLinux():
    default_target = 'Linux'
  elif IsWindows():
    default_target = 'Windows'
  elif IsMac():
    default_target = 'Mac'
  parser.add_option('--target_platform', dest='target_platform',
                    default=default_target,
                    help=('Linux environment can build for Linux, Android  and '
                          'NaCl. This option enables this script to know '
                          'which build should be done. '
                          'If you want Android build, specify "Android". '
                          'If you want NaCl build, specify "NaCl".'))
Пример #5
0
def CleanMain(options, unused_args):
    """The main function for the 'clean' command."""

    # File and directory names to be removed.
    file_names = []
    directory_names = []

    # Collect stuff in the gyp directories.
    gyp_directory_names = [
        os.path.dirname(f) for f in GetGypFileNames(options)
    ]
    for gyp_directory_name in gyp_directory_names:
        if IsWindows():
            for pattern in [
                    '*.ncb', '*.rules', '*.props', '*.sdf', '*.sln', '*.suo',
                    '*.targets', '*.vcproj', '*.vcproj.*.user', '*.vcxproj',
                    '*.vcxproj.filters', '*.vcxproj.user', 'gen_*_files.xml'
            ]:
                file_names.extend(
                    glob.glob(os.path.join(gyp_directory_name, pattern)))
            for build_type in ['Debug', 'Release']:
                directory_names.append(
                    os.path.join(gyp_directory_name, build_type))
        elif IsMac():
            directory_names.extend(
                glob.glob(os.path.join(gyp_directory_name, '*.xcodeproj')))

    # mozc_version.txt does not always exist.
    version_file = '%s/mozc_version.txt' % SRC_DIR
    if os.path.exists(version_file):
        file_names.append(version_file)
        build_base = GetBuildBaseName(GetMozcVersion().GetTargetPlatform())
        if build_base:
            directory_names.append(build_base)

    # Remove files.
    for file_name in file_names:
        RemoveFile(file_name)
    # Remove directories.
    for directory_name in directory_names:
        RemoveDirectoryRecursively(directory_name)
Пример #6
0
+      logging.info('removing ibus.gyp.')
+      gyp_file_names.remove('%s/unix/ibus/ibus.gyp' % SRC_DIR)
+  elif options.target_platform == 'ChromeOS':
+    gyp_file_names.extend(glob.glob('%s/unix/ibus/*.gyp' % SRC_DIR))
   elif options.target_platform == 'NaCl':
     # Add chrome NaCl Mozc gyp scripts.
     gyp_file_names.append('%s/chrome/nacl/nacl_extension.gyp' % SRC_DIR)
@@ -314,6 +325,8 @@ def AddTargetPlatformOption(parser):
   # If you want Android build, specify "Android".
   if IsLinux():
     default_target = 'Linux'
+  elif IsNetBSD():
+    default_target = 'NetBSD'
   elif IsWindows():
     default_target = 'Windows'
   elif IsMac():
@@ -511,6 +524,14 @@ def ExpandMetaTarget(options, meta_targe
                SRC_DIR + '/gui/gui.gyp:mozc_tool']
     if PkgExists('ibus-1.0 >= 1.4.1'):
       targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc')
+  elif target_platform == 'NetBSD':
+    targets = [SRC_DIR + '/server/server.gyp:mozc_server',
+               SRC_DIR + '/renderer/renderer.gyp:mozc_renderer',
+               SRC_DIR + '/gui/gui.gyp:mozc_tool']
+    if PkgExists('ibus-1.0 >= 1.4.1'):
+      targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc')
+  elif target_platform == 'ChromeOS':
+    targets.append(SRC_DIR + '/unix/ibus/ibus.gyp:ibus_mozc')
   elif target_platform == 'Mac':
     targets = [SRC_DIR + '/mac/mac.gyp:DiskImage']
   elif target_platform == 'Windows':
Пример #7
0
def ParseGypOptions(args):
  """Parses command line options for the gyp command."""
  parser = optparse.OptionParser(usage='Usage: %prog gyp [options]')
  AddCommonOptions(parser)
  default_branding = 'Mozc'
  parser.add_option('--branding', dest='branding', default=default_branding,
                    help='Specifies the branding. [default: %default]')
  parser.add_option('--gypdir', dest='gypdir',
                    help='Specifies the location of GYP to be used.')
  parser.add_option('--noqt', action='store_true', dest='noqt', default=False)
  parser.add_option('--version_file', dest='version_file',
                    help='use the specified version template file',
                    default='data/version/mozc_version_template.bzl')
  AddTargetPlatformOption(parser)

  # Mac and Linux
  parser.add_option('--warn_as_error', action='store_true',
                    dest='warn_as_error', default=(default_branding != 'Mozc'),
                    help='Treat compiler warning as error. This option is used '
                    'on Mac and Linux.')

  # Linux
  parser.add_option('--server_dir', dest='server_dir',
                    default='',
                    help='A path to the directory where the server executable'
                    'is installed. This option is used only on Linux.')

  # Android
  parser.add_option('--android_arch', dest='android_arch',
                    type='choice',
                    choices=('arm', 'x86', 'mips', 'arm64', 'x86_64', 'mips64'),
                    default='arm',
                    help='[Android build only] Android architecture '
                    '(arm, x86, mips)')
  parser.add_option('--android_application_id', dest='android_application_id',
                    default='org.mozc.android.inputmethod.japanese',
                    help='[Android build only] Android\'s application id'
                    ' (==package ID). '
                    'If set, On Android2.1 preference screen works '
                    'incorrectly and some Java test cases failes because of '
                    'test framework\'s update.')
  parser.add_option('--android_home', dest='android_home', default=None,
                    help='[Android build only] A path to the Android SDK Home. '
                    'If not specified, automatically detected from ANDROID_HOME'
                    ' or PATH.')
  parser.add_option('--android_ndk_home', dest='android_ndk_home', default=None,
                    help='[Android build only] A path to the Android NDK Home. '
                    'If not specified, automatically detected from PATH.')
  parser.add_option('--android_hide_icon', action='store_true',
                    dest='android_hide_icon', default=False)
  parser.add_option('--android_release_icon', action='store_true',
                    dest='android_release_icon', default=False)

  # NaCl
  parser.add_option('--nacl_sdk_root', dest='nacl_sdk_root', default='',
                    help='A path to the root directory of Native Client SDK. '
                    'This is used when NaCl module build.')

  def AddFeatureOption(option_parser, feature_name, macro_name,
                       option_name):
    """Defines options like '--enable_foober' and '--disable_foober'.

    This function defines options like --enable_foober and --disable_foobar
    based on given parameters.

    Args:
      option_parser: An option parser to which options should be added.
      feature_name: A name of the feature. Will be used for option's help.
      macro_name: A macro name which will be defined when this feature is
          enabled. Will be used for option's help.
          Note that the macro is not automatically set.
          Do this by yourself (typically on common.gypi).
      option_name: A base name of the option. If 'foobar' is specified,
          --enable_foobar and --disable_foobar will be defined.

    Raises:
      ValueError: An error occurred when any name parameter is empty.
    """
    if not feature_name:
      raise ValueError('"feature_name" should be specified')
    if not option_name:
      raise ValueError('"option_name" should be specified')
    if not macro_name:
      raise ValueError('"macro_name" should be specified')
    params = {'feature_name': feature_name,
              'option_name': option_name,
              'macro_name': macro_name}
    help_template = ('Intentionally enable or disable %(feature_name)s '
                     'feature with the %(macro_name)s macro defined in code. '
                     '--enable_%(option_name)s enables it, and '
                     '--disable_%(option_name)s disables it. If both options '
                     'are not set, enables the %(feature_name)s feature '
                     'according to the target environment and branding.')
    option_parser.add_option('--enable_%(option_name)s' % params,
                             action='store_true',
                             dest=('enable_%(option_name)s' % params),
                             help=help_template % params)
    option_parser.add_option('--disable_%(option_name)s' % params,
                             action='store_false',
                             dest=('enable_%(option_name)s' % params),
                             help=help_template % params)

  AddFeatureOption(parser, feature_name='cloud handwriting',
                   macro_name='ENABLE_CLOUD_HANDWRITING',
                   option_name='cloud_handwriting')

  if IsWindows():
    parser.add_option('--wix_dir', dest='wix_dir',
                      default=GetDefaultWixPath(),
                      help='A path to the binary directory of wix.')

  if IsWindows() or IsMac():
    parser.add_option('--qtdir', dest='qtdir',
                      default=os.getenv('QTDIR', None),
                      help='Qt base directory to be used.')

  return parser.parse_args(args)