diff --git a/chrome/chromeos/renderer/chromeos_renderer.gyp b/chrome/chromeos/renderer/chromeos_renderer.gyp index 1d44a93..7938f33 100755 --- a/chrome/chromeos/renderer/chromeos_renderer.gyp +++ b/chrome/chromeos/renderer/chromeos_renderer.gyp @@ -63,8 +63,8 @@ { # Protobuf compiler / generator for the mozc inputmethod commands # protocol buffer. - 'target_name': 'mozc_commands_proto', - 'type': 'static_library', + 'target_name': 'gen_candidates_proto', + 'type': 'none', 'sources': [ '<(third_party_dir)/mozc/session/candidates_lite.proto', ], @@ -106,5 +106,15 @@ '<(third_party_dir)/protobuf/protobuf.gyp:protobuf_lite', ], }, + { + 'target_name': 'mozc_candidates_proto', + 'type': 'static_library', + 'sources': [ + '<(protoc_out_dir)/third_party/mozc/session/candidates_lite.pb.cc', + ], + 'dependencies': [ + 'gen_candidates_proto', + ], + }, ] } diff --git a/third_party/gyp/AUTHORS b/third_party/gyp/AUTHORS deleted file mode 100644 index 6db82b9..0000000 --- a/third_party/gyp/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -# Names should be added to this file like so: -# Name or Organization - -Google Inc. -Steven Knight -Ryan Norton diff --git a/third_party/gyp/DEPS b/third_party/gyp/DEPS deleted file mode 100644 index 0e56c06..0000000 --- a/third_party/gyp/DEPS +++ /dev/null @@ -1,8 +0,0 @@ -# DEPS file for gclient use in buildbot execution of gyp tests. -# -# (You don't need to use gclient for normal GYP development work.) - -deps = { - "scons": - "http://src.chromium.org/svn/trunk/src/third_party/scons@44099", -} diff --git a/third_party/gyp/LICENSE b/third_party/gyp/LICENSE deleted file mode 100644 index ab6b011..0000000 --- a/third_party/gyp/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 Google Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/third_party/gyp/MANIFEST b/third_party/gyp/MANIFEST deleted file mode 100644 index 925ecc1..0000000 --- a/third_party/gyp/MANIFEST +++ /dev/null @@ -1,21 +0,0 @@ -setup.py -gyp -LICENSE -AUTHORS -pylib/gyp/MSVSNew.py -pylib/gyp/MSVSProject.py -pylib/gyp/MSVSToolFile.py -pylib/gyp/MSVSUserFile.py -pylib/gyp/MSVSVersion.py -pylib/gyp/SCons.py -pylib/gyp/__init__.py -pylib/gyp/common.py -pylib/gyp/input.py -pylib/gyp/xcodeproj_file.py -pylib/gyp/generator/__init__.py -pylib/gyp/generator/gypd.py -pylib/gyp/generator/gypsh.py -pylib/gyp/generator/make.py -pylib/gyp/generator/msvs.py -pylib/gyp/generator/scons.py -pylib/gyp/generator/xcode.py diff --git a/third_party/gyp/OWNERS b/third_party/gyp/OWNERS deleted file mode 100644 index 72e8ffc..0000000 --- a/third_party/gyp/OWNERS +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/third_party/gyp/PRESUBMIT.py b/third_party/gyp/PRESUBMIT.py deleted file mode 100755 index 737584b..0000000 --- a/third_party/gyp/PRESUBMIT.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - - -"""Top-level presubmit script for GYP. - -See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts -for more details about the presubmit API built into gcl. -""" - - -def CheckChangeOnUpload(input_api, output_api): - report = [] - report.extend(input_api.canned_checks.PanProjectChecks( - input_api, output_api)) - return report - - -def CheckChangeOnCommit(input_api, output_api): - report = [] - license = ( - r'.*? Copyright \(c\) %(year)s Google Inc\. All rights reserved\.\n' - r'.*? Use of this source code is governed by a BSD-style license that ' - r'can be\n' - r'.*? found in the LICENSE file\.\n' - ) % { - 'year': input_api.time.strftime('%Y'), - } - - report.extend(input_api.canned_checks.PanProjectChecks( - input_api, output_api, license_header=license)) - report.extend(input_api.canned_checks.CheckTreeIsOpen( - input_api, output_api, - 'http://gyp-status.appspot.com/status', - 'http://gyp-status.appspot.com/current')) - return report - - -def GetPreferredTrySlaves(): - return ['gyp-win32', 'gyp-win64', 'gyp-linux', 'gyp-mac'] diff --git a/third_party/gyp/README.mozc b/third_party/gyp/README.mozc deleted file mode 100644 index f4e5628..0000000 --- a/third_party/gyp/README.mozc +++ /dev/null @@ -1,12 +0,0 @@ -URL: http://code.google.com/p/gyp/ -Version: r1034 -License: New BSD License -License File: LICENSE - -Description: -This is Mozc's local copy of gyp, a tool that generates native Visual Studio, -Xcode and SCons and/or make build files from a platform-independent input -format. - -Local Modifications: -test directory is removed. diff --git a/third_party/gyp/buildbot/buildbot_run.py b/third_party/gyp/buildbot/buildbot_run.py deleted file mode 100755 index adad7f9..0000000 --- a/third_party/gyp/buildbot/buildbot_run.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - - -"""Argument-less script to select what to run on the buildbots.""" - - -import os -import shutil -import subprocess -import sys - - -def GypTestFormat(title, format, msvs_version=None): - """Run the gyp tests for a given format, emitting annotator tags. - - See annotator docs at: - https://sites.google.com/a/chromium.org/dev/developers/testing/chromium-build-infrastructure/buildbot-annotations - Args: - format: gyp format to test. - Returns: - 0 for sucesss, 1 for failure. - """ - print '@@@BUILD_STEP ' + title + '@@@' - sys.stdout.flush() - buildbot_dir = os.path.dirname(os.path.abspath(__file__)) - trunk_dir = os.path.dirname(buildbot_dir) - root_dir = os.path.dirname(trunk_dir) - env = os.environ.copy() - if msvs_version: - env['GYP_MSVS_VERSION'] = msvs_version - retcode = subprocess.call(' '.join( - [sys.executable, 'trunk/gyptest.py', - '--all', - '--passed', - '--format', format, - '--chdir', 'trunk', - '--path', '../scons']), - cwd=root_dir, env=env, shell=True) - if retcode: - # Emit failure tag, and keep going. - print '@@@STEP_FAILURE@@@' - return 1 - return 0 - - -def GypBuild(): - # Dump out/ directory. - print '@@@BUILD_STEP cleanup@@@' - print 'Removing out/ ...' - shutil.rmtree('out', ignore_errors=True) - print 'Done.' - - retcode = 0 - if sys.platform.startswith('linux'): - retcode += GypTestFormat('scons', format='scons') - retcode += GypTestFormat('make', format='make') - elif sys.platform == 'darwin': - retcode += GypTestFormat('xcode', format='xcode') - retcode += GypTestFormat('make', format='make') - elif sys.platform == 'win32': - retcode += GypTestFormat('msvs-2008', format='msvs', msvs_version='2008') - if os.environ['BUILDBOT_BUILDERNAME'] == 'gyp-win64': - retcode += GypTestFormat('msvs-2010', format='msvs', msvs_version='2010') - else: - raise Exception('Unknown platform') - if retcode: - # TODO(bradnelson): once the annotator supports a postscript (section for - # after the build proper that could be used for cumulative failures), - # use that instead of this. This isolates the final return value so - # that it isn't misattributed to the last stage. - print '@@@BUILD_STEP failures@@@' - sys.exit(retcode) - - -if __name__ == '__main__': - GypBuild() diff --git a/third_party/gyp/codereview.settings b/third_party/gyp/codereview.settings deleted file mode 100644 index a04a244..0000000 --- a/third_party/gyp/codereview.settings +++ /dev/null @@ -1,10 +0,0 @@ -# This file is used by gcl to get repository specific information. -CODE_REVIEW_SERVER: codereview.chromium.org -CC_LIST: gyp-developer@googlegroups.com -VIEW_VC: http://code.google.com/p/gyp/source/detail?r= -TRY_ON_UPLOAD: True -TRYSERVER_PROJECT: gyp -TRYSERVER_PATCHLEVEL: 0 -TRYSERVER_ROOT: trunk -TRYSERVER_SVN_URL: svn://svn.chromium.org/chrome-try/try-nacl - diff --git a/third_party/gyp/gyp b/third_party/gyp/gyp deleted file mode 100755 index d52e711..0000000 --- a/third_party/gyp/gyp +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import sys - -# TODO(mark): sys.path manipulation is some temporary testing stuff. -try: - import gyp -except ImportError, e: - import os.path - sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), 'pylib')) - import gyp - -if __name__ == '__main__': - sys.exit(gyp.main(sys.argv[1:])) diff --git a/third_party/gyp/gyp.bat b/third_party/gyp/gyp.bat deleted file mode 100755 index 90fbc6d..0000000 --- a/third_party/gyp/gyp.bat +++ /dev/null @@ -1,5 +0,0 @@ -@rem Copyright (c) 2009 Google Inc. All rights reserved. -@rem Use of this source code is governed by a BSD-style license that can be -@rem found in the LICENSE file. - -@python "%~dp0/gyp" %* diff --git a/third_party/gyp/gyp_dummy.c b/third_party/gyp/gyp_dummy.c deleted file mode 100644 index fb55bbc..0000000 --- a/third_party/gyp/gyp_dummy.c +++ /dev/null @@ -1,7 +0,0 @@ -/* Copyright (c) 2009 Google Inc. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. */ - -int main() { - return 0; -} diff --git a/third_party/gyp/gyptest.py b/third_party/gyp/gyptest.py deleted file mode 100755 index 0cf38b1..0000000 --- a/third_party/gyp/gyptest.py +++ /dev/null @@ -1,256 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -__doc__ = """ -gyptest.py -- test runner for GYP tests. -""" - -import os -import optparse -import subprocess -import sys - -class CommandRunner: - """ - Executor class for commands, including "commands" implemented by - Python functions. - """ - verbose = True - active = True - - def __init__(self, dictionary={}): - self.subst_dictionary(dictionary) - - def subst_dictionary(self, dictionary): - self._subst_dictionary = dictionary - - def subst(self, string, dictionary=None): - """ - Substitutes (via the format operator) the values in the specified - dictionary into the specified command. - - The command can be an (action, string) tuple. In all cases, we - perform substitution on strings and don't worry if something isn't - a string. (It's probably a Python function to be executed.) - """ - if dictionary is None: - dictionary = self._subst_dictionary - if dictionary: - try: - string = string % dictionary - except TypeError: - pass - return string - - def display(self, command, stdout=None, stderr=None): - if not self.verbose: - return - if type(command) == type(()): - func = command[0] - args = command[1:] - s = '%s(%s)' % (func.__name__, ', '.join(map(repr, args))) - if type(command) == type([]): - # TODO: quote arguments containing spaces - # TODO: handle meta characters? - s = ' '.join(command) - else: - s = self.subst(command) - if not s.endswith('\n'): - s += '\n' - sys.stdout.write(s) - sys.stdout.flush() - - def execute(self, command, stdout=None, stderr=None): - """ - Executes a single command. - """ - if not self.active: - return 0 - if type(command) == type(''): - command = self.subst(command) - cmdargs = shlex.split(command) - if cmdargs[0] == 'cd': - command = (os.chdir,) + tuple(cmdargs[1:]) - if type(command) == type(()): - func = command[0] - args = command[1:] - return func(*args) - else: - if stdout is sys.stdout: - # Same as passing sys.stdout, except python2.4 doesn't fail on it. - subout = None - else: - # Open pipe for anything else so Popen works on python2.4. - subout = subprocess.PIPE - if stderr is sys.stderr: - # Same as passing sys.stderr, except python2.4 doesn't fail on it. - suberr = None - elif stderr is None: - # Merge with stdout if stderr isn't specified. - suberr = subprocess.STDOUT - else: - # Open pipe for anything else so Popen works on python2.4. - suberr = subprocess.PIPE - p = subprocess.Popen(command, - shell=(sys.platform == 'win32'), - stdout=subout, - stderr=suberr) - p.wait() - if stdout is None: - self.stdout = p.stdout.read() - elif stdout is not sys.stdout: - stdout.write(p.stdout.read()) - if stderr not in (None, sys.stderr): - stderr.write(p.stderr.read()) - return p.returncode - - def run(self, command, display=None, stdout=None, stderr=None): - """ - Runs a single command, displaying it first. - """ - if display is None: - display = command - self.display(display) - return self.execute(command, stdout, stderr) - - -class Unbuffered: - def __init__(self, fp): - self.fp = fp - def write(self, arg): - self.fp.write(arg) - self.fp.flush() - def __getattr__(self, attr): - return getattr(self.fp, attr) - -sys.stdout = Unbuffered(sys.stdout) -sys.stderr = Unbuffered(sys.stderr) - - -def find_all_gyptest_files(directory): - result = [] - for root, dirs, files in os.walk(directory): - if '.svn' in dirs: - dirs.remove('.svn') - result.extend([ os.path.join(root, f) for f in files - if f.startswith('gyptest') and f.endswith('.py') ]) - result.sort() - return result - - -def main(argv=None): - if argv is None: - argv = sys.argv - - usage = "gyptest.py [-ahlnq] [-f formats] [test ...]" - parser = optparse.OptionParser(usage=usage) - parser.add_option("-a", "--all", action="store_true", - help="run all tests") - parser.add_option("-C", "--chdir", action="store", default=None, - help="chdir to the specified directory") - parser.add_option("-f", "--format", action="store", default='', - help="run tests with the specified formats") - parser.add_option("-l", "--list", action="store_true", - help="list available tests and exit") - parser.add_option("-n", "--no-exec", action="store_true", - help="no execute, just print the command line") - parser.add_option("--passed", action="store_true", - help="report passed tests") - parser.add_option("--path", action="append", default=[], - help="additional $PATH directory") - parser.add_option("-q", "--quiet", action="store_true", - help="quiet, don't print test command lines") - opts, args = parser.parse_args(argv[1:]) - - if opts.chdir: - os.chdir(opts.chdir) - - if opts.path: - os.environ['PATH'] += ':' + ':'.join(opts.path) - - if not args: - if not opts.all: - sys.stderr.write('Specify -a to get all tests.\n') - return 1 - args = ['test'] - - tests = [] - for arg in args: - if os.path.isdir(arg): - tests.extend(find_all_gyptest_files(os.path.normpath(arg))) - else: - tests.append(arg) - - if opts.list: - for test in tests: - print test - sys.exit(0) - - CommandRunner.verbose = not opts.quiet - CommandRunner.active = not opts.no_exec - cr = CommandRunner() - - os.environ['PYTHONPATH'] = os.path.abspath('test/lib') - if not opts.quiet: - sys.stdout.write('PYTHONPATH=%s\n' % os.environ['PYTHONPATH']) - - passed = [] - failed = [] - no_result = [] - - if opts.format: - format_list = opts.format.split(',') - else: - # TODO: not duplicate this mapping from pylib/gyp/__init__.py - format_list = { - 'freebsd7': ['make'], - 'freebsd8': ['make'], - 'cygwin': ['msvs'], - 'win32': ['msvs'], - 'linux2': ['make', 'ninja'], - 'linux3': ['make', 'ninja'], - 'darwin': ['make', 'xcode'], - }[sys.platform] - - for format in format_list: - os.environ['TESTGYP_FORMAT'] = format - if not opts.quiet: - sys.stdout.write('TESTGYP_FORMAT=%s\n' % format) - - for test in tests: - status = cr.run([sys.executable, test], - stdout=sys.stdout, - stderr=sys.stderr) - if status == 2: - no_result.append(test) - elif status: - failed.append(test) - else: - passed.append(test) - - if not opts.quiet: - def report(description, tests): - if tests: - if len(tests) == 1: - sys.stdout.write("\n%s the following test:\n" % description) - else: - fmt = "\n%s the following %d tests:\n" - sys.stdout.write(fmt % (description, len(tests))) - sys.stdout.write("\t" + "\n\t".join(tests) + "\n") - - if opts.passed: - report("Passed", passed) - report("Failed", failed) - report("No result from", no_result) - - if failed: - return 1 - else: - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/third_party/gyp/pylib/gyp/MSVSNew.py b/third_party/gyp/pylib/gyp/MSVSNew.py deleted file mode 100644 index ae8cbee..0000000 --- a/third_party/gyp/pylib/gyp/MSVSNew.py +++ /dev/null @@ -1,340 +0,0 @@ -#!/usr/bin/python2.4 - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""New implementation of Visual Studio project generation for SCons.""" - -import common -import os -import random - -import gyp.common - -# hashlib is supplied as of Python 2.5 as the replacement interface for md5 -# and other secure hashes. In 2.6, md5 is deprecated. Import hashlib if -# available, avoiding a deprecation warning under 2.6. Import md5 otherwise, -# preserving 2.4 compatibility. -try: - import hashlib - _new_md5 = hashlib.md5 -except ImportError: - import md5 - _new_md5 = md5.new - - -# Initialize random number generator -random.seed() - -# GUIDs for project types -ENTRY_TYPE_GUIDS = { - 'project': '{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}', - 'folder': '{2150E333-8FDC-42A3-9474-1A3956D46DE8}', -} - -#------------------------------------------------------------------------------ -# Helper functions - - -def MakeGuid(name, seed='msvs_new'): - """Returns a GUID for the specified target name. - - Args: - name: Target name. - seed: Seed for MD5 hash. - Returns: - A GUID-line string calculated from the name and seed. - - This generates something which looks like a GUID, but depends only on the - name and seed. This means the same name/seed will always generate the same - GUID, so that projects and solutions which refer to each other can explicitly - determine the GUID to refer to explicitly. It also means that the GUID will - not change when the project for a target is rebuilt. - """ - # Calculate a MD5 signature for the seed and name. - d = _new_md5(str(seed) + str(name)).hexdigest().upper() - # Convert most of the signature to GUID form (discard the rest) - guid = ('{' + d[:8] + '-' + d[8:12] + '-' + d[12:16] + '-' + d[16:20] - + '-' + d[20:32] + '}') - return guid - -#------------------------------------------------------------------------------ - - -class MSVSFolder: - """Folder in a Visual Studio project or solution.""" - - def __init__(self, path, name = None, entries = None, - guid = None, items = None): - """Initializes the folder. - - Args: - path: Full path to the folder. - name: Name of the folder. - entries: List of folder entries to nest inside this folder. May contain - Folder or Project objects. May be None, if the folder is empty. - guid: GUID to use for folder, if not None. - items: List of solution items to include in the folder project. May be - None, if the folder does not directly contain items. - """ - if name: - self.name = name - else: - # Use last layer. - self.name = os.path.basename(path) - - self.path = path - self.guid = guid - - # Copy passed lists (or set to empty lists) - self.entries = list(entries or []) - self.items = list(items or []) - - self.entry_type_guid = ENTRY_TYPE_GUIDS['folder'] - - def get_guid(self): - if self.guid is None: - # Use consistent guids for folders (so things don't regenerate). - self.guid = MakeGuid(self.path, seed='msvs_folder') - return self.guid - - -#------------------------------------------------------------------------------ - - -class MSVSProject: - """Visual Studio project.""" - - def __init__(self, path, name = None, dependencies = None, guid = None, - spec = None, build_file = None, config_platform_overrides = None, - fixpath_prefix = None): - """Initializes the project. - - Args: - path: Absolute path to the project file. - name: Name of project. If None, the name will be the same as the base - name of the project file. - dependencies: List of other Project objects this project is dependent - upon, if not None. - guid: GUID to use for project, if not None. - spec: Dictionary specifying how to build this project. - build_file: Filename of the .gyp file that the vcproj file comes from. - config_platform_overrides: optional dict of configuration platforms to - used in place of the default for this target. - fixpath_prefix: the path used to adjust the behavior of _fixpath - """ - self.path = path - self.guid = guid - self.spec = spec - self.build_file = build_file - # Use project filename if name not specified - self.name = name or os.path.splitext(os.path.basename(path))[0] - - # Copy passed lists (or set to empty lists) - self.dependencies = list(dependencies or []) - - self.entry_type_guid = ENTRY_TYPE_GUIDS['project'] - - if config_platform_overrides: - self.config_platform_overrides = config_platform_overrides - else: - self.config_platform_overrides = {} - self.fixpath_prefix = fixpath_prefix - - def set_dependencies(self, dependencies): - self.dependencies = list(dependencies or []) - - def get_guid(self): - if self.guid is None: - # Set GUID from path - # TODO(rspangler): This is fragile. - # 1. We can't just use the project filename sans path, since there could - # be multiple projects with the same base name (for example, - # foo/unittest.vcproj and bar/unittest.vcproj). - # 2. The path needs to be relative to $SOURCE_ROOT, so that the project - # GUID is the same whether it's included from base/base.sln or - # foo/bar/baz/baz.sln. - # 3. The GUID needs to be the same each time this builder is invoked, so - # that we don't need to rebuild the solution when the project changes. - # 4. We should be able to handle pre-built project files by reading the - # GUID from the files. - self.guid = MakeGuid(self.name) - return self.guid - -#------------------------------------------------------------------------------ - - -class MSVSSolution: - """Visual Studio solution.""" - - def __init__(self, path, version, entries=None, variants=None, - websiteProperties=True): - """Initializes the solution. - - Args: - path: Path to solution file. - version: Format version to emit. - entries: List of entries in solution. May contain Folder or Project - objects. May be None, if the folder is empty. - variants: List of build variant strings. If none, a default list will - be used. - websiteProperties: Flag to decide if the website properties section - is generated. - """ - self.path = path - self.websiteProperties = websiteProperties - self.version = version - - # Copy passed lists (or set to empty lists) - self.entries = list(entries or []) - - if variants: - # Copy passed list - self.variants = variants[:] - else: - # Use default - self.variants = ['Debug|Win32', 'Release|Win32'] - # TODO(rspangler): Need to be able to handle a mapping of solution config - # to project config. Should we be able to handle variants being a dict, - # or add a separate variant_map variable? If it's a dict, we can't - # guarantee the order of variants since dict keys aren't ordered. - - - # TODO(rspangler): Automatically write to disk for now; should delay until - # node-evaluation time. - self.Write() - - - def Write(self, writer=common.WriteOnDiff): - """Writes the solution file to disk. - - Raises: - IndexError: An entry appears multiple times. - """ - # Walk the entry tree and collect all the folders and projects. - all_entries = set() - entries_to_check = self.entries[:] - while entries_to_check: - e = entries_to_check.pop(0) - - # If this entry has been visited, nothing to do. - if e in all_entries: - continue - - all_entries.add(e) - - # If this is a folder, check its entries too. - if isinstance(e, MSVSFolder): - entries_to_check += e.entries - - # Sort by name then guid (so things are in order on vs2008). - def NameThenGuid(a, b): - if a.name < b.name: return -1 - if a.name > b.name: return 1 - if a.get_guid() < b.get_guid(): return -1 - if a.get_guid() > b.get_guid(): return 1 - return 0 - - all_entries = sorted(all_entries, NameThenGuid) - - # Open file and print header - f = writer(self.path) - f.write('Microsoft Visual Studio Solution File, ' - 'Format Version %s\r\n' % self.version.SolutionVersion()) - f.write('# %s\r\n' % self.version.Description()) - - # Project entries - sln_root = os.path.split(self.path)[0] - for e in all_entries: - relative_path = gyp.common.RelativePath(e.path, sln_root) - # msbuild does not accept an empty folder_name. - # use '.' in case relative_path is empty. - folder_name = relative_path.replace('/', '\\') or '.' - f.write('Project("%s") = "%s", "%s", "%s"\r\n' % ( - e.entry_type_guid, # Entry type GUID - e.name, # Folder name - folder_name, # Folder name (again) - e.get_guid(), # Entry GUID - )) - - # TODO(rspangler): Need a way to configure this stuff - if self.websiteProperties: - f.write('\tProjectSection(WebsiteProperties) = preProject\r\n' - '\t\tDebug.AspNetCompiler.Debug = "True"\r\n' - '\t\tRelease.AspNetCompiler.Debug = "False"\r\n' - '\tEndProjectSection\r\n') - - if isinstance(e, MSVSFolder): - if e.items: - f.write('\tProjectSection(SolutionItems) = preProject\r\n') - for i in e.items: - f.write('\t\t%s = %s\r\n' % (i, i)) - f.write('\tEndProjectSection\r\n') - - if isinstance(e, MSVSProject): - if e.dependencies: - f.write('\tProjectSection(ProjectDependencies) = postProject\r\n') - for d in e.dependencies: - f.write('\t\t%s = %s\r\n' % (d.get_guid(), d.get_guid())) - f.write('\tEndProjectSection\r\n') - - f.write('EndProject\r\n') - - # Global section - f.write('Global\r\n') - - # Configurations (variants) - f.write('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n') - for v in self.variants: - f.write('\t\t%s = %s\r\n' % (v, v)) - f.write('\tEndGlobalSection\r\n') - - # Sort config guids for easier diffing of solution changes. - config_guids = [] - config_guids_overrides = {} - for e in all_entries: - if isinstance(e, MSVSProject): - config_guids.append(e.get_guid()) - config_guids_overrides[e.get_guid()] = e.config_platform_overrides - config_guids.sort() - - f.write('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n') - for g in config_guids: - for v in self.variants: - nv = config_guids_overrides[g].get(v, v) - # Pick which project configuration to build for this solution - # configuration. - f.write('\t\t%s.%s.ActiveCfg = %s\r\n' % ( - g, # Project GUID - v, # Solution build configuration - nv, # Project build config for that solution config - )) - - # Enable project in this solution configuration. - f.write('\t\t%s.%s.Build.0 = %s\r\n' % ( - g, # Project GUID - v, # Solution build configuration - nv, # Project build config for that solution config - )) - f.write('\tEndGlobalSection\r\n') - - # TODO(rspangler): Should be able to configure this stuff too (though I've - # never seen this be any different) - f.write('\tGlobalSection(SolutionProperties) = preSolution\r\n') - f.write('\t\tHideSolutionNode = FALSE\r\n') - f.write('\tEndGlobalSection\r\n') - - # Folder mappings - # TODO(rspangler): Should omit this section if there are no folders - f.write('\tGlobalSection(NestedProjects) = preSolution\r\n') - for e in all_entries: - if not isinstance(e, MSVSFolder): - continue # Does not apply to projects, only folders - for subentry in e.entries: - f.write('\t\t%s = %s\r\n' % (subentry.get_guid(), e.get_guid())) - f.write('\tEndGlobalSection\r\n') - - f.write('EndGlobal\r\n') - - f.close() diff --git a/third_party/gyp/pylib/gyp/MSVSProject.py b/third_party/gyp/pylib/gyp/MSVSProject.py deleted file mode 100644 index fab11f9..0000000 --- a/third_party/gyp/pylib/gyp/MSVSProject.py +++ /dev/null @@ -1,212 +0,0 @@ -#!/usr/bin/python2.4 - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Visual Studio project reader/writer.""" - -import common -import gyp.easy_xml as easy_xml - -#------------------------------------------------------------------------------ - - -class Tool(object): - """Visual Studio tool.""" - - def __init__(self, name, attrs=None): - """Initializes the tool. - - Args: - name: Tool name. - attrs: Dict of tool attributes; may be None. - """ - self._attrs = attrs or {} - self._attrs['Name'] = name - - def _GetSpecification(self): - """Creates an element for the tool. - - Returns: - A new xml.dom.Element for the tool. - """ - return ['Tool', self._attrs] - -class Filter(object): - """Visual Studio filter - that is, a virtual folder.""" - - def __init__(self, name, contents=None): - """Initializes the folder. - - Args: - name: Filter (folder) name. - contents: List of filenames and/or Filter objects contained. - """ - self.name = name - self.contents = list(contents or []) - - -#------------------------------------------------------------------------------ - - -class Writer(object): - """Visual Studio XML project writer.""" - - def __init__(self, project_path, version, name, guid=None, platforms=None): - """Initializes the project. - - Args: - project_path: Path to the project file. - version: Format version to emit. - name: Name of the project. - guid: GUID to use for project, if not None. - platforms: Array of string, the supported platforms. If null, ['Win32'] - """ - self.project_path = project_path - self.version = version - self.name = name - self.guid = guid - - # Default to Win32 for platforms. - if not platforms: - platforms = ['Win32'] - - # Initialize the specifications of the various sections. - self.platform_section = ['Platforms'] - for platform in platforms: - self.platform_section.append(['Platform', {'Name': platform}]) - self.tool_files_section = ['ToolFiles'] - self.configurations_section = ['Configurations'] - self.files_section = ['Files'] - - # Keep a dict keyed on filename to speed up access. - self.files_dict = dict() - - def AddToolFile(self, path): - """Adds a tool file to the project. - - Args: - path: Relative path from project to tool file. - """ - self.tool_files_section.append(['ToolFile', {'RelativePath': path}]) - - def _GetSpecForConfiguration(self, config_type, config_name, attrs, tools): - """Returns the specification for a configuration. - - Args: - config_type: Type of configuration node. - config_name: Configuration name. - attrs: Dict of configuration attributes; may be None. - tools: List of tools (strings or Tool objects); may be None. - Returns: - """ - # Handle defaults - if not attrs: - attrs = {} - if not tools: - tools = [] - - # Add configuration node and its attributes - node_attrs = attrs.copy() - node_attrs['Name'] = config_name - specification = [config_type, node_attrs] - - # Add tool nodes and their attributes - if tools: - for t in tools: - if isinstance(t, Tool): - specification.append(t._GetSpecification()) - else: - specification.append(Tool(t)._GetSpecification()) - return specification - - - def AddConfig(self, name, attrs=None, tools=None): - """Adds a configuration to the project. - - Args: - name: Configuration name. - attrs: Dict of configuration attributes; may be None. - tools: List of tools (strings or Tool objects); may be None. - """ - spec = self._GetSpecForConfiguration('Configuration', name, attrs, tools) - self.configurations_section.append(spec) - - def _AddFilesToNode(self, parent, files): - """Adds files and/or filters to the parent node. - - Args: - parent: Destination node - files: A list of Filter objects and/or relative paths to files. - - Will call itself recursively, if the files list contains Filter objects. - """ - for f in files: - if isinstance(f, Filter): - node = ['Filter', {'Name': f.name}] - self._AddFilesToNode(node, f.contents) - else: - node = ['File', {'RelativePath': f}] - self.files_dict[f] = node - parent.append(node) - - def AddFiles(self, files): - """Adds files to the project. - - Args: - files: A list of Filter objects and/or relative paths to files. - - This makes a copy of the file/filter tree at the time of this call. If you - later add files to a Filter object which was passed into a previous call - to AddFiles(), it will not be reflected in this project. - """ - self._AddFilesToNode(self.files_section, files) - # TODO(rspangler) This also doesn't handle adding files to an existing - # filter. That is, it doesn't merge the trees. - - def AddFileConfig(self, path, config, attrs=None, tools=None): - """Adds a configuration to a file. - - Args: - path: Relative path to the file. - config: Name of configuration to add. - attrs: Dict of configuration attributes; may be None. - tools: List of tools (strings or Tool objects); may be None. - - Raises: - ValueError: Relative path does not match any file added via AddFiles(). - """ - # Find the file node with the right relative path - parent = self.files_dict.get(path) - if not parent: - raise ValueError('AddFileConfig: file "%s" not in project.' % path) - - # Add the config to the file node - spec = self._GetSpecForConfiguration('FileConfiguration', config, attrs, - tools) - parent.append(spec) - - def WriteIfChanged(self): - """Writes the project file.""" - # First create XML content definition - content = [ - 'VisualStudioProject', - {'ProjectType': 'Visual C++', - 'Version': self.version.ProjectVersion(), - 'Name': self.name, - 'ProjectGUID': self.guid, - 'RootNamespace': self.name, - 'Keyword': 'Win32Proj' - }, - self.platform_section, - self.tool_files_section, - self.configurations_section, - ['References'], # empty section - self.files_section, - ['Globals'] # empty section - ] - easy_xml.WriteXmlIfChanged(content, self.project_path, - encoding="Windows-1252") - -#------------------------------------------------------------------------------ diff --git a/third_party/gyp/pylib/gyp/MSVSSettings.py b/third_party/gyp/pylib/gyp/MSVSSettings.py deleted file mode 100644 index 496f179..0000000 --- a/third_party/gyp/pylib/gyp/MSVSSettings.py +++ /dev/null @@ -1,1033 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Code to validate and convert settings of the Microsoft build tools. - -This file contains code to validate and convert settings of the Microsoft -build tools. The function ConvertToMSBuildSettings(), ValidateMSVSSettings(), -and ValidateMSBuildSettings() are the entry points. - -This file was created by comparing the projects created by Visual Studio 2008 -and Visual Studio 2010 for all available settings through the user interface. -The MSBuild schemas were also considered. They are typically found in the -MSBuild install directory, e.g. c:\Program Files (x86)\MSBuild -""" - -import sys - - -# Dictionaries of settings validators. The key is the tool name, the value is -# a dictionary mapping setting names to validation functions. -_msvs_validators = {} -_msbuild_validators = {} - - -# A dictionary of settings converters. The key is the tool name, the value is -# a dictionary mapping setting names to conversion functions. -_msvs_to_msbuild_converters = {} - - -# Tool name mapping from MSVS to MSBuild. -_msbuild_name_of_tool = {} - - -class _Tool(object): - """Represents a tool used by MSVS or MSBuild. - - Attributes: - msvs_name: The name of the tool in MSVS. - msbuild_name: The name of the tool in MSBuild. - """ - - def __init__(self, msvs_name, msbuild_name): - self.msvs_name = msvs_name - self.msbuild_name = msbuild_name - - -def _AddTool(tool): - """Adds a tool to the four dictionaries used to process settings. - - This only defines the tool. Each setting also needs to be added. - - Args: - tool: The _Tool object to be added. - """ - _msvs_validators[tool.msvs_name] = {} - _msbuild_validators[tool.msbuild_name] = {} - _msvs_to_msbuild_converters[tool.msvs_name] = {} - _msbuild_name_of_tool[tool.msvs_name] = tool.msbuild_name - - -def _GetMSBuildToolSettings(msbuild_settings, tool): - """Returns an MSBuild tool dictionary. Creates it if needed.""" - return msbuild_settings.setdefault(tool.msbuild_name, {}) - - -class _Type(object): - """Type of settings (Base class).""" - - def ValidateMSVS(self, value): - """Verifies that the value is legal for MSVS. - - Args: - value: the value to check for this type. - - Raises: - ValueError if value is not valid for MSVS. - """ - - def ValidateMSBuild(self, value): - """Verifies that the value is legal for MSBuild. - - Args: - value: the value to check for this type. - - Raises: - ValueError if value is not valid for MSBuild. - """ - - def ConvertToMSBuild(self, value): - """Returns the MSBuild equivalent of the MSVS value given. - - Args: - value: the MSVS value to convert. - - Returns: - the MSBuild equivalent. - - Raises: - ValueError if value is not valid. - """ - return value - - -class _String(_Type): - """A setting that's just a string.""" - - def ValidateMSVS(self, value): - if not isinstance(value, basestring): - raise ValueError('expected string; got %r' % value) - - def ValidateMSBuild(self, value): - if not isinstance(value, basestring): - raise ValueError('expected string; got %r' % value) - - def ConvertToMSBuild(self, value): - # Convert the macros - return ConvertVCMacrosToMSBuild(value) - - -class _StringList(_Type): - """A settings that's a list of strings.""" - - def ValidateMSVS(self, value): - if not isinstance(value, basestring) and not isinstance(value, list): - raise ValueError('expected string list; got %r' % value) - - def ValidateMSBuild(self, value): - if not isinstance(value, basestring) and not isinstance(value, list): - raise ValueError('expected string list; got %r' % value) - - def ConvertToMSBuild(self, value): - # Convert the macros - if isinstance(value, list): - return [ConvertVCMacrosToMSBuild(i) for i in value] - else: - return ConvertVCMacrosToMSBuild(value) - - -class _Boolean(_Type): - """Boolean settings, can have the values 'false' or 'true'.""" - - def _Validate(self, value): - if value != 'true' and value != 'false': - raise ValueError('expected bool; got %r' % value) - - def ValidateMSVS(self, value): - self._Validate(value) - - def ValidateMSBuild(self, value): - self._Validate(value) - - def ConvertToMSBuild(self, value): - self._Validate(value) - return value - - -class _Integer(_Type): - """Integer settings.""" - - def __init__(self, msbuild_base=10): - _Type.__init__(self) - self._msbuild_base = msbuild_base - - def ValidateMSVS(self, value): - # Try to convert, this will raise ValueError if invalid. - self.ConvertToMSBuild(value) - - def ValidateMSBuild(self, value): - # Try to convert, this will raise ValueError if invalid. - int(value, self._msbuild_base) - - def ConvertToMSBuild(self, value): - msbuild_format = (self._msbuild_base == 10) and '%d' or '0x%04x' - return msbuild_format % int(value) - - -class _Enumeration(_Type): - """Type of settings that is an enumeration. - - In MSVS, the values are indexes like '0', '1', and '2'. - MSBuild uses text labels that are more representative, like 'Win32'. - - Constructor args: - label_list: an array of MSBuild labels that correspond to the MSVS index. - In the rare cases where MSVS has skipped an index value, None is - used in the array to indicate the unused spot. - new: an array of labels that are new to MSBuild. - """ - - def __init__(self, label_list, new=None): - _Type.__init__(self) - self._label_list = label_list - self._msbuild_values = set(value for value in label_list - if value is not None) - if new is not None: - self._msbuild_values.update(new) - - def ValidateMSVS(self, value): - # Try to convert. It will raise an exception if not valid. - self.ConvertToMSBuild(value) - - def ValidateMSBuild(self, value): - if value not in self._msbuild_values: - raise ValueError('unrecognized enumerated value %s' % value) - - def ConvertToMSBuild(self, value): - index = int(value) - if index < 0 or index >= len(self._label_list): - raise ValueError('index value (%d) not in expected range [0, %d)' % - (index, len(self._label_list))) - label = self._label_list[index] - if label is None: - raise ValueError('converted value for %s not specified.' % value) - return label - - -# Instantiate the various generic types. -_boolean = _Boolean() -_integer = _Integer() -# For now, we don't do any special validation on these types: -_string = _String() -_file_name = _String() -_folder_name = _String() -_file_list = _StringList() -_folder_list = _StringList() -_string_list = _StringList() -# Some boolean settings went from numerical values to boolean. The -# mapping is 0: default, 1: false, 2: true. -_newly_boolean = _Enumeration(['', 'false', 'true']) - - -def _Same(tool, name, setting_type): - """Defines a setting that has the same name in MSVS and MSBuild. - - Args: - tool: a dictionary that gives the names of the tool for MSVS and MSBuild. - name: the name of the setting. - setting_type: the type of this setting. - """ - _Renamed(tool, name, name, setting_type) - - -def _Renamed(tool, msvs_name, msbuild_name, setting_type): - """Defines a setting for which the name has changed. - - Args: - tool: a dictionary that gives the names of the tool for MSVS and MSBuild. - msvs_name: the name of the MSVS setting. - msbuild_name: the name of the MSBuild setting. - setting_type: the type of this setting. - """ - - def _Translate(value, msbuild_settings): - msbuild_tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool) - msbuild_tool_settings[msbuild_name] = setting_type.ConvertToMSBuild(value) - - _msvs_validators[tool.msvs_name][msvs_name] = setting_type.ValidateMSVS - _msbuild_validators[tool.msbuild_name][msbuild_name] = ( - setting_type.ValidateMSBuild) - _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate - - -def _Moved(tool, settings_name, msbuild_tool_name, setting_type): - _MovedAndRenamed(tool, settings_name, msbuild_tool_name, settings_name, - setting_type) - - -def _MovedAndRenamed(tool, msvs_settings_name, msbuild_tool_name, - msbuild_settings_name, setting_type): - """Defines a setting that may have moved to a new section. - - Args: - tool: a dictionary that gives the names of the tool for MSVS and MSBuild. - msvs_settings_name: the MSVS name of the setting. - msbuild_tool_name: the name of the MSBuild tool to place the setting under. - msbuild_settings_name: the MSBuild name of the setting. - setting_type: the type of this setting. - """ - - def _Translate(value, msbuild_settings): - tool_settings = msbuild_settings.setdefault(msbuild_tool_name, {}) - tool_settings[msbuild_settings_name] = setting_type.ConvertToMSBuild(value) - - _msvs_validators[tool.msvs_name][msvs_settings_name] = ( - setting_type.ValidateMSVS) - validator = setting_type.ValidateMSBuild - _msbuild_validators[msbuild_tool_name][msbuild_settings_name] = validator - _msvs_to_msbuild_converters[tool.msvs_name][msvs_settings_name] = _Translate - - -def _MSVSOnly(tool, name, setting_type): - """Defines a setting that is only found in MSVS. - - Args: - tool: a dictionary that gives the names of the tool for MSVS and MSBuild. - name: the name of the setting. - setting_type: the type of this setting. - """ - - def _Translate(unused_value, unused_msbuild_settings): - # Since this is for MSVS only settings, no translation will happen. - pass - - _msvs_validators[tool.msvs_name][name] = setting_type.ValidateMSVS - _msvs_to_msbuild_converters[tool.msvs_name][name] = _Translate - - -def _MSBuildOnly(tool, name, setting_type): - """Defines a setting that is only found in MSBuild. - - Args: - tool: a dictionary that gives the names of the tool for MSVS and MSBuild. - name: the name of the setting. - setting_type: the type of this setting. - """ - _msbuild_validators[tool.msbuild_name][name] = setting_type.ValidateMSBuild - - -def _ConvertedToAdditionalOption(tool, msvs_name, flag): - """Defines a setting that's handled via a command line option in MSBuild. - - Args: - tool: a dictionary that gives the names of the tool for MSVS and MSBuild. - msvs_name: the name of the MSVS setting that if 'true' becomes a flag - flag: the flag to insert at the end of the AdditionalOptions - """ - - def _Translate(value, msbuild_settings): - if value == 'true': - tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool) - if 'AdditionalOptions' in tool_settings: - new_flags = '%s %s' % (tool_settings['AdditionalOptions'], flag) - else: - new_flags = flag - tool_settings['AdditionalOptions'] = new_flags - _msvs_validators[tool.msvs_name][msvs_name] = _boolean.ValidateMSVS - _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate - - -def _CustomGeneratePreprocessedFile(tool, msvs_name): - def _Translate(value, msbuild_settings): - tool_settings = _GetMSBuildToolSettings(msbuild_settings, tool) - if value == '0': - tool_settings['PreprocessToFile'] = 'false' - tool_settings['PreprocessSuppressLineNumbers'] = 'false' - elif value == '1': # /P - tool_settings['PreprocessToFile'] = 'true' - tool_settings['PreprocessSuppressLineNumbers'] = 'false' - elif value == '2': # /EP /P - tool_settings['PreprocessToFile'] = 'true' - tool_settings['PreprocessSuppressLineNumbers'] = 'true' - else: - raise ValueError('value must be one of [0, 1, 2]; got %s' % value) - # Create a bogus validator that looks for '0', '1', or '2' - msvs_validator = _Enumeration(['a', 'b', 'c']).ValidateMSVS - _msvs_validators[tool.msvs_name][msvs_name] = msvs_validator - msbuild_validator = _boolean.ValidateMSBuild - msbuild_tool_validators = _msbuild_validators[tool.msbuild_name] - msbuild_tool_validators['PreprocessToFile'] = msbuild_validator - msbuild_tool_validators['PreprocessSuppressLineNumbers'] = msbuild_validator - _msvs_to_msbuild_converters[tool.msvs_name][msvs_name] = _Translate - - -def ConvertVCMacrosToMSBuild(s): - """Convert the the MSVS macros found in the string to the MSBuild equivalent. - - This list is probably not exhaustive. Add as needed. - """ - if '$' in s: - replace_map = { - '$(ConfigurationName)': '$(Configuration)', - '$(InputDir)': '%(RootDir)%(Directory)', - '$(InputExt)': '%(Extension)', - '$(InputFileName)': '%(Filename)%(Extension)', - '$(InputName)': '%(Filename)', - '$(InputPath)': '%(FullPath)', - '$(ParentName)': '$(ProjectFileName)', - '$(PlatformName)': '$(Platform)', - '$(SafeInputName)': '%(Filename)', - - '$(IntDir)\\': '$(IntDir)', - '$(OutDir)\\': '$(OutDir)', - '$(IntDir)/': '$(IntDir)', - '$(OutDir)/': '$(OutDir)', - } - for old, new in replace_map.iteritems(): - s = s.replace(old, new) - return s - - -def ConvertToMSBuildSettings(msvs_settings, stderr=sys.stderr): - """Converts MSVS settings (VS2008 and earlier) to MSBuild settings (VS2010+). - - Args: - msvs_settings: A dictionary. The key is the tool name. The values are - themselves dictionaries of settings and their values. - stderr: The stream receiving the error messages. - - Returns: - A dictionary of MSBuild settings. The key is either the MSBuild tool name - or the empty string (for the global settings). The values are themselves - dictionaries of settings and their values. - """ - msbuild_settings = {} - for msvs_tool_name, msvs_tool_settings in msvs_settings.iteritems(): - if msvs_tool_name in _msvs_to_msbuild_converters: - msvs_tool = _msvs_to_msbuild_converters[msvs_tool_name] - for msvs_setting, msvs_value in msvs_tool_settings.iteritems(): - if msvs_setting in msvs_tool: - # Invoke the translation function. - try: - msvs_tool[msvs_setting](msvs_value, msbuild_settings) - except ValueError, e: - print >> stderr, ('Warning: while converting %s/%s to MSBuild, ' - '%s' % (msvs_tool_name, msvs_setting, e)) - else: - # We don't know this setting. Give a warning. - print >> stderr, ('Warning: unrecognized setting %s/%s ' - 'while converting to MSBuild.' % - (msvs_tool_name, msvs_setting)) - else: - print >> stderr, ('Warning: unrecognized tool %s while converting to ' - 'MSBuild.' % msvs_tool_name) - return msbuild_settings - - -def ValidateMSVSSettings(settings, stderr=sys.stderr): - """Validates that the names of the settings are valid for MSVS. - - Args: - settings: A dictionary. The key is the tool name. The values are - themselves dictionaries of settings and their values. - stderr: The stream receiving the error messages. - """ - _ValidateSettings(_msvs_validators, settings, stderr) - - -def ValidateMSBuildSettings(settings, stderr=sys.stderr): - """Validates that the names of the settings are valid for MSBuild. - - Args: - settings: A dictionary. The key is the tool name. The values are - themselves dictionaries of settings and their values. - stderr: The stream receiving the error messages. - """ - _ValidateSettings(_msbuild_validators, settings, stderr) - - -def _ValidateSettings(validators, settings, stderr): - """Validates that the settings are valid for MSBuild or MSVS. - - We currently only validate the names of the settings, not their values. - - Args: - validators: A dictionary of tools and their validators. - settings: A dictionary. The key is the tool name. The values are - themselves dictionaries of settings and their values. - stderr: The stream receiving the error messages. - """ - for tool_name in settings: - if tool_name in validators: - tool_validators = validators[tool_name] - for setting, value in settings[tool_name].iteritems(): - if setting in tool_validators: - try: - tool_validators[setting](value) - except ValueError, e: - print >> stderr, ('Warning: for %s/%s, %s' % - (tool_name, setting, e)) - else: - print >> stderr, ('Warning: unrecognized setting %s/%s' % - (tool_name, setting)) - else: - print >> stderr, ('Warning: unrecognized tool %s' % tool_name) - - -# MSVS and MBuild names of the tools. -_compile = _Tool('VCCLCompilerTool', 'ClCompile') -_link = _Tool('VCLinkerTool', 'Link') -_midl = _Tool('VCMIDLTool', 'Midl') -_rc = _Tool('VCResourceCompilerTool', 'ResourceCompile') -_lib = _Tool('VCLibrarianTool', 'Lib') -_manifest = _Tool('VCManifestTool', 'Mt') - - -_AddTool(_compile) -_AddTool(_link) -_AddTool(_midl) -_AddTool(_rc) -_AddTool(_lib) -_AddTool(_manifest) -# Add sections only found in the MSBuild settings. -_msbuild_validators[''] = {} -_msbuild_validators['ProjectReference'] = {} -_msbuild_validators['ManifestResourceCompile'] = {} - -# Descriptions of the compiler options, i.e. VCCLCompilerTool in MSVS and -# ClCompile in MSBuild. -# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\cl.xml" for -# the schema of the MSBuild ClCompile settings. - -# Options that have the same name in MSVS and MSBuild -_Same(_compile, 'AdditionalIncludeDirectories', _folder_list) # /I -_Same(_compile, 'AdditionalOptions', _string_list) -_Same(_compile, 'AdditionalUsingDirectories', _folder_list) # /AI -_Same(_compile, 'AssemblerListingLocation', _file_name) # /Fa -_Same(_compile, 'BrowseInformationFile', _file_name) -_Same(_compile, 'BufferSecurityCheck', _boolean) # /GS -_Same(_compile, 'DisableLanguageExtensions', _boolean) # /Za -_Same(_compile, 'DisableSpecificWarnings', _string_list) # /wd -_Same(_compile, 'EnableFiberSafeOptimizations', _boolean) # /GT -_Same(_compile, 'EnablePREfast', _boolean) # /analyze Visible='false' -_Same(_compile, 'ExpandAttributedSource', _boolean) # /Fx -_Same(_compile, 'FloatingPointExceptions', _boolean) # /fp:except -_Same(_compile, 'ForceConformanceInForLoopScope', _boolean) # /Zc:forScope -_Same(_compile, 'ForcedIncludeFiles', _file_list) # /FI -_Same(_compile, 'ForcedUsingFiles', _file_list) # /FU -_Same(_compile, 'GenerateXMLDocumentationFiles', _boolean) # /doc -_Same(_compile, 'IgnoreStandardIncludePath', _boolean) # /X -_Same(_compile, 'MinimalRebuild', _boolean) # /Gm -_Same(_compile, 'OmitDefaultLibName', _boolean) # /Zl -_Same(_compile, 'OmitFramePointers', _boolean) # /Oy -_Same(_compile, 'PreprocessorDefinitions', _string_list) # /D -_Same(_compile, 'ProgramDataBaseFileName', _file_name) # /Fd -_Same(_compile, 'RuntimeTypeInfo', _boolean) # /GR -_Same(_compile, 'ShowIncludes', _boolean) # /showIncludes -_Same(_compile, 'SmallerTypeCheck', _boolean) # /RTCc -_Same(_compile, 'StringPooling', _boolean) # /GF -_Same(_compile, 'SuppressStartupBanner', _boolean) # /nologo -_Same(_compile, 'TreatWChar_tAsBuiltInType', _boolean) # /Zc:wchar_t -_Same(_compile, 'UndefineAllPreprocessorDefinitions', _boolean) # /u -_Same(_compile, 'UndefinePreprocessorDefinitions', _string_list) # /U -_Same(_compile, 'UseFullPaths', _boolean) # /FC -_Same(_compile, 'WholeProgramOptimization', _boolean) # /GL -_Same(_compile, 'XMLDocumentationFileName', _file_name) - -_Same(_compile, 'AssemblerOutput', - _Enumeration(['NoListing', - 'AssemblyCode', # /FA - 'All', # /FAcs - 'AssemblyAndMachineCode', # /FAc - 'AssemblyAndSourceCode'])) # /FAs -_Same(_compile, 'BasicRuntimeChecks', - _Enumeration(['Default', - 'StackFrameRuntimeCheck', # /RTCs - 'UninitializedLocalUsageCheck', # /RTCu - 'EnableFastChecks'])) # /RTC1 -_Same(_compile, 'BrowseInformation', - _Enumeration(['false', - 'true', # /FR - 'true'])) # /Fr -_Same(_compile, 'CallingConvention', - _Enumeration(['Cdecl', # /Gd - 'FastCall', # /Gr - 'StdCall'])) # /Gz -_Same(_compile, 'CompileAs', - _Enumeration(['Default', - 'CompileAsC', # /TC - 'CompileAsCpp'])) # /TP -_Same(_compile, 'DebugInformationFormat', - _Enumeration(['', # Disabled - 'OldStyle', # /Z7 - None, - 'ProgramDatabase', # /Zi - 'EditAndContinue'])) # /ZI -_Same(_compile, 'EnableEnhancedInstructionSet', - _Enumeration(['NotSet', - 'StreamingSIMDExtensions', # /arch:SSE - 'StreamingSIMDExtensions2'])) # /arch:SSE2 -_Same(_compile, 'ErrorReporting', - _Enumeration(['None', # /errorReport:none - 'Prompt', # /errorReport:prompt - 'Queue'], # /errorReport:queue - new=['Send'])) # /errorReport:send" -_Same(_compile, 'ExceptionHandling', - _Enumeration(['false', - 'Sync', # /EHsc - 'Async'], # /EHa - new=['SyncCThrow'])) # /EHs -_Same(_compile, 'FavorSizeOrSpeed', - _Enumeration(['Neither', - 'Speed', # /Ot - 'Size'])) # /Os -_Same(_compile, 'FloatingPointModel', - _Enumeration(['Precise', # /fp:precise - 'Strict', # /fp:strict - 'Fast'])) # /fp:fast -_Same(_compile, 'InlineFunctionExpansion', - _Enumeration(['Default', - 'OnlyExplicitInline', # /Ob1 - 'AnySuitable'], # /Ob2 - new=['Disabled'])) # /Ob0 -_Same(_compile, 'Optimization', - _Enumeration(['Disabled', # /Od - 'MinSpace', # /O1 - 'MaxSpeed', # /O2 - 'Full'])) # /Ox -_Same(_compile, 'RuntimeLibrary', - _Enumeration(['MultiThreaded', # /MT - 'MultiThreadedDebug', # /MTd - 'MultiThreadedDLL', # /MD - 'MultiThreadedDebugDLL'])) # /MDd -_Same(_compile, 'StructMemberAlignment', - _Enumeration(['Default', - '1Byte', # /Zp1 - '2Bytes', # /Zp2 - '4Bytes', # /Zp4 - '8Bytes', # /Zp8 - '16Bytes'])) # /Zp16 -_Same(_compile, 'WarningLevel', - _Enumeration(['TurnOffAllWarnings', # /W0 - 'Level1', # /W1 - 'Level2', # /W2 - 'Level3', # /W3 - 'Level4'], # /W4 - new=['EnableAllWarnings'])) # /Wall - -# Options found in MSVS that have been renamed in MSBuild. -_Renamed(_compile, 'EnableFunctionLevelLinking', 'FunctionLevelLinking', - _boolean) # /Gy -_Renamed(_compile, 'EnableIntrinsicFunctions', 'IntrinsicFunctions', - _boolean) # /Oi -_Renamed(_compile, 'KeepComments', 'PreprocessKeepComments', _boolean) # /C -_Renamed(_compile, 'ObjectFile', 'ObjectFileName', _file_name) # /Fo -_Renamed(_compile, 'OpenMP', 'OpenMPSupport', _boolean) # /openmp -_Renamed(_compile, 'PrecompiledHeaderThrough', 'PrecompiledHeaderFile', - _file_name) # Used with /Yc and /Yu -_Renamed(_compile, 'PrecompiledHeaderFile', 'PrecompiledHeaderOutputFile', - _file_name) # /Fp -_Renamed(_compile, 'UsePrecompiledHeader', 'PrecompiledHeader', - _Enumeration(['NotUsing', # VS recognized '' for this value too. - 'Create', # /Yc - 'Use'])) # /Yu -_Renamed(_compile, 'WarnAsError', 'TreatWarningAsError', _boolean) # /WX - -_ConvertedToAdditionalOption(_compile, 'DefaultCharIsUnsigned', '/J') - -# MSVS options not found in MSBuild. -_MSVSOnly(_compile, 'Detect64BitPortabilityProblems', _boolean) -_MSVSOnly(_compile, 'UseUnicodeResponseFiles', _boolean) - -# MSBuild options not found in MSVS. -_MSBuildOnly(_compile, 'BuildingInIDE', _boolean) -_MSBuildOnly(_compile, 'CompileAsManaged', - _Enumeration([], new=['false', - 'true', # /clr - 'Pure', # /clr:pure - 'Safe', # /clr:safe - 'OldSyntax'])) # /clr:oldSyntax -_MSBuildOnly(_compile, 'CreateHotpatchableImage', _boolean) # /hotpatch -_MSBuildOnly(_compile, 'MultiProcessorCompilation', _boolean) # /MP -_MSBuildOnly(_compile, 'PreprocessOutputPath', _string) # /Fi -_MSBuildOnly(_compile, 'ProcessorNumber', _integer) # the number of processors -_MSBuildOnly(_compile, 'TrackerLogDirectory', _folder_name) -_MSBuildOnly(_compile, 'TreatSpecificWarningsAsErrors', _string_list) # /we -_MSBuildOnly(_compile, 'UseUnicodeForAssemblerListing', _boolean) # /FAu - -# Defines a setting that needs very customized processing -_CustomGeneratePreprocessedFile(_compile, 'GeneratePreprocessedFile') - - -# Directives for converting MSVS VCLinkerTool to MSBuild Link. -# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\link.xml" for -# the schema of the MSBuild Link settings. - -# Options that have the same name in MSVS and MSBuild -_Same(_link, 'AdditionalDependencies', _file_list) -_Same(_link, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH -# /MANIFESTDEPENDENCY: -_Same(_link, 'AdditionalManifestDependencies', _file_list) -_Same(_link, 'AdditionalOptions', _string_list) -_Same(_link, 'AddModuleNamesToAssembly', _file_list) # /ASSEMBLYMODULE -_Same(_link, 'AllowIsolation', _boolean) # /ALLOWISOLATION -_Same(_link, 'AssemblyLinkResource', _file_list) # /ASSEMBLYLINKRESOURCE -_Same(_link, 'BaseAddress', _string) # /BASE -_Same(_link, 'CLRUnmanagedCodeCheck', _boolean) # /CLRUNMANAGEDCODECHECK -_Same(_link, 'DelayLoadDLLs', _file_list) # /DELAYLOAD -_Same(_link, 'DelaySign', _boolean) # /DELAYSIGN -_Same(_link, 'EmbedManagedResourceFile', _file_list) # /ASSEMBLYRESOURCE -_Same(_link, 'EnableUAC', _boolean) # /MANIFESTUAC -_Same(_link, 'EntryPointSymbol', _string) # /ENTRY -_Same(_link, 'ForceSymbolReferences', _file_list) # /INCLUDE -_Same(_link, 'FunctionOrder', _file_name) # /ORDER -_Same(_link, 'GenerateDebugInformation', _boolean) # /DEBUG -_Same(_link, 'GenerateMapFile', _boolean) # /MAP -_Same(_link, 'HeapCommitSize', _string) -_Same(_link, 'HeapReserveSize', _string) # /HEAP -_Same(_link, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB -_Same(_link, 'IgnoreEmbeddedIDL', _boolean) # /IGNOREIDL -_Same(_link, 'ImportLibrary', _file_name) # /IMPLIB -_Same(_link, 'KeyContainer', _file_name) # /KEYCONTAINER -_Same(_link, 'KeyFile', _file_name) # /KEYFILE -_Same(_link, 'ManifestFile', _file_name) # /ManifestFile -_Same(_link, 'MapExports', _boolean) # /MAPINFO:EXPORTS -_Same(_link, 'MapFileName', _file_name) -_Same(_link, 'MergedIDLBaseFileName', _file_name) # /IDLOUT -_Same(_link, 'MergeSections', _string) # /MERGE -_Same(_link, 'MidlCommandFile', _file_name) # /MIDL -_Same(_link, 'ModuleDefinitionFile', _file_name) # /DEF -_Same(_link, 'OutputFile', _file_name) # /OUT -_Same(_link, 'PerUserRedirection', _boolean) -_Same(_link, 'Profile', _boolean) # /PROFILE -_Same(_link, 'ProfileGuidedDatabase', _file_name) # /PGD -_Same(_link, 'ProgramDatabaseFile', _file_name) # /PDB -_Same(_link, 'RegisterOutput', _boolean) -_Same(_link, 'SetChecksum', _boolean) # /RELEASE -_Same(_link, 'StackCommitSize', _string) -_Same(_link, 'StackReserveSize', _string) # /STACK -_Same(_link, 'StripPrivateSymbols', _file_name) # /PDBSTRIPPED -_Same(_link, 'SupportUnloadOfDelayLoadedDLL', _boolean) # /DELAY:UNLOAD -_Same(_link, 'SuppressStartupBanner', _boolean) # /NOLOGO -_Same(_link, 'SwapRunFromCD', _boolean) # /SWAPRUN:CD -_Same(_link, 'TurnOffAssemblyGeneration', _boolean) # /NOASSEMBLY -_Same(_link, 'TypeLibraryFile', _file_name) # /TLBOUT -_Same(_link, 'TypeLibraryResourceID', _integer) # /TLBID -_Same(_link, 'UACUIAccess', _boolean) # /uiAccess='true' -_Same(_link, 'Version', _string) # /VERSION - -_Same(_link, 'EnableCOMDATFolding', _newly_boolean) # /OPT:ICF -_Same(_link, 'FixedBaseAddress', _newly_boolean) # /FIXED -_Same(_link, 'LargeAddressAware', _newly_boolean) # /LARGEADDRESSAWARE -_Same(_link, 'OptimizeReferences', _newly_boolean) # /OPT:REF -_Same(_link, 'RandomizedBaseAddress', _newly_boolean) # /DYNAMICBASE -_Same(_link, 'TerminalServerAware', _newly_boolean) # /TSAWARE - -_subsystem_enumeration = _Enumeration( - ['NotSet', - 'Console', # /SUBSYSTEM:CONSOLE - 'Windows', # /SUBSYSTEM:WINDOWS - 'Native', # /SUBSYSTEM:NATIVE - 'EFI Application', # /SUBSYSTEM:EFI_APPLICATION - 'EFI Boot Service Driver', # /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER - 'EFI ROM', # /SUBSYSTEM:EFI_ROM - 'EFI Runtime', # /SUBSYSTEM:EFI_RUNTIME_DRIVER - 'WindowsCE'], # /SUBSYSTEM:WINDOWSCE - new=['POSIX']) # /SUBSYSTEM:POSIX - -_target_machine_enumeration = _Enumeration( - ['NotSet', - 'MachineX86', # /MACHINE:X86 - None, - 'MachineARM', # /MACHINE:ARM - 'MachineEBC', # /MACHINE:EBC - 'MachineIA64', # /MACHINE:IA64 - None, - 'MachineMIPS', # /MACHINE:MIPS - 'MachineMIPS16', # /MACHINE:MIPS16 - 'MachineMIPSFPU', # /MACHINE:MIPSFPU - 'MachineMIPSFPU16', # /MACHINE:MIPSFPU16 - None, - None, - None, - 'MachineSH4', # /MACHINE:SH4 - None, - 'MachineTHUMB', # /MACHINE:THUMB - 'MachineX64']) # /MACHINE:X64 - -_Same(_link, 'AssemblyDebug', - _Enumeration(['', - 'true', # /ASSEMBLYDEBUG - 'false'])) # /ASSEMBLYDEBUG:DISABLE -_Same(_link, 'CLRImageType', - _Enumeration(['Default', - 'ForceIJWImage', # /CLRIMAGETYPE:IJW - 'ForcePureILImage', # /Switch="CLRIMAGETYPE:PURE - 'ForceSafeILImage'])) # /Switch="CLRIMAGETYPE:SAFE -_Same(_link, 'CLRThreadAttribute', - _Enumeration(['DefaultThreadingAttribute', # /CLRTHREADATTRIBUTE:NONE - 'MTAThreadingAttribute', # /CLRTHREADATTRIBUTE:MTA - 'STAThreadingAttribute'])) # /CLRTHREADATTRIBUTE:STA -_Same(_link, 'DataExecutionPrevention', - _Enumeration(['', - 'false', # /NXCOMPAT:NO - 'true'])) # /NXCOMPAT -_Same(_link, 'Driver', - _Enumeration(['NotSet', - 'Driver', # /Driver - 'UpOnly', # /DRIVER:UPONLY - 'WDM'])) # /DRIVER:WDM -_Same(_link, 'LinkTimeCodeGeneration', - _Enumeration(['Default', - 'UseLinkTimeCodeGeneration', # /LTCG - 'PGInstrument', # /LTCG:PGInstrument - 'PGOptimization', # /LTCG:PGOptimize - 'PGUpdate'])) # /LTCG:PGUpdate -_Same(_link, 'ShowProgress', - _Enumeration(['NotSet', - 'LinkVerbose', # /VERBOSE - 'LinkVerboseLib'], # /VERBOSE:Lib - new=['LinkVerboseICF', # /VERBOSE:ICF - 'LinkVerboseREF', # /VERBOSE:REF - 'LinkVerboseSAFESEH', # /VERBOSE:SAFESEH - 'LinkVerboseCLR'])) # /VERBOSE:CLR -_Same(_link, 'SubSystem', _subsystem_enumeration) -_Same(_link, 'TargetMachine', _target_machine_enumeration) -_Same(_link, 'UACExecutionLevel', - _Enumeration(['AsInvoker', # /level='asInvoker' - 'HighestAvailable', # /level='highestAvailable' - 'RequireAdministrator'])) # /level='requireAdministrator' - - -# Options found in MSVS that have been renamed in MSBuild. -_Renamed(_link, 'ErrorReporting', 'LinkErrorReporting', - _Enumeration(['NoErrorReport', # /ERRORREPORT:NONE - 'PromptImmediately', # /ERRORREPORT:PROMPT - 'QueueForNextLogin'], # /ERRORREPORT:QUEUE - new=['SendErrorReport'])) # /ERRORREPORT:SEND -_Renamed(_link, 'IgnoreDefaultLibraryNames', 'IgnoreSpecificDefaultLibraries', - _file_list) # /NODEFAULTLIB -_Renamed(_link, 'ResourceOnlyDLL', 'NoEntryPoint', _boolean) # /NOENTRY -_Renamed(_link, 'SwapRunFromNet', 'SwapRunFromNET', _boolean) # /SWAPRUN:NET - -_Moved(_link, 'GenerateManifest', '', _boolean) -_Moved(_link, 'IgnoreImportLibrary', '', _boolean) -_Moved(_link, 'LinkIncremental', '', _newly_boolean) -_Moved(_link, 'LinkLibraryDependencies', 'ProjectReference', _boolean) -_Moved(_link, 'UseLibraryDependencyInputs', 'ProjectReference', _boolean) - -# MSVS options not found in MSBuild. -_MSVSOnly(_link, 'OptimizeForWindows98', _newly_boolean) -_MSVSOnly(_link, 'UseUnicodeResponseFiles', _boolean) -# TODO(jeanluc) I don't think these are genuine settings but byproducts of Gyp. -_MSVSOnly(_link, 'AdditionalLibraryDirectories_excluded', _folder_list) - -# MSBuild options not found in MSVS. -_MSBuildOnly(_link, 'BuildingInIDE', _boolean) -_MSBuildOnly(_link, 'ImageHasSafeExceptionHandlers', _boolean) # /SAFESEH -_MSBuildOnly(_link, 'LinkDLL', _boolean) # /DLL Visible='false' -_MSBuildOnly(_link, 'LinkStatus', _boolean) # /LTCG:STATUS -_MSBuildOnly(_link, 'PreventDllBinding', _boolean) # /ALLOWBIND -_MSBuildOnly(_link, 'SupportNobindOfDelayLoadedDLL', _boolean) # /DELAY:NOBIND -_MSBuildOnly(_link, 'TrackerLogDirectory', _folder_name) -_MSBuildOnly(_link, 'TreatLinkerWarningAsErrors', _boolean) # /WX -_MSBuildOnly(_link, 'MinimumRequiredVersion', _string) -_MSBuildOnly(_link, 'MSDOSStubFileName', _file_name) # /STUB Visible='false' -_MSBuildOnly(_link, 'SectionAlignment', _integer) # /ALIGN -_MSBuildOnly(_link, 'SpecifySectionAttributes', _string) # /SECTION -_MSBuildOnly(_link, 'ForceFileOutput', - _Enumeration([], new=['Enabled', # /FORCE - # /FORCE:MULTIPLE - 'MultiplyDefinedSymbolOnly', - 'UndefinedSymbolOnly'])) # /FORCE:UNRESOLVED -_MSBuildOnly(_link, 'CreateHotPatchableImage', - _Enumeration([], new=['Enabled', # /FUNCTIONPADMIN - 'X86Image', # /FUNCTIONPADMIN:5 - 'X64Image', # /FUNCTIONPADMIN:6 - 'ItaniumImage'])) # /FUNCTIONPADMIN:16 -_MSBuildOnly(_link, 'CLRSupportLastError', - _Enumeration([], new=['Enabled', # /CLRSupportLastError - 'Disabled', # /CLRSupportLastError:NO - # /CLRSupportLastError:SYSTEMDLL - 'SystemDlls'])) - - -# Directives for converting VCResourceCompilerTool to ResourceCompile. -# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\rc.xml" for -# the schema of the MSBuild ResourceCompile settings. - -_Same(_rc, 'AdditionalOptions', _string_list) -_Same(_rc, 'AdditionalIncludeDirectories', _folder_list) # /I -_Same(_rc, 'Culture', _Integer(msbuild_base=16)) -_Same(_rc, 'IgnoreStandardIncludePath', _boolean) # /X -_Same(_rc, 'PreprocessorDefinitions', _string_list) # /D -_Same(_rc, 'ResourceOutputFileName', _string) # /fo -_Same(_rc, 'ShowProgress', _boolean) # /v -# There is no UI in VisualStudio 2008 to set the following properties. -# However they are found in CL and other tools. Include them here for -# completeness, as they are very likely to have the same usage pattern. -_Same(_rc, 'SuppressStartupBanner', _boolean) # /nologo -_Same(_rc, 'UndefinePreprocessorDefinitions', _string_list) # /u - -# MSBuild options not found in MSVS. -_MSBuildOnly(_rc, 'NullTerminateStrings', _boolean) # /n -_MSBuildOnly(_rc, 'TrackerLogDirectory', _folder_name) - - -# Directives for converting VCMIDLTool to Midl. -# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\midl.xml" for -# the schema of the MSBuild Midl settings. - -_Same(_midl, 'AdditionalIncludeDirectories', _folder_list) # /I -_Same(_midl, 'AdditionalOptions', _string_list) -_Same(_midl, 'CPreprocessOptions', _string) # /cpp_opt -_Same(_midl, 'ErrorCheckAllocations', _boolean) # /error allocation -_Same(_midl, 'ErrorCheckBounds', _boolean) # /error bounds_check -_Same(_midl, 'ErrorCheckEnumRange', _boolean) # /error enum -_Same(_midl, 'ErrorCheckRefPointers', _boolean) # /error ref -_Same(_midl, 'ErrorCheckStubData', _boolean) # /error stub_data -_Same(_midl, 'GenerateStublessProxies', _boolean) # /Oicf -_Same(_midl, 'GenerateTypeLibrary', _boolean) -_Same(_midl, 'HeaderFileName', _file_name) # /h -_Same(_midl, 'IgnoreStandardIncludePath', _boolean) # /no_def_idir -_Same(_midl, 'InterfaceIdentifierFileName', _file_name) # /iid -_Same(_midl, 'MkTypLibCompatible', _boolean) # /mktyplib203 -_Same(_midl, 'OutputDirectory', _string) # /out -_Same(_midl, 'PreprocessorDefinitions', _string_list) # /D -_Same(_midl, 'ProxyFileName', _file_name) # /proxy -_Same(_midl, 'RedirectOutputAndErrors', _file_name) # /o -_Same(_midl, 'SuppressStartupBanner', _boolean) # /nologo -_Same(_midl, 'TypeLibraryName', _file_name) # /tlb -_Same(_midl, 'UndefinePreprocessorDefinitions', _string_list) # /U -_Same(_midl, 'WarnAsError', _boolean) # /WX - -_Same(_midl, 'DefaultCharType', - _Enumeration(['Unsigned', # /char unsigned - 'Signed', # /char signed - 'Ascii'])) # /char ascii7 -_Same(_midl, 'TargetEnvironment', - _Enumeration(['NotSet', - 'Win32', # /env win32 - 'Itanium', # /env ia64 - 'X64'])) # /env x64 -_Same(_midl, 'EnableErrorChecks', - _Enumeration(['EnableCustom', - 'None', # /error none - 'All'])) # /error all -_Same(_midl, 'StructMemberAlignment', - _Enumeration(['NotSet', - '1', # Zp1 - '2', # Zp2 - '4', # Zp4 - '8'])) # Zp8 -_Same(_midl, 'WarningLevel', - _Enumeration(['0', # /W0 - '1', # /W1 - '2', # /W2 - '3', # /W3 - '4'])) # /W4 - -_Renamed(_midl, 'DLLDataFileName', 'DllDataFileName', _file_name) # /dlldata -_Renamed(_midl, 'ValidateParameters', 'ValidateAllParameters', - _boolean) # /robust - -# MSBuild options not found in MSVS. -_MSBuildOnly(_midl, 'ApplicationConfigurationMode', _boolean) # /app_config -_MSBuildOnly(_midl, 'ClientStubFile', _file_name) # /cstub -_MSBuildOnly(_midl, 'GenerateClientFiles', - _Enumeration([], new=['Stub', # /client stub - 'None'])) # /client none -_MSBuildOnly(_midl, 'GenerateServerFiles', - _Enumeration([], new=['Stub', # /client stub - 'None'])) # /client none -_MSBuildOnly(_midl, 'LocaleID', _integer) # /lcid DECIMAL -_MSBuildOnly(_midl, 'ServerStubFile', _file_name) # /sstub -_MSBuildOnly(_midl, 'SuppressCompilerWarnings', _boolean) # /no_warn -_MSBuildOnly(_midl, 'TrackerLogDirectory', _folder_name) -_MSBuildOnly(_midl, 'TypeLibFormat', - _Enumeration([], new=['NewFormat', # /newtlb - 'OldFormat'])) # /oldtlb - - -# Directives for converting VCLibrarianTool to Lib. -# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\lib.xml" for -# the schema of the MSBuild Lib settings. - -_Same(_lib, 'AdditionalDependencies', _file_list) -_Same(_lib, 'AdditionalLibraryDirectories', _folder_list) # /LIBPATH -_Same(_lib, 'AdditionalOptions', _string_list) -_Same(_lib, 'ExportNamedFunctions', _string_list) # /EXPORT -_Same(_lib, 'ForceSymbolReferences', _string) # /INCLUDE -_Same(_lib, 'IgnoreAllDefaultLibraries', _boolean) # /NODEFAULTLIB -_Same(_lib, 'IgnoreSpecificDefaultLibraries', _file_list) # /NODEFAULTLIB -_Same(_lib, 'ModuleDefinitionFile', _file_name) # /DEF -_Same(_lib, 'OutputFile', _file_name) # /OUT -_Same(_lib, 'SuppressStartupBanner', _boolean) # /NOLOGO -_Same(_lib, 'UseUnicodeResponseFiles', _boolean) - -# TODO(jeanluc) _link defines the same value that gets moved to -# ProjectReference. We may want to validate that they are consistent. -_Moved(_lib, 'LinkLibraryDependencies', 'ProjectReference', _boolean) - -# TODO(jeanluc) I don't think these are genuine settings but byproducts of Gyp. -_MSVSOnly(_lib, 'AdditionalLibraryDirectories_excluded', _folder_list) - -_MSBuildOnly(_lib, 'DisplayLibrary', _string) # /LIST Visible='false' -_MSBuildOnly(_lib, 'ErrorReporting', - _Enumeration([], new=['PromptImmediately', # /ERRORREPORT:PROMPT - 'QueueForNextLogin', # /ERRORREPORT:QUEUE - 'SendErrorReport', # /ERRORREPORT:SEND - 'NoErrorReport'])) # /ERRORREPORT:NONE -_MSBuildOnly(_lib, 'LinkTimeCodeGeneration', _boolean) # /LTCG -_MSBuildOnly(_lib, 'MinimumRequiredVersion', _string) -_MSBuildOnly(_lib, 'Name', _file_name) # /NAME -_MSBuildOnly(_lib, 'RemoveObjects', _file_list) # /REMOVE -_MSBuildOnly(_lib, 'SubSystem', _subsystem_enumeration) -_MSBuildOnly(_lib, 'TargetMachine', _target_machine_enumeration) -_MSBuildOnly(_lib, 'TrackerLogDirectory', _folder_name) -_MSBuildOnly(_lib, 'TreatLibWarningAsErrors', _boolean) # /WX -_MSBuildOnly(_lib, 'Verbose', _boolean) - - -# Directives for converting VCManifestTool to Mt. -# See "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\1033\mt.xml" for -# the schema of the MSBuild Lib settings. - -# Options that have the same name in MSVS and MSBuild -_Same(_manifest, 'AdditionalManifestFiles', _file_list) # /manifest -_Same(_manifest, 'AdditionalOptions', _string_list) -_Same(_manifest, 'AssemblyIdentity', _string) # /identity: -_Same(_manifest, 'ComponentFileName', _file_name) # /dll -_Same(_manifest, 'GenerateCatalogFiles', _boolean) # /makecdfs -_Same(_manifest, 'InputResourceManifests', _string) # /inputresource -_Same(_manifest, 'OutputManifestFile', _file_name) # /out -_Same(_manifest, 'RegistrarScriptFile', _file_name) # /rgs -_Same(_manifest, 'ReplacementsFile', _file_name) # /replacements -_Same(_manifest, 'SuppressStartupBanner', _boolean) # /nologo -_Same(_manifest, 'TypeLibraryFile', _file_name) # /tlb: -_Same(_manifest, 'UpdateFileHashes', _boolean) # /hashupdate -_Same(_manifest, 'UpdateFileHashesSearchPath', _file_name) -_Same(_manifest, 'VerboseOutput', _boolean) # /verbose - -# Options that have moved location. -_MovedAndRenamed(_manifest, 'ManifestResourceFile', - 'ManifestResourceCompile', - 'ResourceOutputFileName', - _file_name) -_Moved(_manifest, 'EmbedManifest', '', _boolean) - -# MSVS options not found in MSBuild. -_MSVSOnly(_manifest, 'DependencyInformationFile', _file_name) -_MSVSOnly(_manifest, 'UseFAT32Workaround', _boolean) -_MSVSOnly(_manifest, 'UseUnicodeResponseFiles', _boolean) - -# MSBuild options not found in MSVS. -_MSBuildOnly(_manifest, 'EnableDPIAwareness', _boolean) -_MSBuildOnly(_manifest, 'GenerateCategoryTags', _boolean) # /category -_MSBuildOnly(_manifest, 'ManifestFromManagedAssembly', - _file_name) # /managedassemblyname -_MSBuildOnly(_manifest, 'OutputResourceManifests', _string) # /outputresource -_MSBuildOnly(_manifest, 'SuppressDependencyElement', _boolean) # /nodependency -_MSBuildOnly(_manifest, 'TrackerLogDirectory', _folder_name) diff --git a/third_party/gyp/pylib/gyp/MSVSSettings_test.py b/third_party/gyp/pylib/gyp/MSVSSettings_test.py deleted file mode 100644 index 199f98b..0000000 --- a/third_party/gyp/pylib/gyp/MSVSSettings_test.py +++ /dev/null @@ -1,1480 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Unit tests for the MSVSSettings.py file.""" - -import StringIO -import unittest -import gyp.MSVSSettings as MSVSSettings - - -class TestSequenceFunctions(unittest.TestCase): - - def setUp(self): - self.stderr = StringIO.StringIO() - - def _ExpectedWarnings(self, expected): - """Compares recorded lines to expected warnings.""" - self.stderr.seek(0) - actual = self.stderr.read().split('\n') - actual = [line for line in actual if line] - self.assertEqual(sorted(expected), sorted(actual)) - - def testValidateMSVSSettings_tool_names(self): - """Tests that only MSVS tool names are allowed.""" - MSVSSettings.ValidateMSVSSettings( - {'VCCLCompilerTool': {}, - 'VCLinkerTool': {}, - 'VCMIDLTool': {}, - 'foo': {}, - 'VCResourceCompilerTool': {}, - 'VCLibrarianTool': {}, - 'VCManifestTool': {}, - 'ClCompile': {}}, - self.stderr) - self._ExpectedWarnings([ - 'Warning: unrecognized tool foo', - 'Warning: unrecognized tool ClCompile']) - - def testValidateMSVSSettings_settings(self): - """Tests that for invalid MSVS settings.""" - MSVSSettings.ValidateMSVSSettings( - {'VCCLCompilerTool': { - 'AdditionalIncludeDirectories': 'folder1;folder2', - 'AdditionalOptions': ['string1', 'string2'], - 'AdditionalUsingDirectories': 'folder1;folder2', - 'AssemblerListingLocation': 'a_file_name', - 'AssemblerOutput': '0', - 'BasicRuntimeChecks': '5', - 'BrowseInformation': 'fdkslj', - 'BrowseInformationFile': 'a_file_name', - 'BufferSecurityCheck': 'true', - 'CallingConvention': '-1', - 'CompileAs': '1', - 'DebugInformationFormat': '2', - 'DefaultCharIsUnsigned': 'true', - 'Detect64BitPortabilityProblems': 'true', - 'DisableLanguageExtensions': 'true', - 'DisableSpecificWarnings': 'string1;string2', - 'EnableEnhancedInstructionSet': '1', - 'EnableFiberSafeOptimizations': 'true', - 'EnableFunctionLevelLinking': 'true', - 'EnableIntrinsicFunctions': 'true', - 'EnablePREfast': 'true', - 'Enableprefast': 'bogus', - 'ErrorReporting': '1', - 'ExceptionHandling': '1', - 'ExpandAttributedSource': 'true', - 'FavorSizeOrSpeed': '1', - 'FloatingPointExceptions': 'true', - 'FloatingPointModel': '1', - 'ForceConformanceInForLoopScope': 'true', - 'ForcedIncludeFiles': 'file1;file2', - 'ForcedUsingFiles': 'file1;file2', - 'GeneratePreprocessedFile': '1', - 'GenerateXMLDocumentationFiles': 'true', - 'IgnoreStandardIncludePath': 'true', - 'InlineFunctionExpansion': '1', - 'KeepComments': 'true', - 'MinimalRebuild': 'true', - 'ObjectFile': 'a_file_name', - 'OmitDefaultLibName': 'true', - 'OmitFramePointers': 'true', - 'OpenMP': 'true', - 'Optimization': '1', - 'PrecompiledHeaderFile': 'a_file_name', - 'PrecompiledHeaderThrough': 'a_file_name', - 'PreprocessorDefinitions': 'string1;string2', - 'ProgramDataBaseFileName': 'a_file_name', - 'RuntimeLibrary': '1', - 'RuntimeTypeInfo': 'true', - 'ShowIncludes': 'true', - 'SmallerTypeCheck': 'true', - 'StringPooling': 'true', - 'StructMemberAlignment': '1', - 'SuppressStartupBanner': 'true', - 'TreatWChar_tAsBuiltInType': 'true', - 'UndefineAllPreprocessorDefinitions': 'true', - 'UndefinePreprocessorDefinitions': 'string1;string2', - 'UseFullPaths': 'true', - 'UsePrecompiledHeader': '1', - 'UseUnicodeResponseFiles': 'true', - 'WarnAsError': 'true', - 'WarningLevel': '1', - 'WholeProgramOptimization': 'true', - 'XMLDocumentationFileName': 'a_file_name', - 'ZZXYZ': 'bogus'}, - 'VCLinkerTool': { - 'AdditionalDependencies': 'file1;file2', - 'AdditionalLibraryDirectories': 'folder1;folder2', - 'AdditionalManifestDependencies': 'file1;file2', - 'AdditionalOptions': 'a string1', - 'AddModuleNamesToAssembly': 'file1;file2', - 'AllowIsolation': 'true', - 'AssemblyDebug': '2', - 'AssemblyLinkResource': 'file1;file2', - 'BaseAddress': 'a string1', - 'CLRImageType': '2', - 'CLRThreadAttribute': '2', - 'CLRUnmanagedCodeCheck': 'true', - 'DataExecutionPrevention': '2', - 'DelayLoadDLLs': 'file1;file2', - 'DelaySign': 'true', - 'Driver': '2', - 'EmbedManagedResourceFile': 'file1;file2', - 'EnableCOMDATFolding': '2', - 'EnableUAC': 'true', - 'EntryPointSymbol': 'a string1', - 'ErrorReporting': '2', - 'FixedBaseAddress': '2', - 'ForceSymbolReferences': 'file1;file2', - 'FunctionOrder': 'a_file_name', - 'GenerateDebugInformation': 'true', - 'GenerateManifest': 'true', - 'GenerateMapFile': 'true', - 'HeapCommitSize': 'a string1', - 'HeapReserveSize': 'a string1', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreDefaultLibraryNames': 'file1;file2', - 'IgnoreEmbeddedIDL': 'true', - 'IgnoreImportLibrary': 'true', - 'ImportLibrary': 'a_file_name', - 'KeyContainer': 'a_file_name', - 'KeyFile': 'a_file_name', - 'LargeAddressAware': '2', - 'LinkIncremental': '2', - 'LinkLibraryDependencies': 'true', - 'LinkTimeCodeGeneration': '2', - 'ManifestFile': 'a_file_name', - 'MapExports': 'true', - 'MapFileName': 'a_file_name', - 'MergedIDLBaseFileName': 'a_file_name', - 'MergeSections': 'a string1', - 'MidlCommandFile': 'a_file_name', - 'ModuleDefinitionFile': 'a_file_name', - 'OptimizeForWindows98': '1', - 'OptimizeReferences': '2', - 'OutputFile': 'a_file_name', - 'PerUserRedirection': 'true', - 'Profile': 'true', - 'ProfileGuidedDatabase': 'a_file_name', - 'ProgramDatabaseFile': 'a_file_name', - 'RandomizedBaseAddress': '2', - 'RegisterOutput': 'true', - 'ResourceOnlyDLL': 'true', - 'SetChecksum': 'true', - 'ShowProgress': '2', - 'StackCommitSize': 'a string1', - 'StackReserveSize': 'a string1', - 'StripPrivateSymbols': 'a_file_name', - 'SubSystem': '2', - 'SupportUnloadOfDelayLoadedDLL': 'true', - 'SuppressStartupBanner': 'true', - 'SwapRunFromCD': 'true', - 'SwapRunFromNet': 'true', - 'TargetMachine': '2', - 'TerminalServerAware': '2', - 'TurnOffAssemblyGeneration': 'true', - 'TypeLibraryFile': 'a_file_name', - 'TypeLibraryResourceID': '33', - 'UACExecutionLevel': '2', - 'UACUIAccess': 'true', - 'UseLibraryDependencyInputs': 'true', - 'UseUnicodeResponseFiles': 'true', - 'Version': 'a string1'}, - 'VCMIDLTool': { - 'AdditionalIncludeDirectories': 'folder1;folder2', - 'AdditionalOptions': 'a string1', - 'CPreprocessOptions': 'a string1', - 'DefaultCharType': '1', - 'DLLDataFileName': 'a_file_name', - 'EnableErrorChecks': '1', - 'ErrorCheckAllocations': 'true', - 'ErrorCheckBounds': 'true', - 'ErrorCheckEnumRange': 'true', - 'ErrorCheckRefPointers': 'true', - 'ErrorCheckStubData': 'true', - 'GenerateStublessProxies': 'true', - 'GenerateTypeLibrary': 'true', - 'HeaderFileName': 'a_file_name', - 'IgnoreStandardIncludePath': 'true', - 'InterfaceIdentifierFileName': 'a_file_name', - 'MkTypLibCompatible': 'true', - 'notgood': 'bogus', - 'OutputDirectory': 'a string1', - 'PreprocessorDefinitions': 'string1;string2', - 'ProxyFileName': 'a_file_name', - 'RedirectOutputAndErrors': 'a_file_name', - 'StructMemberAlignment': '1', - 'SuppressStartupBanner': 'true', - 'TargetEnvironment': '1', - 'TypeLibraryName': 'a_file_name', - 'UndefinePreprocessorDefinitions': 'string1;string2', - 'ValidateParameters': 'true', - 'WarnAsError': 'true', - 'WarningLevel': '1'}, - 'VCResourceCompilerTool': { - 'AdditionalOptions': 'a string1', - 'AdditionalIncludeDirectories': 'folder1;folder2', - 'Culture': '1003', - 'IgnoreStandardIncludePath': 'true', - 'notgood2': 'bogus', - 'PreprocessorDefinitions': 'string1;string2', - 'ResourceOutputFileName': 'a string1', - 'ShowProgress': 'true', - 'SuppressStartupBanner': 'true', - 'UndefinePreprocessorDefinitions': 'string1;string2'}, - 'VCLibrarianTool': { - 'AdditionalDependencies': 'file1;file2', - 'AdditionalLibraryDirectories': 'folder1;folder2', - 'AdditionalOptions': 'a string1', - 'ExportNamedFunctions': 'string1;string2', - 'ForceSymbolReferences': 'a string1', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreSpecificDefaultLibraries': 'file1;file2', - 'LinkLibraryDependencies': 'true', - 'ModuleDefinitionFile': 'a_file_name', - 'OutputFile': 'a_file_name', - 'SuppressStartupBanner': 'true', - 'UseUnicodeResponseFiles': 'true'}, - 'VCManifestTool': { - 'AdditionalManifestFiles': 'file1;file2', - 'AdditionalOptions': 'a string1', - 'AssemblyIdentity': 'a string1', - 'ComponentFileName': 'a_file_name', - 'DependencyInformationFile': 'a_file_name', - 'GenerateCatalogFiles': 'true', - 'InputResourceManifests': 'a string1', - 'ManifestResourceFile': 'a_file_name', - 'OutputManifestFile': 'a_file_name', - 'RegistrarScriptFile': 'a_file_name', - 'ReplacementsFile': 'a_file_name', - 'SuppressStartupBanner': 'true', - 'TypeLibraryFile': 'a_file_name', - 'UpdateFileHashes': 'truel', - 'UpdateFileHashesSearchPath': 'a_file_name', - 'UseFAT32Workaround': 'true', - 'UseUnicodeResponseFiles': 'true', - 'VerboseOutput': 'true'}}, - self.stderr) - self._ExpectedWarnings([ - 'Warning: for VCCLCompilerTool/BasicRuntimeChecks, ' - 'index value (5) not in expected range [0, 4)', - 'Warning: for VCCLCompilerTool/BrowseInformation, ' - "invalid literal for int() with base 10: 'fdkslj'", - 'Warning: for VCCLCompilerTool/CallingConvention, ' - 'index value (-1) not in expected range [0, 3)', - 'Warning: for VCCLCompilerTool/DebugInformationFormat, ' - 'converted value for 2 not specified.', - 'Warning: unrecognized setting VCCLCompilerTool/Enableprefast', - 'Warning: unrecognized setting VCCLCompilerTool/ZZXYZ', - 'Warning: for VCLinkerTool/TargetMachine, ' - 'converted value for 2 not specified.', - 'Warning: unrecognized setting VCMIDLTool/notgood', - 'Warning: unrecognized setting VCResourceCompilerTool/notgood2', - 'Warning: for VCManifestTool/UpdateFileHashes, ' - "expected bool; got 'truel'" - '']) - - def testValidateMSBuildSettings_settings(self): - """Tests that for invalid MSBuild settings.""" - MSVSSettings.ValidateMSBuildSettings( - {'ClCompile': { - 'AdditionalIncludeDirectories': 'folder1;folder2', - 'AdditionalOptions': ['string1', 'string2'], - 'AdditionalUsingDirectories': 'folder1;folder2', - 'AssemblerListingLocation': 'a_file_name', - 'AssemblerOutput': 'NoListing', - 'BasicRuntimeChecks': 'StackFrameRuntimeCheck', - 'BrowseInformation': 'false', - 'BrowseInformationFile': 'a_file_name', - 'BufferSecurityCheck': 'true', - 'BuildingInIDE': 'true', - 'CallingConvention': 'Cdecl', - 'CompileAs': 'CompileAsC', - 'CompileAsManaged': 'Pure', - 'CreateHotpatchableImage': 'true', - 'DebugInformationFormat': 'ProgramDatabase', - 'DisableLanguageExtensions': 'true', - 'DisableSpecificWarnings': 'string1;string2', - 'EnableEnhancedInstructionSet': 'StreamingSIMDExtensions', - 'EnableFiberSafeOptimizations': 'true', - 'EnablePREfast': 'true', - 'Enableprefast': 'bogus', - 'ErrorReporting': 'Prompt', - 'ExceptionHandling': 'SyncCThrow', - 'ExpandAttributedSource': 'true', - 'FavorSizeOrSpeed': 'Neither', - 'FloatingPointExceptions': 'true', - 'FloatingPointModel': 'Precise', - 'ForceConformanceInForLoopScope': 'true', - 'ForcedIncludeFiles': 'file1;file2', - 'ForcedUsingFiles': 'file1;file2', - 'FunctionLevelLinking': 'false', - 'GenerateXMLDocumentationFiles': 'true', - 'IgnoreStandardIncludePath': 'true', - 'InlineFunctionExpansion': 'OnlyExplicitInline', - 'IntrinsicFunctions': 'false', - 'MinimalRebuild': 'true', - 'MultiProcessorCompilation': 'true', - 'ObjectFileName': 'a_file_name', - 'OmitDefaultLibName': 'true', - 'OmitFramePointers': 'true', - 'OpenMPSupport': 'true', - 'Optimization': 'Disabled', - 'PrecompiledHeader': 'NotUsing', - 'PrecompiledHeaderFile': 'a_file_name', - 'PrecompiledHeaderOutputFile': 'a_file_name', - 'PreprocessKeepComments': 'true', - 'PreprocessorDefinitions': 'string1;string2', - 'PreprocessOutputPath': 'a string1', - 'PreprocessSuppressLineNumbers': 'false', - 'PreprocessToFile': 'false', - 'ProcessorNumber': '33', - 'ProgramDataBaseFileName': 'a_file_name', - 'RuntimeLibrary': 'MultiThreaded', - 'RuntimeTypeInfo': 'true', - 'ShowIncludes': 'true', - 'SmallerTypeCheck': 'true', - 'StringPooling': 'true', - 'StructMemberAlignment': '1Byte', - 'SuppressStartupBanner': 'true', - 'TrackerLogDirectory': 'a_folder', - 'TreatSpecificWarningsAsErrors': 'string1;string2', - 'TreatWarningAsError': 'true', - 'TreatWChar_tAsBuiltInType': 'true', - 'UndefineAllPreprocessorDefinitions': 'true', - 'UndefinePreprocessorDefinitions': 'string1;string2', - 'UseFullPaths': 'true', - 'UseUnicodeForAssemblerListing': 'true', - 'WarningLevel': 'TurnOffAllWarnings', - 'WholeProgramOptimization': 'true', - 'XMLDocumentationFileName': 'a_file_name', - 'ZZXYZ': 'bogus'}, - 'Link': { - 'AdditionalDependencies': 'file1;file2', - 'AdditionalLibraryDirectories': 'folder1;folder2', - 'AdditionalManifestDependencies': 'file1;file2', - 'AdditionalOptions': 'a string1', - 'AddModuleNamesToAssembly': 'file1;file2', - 'AllowIsolation': 'true', - 'AssemblyDebug': '', - 'AssemblyLinkResource': 'file1;file2', - 'BaseAddress': 'a string1', - 'BuildingInIDE': 'true', - 'CLRImageType': 'ForceIJWImage', - 'CLRSupportLastError': 'Enabled', - 'CLRThreadAttribute': 'MTAThreadingAttribute', - 'CLRUnmanagedCodeCheck': 'true', - 'CreateHotPatchableImage': 'X86Image', - 'DataExecutionPrevention': 'false', - 'DelayLoadDLLs': 'file1;file2', - 'DelaySign': 'true', - 'Driver': 'NotSet', - 'EmbedManagedResourceFile': 'file1;file2', - 'EnableCOMDATFolding': 'false', - 'EnableUAC': 'true', - 'EntryPointSymbol': 'a string1', - 'FixedBaseAddress': 'false', - 'ForceFileOutput': 'Enabled', - 'ForceSymbolReferences': 'file1;file2', - 'FunctionOrder': 'a_file_name', - 'GenerateDebugInformation': 'true', - 'GenerateMapFile': 'true', - 'HeapCommitSize': 'a string1', - 'HeapReserveSize': 'a string1', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreEmbeddedIDL': 'true', - 'IgnoreSpecificDefaultLibraries': 'a_file_list', - 'ImageHasSafeExceptionHandlers': 'true', - 'ImportLibrary': 'a_file_name', - 'KeyContainer': 'a_file_name', - 'KeyFile': 'a_file_name', - 'LargeAddressAware': 'false', - 'LinkDLL': 'true', - 'LinkErrorReporting': 'SendErrorReport', - 'LinkStatus': 'true', - 'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration', - 'ManifestFile': 'a_file_name', - 'MapExports': 'true', - 'MapFileName': 'a_file_name', - 'MergedIDLBaseFileName': 'a_file_name', - 'MergeSections': 'a string1', - 'MidlCommandFile': 'a_file_name', - 'MinimumRequiredVersion': 'a string1', - 'ModuleDefinitionFile': 'a_file_name', - 'MSDOSStubFileName': 'a_file_name', - 'NoEntryPoint': 'true', - 'OptimizeReferences': 'false', - 'OutputFile': 'a_file_name', - 'PerUserRedirection': 'true', - 'PreventDllBinding': 'true', - 'Profile': 'true', - 'ProfileGuidedDatabase': 'a_file_name', - 'ProgramDatabaseFile': 'a_file_name', - 'RandomizedBaseAddress': 'false', - 'RegisterOutput': 'true', - 'SectionAlignment': '33', - 'SetChecksum': 'true', - 'ShowProgress': 'LinkVerboseREF', - 'SpecifySectionAttributes': 'a string1', - 'StackCommitSize': 'a string1', - 'StackReserveSize': 'a string1', - 'StripPrivateSymbols': 'a_file_name', - 'SubSystem': 'Console', - 'SupportNobindOfDelayLoadedDLL': 'true', - 'SupportUnloadOfDelayLoadedDLL': 'true', - 'SuppressStartupBanner': 'true', - 'SwapRunFromCD': 'true', - 'SwapRunFromNET': 'true', - 'TargetMachine': 'MachineX86', - 'TerminalServerAware': 'false', - 'TrackerLogDirectory': 'a_folder', - 'TreatLinkerWarningAsErrors': 'true', - 'TurnOffAssemblyGeneration': 'true', - 'TypeLibraryFile': 'a_file_name', - 'TypeLibraryResourceID': '33', - 'UACExecutionLevel': 'AsInvoker', - 'UACUIAccess': 'true', - 'Version': 'a string1'}, - 'ResourceCompile': { - 'AdditionalIncludeDirectories': 'folder1;folder2', - 'AdditionalOptions': 'a string1', - 'Culture': '0x236', - 'IgnoreStandardIncludePath': 'true', - 'NullTerminateStrings': 'true', - 'PreprocessorDefinitions': 'string1;string2', - 'ResourceOutputFileName': 'a string1', - 'ShowProgress': 'true', - 'SuppressStartupBanner': 'true', - 'TrackerLogDirectory': 'a_folder', - 'UndefinePreprocessorDefinitions': 'string1;string2'}, - 'Midl': { - 'AdditionalIncludeDirectories': 'folder1;folder2', - 'AdditionalOptions': 'a string1', - 'ApplicationConfigurationMode': 'true', - 'ClientStubFile': 'a_file_name', - 'CPreprocessOptions': 'a string1', - 'DefaultCharType': 'Signed', - 'DllDataFileName': 'a_file_name', - 'EnableErrorChecks': 'EnableCustom', - 'ErrorCheckAllocations': 'true', - 'ErrorCheckBounds': 'true', - 'ErrorCheckEnumRange': 'true', - 'ErrorCheckRefPointers': 'true', - 'ErrorCheckStubData': 'true', - 'GenerateClientFiles': 'Stub', - 'GenerateServerFiles': 'None', - 'GenerateStublessProxies': 'true', - 'GenerateTypeLibrary': 'true', - 'HeaderFileName': 'a_file_name', - 'IgnoreStandardIncludePath': 'true', - 'InterfaceIdentifierFileName': 'a_file_name', - 'LocaleID': '33', - 'MkTypLibCompatible': 'true', - 'OutputDirectory': 'a string1', - 'PreprocessorDefinitions': 'string1;string2', - 'ProxyFileName': 'a_file_name', - 'RedirectOutputAndErrors': 'a_file_name', - 'ServerStubFile': 'a_file_name', - 'StructMemberAlignment': 'NotSet', - 'SuppressCompilerWarnings': 'true', - 'SuppressStartupBanner': 'true', - 'TargetEnvironment': 'Itanium', - 'TrackerLogDirectory': 'a_folder', - 'TypeLibFormat': 'NewFormat', - 'TypeLibraryName': 'a_file_name', - 'UndefinePreprocessorDefinitions': 'string1;string2', - 'ValidateAllParameters': 'true', - 'WarnAsError': 'true', - 'WarningLevel': '1'}, - 'Lib': { - 'AdditionalDependencies': 'file1;file2', - 'AdditionalLibraryDirectories': 'folder1;folder2', - 'AdditionalOptions': 'a string1', - 'DisplayLibrary': 'a string1', - 'ErrorReporting': 'PromptImmediately', - 'ExportNamedFunctions': 'string1;string2', - 'ForceSymbolReferences': 'a string1', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreSpecificDefaultLibraries': 'file1;file2', - 'LinkTimeCodeGeneration': 'true', - 'MinimumRequiredVersion': 'a string1', - 'ModuleDefinitionFile': 'a_file_name', - 'Name': 'a_file_name', - 'OutputFile': 'a_file_name', - 'RemoveObjects': 'file1;file2', - 'SubSystem': 'Console', - 'SuppressStartupBanner': 'true', - 'TargetMachine': 'MachineX86i', - 'TrackerLogDirectory': 'a_folder', - 'TreatLibWarningAsErrors': 'true', - 'UseUnicodeResponseFiles': 'true', - 'Verbose': 'true'}, - 'Mt': { - 'AdditionalManifestFiles': 'file1;file2', - 'AdditionalOptions': 'a string1', - 'AssemblyIdentity': 'a string1', - 'ComponentFileName': 'a_file_name', - 'EnableDPIAwareness': 'fal', - 'GenerateCatalogFiles': 'truel', - 'GenerateCategoryTags': 'true', - 'InputResourceManifests': 'a string1', - 'ManifestFromManagedAssembly': 'a_file_name', - 'notgood3': 'bogus', - 'OutputManifestFile': 'a_file_name', - 'OutputResourceManifests': 'a string1', - 'RegistrarScriptFile': 'a_file_name', - 'ReplacementsFile': 'a_file_name', - 'SuppressDependencyElement': 'true', - 'SuppressStartupBanner': 'true', - 'TrackerLogDirectory': 'a_folder', - 'TypeLibraryFile': 'a_file_name', - 'UpdateFileHashes': 'true', - 'UpdateFileHashesSearchPath': 'a_file_name', - 'VerboseOutput': 'true'}, - 'ProjectReference': { - 'LinkLibraryDependencies': 'true', - 'UseLibraryDependencyInputs': 'true'}, - 'ManifestResourceCompile': { - 'ResourceOutputFileName': 'a_file_name'}, - '': { - 'EmbedManifest': 'true', - 'GenerateManifest': 'true', - 'IgnoreImportLibrary': 'true', - 'LinkIncremental': 'false'}}, - self.stderr) - self._ExpectedWarnings([ - 'Warning: unrecognized setting ClCompile/Enableprefast', - 'Warning: unrecognized setting ClCompile/ZZXYZ', - 'Warning: unrecognized setting Mt/notgood3', - "Warning: for Mt/GenerateCatalogFiles, expected bool; got 'truel'", - 'Warning: for Lib/TargetMachine, unrecognized enumerated value ' - 'MachineX86i', - "Warning: for Mt/EnableDPIAwareness, expected bool; got 'fal'"]) - - def testConvertToMSBuildSettings_empty(self): - """Tests an empty conversion.""" - msvs_settings = {} - expected_msbuild_settings = {} - actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings( - msvs_settings, - self.stderr) - self.assertEqual(expected_msbuild_settings, actual_msbuild_settings) - self._ExpectedWarnings([]) - - def testConvertToMSBuildSettings_minimal(self): - """Tests a minimal conversion.""" - msvs_settings = { - 'VCCLCompilerTool': { - 'AdditionalIncludeDirectories': 'dir1', - 'AdditionalOptions': '/foo', - 'BasicRuntimeChecks': '0', - }, - 'VCLinkerTool': { - 'LinkTimeCodeGeneration': '1', - 'ErrorReporting': '1', - 'DataExecutionPrevention': '2', - }, - } - expected_msbuild_settings = { - 'ClCompile': { - 'AdditionalIncludeDirectories': 'dir1', - 'AdditionalOptions': '/foo', - 'BasicRuntimeChecks': 'Default', - }, - 'Link': { - 'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration', - 'LinkErrorReporting': 'PromptImmediately', - 'DataExecutionPrevention': 'true', - }, - } - actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings( - msvs_settings, - self.stderr) - self.assertEqual(expected_msbuild_settings, actual_msbuild_settings) - self._ExpectedWarnings([]) - - def testConvertToMSBuildSettings_warnings(self): - """Tests conversion that generates warnings.""" - msvs_settings = { - 'VCCLCompilerTool': { - 'AdditionalIncludeDirectories': '1', - 'AdditionalOptions': '2', - # These are incorrect values: - 'BasicRuntimeChecks': '12', - 'BrowseInformation': '21', - 'UsePrecompiledHeader': '13', - 'GeneratePreprocessedFile': '14'}, - 'VCLinkerTool': { - # These are incorrect values: - 'Driver': '10', - 'LinkTimeCodeGeneration': '31', - 'ErrorReporting': '21', - 'FixedBaseAddress': '6'}, - 'VCResourceCompilerTool': { - # Custom - 'Culture': '1003'}} - expected_msbuild_settings = { - 'ClCompile': { - 'AdditionalIncludeDirectories': '1', - 'AdditionalOptions': '2'}, - 'Link': {}, - 'ResourceCompile': { - # Custom - 'Culture': '0x03eb'}} - actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings( - msvs_settings, - self.stderr) - self.assertEqual(expected_msbuild_settings, actual_msbuild_settings) - self._ExpectedWarnings([ - 'Warning: while converting VCCLCompilerTool/BasicRuntimeChecks to ' - 'MSBuild, index value (12) not in expected range [0, 4)', - 'Warning: while converting VCCLCompilerTool/BrowseInformation to ' - 'MSBuild, index value (21) not in expected range [0, 3)', - 'Warning: while converting VCCLCompilerTool/UsePrecompiledHeader to ' - 'MSBuild, index value (13) not in expected range [0, 3)', - 'Warning: while converting VCCLCompilerTool/GeneratePreprocessedFile to ' - 'MSBuild, value must be one of [0, 1, 2]; got 14', - - 'Warning: while converting VCLinkerTool/Driver to ' - 'MSBuild, index value (10) not in expected range [0, 4)', - 'Warning: while converting VCLinkerTool/LinkTimeCodeGeneration to ' - 'MSBuild, index value (31) not in expected range [0, 5)', - 'Warning: while converting VCLinkerTool/ErrorReporting to ' - 'MSBuild, index value (21) not in expected range [0, 3)', - 'Warning: while converting VCLinkerTool/FixedBaseAddress to ' - 'MSBuild, index value (6) not in expected range [0, 3)', - ]) - - def testConvertToMSBuildSettings_full_synthetic(self): - """Tests conversion of all the MSBuild settings.""" - msvs_settings = { - 'VCCLCompilerTool': { - 'AdditionalIncludeDirectories': 'folder1;folder2;folder3', - 'AdditionalOptions': 'a_string', - 'AdditionalUsingDirectories': 'folder1;folder2;folder3', - 'AssemblerListingLocation': 'a_file_name', - 'AssemblerOutput': '0', - 'BasicRuntimeChecks': '1', - 'BrowseInformation': '2', - 'BrowseInformationFile': 'a_file_name', - 'BufferSecurityCheck': 'true', - 'CallingConvention': '0', - 'CompileAs': '1', - 'DebugInformationFormat': '4', - 'DefaultCharIsUnsigned': 'true', - 'Detect64BitPortabilityProblems': 'true', - 'DisableLanguageExtensions': 'true', - 'DisableSpecificWarnings': 'd1;d2;d3', - 'EnableEnhancedInstructionSet': '0', - 'EnableFiberSafeOptimizations': 'true', - 'EnableFunctionLevelLinking': 'true', - 'EnableIntrinsicFunctions': 'true', - 'EnablePREfast': 'true', - 'ErrorReporting': '1', - 'ExceptionHandling': '2', - 'ExpandAttributedSource': 'true', - 'FavorSizeOrSpeed': '0', - 'FloatingPointExceptions': 'true', - 'FloatingPointModel': '1', - 'ForceConformanceInForLoopScope': 'true', - 'ForcedIncludeFiles': 'file1;file2;file3', - 'ForcedUsingFiles': 'file1;file2;file3', - 'GeneratePreprocessedFile': '1', - 'GenerateXMLDocumentationFiles': 'true', - 'IgnoreStandardIncludePath': 'true', - 'InlineFunctionExpansion': '2', - 'KeepComments': 'true', - 'MinimalRebuild': 'true', - 'ObjectFile': 'a_file_name', - 'OmitDefaultLibName': 'true', - 'OmitFramePointers': 'true', - 'OpenMP': 'true', - 'Optimization': '3', - 'PrecompiledHeaderFile': 'a_file_name', - 'PrecompiledHeaderThrough': 'a_file_name', - 'PreprocessorDefinitions': 'd1;d2;d3', - 'ProgramDataBaseFileName': 'a_file_name', - 'RuntimeLibrary': '0', - 'RuntimeTypeInfo': 'true', - 'ShowIncludes': 'true', - 'SmallerTypeCheck': 'true', - 'StringPooling': 'true', - 'StructMemberAlignment': '1', - 'SuppressStartupBanner': 'true', - 'TreatWChar_tAsBuiltInType': 'true', - 'UndefineAllPreprocessorDefinitions': 'true', - 'UndefinePreprocessorDefinitions': 'd1;d2;d3', - 'UseFullPaths': 'true', - 'UsePrecompiledHeader': '1', - 'UseUnicodeResponseFiles': 'true', - 'WarnAsError': 'true', - 'WarningLevel': '2', - 'WholeProgramOptimization': 'true', - 'XMLDocumentationFileName': 'a_file_name'}, - 'VCLinkerTool': { - 'AdditionalDependencies': 'file1;file2;file3', - 'AdditionalLibraryDirectories': 'folder1;folder2;folder3', - 'AdditionalLibraryDirectories_excluded': 'folder1;folder2;folder3', - 'AdditionalManifestDependencies': 'file1;file2;file3', - 'AdditionalOptions': 'a_string', - 'AddModuleNamesToAssembly': 'file1;file2;file3', - 'AllowIsolation': 'true', - 'AssemblyDebug': '0', - 'AssemblyLinkResource': 'file1;file2;file3', - 'BaseAddress': 'a_string', - 'CLRImageType': '1', - 'CLRThreadAttribute': '2', - 'CLRUnmanagedCodeCheck': 'true', - 'DataExecutionPrevention': '0', - 'DelayLoadDLLs': 'file1;file2;file3', - 'DelaySign': 'true', - 'Driver': '1', - 'EmbedManagedResourceFile': 'file1;file2;file3', - 'EnableCOMDATFolding': '0', - 'EnableUAC': 'true', - 'EntryPointSymbol': 'a_string', - 'ErrorReporting': '0', - 'FixedBaseAddress': '1', - 'ForceSymbolReferences': 'file1;file2;file3', - 'FunctionOrder': 'a_file_name', - 'GenerateDebugInformation': 'true', - 'GenerateManifest': 'true', - 'GenerateMapFile': 'true', - 'HeapCommitSize': 'a_string', - 'HeapReserveSize': 'a_string', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreDefaultLibraryNames': 'file1;file2;file3', - 'IgnoreEmbeddedIDL': 'true', - 'IgnoreImportLibrary': 'true', - 'ImportLibrary': 'a_file_name', - 'KeyContainer': 'a_file_name', - 'KeyFile': 'a_file_name', - 'LargeAddressAware': '2', - 'LinkIncremental': '1', - 'LinkLibraryDependencies': 'true', - 'LinkTimeCodeGeneration': '2', - 'ManifestFile': 'a_file_name', - 'MapExports': 'true', - 'MapFileName': 'a_file_name', - 'MergedIDLBaseFileName': 'a_file_name', - 'MergeSections': 'a_string', - 'MidlCommandFile': 'a_file_name', - 'ModuleDefinitionFile': 'a_file_name', - 'OptimizeForWindows98': '1', - 'OptimizeReferences': '0', - 'OutputFile': 'a_file_name', - 'PerUserRedirection': 'true', - 'Profile': 'true', - 'ProfileGuidedDatabase': 'a_file_name', - 'ProgramDatabaseFile': 'a_file_name', - 'RandomizedBaseAddress': '1', - 'RegisterOutput': 'true', - 'ResourceOnlyDLL': 'true', - 'SetChecksum': 'true', - 'ShowProgress': '0', - 'StackCommitSize': 'a_string', - 'StackReserveSize': 'a_string', - 'StripPrivateSymbols': 'a_file_name', - 'SubSystem': '2', - 'SupportUnloadOfDelayLoadedDLL': 'true', - 'SuppressStartupBanner': 'true', - 'SwapRunFromCD': 'true', - 'SwapRunFromNet': 'true', - 'TargetMachine': '3', - 'TerminalServerAware': '2', - 'TurnOffAssemblyGeneration': 'true', - 'TypeLibraryFile': 'a_file_name', - 'TypeLibraryResourceID': '33', - 'UACExecutionLevel': '1', - 'UACUIAccess': 'true', - 'UseLibraryDependencyInputs': 'false', - 'UseUnicodeResponseFiles': 'true', - 'Version': 'a_string'}, - 'VCResourceCompilerTool': { - 'AdditionalIncludeDirectories': 'folder1;folder2;folder3', - 'AdditionalOptions': 'a_string', - 'Culture': '1003', - 'IgnoreStandardIncludePath': 'true', - 'PreprocessorDefinitions': 'd1;d2;d3', - 'ResourceOutputFileName': 'a_string', - 'ShowProgress': 'true', - 'SuppressStartupBanner': 'true', - 'UndefinePreprocessorDefinitions': 'd1;d2;d3'}, - 'VCMIDLTool': { - 'AdditionalIncludeDirectories': 'folder1;folder2;folder3', - 'AdditionalOptions': 'a_string', - 'CPreprocessOptions': 'a_string', - 'DefaultCharType': '0', - 'DLLDataFileName': 'a_file_name', - 'EnableErrorChecks': '2', - 'ErrorCheckAllocations': 'true', - 'ErrorCheckBounds': 'true', - 'ErrorCheckEnumRange': 'true', - 'ErrorCheckRefPointers': 'true', - 'ErrorCheckStubData': 'true', - 'GenerateStublessProxies': 'true', - 'GenerateTypeLibrary': 'true', - 'HeaderFileName': 'a_file_name', - 'IgnoreStandardIncludePath': 'true', - 'InterfaceIdentifierFileName': 'a_file_name', - 'MkTypLibCompatible': 'true', - 'OutputDirectory': 'a_string', - 'PreprocessorDefinitions': 'd1;d2;d3', - 'ProxyFileName': 'a_file_name', - 'RedirectOutputAndErrors': 'a_file_name', - 'StructMemberAlignment': '3', - 'SuppressStartupBanner': 'true', - 'TargetEnvironment': '1', - 'TypeLibraryName': 'a_file_name', - 'UndefinePreprocessorDefinitions': 'd1;d2;d3', - 'ValidateParameters': 'true', - 'WarnAsError': 'true', - 'WarningLevel': '4'}, - 'VCLibrarianTool': { - 'AdditionalDependencies': 'file1;file2;file3', - 'AdditionalLibraryDirectories': 'folder1;folder2;folder3', - 'AdditionalLibraryDirectories_excluded': 'folder1;folder2;folder3', - 'AdditionalOptions': 'a_string', - 'ExportNamedFunctions': 'd1;d2;d3', - 'ForceSymbolReferences': 'a_string', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3', - 'LinkLibraryDependencies': 'true', - 'ModuleDefinitionFile': 'a_file_name', - 'OutputFile': 'a_file_name', - 'SuppressStartupBanner': 'true', - 'UseUnicodeResponseFiles': 'true'}, - 'VCManifestTool': { - 'AdditionalManifestFiles': 'file1;file2;file3', - 'AdditionalOptions': 'a_string', - 'AssemblyIdentity': 'a_string', - 'ComponentFileName': 'a_file_name', - 'DependencyInformationFile': 'a_file_name', - 'EmbedManifest': 'true', - 'GenerateCatalogFiles': 'true', - 'InputResourceManifests': 'a_string', - 'ManifestResourceFile': 'my_name', - 'OutputManifestFile': 'a_file_name', - 'RegistrarScriptFile': 'a_file_name', - 'ReplacementsFile': 'a_file_name', - 'SuppressStartupBanner': 'true', - 'TypeLibraryFile': 'a_file_name', - 'UpdateFileHashes': 'true', - 'UpdateFileHashesSearchPath': 'a_file_name', - 'UseFAT32Workaround': 'true', - 'UseUnicodeResponseFiles': 'true', - 'VerboseOutput': 'true'}} - expected_msbuild_settings = { - 'ClCompile': { - 'AdditionalIncludeDirectories': 'folder1;folder2;folder3', - 'AdditionalOptions': 'a_string /J', - 'AdditionalUsingDirectories': 'folder1;folder2;folder3', - 'AssemblerListingLocation': 'a_file_name', - 'AssemblerOutput': 'NoListing', - 'BasicRuntimeChecks': 'StackFrameRuntimeCheck', - 'BrowseInformation': 'true', - 'BrowseInformationFile': 'a_file_name', - 'BufferSecurityCheck': 'true', - 'CallingConvention': 'Cdecl', - 'CompileAs': 'CompileAsC', - 'DebugInformationFormat': 'EditAndContinue', - 'DisableLanguageExtensions': 'true', - 'DisableSpecificWarnings': 'd1;d2;d3', - 'EnableEnhancedInstructionSet': 'NotSet', - 'EnableFiberSafeOptimizations': 'true', - 'EnablePREfast': 'true', - 'ErrorReporting': 'Prompt', - 'ExceptionHandling': 'Async', - 'ExpandAttributedSource': 'true', - 'FavorSizeOrSpeed': 'Neither', - 'FloatingPointExceptions': 'true', - 'FloatingPointModel': 'Strict', - 'ForceConformanceInForLoopScope': 'true', - 'ForcedIncludeFiles': 'file1;file2;file3', - 'ForcedUsingFiles': 'file1;file2;file3', - 'FunctionLevelLinking': 'true', - 'GenerateXMLDocumentationFiles': 'true', - 'IgnoreStandardIncludePath': 'true', - 'InlineFunctionExpansion': 'AnySuitable', - 'IntrinsicFunctions': 'true', - 'MinimalRebuild': 'true', - 'ObjectFileName': 'a_file_name', - 'OmitDefaultLibName': 'true', - 'OmitFramePointers': 'true', - 'OpenMPSupport': 'true', - 'Optimization': 'Full', - 'PrecompiledHeader': 'Create', - 'PrecompiledHeaderFile': 'a_file_name', - 'PrecompiledHeaderOutputFile': 'a_file_name', - 'PreprocessKeepComments': 'true', - 'PreprocessorDefinitions': 'd1;d2;d3', - 'PreprocessSuppressLineNumbers': 'false', - 'PreprocessToFile': 'true', - 'ProgramDataBaseFileName': 'a_file_name', - 'RuntimeLibrary': 'MultiThreaded', - 'RuntimeTypeInfo': 'true', - 'ShowIncludes': 'true', - 'SmallerTypeCheck': 'true', - 'StringPooling': 'true', - 'StructMemberAlignment': '1Byte', - 'SuppressStartupBanner': 'true', - 'TreatWarningAsError': 'true', - 'TreatWChar_tAsBuiltInType': 'true', - 'UndefineAllPreprocessorDefinitions': 'true', - 'UndefinePreprocessorDefinitions': 'd1;d2;d3', - 'UseFullPaths': 'true', - 'WarningLevel': 'Level2', - 'WholeProgramOptimization': 'true', - 'XMLDocumentationFileName': 'a_file_name'}, - 'Link': { - 'AdditionalDependencies': 'file1;file2;file3', - 'AdditionalLibraryDirectories': 'folder1;folder2;folder3', - 'AdditionalManifestDependencies': 'file1;file2;file3', - 'AdditionalOptions': 'a_string', - 'AddModuleNamesToAssembly': 'file1;file2;file3', - 'AllowIsolation': 'true', - 'AssemblyDebug': '', - 'AssemblyLinkResource': 'file1;file2;file3', - 'BaseAddress': 'a_string', - 'CLRImageType': 'ForceIJWImage', - 'CLRThreadAttribute': 'STAThreadingAttribute', - 'CLRUnmanagedCodeCheck': 'true', - 'DataExecutionPrevention': '', - 'DelayLoadDLLs': 'file1;file2;file3', - 'DelaySign': 'true', - 'Driver': 'Driver', - 'EmbedManagedResourceFile': 'file1;file2;file3', - 'EnableCOMDATFolding': '', - 'EnableUAC': 'true', - 'EntryPointSymbol': 'a_string', - 'FixedBaseAddress': 'false', - 'ForceSymbolReferences': 'file1;file2;file3', - 'FunctionOrder': 'a_file_name', - 'GenerateDebugInformation': 'true', - 'GenerateMapFile': 'true', - 'HeapCommitSize': 'a_string', - 'HeapReserveSize': 'a_string', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreEmbeddedIDL': 'true', - 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3', - 'ImportLibrary': 'a_file_name', - 'KeyContainer': 'a_file_name', - 'KeyFile': 'a_file_name', - 'LargeAddressAware': 'true', - 'LinkErrorReporting': 'NoErrorReport', - 'LinkTimeCodeGeneration': 'PGInstrument', - 'ManifestFile': 'a_file_name', - 'MapExports': 'true', - 'MapFileName': 'a_file_name', - 'MergedIDLBaseFileName': 'a_file_name', - 'MergeSections': 'a_string', - 'MidlCommandFile': 'a_file_name', - 'ModuleDefinitionFile': 'a_file_name', - 'NoEntryPoint': 'true', - 'OptimizeReferences': '', - 'OutputFile': 'a_file_name', - 'PerUserRedirection': 'true', - 'Profile': 'true', - 'ProfileGuidedDatabase': 'a_file_name', - 'ProgramDatabaseFile': 'a_file_name', - 'RandomizedBaseAddress': 'false', - 'RegisterOutput': 'true', - 'SetChecksum': 'true', - 'ShowProgress': 'NotSet', - 'StackCommitSize': 'a_string', - 'StackReserveSize': 'a_string', - 'StripPrivateSymbols': 'a_file_name', - 'SubSystem': 'Windows', - 'SupportUnloadOfDelayLoadedDLL': 'true', - 'SuppressStartupBanner': 'true', - 'SwapRunFromCD': 'true', - 'SwapRunFromNET': 'true', - 'TargetMachine': 'MachineARM', - 'TerminalServerAware': 'true', - 'TurnOffAssemblyGeneration': 'true', - 'TypeLibraryFile': 'a_file_name', - 'TypeLibraryResourceID': '33', - 'UACExecutionLevel': 'HighestAvailable', - 'UACUIAccess': 'true', - 'Version': 'a_string'}, - 'ResourceCompile': { - 'AdditionalIncludeDirectories': 'folder1;folder2;folder3', - 'AdditionalOptions': 'a_string', - 'Culture': '0x03eb', - 'IgnoreStandardIncludePath': 'true', - 'PreprocessorDefinitions': 'd1;d2;d3', - 'ResourceOutputFileName': 'a_string', - 'ShowProgress': 'true', - 'SuppressStartupBanner': 'true', - 'UndefinePreprocessorDefinitions': 'd1;d2;d3'}, - 'Midl': { - 'AdditionalIncludeDirectories': 'folder1;folder2;folder3', - 'AdditionalOptions': 'a_string', - 'CPreprocessOptions': 'a_string', - 'DefaultCharType': 'Unsigned', - 'DllDataFileName': 'a_file_name', - 'EnableErrorChecks': 'All', - 'ErrorCheckAllocations': 'true', - 'ErrorCheckBounds': 'true', - 'ErrorCheckEnumRange': 'true', - 'ErrorCheckRefPointers': 'true', - 'ErrorCheckStubData': 'true', - 'GenerateStublessProxies': 'true', - 'GenerateTypeLibrary': 'true', - 'HeaderFileName': 'a_file_name', - 'IgnoreStandardIncludePath': 'true', - 'InterfaceIdentifierFileName': 'a_file_name', - 'MkTypLibCompatible': 'true', - 'OutputDirectory': 'a_string', - 'PreprocessorDefinitions': 'd1;d2;d3', - 'ProxyFileName': 'a_file_name', - 'RedirectOutputAndErrors': 'a_file_name', - 'StructMemberAlignment': '4', - 'SuppressStartupBanner': 'true', - 'TargetEnvironment': 'Win32', - 'TypeLibraryName': 'a_file_name', - 'UndefinePreprocessorDefinitions': 'd1;d2;d3', - 'ValidateAllParameters': 'true', - 'WarnAsError': 'true', - 'WarningLevel': '4'}, - 'Lib': { - 'AdditionalDependencies': 'file1;file2;file3', - 'AdditionalLibraryDirectories': 'folder1;folder2;folder3', - 'AdditionalOptions': 'a_string', - 'ExportNamedFunctions': 'd1;d2;d3', - 'ForceSymbolReferences': 'a_string', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreSpecificDefaultLibraries': 'file1;file2;file3', - 'ModuleDefinitionFile': 'a_file_name', - 'OutputFile': 'a_file_name', - 'SuppressStartupBanner': 'true', - 'UseUnicodeResponseFiles': 'true'}, - 'Mt': { - 'AdditionalManifestFiles': 'file1;file2;file3', - 'AdditionalOptions': 'a_string', - 'AssemblyIdentity': 'a_string', - 'ComponentFileName': 'a_file_name', - 'GenerateCatalogFiles': 'true', - 'InputResourceManifests': 'a_string', - 'OutputManifestFile': 'a_file_name', - 'RegistrarScriptFile': 'a_file_name', - 'ReplacementsFile': 'a_file_name', - 'SuppressStartupBanner': 'true', - 'TypeLibraryFile': 'a_file_name', - 'UpdateFileHashes': 'true', - 'UpdateFileHashesSearchPath': 'a_file_name', - 'VerboseOutput': 'true'}, - 'ManifestResourceCompile': { - 'ResourceOutputFileName': 'my_name'}, - 'ProjectReference': { - 'LinkLibraryDependencies': 'true', - 'UseLibraryDependencyInputs': 'false'}, - '': { - 'EmbedManifest': 'true', - 'GenerateManifest': 'true', - 'IgnoreImportLibrary': 'true', - 'LinkIncremental': 'false'}} - actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings( - msvs_settings, - self.stderr) - self.assertEqual(expected_msbuild_settings, actual_msbuild_settings) - self._ExpectedWarnings([]) - - def testConvertToMSBuildSettings_actual(self): - """Tests the conversion of an actual project. - - A VS2008 project with most of the options defined was created through the - VS2008 IDE. It was then converted to VS2010. The tool settings found in - the .vcproj and .vcxproj files were converted to the two dictionaries - msvs_settings and expected_msbuild_settings. - - Note that for many settings, the VS2010 converter adds macros like - %(AdditionalIncludeDirectories) to make sure than inherited values are - included. Since the Gyp projects we generate do not use inheritance, - we removed these macros. They were: - ClCompile: - AdditionalIncludeDirectories: ';%(AdditionalIncludeDirectories)' - AdditionalOptions: ' %(AdditionalOptions)' - AdditionalUsingDirectories: ';%(AdditionalUsingDirectories)' - DisableSpecificWarnings: ';%(DisableSpecificWarnings)', - ForcedIncludeFiles: ';%(ForcedIncludeFiles)', - ForcedUsingFiles: ';%(ForcedUsingFiles)', - PreprocessorDefinitions: ';%(PreprocessorDefinitions)', - UndefinePreprocessorDefinitions: - ';%(UndefinePreprocessorDefinitions)', - Link: - AdditionalDependencies: ';%(AdditionalDependencies)', - AdditionalLibraryDirectories: ';%(AdditionalLibraryDirectories)', - AdditionalManifestDependencies: - ';%(AdditionalManifestDependencies)', - AdditionalOptions: ' %(AdditionalOptions)', - AddModuleNamesToAssembly: ';%(AddModuleNamesToAssembly)', - AssemblyLinkResource: ';%(AssemblyLinkResource)', - DelayLoadDLLs: ';%(DelayLoadDLLs)', - EmbedManagedResourceFile: ';%(EmbedManagedResourceFile)', - ForceSymbolReferences: ';%(ForceSymbolReferences)', - IgnoreSpecificDefaultLibraries: - ';%(IgnoreSpecificDefaultLibraries)', - ResourceCompile: - AdditionalIncludeDirectories: ';%(AdditionalIncludeDirectories)', - AdditionalOptions: ' %(AdditionalOptions)', - PreprocessorDefinitions: ';%(PreprocessorDefinitions)', - Mt: - AdditionalManifestFiles: ';%(AdditionalManifestFiles)', - AdditionalOptions: ' %(AdditionalOptions)', - InputResourceManifests: ';%(InputResourceManifests)', - """ - msvs_settings = { - 'VCCLCompilerTool': { - 'AdditionalIncludeDirectories': 'dir1', - 'AdditionalOptions': '/more', - 'AdditionalUsingDirectories': 'test', - 'AssemblerListingLocation': '$(IntDir)\\a', - 'AssemblerOutput': '1', - 'BasicRuntimeChecks': '3', - 'BrowseInformation': '1', - 'BrowseInformationFile': '$(IntDir)\\e', - 'BufferSecurityCheck': 'false', - 'CallingConvention': '1', - 'CompileAs': '1', - 'DebugInformationFormat': '4', - 'DefaultCharIsUnsigned': 'true', - 'Detect64BitPortabilityProblems': 'true', - 'DisableLanguageExtensions': 'true', - 'DisableSpecificWarnings': 'abc', - 'EnableEnhancedInstructionSet': '1', - 'EnableFiberSafeOptimizations': 'true', - 'EnableFunctionLevelLinking': 'true', - 'EnableIntrinsicFunctions': 'true', - 'EnablePREfast': 'true', - 'ErrorReporting': '2', - 'ExceptionHandling': '2', - 'ExpandAttributedSource': 'true', - 'FavorSizeOrSpeed': '2', - 'FloatingPointExceptions': 'true', - 'FloatingPointModel': '1', - 'ForceConformanceInForLoopScope': 'false', - 'ForcedIncludeFiles': 'def', - 'ForcedUsingFiles': 'ge', - 'GeneratePreprocessedFile': '2', - 'GenerateXMLDocumentationFiles': 'true', - 'IgnoreStandardIncludePath': 'true', - 'InlineFunctionExpansion': '1', - 'KeepComments': 'true', - 'MinimalRebuild': 'true', - 'ObjectFile': '$(IntDir)\\b', - 'OmitDefaultLibName': 'true', - 'OmitFramePointers': 'true', - 'OpenMP': 'true', - 'Optimization': '3', - 'PrecompiledHeaderFile': '$(IntDir)\\$(TargetName).pche', - 'PrecompiledHeaderThrough': 'StdAfx.hd', - 'PreprocessorDefinitions': 'WIN32;_DEBUG;_CONSOLE', - 'ProgramDataBaseFileName': '$(IntDir)\\vc90b.pdb', - 'RuntimeLibrary': '3', - 'RuntimeTypeInfo': 'false', - 'ShowIncludes': 'true', - 'SmallerTypeCheck': 'true', - 'StringPooling': 'true', - 'StructMemberAlignment': '3', - 'SuppressStartupBanner': 'false', - 'TreatWChar_tAsBuiltInType': 'false', - 'UndefineAllPreprocessorDefinitions': 'true', - 'UndefinePreprocessorDefinitions': 'wer', - 'UseFullPaths': 'true', - 'UsePrecompiledHeader': '0', - 'UseUnicodeResponseFiles': 'false', - 'WarnAsError': 'true', - 'WarningLevel': '3', - 'WholeProgramOptimization': 'true', - 'XMLDocumentationFileName': '$(IntDir)\\c'}, - 'VCLinkerTool': { - 'AdditionalDependencies': 'zx', - 'AdditionalLibraryDirectories': 'asd', - 'AdditionalManifestDependencies': 's2', - 'AdditionalOptions': '/mor2', - 'AddModuleNamesToAssembly': 'd1', - 'AllowIsolation': 'false', - 'AssemblyDebug': '1', - 'AssemblyLinkResource': 'd5', - 'BaseAddress': '23423', - 'CLRImageType': '3', - 'CLRThreadAttribute': '1', - 'CLRUnmanagedCodeCheck': 'true', - 'DataExecutionPrevention': '0', - 'DelayLoadDLLs': 'd4', - 'DelaySign': 'true', - 'Driver': '2', - 'EmbedManagedResourceFile': 'd2', - 'EnableCOMDATFolding': '1', - 'EnableUAC': 'false', - 'EntryPointSymbol': 'f5', - 'ErrorReporting': '2', - 'FixedBaseAddress': '1', - 'ForceSymbolReferences': 'd3', - 'FunctionOrder': 'fssdfsd', - 'GenerateDebugInformation': 'true', - 'GenerateManifest': 'false', - 'GenerateMapFile': 'true', - 'HeapCommitSize': '13', - 'HeapReserveSize': '12', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreDefaultLibraryNames': 'flob;flok', - 'IgnoreEmbeddedIDL': 'true', - 'IgnoreImportLibrary': 'true', - 'ImportLibrary': 'f4', - 'KeyContainer': 'f7', - 'KeyFile': 'f6', - 'LargeAddressAware': '2', - 'LinkIncremental': '0', - 'LinkLibraryDependencies': 'false', - 'LinkTimeCodeGeneration': '1', - 'ManifestFile': - '$(IntDir)\\$(TargetFileName).2intermediate.manifest', - 'MapExports': 'true', - 'MapFileName': 'd5', - 'MergedIDLBaseFileName': 'f2', - 'MergeSections': 'f5', - 'MidlCommandFile': 'f1', - 'ModuleDefinitionFile': 'sdsd', - 'OptimizeForWindows98': '2', - 'OptimizeReferences': '2', - 'OutputFile': '$(OutDir)\\$(ProjectName)2.exe', - 'PerUserRedirection': 'true', - 'Profile': 'true', - 'ProfileGuidedDatabase': '$(TargetDir)$(TargetName).pgdd', - 'ProgramDatabaseFile': 'Flob.pdb', - 'RandomizedBaseAddress': '1', - 'RegisterOutput': 'true', - 'ResourceOnlyDLL': 'true', - 'SetChecksum': 'false', - 'ShowProgress': '1', - 'StackCommitSize': '15', - 'StackReserveSize': '14', - 'StripPrivateSymbols': 'd3', - 'SubSystem': '1', - 'SupportUnloadOfDelayLoadedDLL': 'true', - 'SuppressStartupBanner': 'false', - 'SwapRunFromCD': 'true', - 'SwapRunFromNet': 'true', - 'TargetMachine': '1', - 'TerminalServerAware': '1', - 'TurnOffAssemblyGeneration': 'true', - 'TypeLibraryFile': 'f3', - 'TypeLibraryResourceID': '12', - 'UACExecutionLevel': '2', - 'UACUIAccess': 'true', - 'UseLibraryDependencyInputs': 'true', - 'UseUnicodeResponseFiles': 'false', - 'Version': '333'}, - 'VCResourceCompilerTool': { - 'AdditionalIncludeDirectories': 'f3', - 'AdditionalOptions': '/more3', - 'Culture': '3084', - 'IgnoreStandardIncludePath': 'true', - 'PreprocessorDefinitions': '_UNICODE;UNICODE2', - 'ResourceOutputFileName': '$(IntDir)/$(InputName)3.res', - 'ShowProgress': 'true'}, - 'VCManifestTool': { - 'AdditionalManifestFiles': 'sfsdfsd', - 'AdditionalOptions': 'afdsdafsd', - 'AssemblyIdentity': 'sddfdsadfsa', - 'ComponentFileName': 'fsdfds', - 'DependencyInformationFile': '$(IntDir)\\mt.depdfd', - 'EmbedManifest': 'false', - 'GenerateCatalogFiles': 'true', - 'InputResourceManifests': 'asfsfdafs', - 'ManifestResourceFile': - '$(IntDir)\\$(TargetFileName).embed.manifest.resfdsf', - 'OutputManifestFile': '$(TargetPath).manifestdfs', - 'RegistrarScriptFile': 'sdfsfd', - 'ReplacementsFile': 'sdffsd', - 'SuppressStartupBanner': 'false', - 'TypeLibraryFile': 'sfsd', - 'UpdateFileHashes': 'true', - 'UpdateFileHashesSearchPath': 'sfsd', - 'UseFAT32Workaround': 'true', - 'UseUnicodeResponseFiles': 'false', - 'VerboseOutput': 'true'}} - expected_msbuild_settings = { - 'ClCompile': { - 'AdditionalIncludeDirectories': 'dir1', - 'AdditionalOptions': '/more /J', - 'AdditionalUsingDirectories': 'test', - 'AssemblerListingLocation': '$(IntDir)a', - 'AssemblerOutput': 'AssemblyCode', - 'BasicRuntimeChecks': 'EnableFastChecks', - 'BrowseInformation': 'true', - 'BrowseInformationFile': '$(IntDir)e', - 'BufferSecurityCheck': 'false', - 'CallingConvention': 'FastCall', - 'CompileAs': 'CompileAsC', - 'DebugInformationFormat': 'EditAndContinue', - 'DisableLanguageExtensions': 'true', - 'DisableSpecificWarnings': 'abc', - 'EnableEnhancedInstructionSet': 'StreamingSIMDExtensions', - 'EnableFiberSafeOptimizations': 'true', - 'EnablePREfast': 'true', - 'ErrorReporting': 'Queue', - 'ExceptionHandling': 'Async', - 'ExpandAttributedSource': 'true', - 'FavorSizeOrSpeed': 'Size', - 'FloatingPointExceptions': 'true', - 'FloatingPointModel': 'Strict', - 'ForceConformanceInForLoopScope': 'false', - 'ForcedIncludeFiles': 'def', - 'ForcedUsingFiles': 'ge', - 'FunctionLevelLinking': 'true', - 'GenerateXMLDocumentationFiles': 'true', - 'IgnoreStandardIncludePath': 'true', - 'InlineFunctionExpansion': 'OnlyExplicitInline', - 'IntrinsicFunctions': 'true', - 'MinimalRebuild': 'true', - 'ObjectFileName': '$(IntDir)b', - 'OmitDefaultLibName': 'true', - 'OmitFramePointers': 'true', - 'OpenMPSupport': 'true', - 'Optimization': 'Full', - 'PrecompiledHeader': 'NotUsing', # Actual conversion gives '' - 'PrecompiledHeaderFile': 'StdAfx.hd', - 'PrecompiledHeaderOutputFile': '$(IntDir)$(TargetName).pche', - 'PreprocessKeepComments': 'true', - 'PreprocessorDefinitions': 'WIN32;_DEBUG;_CONSOLE', - 'PreprocessSuppressLineNumbers': 'true', - 'PreprocessToFile': 'true', - 'ProgramDataBaseFileName': '$(IntDir)vc90b.pdb', - 'RuntimeLibrary': 'MultiThreadedDebugDLL', - 'RuntimeTypeInfo': 'false', - 'ShowIncludes': 'true', - 'SmallerTypeCheck': 'true', - 'StringPooling': 'true', - 'StructMemberAlignment': '4Bytes', - 'SuppressStartupBanner': 'false', - 'TreatWarningAsError': 'true', - 'TreatWChar_tAsBuiltInType': 'false', - 'UndefineAllPreprocessorDefinitions': 'true', - 'UndefinePreprocessorDefinitions': 'wer', - 'UseFullPaths': 'true', - 'WarningLevel': 'Level3', - 'WholeProgramOptimization': 'true', - 'XMLDocumentationFileName': '$(IntDir)c'}, - 'Link': { - 'AdditionalDependencies': 'zx', - 'AdditionalLibraryDirectories': 'asd', - 'AdditionalManifestDependencies': 's2', - 'AdditionalOptions': '/mor2', - 'AddModuleNamesToAssembly': 'd1', - 'AllowIsolation': 'false', - 'AssemblyDebug': 'true', - 'AssemblyLinkResource': 'd5', - 'BaseAddress': '23423', - 'CLRImageType': 'ForceSafeILImage', - 'CLRThreadAttribute': 'MTAThreadingAttribute', - 'CLRUnmanagedCodeCheck': 'true', - 'DataExecutionPrevention': '', - 'DelayLoadDLLs': 'd4', - 'DelaySign': 'true', - 'Driver': 'UpOnly', - 'EmbedManagedResourceFile': 'd2', - 'EnableCOMDATFolding': 'false', - 'EnableUAC': 'false', - 'EntryPointSymbol': 'f5', - 'FixedBaseAddress': 'false', - 'ForceSymbolReferences': 'd3', - 'FunctionOrder': 'fssdfsd', - 'GenerateDebugInformation': 'true', - 'GenerateMapFile': 'true', - 'HeapCommitSize': '13', - 'HeapReserveSize': '12', - 'IgnoreAllDefaultLibraries': 'true', - 'IgnoreEmbeddedIDL': 'true', - 'IgnoreSpecificDefaultLibraries': 'flob;flok', - 'ImportLibrary': 'f4', - 'KeyContainer': 'f7', - 'KeyFile': 'f6', - 'LargeAddressAware': 'true', - 'LinkErrorReporting': 'QueueForNextLogin', - 'LinkTimeCodeGeneration': 'UseLinkTimeCodeGeneration', - 'ManifestFile': '$(IntDir)$(TargetFileName).2intermediate.manifest', - 'MapExports': 'true', - 'MapFileName': 'd5', - 'MergedIDLBaseFileName': 'f2', - 'MergeSections': 'f5', - 'MidlCommandFile': 'f1', - 'ModuleDefinitionFile': 'sdsd', - 'NoEntryPoint': 'true', - 'OptimizeReferences': 'true', - 'OutputFile': '$(OutDir)$(ProjectName)2.exe', - 'PerUserRedirection': 'true', - 'Profile': 'true', - 'ProfileGuidedDatabase': '$(TargetDir)$(TargetName).pgdd', - 'ProgramDatabaseFile': 'Flob.pdb', - 'RandomizedBaseAddress': 'false', - 'RegisterOutput': 'true', - 'SetChecksum': 'false', - 'ShowProgress': 'LinkVerbose', - 'StackCommitSize': '15', - 'StackReserveSize': '14', - 'StripPrivateSymbols': 'd3', - 'SubSystem': 'Console', - 'SupportUnloadOfDelayLoadedDLL': 'true', - 'SuppressStartupBanner': 'false', - 'SwapRunFromCD': 'true', - 'SwapRunFromNET': 'true', - 'TargetMachine': 'MachineX86', - 'TerminalServerAware': 'false', - 'TurnOffAssemblyGeneration': 'true', - 'TypeLibraryFile': 'f3', - 'TypeLibraryResourceID': '12', - 'UACExecutionLevel': 'RequireAdministrator', - 'UACUIAccess': 'true', - 'Version': '333'}, - 'ResourceCompile': { - 'AdditionalIncludeDirectories': 'f3', - 'AdditionalOptions': '/more3', - 'Culture': '0x0c0c', - 'IgnoreStandardIncludePath': 'true', - 'PreprocessorDefinitions': '_UNICODE;UNICODE2', - 'ResourceOutputFileName': '$(IntDir)%(Filename)3.res', - 'ShowProgress': 'true'}, - 'Mt': { - 'AdditionalManifestFiles': 'sfsdfsd', - 'AdditionalOptions': 'afdsdafsd', - 'AssemblyIdentity': 'sddfdsadfsa', - 'ComponentFileName': 'fsdfds', - 'GenerateCatalogFiles': 'true', - 'InputResourceManifests': 'asfsfdafs', - 'OutputManifestFile': '$(TargetPath).manifestdfs', - 'RegistrarScriptFile': 'sdfsfd', - 'ReplacementsFile': 'sdffsd', - 'SuppressStartupBanner': 'false', - 'TypeLibraryFile': 'sfsd', - 'UpdateFileHashes': 'true', - 'UpdateFileHashesSearchPath': 'sfsd', - 'VerboseOutput': 'true'}, - 'ProjectReference': { - 'LinkLibraryDependencies': 'false', - 'UseLibraryDependencyInputs': 'true'}, - '': { - 'EmbedManifest': 'false', - 'GenerateManifest': 'false', - 'IgnoreImportLibrary': 'true', - 'LinkIncremental': '' - }, - 'ManifestResourceCompile': { - 'ResourceOutputFileName': - '$(IntDir)$(TargetFileName).embed.manifest.resfdsf'} - } - actual_msbuild_settings = MSVSSettings.ConvertToMSBuildSettings( - msvs_settings, - self.stderr) - self.assertEqual(expected_msbuild_settings, actual_msbuild_settings) - self._ExpectedWarnings([]) - -if __name__ == '__main__': - unittest.main() diff --git a/third_party/gyp/pylib/gyp/MSVSToolFile.py b/third_party/gyp/pylib/gyp/MSVSToolFile.py deleted file mode 100644 index fcad90a..0000000 --- a/third_party/gyp/pylib/gyp/MSVSToolFile.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python2.4 - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Visual Studio project reader/writer.""" - -import common -import gyp.easy_xml as easy_xml - - -class Writer(object): - """Visual Studio XML tool file writer.""" - - def __init__(self, tool_file_path, name): - """Initializes the tool file. - - Args: - tool_file_path: Path to the tool file. - name: Name of the tool file. - """ - self.tool_file_path = tool_file_path - self.name = name - self.rules_section = ['Rules'] - - def AddCustomBuildRule(self, name, cmd, description, - additional_dependencies, - outputs, extensions): - """Adds a rule to the tool file. - - Args: - name: Name of the rule. - description: Description of the rule. - cmd: Command line of the rule. - additional_dependencies: other files which may trigger the rule. - outputs: outputs of the rule. - extensions: extensions handled by the rule. - """ - rule = ['CustomBuildRule', - {'Name': name, - 'ExecutionDescription': description, - 'CommandLine': cmd, - 'Outputs': ';'.join(outputs), - 'FileExtensions': ';'.join(extensions), - 'AdditionalDependencies': - ';'.join(additional_dependencies) - }] - self.rules_section.append(rule) - - def WriteIfChanged(self): - """Writes the tool file.""" - content = ['VisualStudioToolFile', - {'Version': '8.00', - 'Name': self.name - }, - self.rules_section - ] - easy_xml.WriteXmlIfChanged(content, self.tool_file_path, - encoding="Windows-1252") diff --git a/third_party/gyp/pylib/gyp/MSVSUserFile.py b/third_party/gyp/pylib/gyp/MSVSUserFile.py deleted file mode 100644 index 423649f..0000000 --- a/third_party/gyp/pylib/gyp/MSVSUserFile.py +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/python2.4 - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Visual Studio user preferences file writer.""" - -import common -import os -import re -import socket # for gethostname -import gyp.easy_xml as easy_xml - - -#------------------------------------------------------------------------------ - -def _FindCommandInPath(command): - """If there are no slashes in the command given, this function - searches the PATH env to find the given command, and converts it - to an absolute path. We have to do this because MSVS is looking - for an actual file to launch a debugger on, not just a command - line. Note that this happens at GYP time, so anything needing to - be built needs to have a full path.""" - if '/' in command or '\\' in command: - # If the command already has path elements (either relative or - # absolute), then assume it is constructed properly. - return command - else: - # Search through the path list and find an existing file that - # we can access. - paths = os.environ.get('PATH','').split(os.pathsep) - for path in paths: - item = os.path.join(path, command) - if os.path.isfile(item) and os.access(item, os.X_OK): - return item - return command - -def _QuoteWin32CommandLineArgs(args): - new_args = [] - for arg in args: - # Replace all double-quotes with double-double-quotes to escape - # them for cmd shell, and then quote the whole thing if there - # are any. - if arg.find('"') != -1: - arg = '""'.join(arg.split('"')) - arg = '"%s"' % arg - - # Otherwise, if there are any spaces, quote the whole arg. - elif re.search(r'[ \t\n]', arg): - arg = '"%s"' % arg - new_args.append(arg) - return new_args - -class Writer(object): - """Visual Studio XML user user file writer.""" - - def __init__(self, user_file_path, version, name): - """Initializes the user file. - - Args: - user_file_path: Path to the user file. - version: Version info. - name: Name of the user file. - """ - self.user_file_path = user_file_path - self.version = version - self.name = name - self.configurations = {} - - def AddConfig(self, name): - """Adds a configuration to the project. - - Args: - name: Configuration name. - """ - self.configurations[name] = ['Configuration', {'Name': name}] - - def AddDebugSettings(self, config_name, command, environment = {}, - working_directory=""): - """Adds a DebugSettings node to the user file for a particular config. - - Args: - command: command line to run. First element in the list is the - executable. All elements of the command will be quoted if - necessary. - working_directory: other files which may trigger the rule. (optional) - """ - command = _QuoteWin32CommandLineArgs(command) - - abs_command = _FindCommandInPath(command[0]) - - if environment and isinstance(environment, dict): - env_list = ['%s="%s"' % (key, val) - for (key,val) in environment.iteritems()] - environment = ' '.join(env_list) - else: - environment = '' - - n_cmd = ['DebugSettings', - {'Command': abs_command, - 'WorkingDirectory': working_directory, - 'CommandArguments': " ".join(command[1:]), - 'RemoteMachine': socket.gethostname(), - 'Environment': environment, - 'EnvironmentMerge': 'true', - # Currently these are all "dummy" values that we're just setting - # in the default manner that MSVS does it. We could use some of - # these to add additional capabilities, I suppose, but they might - # not have parity with other platforms then. - 'Attach': 'false', - 'DebuggerType': '3', # 'auto' debugger - 'Remote': '1', - 'RemoteCommand': '', - 'HttpUrl': '', - 'PDBPath': '', - 'SQLDebugging': '', - 'DebuggerFlavor': '0', - 'MPIRunCommand': '', - 'MPIRunArguments': '', - 'MPIRunWorkingDirectory': '', - 'ApplicationCommand': '', - 'ApplicationArguments': '', - 'ShimCommand': '', - 'MPIAcceptMode': '', - 'MPIAcceptFilter': '' - }] - - # Find the config, and add it if it doesn't exist. - if config_name not in self.configurations: - self.AddConfig(config_name) - - # Add the DebugSettings onto the appropriate config. - self.configurations[config_name].append(n_cmd) - - def WriteIfChanged(self): - """Writes the user file.""" - configs = ['Configurations'] - for config, spec in sorted(self.configurations.iteritems()): - configs.append(spec) - - content = ['VisualStudioUserFile', - {'Version': self.version.ProjectVersion(), - 'Name': self.name - }, - configs] - easy_xml.WriteXmlIfChanged(content, self.user_file_path, - encoding="Windows-1252") diff --git a/third_party/gyp/pylib/gyp/MSVSVersion.py b/third_party/gyp/pylib/gyp/MSVSVersion.py deleted file mode 100755 index fd3e191..0000000 --- a/third_party/gyp/pylib/gyp/MSVSVersion.py +++ /dev/null @@ -1,262 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Handle version information related to Visual Stuio.""" - -import errno -import os -import re -import subprocess -import sys - - -class VisualStudioVersion: - """Information regarding a version of Visual Studio.""" - - def __init__(self, short_name, description, - solution_version, project_version, flat_sln, uses_vcxproj): - self.short_name = short_name - self.description = description - self.solution_version = solution_version - self.project_version = project_version - self.flat_sln = flat_sln - self.uses_vcxproj = uses_vcxproj - - def ShortName(self): - return self.short_name - - def Description(self): - """Get the full description of the version.""" - return self.description - - def SolutionVersion(self): - """Get the version number of the sln files.""" - return self.solution_version - - def ProjectVersion(self): - """Get the version number of the vcproj or vcxproj files.""" - return self.project_version - - def FlatSolution(self): - return self.flat_sln - - def UsesVcxproj(self): - """Returns true if this version uses a vcxproj file.""" - return self.uses_vcxproj - - def ProjectExtension(self): - """Returns the file extension for the project.""" - return self.uses_vcxproj and '.vcxproj' or '.vcproj' - -def _RegistryQueryBase(sysdir, key, value): - """Use reg.exe to read a particular key. - - While ideally we might use the win32 module, we would like gyp to be - python neutral, so for instance cygwin python lacks this module. - - Arguments: - sysdir: The system subdirectory to attempt to launch reg.exe from. - key: The registry key to read from. - value: The particular value to read. - Return: - stdout from reg.exe, or None for failure. - """ - # Skip if not on Windows or Python Win32 setup issue - if sys.platform not in ('win32', 'cygwin'): - return None - # Setup params to pass to and attempt to launch reg.exe - cmd = [os.path.join(os.environ.get('WINDIR', ''), sysdir, 'reg.exe'), - 'query', key] - if value: - cmd.extend(['/v', value]) - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - # Obtain the stdout from reg.exe, reading to the end so p.returncode is valid - # Note that the error text may be in [1] in some cases - text = p.communicate()[0] - # Check return code from reg.exe; officially 0==success and 1==error - if p.returncode: - return None - return text - -def _RegistryQuery(key, value=None): - """Use reg.exe to read a particular key through _RegistryQueryBase. - - First tries to launch from %WinDir%\Sysnative to avoid WoW64 redirection. If - that fails, it falls back to System32. Sysnative is available on Vista and - up and available on Windows Server 2003 and XP through KB patch 942589. Note - that Sysnative will always fail if using 64-bit python due to it being a - virtual directory and System32 will work correctly in the first place. - - KB 942589 - http://support.microsoft.com/kb/942589/en-us. - - Arguments: - key: The registry key. - value: The particular registry value to read (optional). - Return: - stdout from reg.exe, or None for failure. - """ - text = None - try: - text = _RegistryQueryBase('Sysnative', key, value) - except OSError, e: - if e.errno == errno.ENOENT: - text = _RegistryQueryBase('System32', key, value) - else: - raise - return text - -def _RegistryGetValue(key, value): - """Use reg.exe to obtain the value of a registry key. - - Args: - key: The registry key. - value: The particular registry value to read. - Return: - contents of the registry key's value, or None on failure. - """ - text = _RegistryQuery(key, value) - if not text: - return None - # Extract value. - match = re.search(r'REG_\w+\s+([^\r]+)\r\n', text) - if not match: - return None - return match.group(1) - -def _RegistryKeyExists(key): - """Use reg.exe to see if a key exists. - - Args: - key: The registry key to check. - Return: - True if the key exists - """ - if not _RegistryQuery(key): - return False - return True - - -def _CreateVersion(name): - """Sets up MSVS project generation. - - Setup is based off the GYP_MSVS_VERSION environment variable or whatever is - autodetected if GYP_MSVS_VERSION is not explicitly specified. If a version is - passed in that doesn't match a value in versions python will throw a error. - """ - versions = { - '2010': VisualStudioVersion('2010', - 'Visual Studio 2010', - solution_version='11.00', - project_version='4.0', - flat_sln=False, - uses_vcxproj=True), - '2010e': VisualStudioVersion('2010e', - 'Visual Studio 2010', - solution_version='11.00', - project_version='4.0', - flat_sln=True, - uses_vcxproj=True), - '2008': VisualStudioVersion('2008', - 'Visual Studio 2008', - solution_version='10.00', - project_version='9.00', - flat_sln=False, - uses_vcxproj=False), - '2008e': VisualStudioVersion('2008e', - 'Visual Studio 2008', - solution_version='10.00', - project_version='9.00', - flat_sln=True, - uses_vcxproj=False), - '2005': VisualStudioVersion('2005', - 'Visual Studio 2005', - solution_version='9.00', - project_version='8.00', - flat_sln=False, - uses_vcxproj=False), - '2005e': VisualStudioVersion('2005e', - 'Visual Studio 2005', - solution_version='9.00', - project_version='8.00', - flat_sln=True, - uses_vcxproj=False), - } - return versions[str(name)] - - -def _DetectVisualStudioVersions(): - """Collect the list of installed visual studio versions. - - Returns: - A list of visual studio versions installed in descending order of - usage preference. - Base this on the registry and a quick check if devenv.exe exists. - Only versions 8-10 are considered. - Possibilities are: - 2005(e) - Visual Studio 2005 (8) - 2008(e) - Visual Studio 2008 (9) - 2010(e) - Visual Studio 2010 (10) - Where (e) is e for express editions of MSVS and blank otherwise. - """ - version_to_year = {'8.0': '2005', '9.0': '2008', '10.0': '2010'} - versions = [] - # For now, prefer versions before VS2010 - for version in ('9.0', '8.0', '10.0'): - # Check if VS2010 and later is installed as specified by - # http://msdn.microsoft.com/en-us/library/bb164659.aspx - keys = [r'HKLM\SOFTWARE\Microsoft\DevDiv\VS\Servicing\%s' % version, - r'HKLM\SOFTWARE\Wow6432Node\Microsoft\DevDiv\VS\Servicing\%s' % ( - version)] - for index in range(len(keys)): - if not _RegistryKeyExists(keys[index]): - continue - # Check for express - if _RegistryKeyExists(keys[index] + '\\expbsln'): - # Add this one - versions.append(_CreateVersion(version_to_year[version] + 'e')) - else: - # Add this one - versions.append(_CreateVersion(version_to_year[version])) - - # Old (pre-VS2010) method of searching for which VS version is installed - keys = [r'HKLM\Software\Microsoft\VisualStudio\%s' % version, - r'HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%s' % version, - r'HKLM\Software\Microsoft\VCExpress\%s' % version, - r'HKLM\Software\Wow6432Node\Microsoft\VCExpress\%s' % version] - for index in range(len(keys)): - path = _RegistryGetValue(keys[index], 'InstallDir') - if not path: - continue - # Check for full. - if os.path.exists(os.path.join(path, 'devenv.exe')): - # Add this one. - versions.append(_CreateVersion(version_to_year[version])) - # Check for express. - elif os.path.exists(os.path.join(path, 'vcexpress.exe')): - # Add this one. - versions.append(_CreateVersion(version_to_year[version] + 'e')) - return versions - - -def SelectVisualStudioVersion(version='auto'): - """Select which version of Visual Studio projects to generate. - - Arguments: - version: Hook to allow caller to force a particular version (vs auto). - Returns: - An object representing a visual studio project format version. - """ - # In auto mode, check environment variable for override. - if version == 'auto': - version = os.environ.get('GYP_MSVS_VERSION', 'auto') - # In auto mode, pick the most preferred version present. - if version == 'auto': - versions = _DetectVisualStudioVersions() - if not versions: - # Default to 2005. - return _CreateVersion('2005') - return versions[0] - # Convert version string into a version object. - return _CreateVersion(version) diff --git a/third_party/gyp/pylib/gyp/SCons.py b/third_party/gyp/pylib/gyp/SCons.py deleted file mode 100644 index 9c57bcb..0000000 --- a/third_party/gyp/pylib/gyp/SCons.py +++ /dev/null @@ -1,200 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -""" -SCons generator. - -This contains class definitions and supporting functions for generating -pieces of SCons files for the different types of GYP targets. -""" - -import os - - -def WriteList(fp, list, prefix='', - separator=',\n ', - preamble=None, - postamble=None): - fp.write(preamble or '') - fp.write((separator or ' ').join([prefix + l for l in list])) - fp.write(postamble or '') - - -class TargetBase(object): - """ - Base class for a SCons representation of a GYP target. - """ - is_ignored = False - target_prefix = '' - target_suffix = '' - def __init__(self, spec): - self.spec = spec - def full_product_name(self): - """ - Returns the full name of the product being built: - - * Uses 'product_name' if it's set, else prefix + 'target_name'. - * Prepends 'product_dir' if set. - * Appends SCons suffix variables for the target type (or - product_extension). - """ - suffix = self.target_suffix - product_extension = self.spec.get('product_extension') - if product_extension: - suffix = '.' + product_extension - prefix = self.spec.get('product_prefix', self.target_prefix) - name = self.spec['target_name'] - name = prefix + self.spec.get('product_name', name) + suffix - product_dir = self.spec.get('product_dir') - if product_dir: - name = os.path.join(product_dir, name) - else: - name = os.path.join(self.out_dir, name) - return name - - def write_input_files(self, fp): - """ - Writes the definition of the input files (sources). - """ - sources = self.spec.get('sources') - if not sources: - fp.write('\ninput_files = []\n') - return - preamble = '\ninput_files = [\n ' - postamble = ',\n]\n' - WriteList(fp, map(repr, sources), preamble=preamble, postamble=postamble) - - def builder_call(self): - """ - Returns the actual SCons builder call to build this target. - """ - name = self.full_product_name() - return 'env.%s(env.File(%r), input_files)' % (self.builder_name, name) - def write_target(self, fp, src_dir='', pre=''): - """ - Writes the lines necessary to build this target. - """ - fp.write('\n' + pre) - fp.write('_outputs = %s\n' % self.builder_call()) - fp.write('target_files.extend(_outputs)\n') - - -class NoneTarget(TargetBase): - """ - A GYP target type of 'none', implicitly or explicitly. - """ - def write_target(self, fp, pre=''): - fp.write('\ntarget_files.extend(input_files)\n') - - -class SettingsTarget(TargetBase): - """ - A GYP target type of 'settings'. - """ - is_ignored = True - - -compilable_sources_template = """ -_result = [] -for infile in input_files: - if env.compilable(infile): - if (type(infile) == type('') - and (infile.startswith(%(src_dir)r) - or not os.path.isabs(env.subst(infile)))): - # Force files below the build directory by replacing all '..' - # elements in the path with '__': - base, ext = os.path.splitext(os.path.normpath(infile)) - base = [d == '..' and '__' or d for d in base.split('/')] - base = os.path.join(*base) - object = '${OBJ_DIR}/${COMPONENT_NAME}/${TARGET_NAME}/' + base - if not infile.startswith(%(src_dir)r): - infile = %(src_dir)r + infile - infile = env.%(name)s(object, infile)[0] - else: - infile = env.%(name)s(infile)[0] - _result.append(infile) -input_files = _result -""" - -class CompilableSourcesTargetBase(TargetBase): - """ - An abstract base class for targets that compile their source files. - - We explicitly transform compilable files into object files, - even though SCons could infer that for us, because we want - to control where the object file ends up. (The implicit rules - in SCons always put the object file next to the source file.) - """ - intermediate_builder_name = None - def write_target(self, fp, src_dir='', pre=''): - if self.intermediate_builder_name is None: - raise NotImplementedError - if src_dir and not src_dir.endswith('/'): - src_dir += '/' - variables = { - 'src_dir': src_dir, - 'name': self.intermediate_builder_name, - } - fp.write(compilable_sources_template % variables) - super(CompilableSourcesTargetBase, self).write_target(fp) - - -class ProgramTarget(CompilableSourcesTargetBase): - """ - A GYP target type of 'executable'. - """ - builder_name = 'GypProgram' - intermediate_builder_name = 'StaticObject' - target_prefix = '${PROGPREFIX}' - target_suffix = '${PROGSUFFIX}' - out_dir = '${TOP_BUILDDIR}' - - -class StaticLibraryTarget(CompilableSourcesTargetBase): - """ - A GYP target type of 'static_library'. - """ - builder_name = 'GypStaticLibrary' - intermediate_builder_name = 'StaticObject' - target_prefix = '${LIBPREFIX}' - target_suffix = '${LIBSUFFIX}' - out_dir = '${LIB_DIR}' - - -class SharedLibraryTarget(CompilableSourcesTargetBase): - """ - A GYP target type of 'shared_library'. - """ - builder_name = 'GypSharedLibrary' - intermediate_builder_name = 'SharedObject' - target_prefix = '${SHLIBPREFIX}' - target_suffix = '${SHLIBSUFFIX}' - out_dir = '${LIB_DIR}' - - -class LoadableModuleTarget(CompilableSourcesTargetBase): - """ - A GYP target type of 'loadable_module'. - """ - builder_name = 'GypLoadableModule' - intermediate_builder_name = 'SharedObject' - target_prefix = '${SHLIBPREFIX}' - target_suffix = '${SHLIBSUFFIX}' - out_dir = '${TOP_BUILDDIR}' - - -TargetMap = { - None : NoneTarget, - 'none' : NoneTarget, - 'settings' : SettingsTarget, - 'executable' : ProgramTarget, - 'static_library' : StaticLibraryTarget, - 'shared_library' : SharedLibraryTarget, - 'loadable_module' : LoadableModuleTarget, -} - -def Target(spec): - return TargetMap[spec.get('type')](spec) diff --git a/third_party/gyp/pylib/gyp/__init__.py b/third_party/gyp/pylib/gyp/__init__.py deleted file mode 100644 index 37635d0..0000000 --- a/third_party/gyp/pylib/gyp/__init__.py +++ /dev/null @@ -1,479 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import copy -import gyp.input -import optparse -import os.path -import re -import shlex -import sys - -# Default debug modes for GYP -debug = {} - -# List of "official" debug modes, but you can use anything you like. -DEBUG_GENERAL = 'general' -DEBUG_VARIABLES = 'variables' -DEBUG_INCLUDES = 'includes' - -def DebugOutput(mode, message): - if mode in gyp.debug.keys(): - print "%s: %s" % (mode.upper(), message) - -def FindBuildFiles(): - extension = '.gyp' - files = os.listdir(os.getcwd()) - build_files = [] - for file in files: - if file[-len(extension):] == extension: - build_files.append(file) - return build_files - - -def Load(build_files, format, default_variables={}, - includes=[], depth='.', params=None, check=False, circular_check=True): - """ - Loads one or more specified build files. - default_variables and includes will be copied before use. - Returns the generator for the specified format and the - data returned by loading the specified build files. - """ - if params is None: - params = {} - - flavor = None - if '-' in format: - format, params['flavor'] = format.split('-', 1) - - default_variables = copy.copy(default_variables) - - # Default variables provided by this program and its modules should be - # named WITH_CAPITAL_LETTERS to provide a distinct "best practice" namespace, - # avoiding collisions with user and automatic variables. - default_variables['GENERATOR'] = format - - generator_name = 'gyp.generator.' + format - # These parameters are passed in order (as opposed to by key) - # because ActivePython cannot handle key parameters to __import__. - generator = __import__(generator_name, globals(), locals(), generator_name) - for (key, val) in generator.generator_default_variables.items(): - default_variables.setdefault(key, val) - - # Give the generator the opportunity to set additional variables based on - # the params it will receive in the output phase. - if getattr(generator, 'CalculateVariables', None): - generator.CalculateVariables(default_variables, params) - - # Give the generator the opportunity to set generator_input_info based on - # the params it will receive in the output phase. - if getattr(generator, 'CalculateGeneratorInputInfo', None): - generator.CalculateGeneratorInputInfo(params) - - # Fetch the generator specific info that gets fed to input, we use getattr - # so we can default things and the generators only have to provide what - # they need. - generator_input_info = { - 'generator_wants_absolute_build_file_paths': - getattr(generator, 'generator_wants_absolute_build_file_paths', False), - 'generator_handles_variants': - getattr(generator, 'generator_handles_variants', False), - 'non_configuration_keys': - getattr(generator, 'generator_additional_non_configuration_keys', []), - 'path_sections': - getattr(generator, 'generator_additional_path_sections', []), - 'extra_sources_for_rules': - getattr(generator, 'generator_extra_sources_for_rules', []), - 'generator_supports_multiple_toolsets': - getattr(generator, 'generator_supports_multiple_toolsets', False), - 'generator_wants_static_library_dependencies_adjusted': - getattr(generator, - 'generator_wants_static_library_dependencies_adjusted', True), - 'generator_wants_sorted_dependencies': - getattr(generator, 'generator_wants_sorted_dependencies', False), - } - - # Process the input specific to this generator. - result = gyp.input.Load(build_files, default_variables, includes[:], - depth, generator_input_info, check, circular_check) - return [generator] + result - -def NameValueListToDict(name_value_list): - """ - Takes an array of strings of the form 'NAME=VALUE' and creates a dictionary - of the pairs. If a string is simply NAME, then the value in the dictionary - is set to True. If VALUE can be converted to an integer, it is. - """ - result = { } - for item in name_value_list: - tokens = item.split('=', 1) - if len(tokens) == 2: - # If we can make it an int, use that, otherwise, use the string. - try: - token_value = int(tokens[1]) - except ValueError: - token_value = tokens[1] - # Set the variable to the supplied value. - result[tokens[0]] = token_value - else: - # No value supplied, treat it as a boolean and set it. - result[tokens[0]] = True - return result - -def ShlexEnv(env_name): - flags = os.environ.get(env_name, []) - if flags: - flags = shlex.split(flags) - return flags - -def FormatOpt(opt, value): - if opt.startswith('--'): - return '%s=%s' % (opt, value) - return opt + value - -def RegenerateAppendFlag(flag, values, predicate, env_name, options): - """Regenerate a list of command line flags, for an option of action='append'. - - The |env_name|, if given, is checked in the environment and used to generate - an initial list of options, then the options that were specified on the - command line (given in |values|) are appended. This matches the handling of - environment variables and command line flags where command line flags override - the environment, while not requiring the environment to be set when the flags - are used again. - """ - flags = [] - if options.use_environment and env_name: - for flag_value in ShlexEnv(env_name): - flags.append(FormatOpt(flag, predicate(flag_value))) - if values: - for flag_value in values: - flags.append(FormatOpt(flag, predicate(flag_value))) - return flags - -def RegenerateFlags(options): - """Given a parsed options object, and taking the environment variables into - account, returns a list of flags that should regenerate an equivalent options - object (even in the absence of the environment variables.) - - Any path options will be normalized relative to depth. - - The format flag is not included, as it is assumed the calling generator will - set that as appropriate. - """ - def FixPath(path): - path = gyp.common.FixIfRelativePath(path, options.depth) - if not path: - return os.path.curdir - return path - - def Noop(value): - return value - - # We always want to ignore the environment when regenerating, to avoid - # duplicate or changed flags in the environment at the time of regeneration. - flags = ['--ignore-environment'] - for name, metadata in options._regeneration_metadata.iteritems(): - opt = metadata['opt'] - value = getattr(options, name) - value_predicate = metadata['type'] == 'path' and FixPath or Noop - action = metadata['action'] - env_name = metadata['env_name'] - if action == 'append': - flags.extend(RegenerateAppendFlag(opt, value, value_predicate, - env_name, options)) - elif action in ('store', None): # None is a synonym for 'store'. - if value: - flags.append(FormatOpt(opt, value_predicate(value))) - elif options.use_environment and env_name and os.environ.get(env_name): - flags.append(FormatOpt(opt, value_predicate(os.environ.get(env_name)))) - elif action in ('store_true', 'store_false'): - if ((action == 'store_true' and value) or - (action == 'store_false' and not value)): - flags.append(opt) - elif options.use_environment and env_name: - print >>sys.stderr, ('Warning: environment regeneration unimplemented ' - 'for %s flag %r env_name %r' % (action, opt, - env_name)) - else: - print >>sys.stderr, ('Warning: regeneration unimplemented for action %r ' - 'flag %r' % (action, opt)) - - return flags - -class RegeneratableOptionParser(optparse.OptionParser): - def __init__(self): - self.__regeneratable_options = {} - optparse.OptionParser.__init__(self) - - def add_option(self, *args, **kw): - """Add an option to the parser. - - This accepts the same arguments as OptionParser.add_option, plus the - following: - regenerate: can be set to False to prevent this option from being included - in regeneration. - env_name: name of environment variable that additional values for this - option come from. - type: adds type='path', to tell the regenerator that the values of - this option need to be made relative to options.depth - """ - env_name = kw.pop('env_name', None) - if 'dest' in kw and kw.pop('regenerate', True): - dest = kw['dest'] - - # The path type is needed for regenerating, for optparse we can just treat - # it as a string. - type = kw.get('type') - if type == 'path': - kw['type'] = 'string' - - self.__regeneratable_options[dest] = { - 'action': kw.get('action'), - 'type': type, - 'env_name': env_name, - 'opt': args[0], - } - - optparse.OptionParser.add_option(self, *args, **kw) - - def parse_args(self, *args): - values, args = optparse.OptionParser.parse_args(self, *args) - values._regeneration_metadata = self.__regeneratable_options - return values, args - -def main(args): - my_name = os.path.basename(sys.argv[0]) - - parser = RegeneratableOptionParser() - usage = 'usage: %s [options ...] [build_file ...]' - parser.set_usage(usage.replace('%s', '%prog')) - parser.add_option('-D', dest='defines', action='append', metavar='VAR=VAL', - env_name='GYP_DEFINES', - help='sets variable VAR to value VAL') - parser.add_option('-f', '--format', dest='formats', action='append', - env_name='GYP_GENERATORS', regenerate=False, - help='output formats to generate') - parser.add_option('--msvs-version', dest='msvs_version', - regenerate=False, - help='Deprecated; use -G msvs_version=MSVS_VERSION instead') - parser.add_option('-I', '--include', dest='includes', action='append', - metavar='INCLUDE', type='path', - help='files to include in all loaded .gyp files') - parser.add_option('--depth', dest='depth', metavar='PATH', type='path', - help='set DEPTH gyp variable to a relative path to PATH') - parser.add_option('-d', '--debug', dest='debug', metavar='DEBUGMODE', - action='append', default=[], help='turn on a debugging ' - 'mode for debugging GYP. Supported modes are "variables" ' - 'and "general"') - parser.add_option('-S', '--suffix', dest='suffix', default='', - help='suffix to add to generated files') - parser.add_option('-G', dest='generator_flags', action='append', default=[], - metavar='FLAG=VAL', env_name='GYP_GENERATOR_FLAGS', - help='sets generator flag FLAG to VAL') - parser.add_option('--generator-output', dest='generator_output', - action='store', default=None, metavar='DIR', type='path', - env_name='GYP_GENERATOR_OUTPUT', - help='puts generated build files under DIR') - parser.add_option('--ignore-environment', dest='use_environment', - action='store_false', default=True, regenerate=False, - help='do not read options from environment variables') - parser.add_option('--check', dest='check', action='store_true', - help='check format of gyp files') - parser.add_option('--toplevel-dir', dest='toplevel_dir', action='store', - default=None, metavar='DIR', type='path', - help='directory to use as the root of the source tree') - # --no-circular-check disables the check for circular relationships between - # .gyp files. These relationships should not exist, but they've only been - # observed to be harmful with the Xcode generator. Chromium's .gyp files - # currently have some circular relationships on non-Mac platforms, so this - # option allows the strict behavior to be used on Macs and the lenient - # behavior to be used elsewhere. - # TODO(mark): Remove this option when http://crbug.com/35878 is fixed. - parser.add_option('--no-circular-check', dest='circular_check', - action='store_false', default=True, regenerate=False, - help="don't check for circular relationships between files") - - # We read a few things from ~/.gyp, so set up a var for that. - home_vars = ['HOME'] - if sys.platform in ('cygwin', 'win32'): - home_vars.append('USERPROFILE') - home = None - home_dot_gyp = None - for home_var in home_vars: - home = os.getenv(home_var) - if home != None: - home_dot_gyp = os.path.join(home, '.gyp') - if not os.path.exists(home_dot_gyp): - home_dot_gyp = None - else: - break - - # TODO(thomasvl): add support for ~/.gyp/defaults - - options, build_files_arg = parser.parse_args(args) - build_files = build_files_arg - - if not options.formats: - # If no format was given on the command line, then check the env variable. - generate_formats = [] - if options.use_environment: - generate_formats = os.environ.get('GYP_GENERATORS', []) - if generate_formats: - generate_formats = re.split('[\s,]', generate_formats) - if generate_formats: - options.formats = generate_formats - else: - # Nothing in the variable, default based on platform. - options.formats = [ {'darwin': 'xcode', - 'win32': 'msvs', - 'cygwin': 'msvs', - 'freebsd7': 'make', - 'freebsd8': 'make', - 'linux2': 'make', - 'linux3': 'make', - 'openbsd4': 'make', - 'sunos5': 'make',}[sys.platform] ] - - if not options.generator_output and options.use_environment: - g_o = os.environ.get('GYP_GENERATOR_OUTPUT') - if g_o: - options.generator_output = g_o - - for mode in options.debug: - gyp.debug[mode] = 1 - - # Do an extra check to avoid work when we're not debugging. - if DEBUG_GENERAL in gyp.debug.keys(): - DebugOutput(DEBUG_GENERAL, 'running with these options:') - for option, value in sorted(options.__dict__.items()): - if option[0] == '_': - continue - if isinstance(value, basestring): - DebugOutput(DEBUG_GENERAL, " %s: '%s'" % (option, value)) - else: - DebugOutput(DEBUG_GENERAL, " %s: %s" % (option, str(value))) - - if not build_files: - build_files = FindBuildFiles() - if not build_files: - print >>sys.stderr, (usage + '\n\n%s: error: no build_file') % \ - (my_name, my_name) - return 1 - - # TODO(mark): Chromium-specific hack! - # For Chromium, the gyp "depth" variable should always be a relative path - # to Chromium's top-level "src" directory. If no depth variable was set - # on the command line, try to find a "src" directory by looking at the - # absolute path to each build file's directory. The first "src" component - # found will be treated as though it were the path used for --depth. - if not options.depth: - for build_file in build_files: - build_file_dir = os.path.abspath(os.path.dirname(build_file)) - build_file_dir_components = build_file_dir.split(os.path.sep) - components_len = len(build_file_dir_components) - for index in xrange(components_len - 1, -1, -1): - if build_file_dir_components[index] == 'src': - options.depth = os.path.sep.join(build_file_dir_components) - break - del build_file_dir_components[index] - - # If the inner loop found something, break without advancing to another - # build file. - if options.depth: - break - - if not options.depth: - raise Exception, \ - 'Could not automatically locate src directory. This is a ' + \ - 'temporary Chromium feature that will be removed. Use ' + \ - '--depth as a workaround.' - - # If toplevel-dir is not set, we assume that depth is the root of our source - # tree. - if not options.toplevel_dir: - options.toplevel_dir = options.depth - - # -D on the command line sets variable defaults - D isn't just for define, - # it's for default. Perhaps there should be a way to force (-F?) a - # variable's value so that it can't be overridden by anything else. - cmdline_default_variables = {} - defines = [] - if options.use_environment: - defines += ShlexEnv('GYP_DEFINES') - if options.defines: - defines += options.defines - cmdline_default_variables = NameValueListToDict(defines) - if DEBUG_GENERAL in gyp.debug.keys(): - DebugOutput(DEBUG_GENERAL, - "cmdline_default_variables: %s" % cmdline_default_variables) - - # Set up includes. - includes = [] - - # If ~/.gyp/include.gypi exists, it'll be forcibly included into every - # .gyp file that's loaded, before anything else is included. - if home_dot_gyp != None: - default_include = os.path.join(home_dot_gyp, 'include.gypi') - if os.path.exists(default_include): - includes.append(default_include) - - # Command-line --include files come after the default include. - if options.includes: - includes.extend(options.includes) - - # Generator flags should be prefixed with the target generator since they - # are global across all generator runs. - gen_flags = [] - if options.use_environment: - gen_flags += ShlexEnv('GYP_GENERATOR_FLAGS') - if options.generator_flags: - gen_flags += options.generator_flags - generator_flags = NameValueListToDict(gen_flags) - if DEBUG_GENERAL in gyp.debug.keys(): - DebugOutput(DEBUG_GENERAL, "generator_flags: %s" % generator_flags) - - # TODO: Remove this and the option after we've gotten folks to move to the - # generator flag. - if options.msvs_version: - print >>sys.stderr, \ - 'DEPRECATED: Use generator flag (-G msvs_version=' + \ - options.msvs_version + ') instead of --msvs-version=' + \ - options.msvs_version - generator_flags['msvs_version'] = options.msvs_version - - # Generate all requested formats (use a set in case we got one format request - # twice) - for format in set(options.formats): - params = {'options': options, - 'build_files': build_files, - 'generator_flags': generator_flags, - 'cwd': os.getcwd(), - 'build_files_arg': build_files_arg, - 'gyp_binary': sys.argv[0], - 'home_dot_gyp': home_dot_gyp} - - # Start with the default variables from the command line. - [generator, flat_list, targets, data] = Load(build_files, format, - cmdline_default_variables, - includes, options.depth, - params, options.check, - options.circular_check) - - # TODO(mark): Pass |data| for now because the generator needs a list of - # build files that came in. In the future, maybe it should just accept - # a list, and not the whole data dict. - # NOTE: flat_list is the flattened dependency graph specifying the order - # that targets may be built. Build systems that operate serially or that - # need to have dependencies defined before dependents reference them should - # generate targets in the order specified in flat_list. - generator.GenerateOutput(flat_list, targets, data, params) - - # Done - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/third_party/gyp/pylib/gyp/common.py b/third_party/gyp/pylib/gyp/common.py deleted file mode 100644 index 880820e..0000000 --- a/third_party/gyp/pylib/gyp/common.py +++ /dev/null @@ -1,362 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import errno -import filecmp -import os.path -import re -import tempfile -import sys - - -# A minimal memoizing decorator. It'll blow up if the args aren't immutable, -# among other "problems". -class memoize(object): - def __init__(self, func): - self.func = func - self.cache = {} - def __call__(self, *args): - try: - return self.cache[args] - except KeyError: - result = self.func(*args) - self.cache[args] = result - return result - - -def ExceptionAppend(e, msg): - """Append a message to the given exception's message.""" - if not e.args: - e.args = (msg,) - elif len(e.args) == 1: - e.args = (str(e.args[0]) + ' ' + msg,) - else: - e.args = (str(e.args[0]) + ' ' + msg,) + e.args[1:] - - -def ParseQualifiedTarget(target): - # Splits a qualified target into a build file, target name and toolset. - - # NOTE: rsplit is used to disambiguate the Windows drive letter separator. - target_split = target.rsplit(':', 1) - if len(target_split) == 2: - [build_file, target] = target_split - else: - build_file = None - - target_split = target.rsplit('#', 1) - if len(target_split) == 2: - [target, toolset] = target_split - else: - toolset = None - - return [build_file, target, toolset] - - -def ResolveTarget(build_file, target, toolset): - # This function resolves a target into a canonical form: - # - a fully defined build file, either absolute or relative to the current - # directory - # - a target name - # - a toolset - # - # build_file is the file relative to which 'target' is defined. - # target is the qualified target. - # toolset is the default toolset for that target. - [parsed_build_file, target, parsed_toolset] = ParseQualifiedTarget(target) - - if parsed_build_file: - if build_file: - # If a relative path, parsed_build_file is relative to the directory - # containing build_file. If build_file is not in the current directory, - # parsed_build_file is not a usable path as-is. Resolve it by - # interpreting it as relative to build_file. If parsed_build_file is - # absolute, it is usable as a path regardless of the current directory, - # and os.path.join will return it as-is. - build_file = os.path.normpath(os.path.join(os.path.dirname(build_file), - parsed_build_file)) - else: - build_file = parsed_build_file - - if parsed_toolset: - toolset = parsed_toolset - - return [build_file, target, toolset] - - -def BuildFile(fully_qualified_target): - # Extracts the build file from the fully qualified target. - return ParseQualifiedTarget(fully_qualified_target)[0] - - -def QualifiedTarget(build_file, target, toolset): - # "Qualified" means the file that a target was defined in and the target - # name, separated by a colon, suffixed by a # and the toolset name: - # /path/to/file.gyp:target_name#toolset - fully_qualified = build_file + ':' + target - if toolset: - fully_qualified = fully_qualified + '#' + toolset - return fully_qualified - - -@memoize -def RelativePath(path, relative_to): - # Assuming both |path| and |relative_to| are relative to the current - # directory, returns a relative path that identifies path relative to - # relative_to. - - # Convert to absolute (and therefore normalized paths). - path = os.path.abspath(path) - relative_to = os.path.abspath(relative_to) - - # Split the paths into components. - path_split = path.split(os.path.sep) - relative_to_split = relative_to.split(os.path.sep) - - # Determine how much of the prefix the two paths share. - prefix_len = len(os.path.commonprefix([path_split, relative_to_split])) - - # Put enough ".." components to back up out of relative_to to the common - # prefix, and then append the part of path_split after the common prefix. - relative_split = [os.path.pardir] * (len(relative_to_split) - prefix_len) + \ - path_split[prefix_len:] - - if len(relative_split) == 0: - # The paths were the same. - return '' - - # Turn it back into a string and we're done. - return os.path.join(*relative_split) - - -def FixIfRelativePath(path, relative_to): - # Like RelativePath but returns |path| unchanged if it is absolute. - if os.path.isabs(path): - return path - return RelativePath(path, relative_to) - - -def UnrelativePath(path, relative_to): - # Assuming that |relative_to| is relative to the current directory, and |path| - # is a path relative to the dirname of |relative_to|, returns a path that - # identifies |path| relative to the current directory. - rel_dir = os.path.dirname(relative_to) - return os.path.normpath(os.path.join(rel_dir, path)) - - -# re objects used by EncodePOSIXShellArgument. See IEEE 1003.1 XCU.2.2 at -# http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_02 -# and the documentation for various shells. - -# _quote is a pattern that should match any argument that needs to be quoted -# with double-quotes by EncodePOSIXShellArgument. It matches the following -# characters appearing anywhere in an argument: -# \t, \n, space parameter separators -# # comments -# $ expansions (quoted to always expand within one argument) -# % called out by IEEE 1003.1 XCU.2.2 -# & job control -# ' quoting -# (, ) subshell execution -# *, ?, [ pathname expansion -# ; command delimiter -# <, >, | redirection -# = assignment -# {, } brace expansion (bash) -# ~ tilde expansion -# It also matches the empty string, because "" (or '') is the only way to -# represent an empty string literal argument to a POSIX shell. -# -# This does not match the characters in _escape, because those need to be -# backslash-escaped regardless of whether they appear in a double-quoted -# string. -_quote = re.compile('[\t\n #$%&\'()*;<=>?[{|}~]|^$') - -# _escape is a pattern that should match any character that needs to be -# escaped with a backslash, whether or not the argument matched the _quote -# pattern. _escape is used with re.sub to backslash anything in _escape's -# first match group, hence the (parentheses) in the regular expression. -# -# _escape matches the following characters appearing anywhere in an argument: -# " to prevent POSIX shells from interpreting this character for quoting -# \ to prevent POSIX shells from interpreting this character for escaping -# ` to prevent POSIX shells from interpreting this character for command -# substitution -# Missing from this list is $, because the desired behavior of -# EncodePOSIXShellArgument is to permit parameter (variable) expansion. -# -# Also missing from this list is !, which bash will interpret as the history -# expansion character when history is enabled. bash does not enable history -# by default in non-interactive shells, so this is not thought to be a problem. -# ! was omitted from this list because bash interprets "\!" as a literal string -# including the backslash character (avoiding history expansion but retaining -# the backslash), which would not be correct for argument encoding. Handling -# this case properly would also be problematic because bash allows the history -# character to be changed with the histchars shell variable. Fortunately, -# as history is not enabled in non-interactive shells and -# EncodePOSIXShellArgument is only expected to encode for non-interactive -# shells, there is no room for error here by ignoring !. -_escape = re.compile(r'(["\\`])') - -def EncodePOSIXShellArgument(argument): - """Encodes |argument| suitably for consumption by POSIX shells. - - argument may be quoted and escaped as necessary to ensure that POSIX shells - treat the returned value as a literal representing the argument passed to - this function. Parameter (variable) expansions beginning with $ are allowed - to remain intact without escaping the $, to allow the argument to contain - references to variables to be expanded by the shell. - """ - - if not isinstance(argument, str): - argument = str(argument) - - if _quote.search(argument): - quote = '"' - else: - quote = '' - - encoded = quote + re.sub(_escape, r'\\\1', argument) + quote - - return encoded - - -def EncodePOSIXShellList(list): - """Encodes |list| suitably for consumption by POSIX shells. - - Returns EncodePOSIXShellArgument for each item in list, and joins them - together using the space character as an argument separator. - """ - - encoded_arguments = [] - for argument in list: - encoded_arguments.append(EncodePOSIXShellArgument(argument)) - return ' '.join(encoded_arguments) - - -def DeepDependencyTargets(target_dicts, roots): - """Returns the recursive list of target dependencies.""" - dependencies = set() - pending = set(roots) - while pending: - # Pluck out one. - r = pending.pop() - # Skip if visited already. - if r in dependencies: - continue - # Add it. - dependencies.add(r) - # Add its children. - spec = target_dicts[r] - pending.update(set(spec.get('dependencies', []))) - pending.update(set(spec.get('dependencies_original', []))) - return list(dependencies - set(roots)) - - -def BuildFileTargets(target_list, build_file): - """From a target_list, returns the subset from the specified build_file. - """ - return [p for p in target_list if BuildFile(p) == build_file] - - -def AllTargets(target_list, target_dicts, build_file): - """Returns all targets (direct and dependencies) for the specified build_file. - """ - bftargets = BuildFileTargets(target_list, build_file) - deptargets = DeepDependencyTargets(target_dicts, bftargets) - return bftargets + deptargets - - -def WriteOnDiff(filename): - """Write to a file only if the new contents differ. - - Arguments: - filename: name of the file to potentially write to. - Returns: - A file like object which will write to temporary file and only overwrite - the target if it differs (on close). - """ - - class Writer: - """Wrapper around file which only covers the target if it differs.""" - def __init__(self): - # Pick temporary file. - tmp_fd, self.tmp_path = tempfile.mkstemp( - suffix='.tmp', - prefix=os.path.split(filename)[1] + '.gyp.', - dir=os.path.split(filename)[0]) - try: - self.tmp_file = os.fdopen(tmp_fd, 'wb') - except Exception: - # Don't leave turds behind. - os.unlink(self.tmp_path) - raise - - def __getattr__(self, attrname): - # Delegate everything else to self.tmp_file - return getattr(self.tmp_file, attrname) - - def close(self): - try: - # Close tmp file. - self.tmp_file.close() - # Determine if different. - same = False - try: - same = filecmp.cmp(self.tmp_path, filename, False) - except OSError, e: - if e.errno != errno.ENOENT: - raise - - if same: - # The new file is identical to the old one, just get rid of the new - # one. - os.unlink(self.tmp_path) - else: - # The new file is different from the old one, or there is no old one. - # Rename the new file to the permanent name. - # - # tempfile.mkstemp uses an overly restrictive mode, resulting in a - # file that can only be read by the owner, regardless of the umask. - # There's no reason to not respect the umask here, which means that - # an extra hoop is required to fetch it and reset the new file's mode. - # - # No way to get the umask without setting a new one? Set a safe one - # and then set it back to the old value. - umask = os.umask(077) - os.umask(umask) - os.chmod(self.tmp_path, 0666 & ~umask) - if sys.platform == 'win32' and os.path.exists(filename): - # NOTE: on windows (but not cygwin) rename will not replace an - # existing file, so it must be preceded with a remove. Sadly there - # is no way to make the switch atomic. - os.remove(filename) - os.rename(self.tmp_path, filename) - except Exception: - # Don't leave turds behind. - os.unlink(self.tmp_path) - raise - - return Writer() - - -# From Alex Martelli, -# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560 -# ASPN: Python Cookbook: Remove duplicates from a sequence -# First comment, dated 2001/10/13. -# (Also in the printed Python Cookbook.) - -def uniquer(seq, idfun=None): - if idfun is None: - def idfun(x): return x - seen = {} - result = [] - for item in seq: - marker = idfun(item) - if marker in seen: continue - seen[marker] = 1 - result.append(item) - return result diff --git a/third_party/gyp/pylib/gyp/easy_xml.py b/third_party/gyp/pylib/gyp/easy_xml.py deleted file mode 100644 index 6624175..0000000 --- a/third_party/gyp/pylib/gyp/easy_xml.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import re - - -def XmlToString(content, encoding='utf-8', pretty=False): - """ Writes the XML content to disk, touching the file only if it has changed. - - Visual Studio files have a lot of pre-defined structures. This function makes - it easy to represent these structures as Python data structures, instead of - having to create a lot of function calls. - - Each XML element of the content is represented as a list composed of: - 1. The name of the element, a string, - 2. The attributes of the element, a dictionary (optional), and - 3+. The content of the element, if any. Strings are simple text nodes and - lists are child elements. - - Example 1: - - becomes - ['test'] - - Example 2: - - This is - it! - - - becomes - ['myelement', {'a':'value1', 'b':'value2'}, - ['childtype', 'This is'], - ['childtype', 'it!'], - ] - - Args: - content: The structured content to be converted. - encoding: The encoding to report on the first XML line. - pretty: True if we want pretty printing with indents and new lines. - - Returns: - The XML content as a string. - """ - # We create a huge list of all the elements of the file. - xml_parts = ['' % encoding] - if pretty: - xml_parts.append('\n') - _ConstructContentList(xml_parts, content, pretty) - - # Convert it to a string - return ''.join(xml_parts) - - -def _ConstructContentList(xml_parts, specification, pretty, level=0): - """ Appends the XML parts corresponding to the specification. - - Args: - xml_parts: A list of XML parts to be appended to. - specification: The specification of the element. See EasyXml docs. - pretty: True if we want pretty printing with indents and new lines. - level: Indentation level. - """ - # The first item in a specification is the name of the element. - if pretty: - indentation = ' ' * level - new_line = '\n' - else: - indentation = '' - new_line = '' - name = specification[0] - if not isinstance(name, str): - raise Exception('The first item of an EasyXml specification should be ' - 'a string. Specification was ' + str(specification)) - xml_parts.append(indentation + '<' + name) - - # Optionally in second position is a dictionary of the attributes. - rest = specification[1:] - if rest and isinstance(rest[0], dict): - for at, val in sorted(rest[0].iteritems()): - xml_parts.append(' %s="%s"' % (at, _XmlEscape(val))) - rest = rest[1:] - if rest: - xml_parts.append('>') - all_strings = reduce(lambda x, y: x and isinstance(y, str), rest, True) - multi_line = not all_strings - if multi_line and new_line: - xml_parts.append(new_line) - for child_spec in rest: - # If it's a string, append a text node. - # Otherwise recurse over that child definition - if isinstance(child_spec, str): - xml_parts.append(_XmlEscape(child_spec)) - else: - _ConstructContentList(xml_parts, child_spec, pretty, level + 1) - if multi_line and indentation: - xml_parts.append(indentation) - xml_parts.append('%s' % (name, new_line)) - else: - xml_parts.append('/>%s' % new_line) - - -def WriteXmlIfChanged(content, path, encoding='utf-8', pretty=False): - """ Writes the XML content to disk, touching the file only if it has changed. - - Args: - content: The structured content to be written. - path: Location of the file. - encoding: The encoding to report on the first line of the XML file. - pretty: True if we want pretty printing with indents and new lines. - """ - xml_string = XmlToString(content, encoding, pretty) - - # Get the old content - try: - f = open(path, 'r') - existing = f.read() - f.close() - except: - existing = None - - # It has changed, write it - if existing != xml_string: - f = open(path, 'w') - f.write(xml_string) - f.close() - - -_xml_escape_map = { - '"': '"', - "'": ''', - '<': '<', - '>': '>', - '&': '&', - '\n': ' ', - '\r': ' ', -} - - -_xml_escape_re = re.compile( - "(%s)" % "|".join(map(re.escape, _xml_escape_map.keys()))) - - -def _XmlEscape(value): - """ Escape a string for inclusion in XML.""" - replace = lambda m: _xml_escape_map[m.string[m.start() : m.end()]] - return _xml_escape_re.sub(replace, value) diff --git a/third_party/gyp/pylib/gyp/easy_xml_test.py b/third_party/gyp/pylib/gyp/easy_xml_test.py deleted file mode 100644 index 9e59559..0000000 --- a/third_party/gyp/pylib/gyp/easy_xml_test.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -""" Unit tests for the easy_xml.py file. """ - -import gyp.easy_xml as easy_xml -import unittest -import StringIO - - -class TestSequenceFunctions(unittest.TestCase): - - def setUp(self): - self.stderr = StringIO.StringIO() - - def test_EasyXml_simple(self): - self.assertEqual( - easy_xml.XmlToString(['test']), - '') - - self.assertEqual( - easy_xml.XmlToString(['test'], encoding='Windows-1252'), - '') - - def test_EasyXml_simple_with_attributes(self): - self.assertEqual( - easy_xml.XmlToString(['test2', {'a': 'value1', 'b': 'value2'}]), - '') - - def test_EasyXml_escaping(self): - original = '\'"\r&\nfoo' - converted = '<test>'" & foo' - self.assertEqual( - easy_xml.XmlToString(['test3', {'a': original}, original]), - '%s' % - (converted, converted)) - - def test_EasyXml_pretty(self): - self.assertEqual( - easy_xml.XmlToString( - ['test3', - ['GrandParent', - ['Parent1', - ['Child'] - ], - ['Parent2'] - ] - ], - pretty=True), - '\n' - '\n' - ' \n' - ' \n' - ' \n' - ' \n' - ' \n' - ' \n' - '\n') - - - def test_EasyXml_complex(self): - # We want to create: - target = ( - '' - '' - '' - '{D2250C20-3A94-4FB9-AF73-11BC5B73884B}' - 'Win32Proj' - 'automated_ui_tests' - '' - '' - '' - 'Application' - 'Unicode' - '' - '') - - xml = easy_xml.XmlToString( - ['Project', - ['PropertyGroup', {'Label': 'Globals'}, - ['ProjectGuid', '{D2250C20-3A94-4FB9-AF73-11BC5B73884B}'], - ['Keyword', 'Win32Proj'], - ['RootNamespace', 'automated_ui_tests'] - ], - ['Import', {'Project': '$(VCTargetsPath)\\Microsoft.Cpp.props'}], - ['PropertyGroup', - {'Condition': "'$(Configuration)|$(Platform)'=='Debug|Win32'", - 'Label': 'Configuration'}, - ['ConfigurationType', 'Application'], - ['CharacterSet', 'Unicode'] - ] - ]) - self.assertEqual(xml, target) - - -if __name__ == '__main__': - unittest.main() diff --git a/third_party/gyp/pylib/gyp/generator/__init__.py b/third_party/gyp/pylib/gyp/generator/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/third_party/gyp/pylib/gyp/generator/dump_dependency_json.py b/third_party/gyp/pylib/gyp/generator/dump_dependency_json.py deleted file mode 100644 index ebb7ff9..0000000 --- a/third_party/gyp/pylib/gyp/generator/dump_dependency_json.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import collections -import gyp -import gyp.common -import json - -generator_wants_static_library_dependencies_adjusted = False - -generator_default_variables = { - 'OS': 'linux', -} -for dirname in ['INTERMEDIATE_DIR', 'SHARED_INTERMEDIATE_DIR', 'PRODUCT_DIR', - 'LIB_DIR', 'SHARED_LIB_DIR']: - # Some gyp steps fail if these are empty(!). - generator_default_variables[dirname] = 'dir' -for unused in ['RULE_INPUT_PATH', 'RULE_INPUT_ROOT', 'RULE_INPUT_NAME', - 'RULE_INPUT_EXT', - 'EXECUTABLE_PREFIX', 'EXECUTABLE_SUFFIX', - 'STATIC_LIB_PREFIX', 'STATIC_LIB_SUFFIX', - 'SHARED_LIB_PREFIX', 'SHARED_LIB_SUFFIX', - 'LINKER_SUPPORTS_ICF']: - generator_default_variables[unused] = '' - - -def CalculateVariables(default_variables, params): - generator_flags = params.get('generator_flags', {}) - default_variables['OS'] = generator_flags.get('os', 'linux') - - -def CalculateGeneratorInputInfo(params): - """Calculate the generator specific info that gets fed to input (called by - gyp).""" - generator_flags = params.get('generator_flags', {}) - if generator_flags.get('adjust_static_libraries', False): - global generator_wants_static_library_dependencies_adjusted - generator_wants_static_library_dependencies_adjusted = True - - -def GenerateOutput(target_list, target_dicts, data, params): - # Map of target -> list of targets it depends on. - edges = {} - - # Queue of targets to visit. - targets_to_visit = target_list[:] - - while len(targets_to_visit) > 0: - target = targets_to_visit.pop() - if target in edges: - continue - edges[target] = [] - - for dep in target_dicts[target].get('dependencies', []): - edges[target].append(dep) - targets_to_visit.append(dep) - - filename = 'dump.json' - f = open(filename, 'w') - json.dump(edges, f) - f.close() - print 'Wrote json to %s.' % filename diff --git a/third_party/gyp/pylib/gyp/generator/gypd.py b/third_party/gyp/pylib/gyp/generator/gypd.py deleted file mode 100644 index 948f0b8..0000000 --- a/third_party/gyp/pylib/gyp/generator/gypd.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""gypd output module - -This module produces gyp input as its output. Output files are given the -.gypd extension to avoid overwriting the .gyp files that they are generated -from. Internal references to .gyp files (such as those found in -"dependencies" sections) are not adjusted to point to .gypd files instead; -unlike other paths, which are relative to the .gyp or .gypd file, such paths -are relative to the directory from which gyp was run to create the .gypd file. - -This generator module is intended to be a sample and a debugging aid, hence -the "d" for "debug" in .gypd. It is useful to inspect the results of the -various merges, expansions, and conditional evaluations performed by gyp -and to see a representation of what would be fed to a generator module. - -It's not advisable to rename .gypd files produced by this module to .gyp, -because they will have all merges, expansions, and evaluations already -performed and the relevant constructs not present in the output; paths to -dependencies may be wrong; and various sections that do not belong in .gyp -files such as such as "included_files" and "*_excluded" will be present. -Output will also be stripped of comments. This is not intended to be a -general-purpose gyp pretty-printer; for that, you probably just want to -run "pprint.pprint(eval(open('source.gyp').read()))", which will still strip -comments but won't do all of the other things done to this module's output. - -The specific formatting of the output generated by this module is subject -to change. -""" - - -import gyp.common -import errno -import os -import pprint - - -# These variables should just be spit back out as variable references. -_generator_identity_variables = [ - 'EXECUTABLE_PREFIX', - 'EXECUTABLE_SUFFIX', - 'INTERMEDIATE_DIR', - 'PRODUCT_DIR', - 'RULE_INPUT_ROOT', - 'RULE_INPUT_EXT', - 'RULE_INPUT_NAME', - 'RULE_INPUT_PATH', - 'SHARED_INTERMEDIATE_DIR', -] - -# gypd doesn't define a default value for OS like many other generator -# modules. Specify "-D OS=whatever" on the command line to provide a value. -generator_default_variables = { -} - -# gypd supports multiple toolsets -generator_supports_multiple_toolsets = True - -# TODO(mark): This always uses <, which isn't right. The input module should -# notify the generator to tell it which phase it is operating in, and this -# module should use < for the early phase and then switch to > for the late -# phase. Bonus points for carrying @ back into the output too. -for v in _generator_identity_variables: - generator_default_variables[v] = '<(%s)' % v - - -def GenerateOutput(target_list, target_dicts, data, params): - output_files = {} - for qualified_target in target_list: - [input_file, target] = \ - gyp.common.ParseQualifiedTarget(qualified_target)[0:2] - - if input_file[-4:] != '.gyp': - continue - input_file_stem = input_file[:-4] - output_file = input_file_stem + params['options'].suffix + '.gypd' - - if not output_file in output_files: - output_files[output_file] = input_file - - for output_file, input_file in output_files.iteritems(): - output = open(output_file, 'w') - pprint.pprint(data[input_file], output) - output.close() diff --git a/third_party/gyp/pylib/gyp/generator/gypsh.py b/third_party/gyp/pylib/gyp/generator/gypsh.py deleted file mode 100644 index f48b03f..0000000 --- a/third_party/gyp/pylib/gyp/generator/gypsh.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""gypsh output module - -gypsh is a GYP shell. It's not really a generator per se. All it does is -fire up an interactive Python session with a few local variables set to the -variables passed to the generator. Like gypd, it's intended as a debugging -aid, to facilitate the exploration of .gyp structures after being processed -by the input module. - -The expected usage is "gyp -f gypsh -D OS=desired_os". -""" - - -import code -import sys - - -# All of this stuff about generator variables was lovingly ripped from gypd.py. -# That module has a much better description of what's going on and why. -_generator_identity_variables = [ - 'EXECUTABLE_PREFIX', - 'EXECUTABLE_SUFFIX', - 'INTERMEDIATE_DIR', - 'PRODUCT_DIR', - 'RULE_INPUT_ROOT', - 'RULE_INPUT_EXT', - 'RULE_INPUT_NAME', - 'RULE_INPUT_PATH', - 'SHARED_INTERMEDIATE_DIR', -] - -generator_default_variables = { -} - -for v in _generator_identity_variables: - generator_default_variables[v] = '<(%s)' % v - - -def GenerateOutput(target_list, target_dicts, data, params): - locals = { - 'target_list': target_list, - 'target_dicts': target_dicts, - 'data': data, - } - - # Use a banner that looks like the stock Python one and like what - # code.interact uses by default, but tack on something to indicate what - # locals are available, and identify gypsh. - banner='Python %s on %s\nlocals.keys() = %s\ngypsh' % \ - (sys.version, sys.platform, repr(sorted(locals.keys()))) - - code.interact(banner, local=locals) diff --git a/third_party/gyp/pylib/gyp/generator/make.py b/third_party/gyp/pylib/gyp/generator/make.py deleted file mode 100644 index 56a02eb..0000000 --- a/third_party/gyp/pylib/gyp/generator/make.py +++ /dev/null @@ -1,2624 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Notes: -# -# This is all roughly based on the Makefile system used by the Linux -# kernel, but is a non-recursive make -- we put the entire dependency -# graph in front of make and let it figure it out. -# -# The code below generates a separate .mk file for each target, but -# all are sourced by the top-level Makefile. This means that all -# variables in .mk-files clobber one another. Be careful to use := -# where appropriate for immediate evaluation, and similarly to watch -# that you're not relying on a variable value to last beween different -# .mk files. -# -# TODOs: -# -# Global settings and utility functions are currently stuffed in the -# toplevel Makefile. It may make sense to generate some .mk files on -# the side to keep the the files readable. - -import gyp -import gyp.common -import gyp.system_test -import os.path -import os -import sys - -# Debugging-related imports -- remove me once we're solid. -import code -import pprint - -generator_default_variables = { - 'EXECUTABLE_PREFIX': '', - 'EXECUTABLE_SUFFIX': '', - 'STATIC_LIB_PREFIX': 'lib', - 'SHARED_LIB_PREFIX': 'lib', - 'STATIC_LIB_SUFFIX': '.a', - 'INTERMEDIATE_DIR': '$(obj).$(TOOLSET)/geni', - 'SHARED_INTERMEDIATE_DIR': '$(obj)/gen', - 'PRODUCT_DIR': '$(builddir)', - 'RULE_INPUT_ROOT': '%(INPUT_ROOT)s', # This gets expanded by Python. - 'RULE_INPUT_PATH': '$(abspath $<)', - 'RULE_INPUT_EXT': '$(suffix $<)', - 'RULE_INPUT_NAME': '$(notdir $<)', - - # This appears unused --- ? - 'CONFIGURATION_NAME': '$(BUILDTYPE)', -} - -# Make supports multiple toolsets -generator_supports_multiple_toolsets = True - -# Request sorted dependencies in the order from dependents to dependencies. -generator_wants_sorted_dependencies = False - - -def GetFlavor(params): - """Returns |params.flavor| if it's set, the system's default flavor else.""" - return params.get('flavor', 'mac' if sys.platform == 'darwin' else 'linux') - - -def CalculateVariables(default_variables, params): - """Calculate additional variables for use in the build (called by gyp).""" - cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) - default_variables['LINKER_SUPPORTS_ICF'] = \ - gyp.system_test.TestLinkerSupportsICF(cc_command=cc_target) - - if GetFlavor(params) == 'mac': - default_variables.setdefault('OS', 'mac') - default_variables.setdefault('SHARED_LIB_SUFFIX', '.dylib') - default_variables.setdefault('SHARED_LIB_DIR', - generator_default_variables['PRODUCT_DIR']) - default_variables.setdefault('LIB_DIR', - generator_default_variables['PRODUCT_DIR']) - - # Copy additional generator configuration data from Xcode, which is shared - # by the Mac Make generator. - import gyp.generator.xcode as xcode_generator - global generator_additional_non_configuration_keys - generator_additional_non_configuration_keys = getattr(xcode_generator, - 'generator_additional_non_configuration_keys', []) - global generator_additional_path_sections - generator_additional_path_sections = getattr(xcode_generator, - 'generator_additional_path_sections', []) - global generator_extra_sources_for_rules - generator_extra_sources_for_rules = getattr(xcode_generator, - 'generator_extra_sources_for_rules', []) - global COMPILABLE_EXTENSIONS - COMPILABLE_EXTENSIONS.update({'.m': 'objc', '.mm' : 'objcxx'}) - else: - default_variables.setdefault('OS', 'linux') - default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') - default_variables.setdefault('SHARED_LIB_DIR','$(builddir)/lib.$(TOOLSET)') - default_variables.setdefault('LIB_DIR', '$(obj).$(TOOLSET)') - - -def CalculateGeneratorInputInfo(params): - """Calculate the generator specific info that gets fed to input (called by - gyp).""" - generator_flags = params.get('generator_flags', {}) - android_ndk_version = generator_flags.get('android_ndk_version', None) - # Android NDK requires a strict link order. - if android_ndk_version: - global generator_wants_sorted_dependencies - generator_wants_sorted_dependencies = True - - -def ensure_directory_exists(path): - dir = os.path.dirname(path) - if dir and not os.path.exists(dir): - os.makedirs(dir) - - -# The .d checking code below uses these functions: -# wildcard, sort, foreach, shell, wordlist -# wildcard can handle spaces, the rest can't. -# Since I could find no way to make foreach work with spaces in filenames -# correctly, the .d files have spaces replaced with another character. The .d -# file for -# Chromium\ Framework.framework/foo -# is for example -# out/Release/.deps/out/Release/Chromium?Framework.framework/foo -# This is the replacement character. -SPACE_REPLACEMENT = '?' - - -LINK_COMMANDS_LINUX = """\ -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) -""" - -LINK_COMMANDS_MAC = """\ -quiet_cmd_alink = LIBTOOL-STATIC $@ -cmd_alink = rm -f $@ && libtool -static -o $@ $(filter %.o,$^) - -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): Find out and document the difference between shared_library and -# loadable_module on mac. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) - -# TODO(thakis): The solink_module rule is likely wrong. Xcode seems to pass -# -bundle -single_module here (for osmesa.so). -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) -""" - -# Header of toplevel Makefile. -# This should go into the build tree, but it's easier to keep it here for now. -SHARED_HEADER = ("""\ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := %(srcdir)s - -# The name of the builddir. -builddir_name ?= %(builddir)s - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= %(default_configuration)s - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - -# C++ apps need to be linked with g++. Not sure what's appropriate. -# -# Note, the flock is used to seralize linking. Linking is a memory-intensive -# process so running parallel links can often lead to thrashing. To disable -# the serialization, override FLOCK via an envrionment variable as follows: -# -# export FLOCK= -# -# This will allow make to invoke N linker processes as specified in -jN. -FLOCK ?= %(flock)s $(builddir)/linker.lock - -%(make_global_settings)s - -LINK ?= $(FLOCK) $(CXX) -CC.target ?= $(CC) -CFLAGS.target ?= $(CFLAGS) -CXX.target ?= $(CXX) -CXXFLAGS.target ?= $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) %(LINK_flags)s -AR.target ?= $(AR) -ARFLAGS.target ?= %(ARFLAGS.target)s - -# N.B.: the logic of which commands to run should match the computation done -# in gyp's make.py where ARFLAGS.host etc. is computed. -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= gcc -CFLAGS.host ?= -CXX.host ?= g++ -CXXFLAGS.host ?= -LINK.host ?= g++ -LDFLAGS.host ?= -AR.host ?= ar -ARFLAGS.host := %(ARFLAGS.host)s - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),""" + SPACE_REPLACEMENT + """,$1) -unreplace_spaces = $(subst """ + SPACE_REPLACEMENT + """,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \\ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters.""" -r""" -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef -""" -""" -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -%(mac_commands)s -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -%(link_commands)s -""" - -r""" -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%%s\n' '$(call escape_quotes,$(1))' -""" -""" -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \\ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain """ + SPACE_REPLACEMENT + \ - """ instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains """ + \ - SPACE_REPLACEMENT + """ for -# spaces already and dirx strips the """ + SPACE_REPLACEMENT + \ - """ characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word %(flock_index)d,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - @for p in $(POSTBUILDS); do eval $$p; done - ) -) -endef - -# Declare "all" target first so it is the default, even though we don't have the -# deps yet. -.PHONY: all -all: - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -""") - -SHARED_HEADER_MAC_COMMANDS = """ -quiet_cmd_objc = CXX($(TOOLSET)) $@ -cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< - -quiet_cmd_objcxx = CXX($(TOOLSET)) $@ -cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# Commands for precompiled header files. -quiet_cmd_pch_c = CXX($(TOOLSET)) $@ -cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ -cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CCFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< -quiet_cmd_pch_m = CXX($(TOOLSET)) $@ -cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< -quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ -cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< - -# gyp-mac-tool is written next to the root Makefile by gyp. -# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd -# already. -quiet_cmd_mac_tool = MACTOOL $(4) $< -cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" - -quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ -cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) -""" - - -def WriteRootHeaderSuffixRules(writer): - extensions = sorted(COMPILABLE_EXTENSIONS.keys(), key=str.lower) - - writer.write('# Suffix rules, putting all outputs into $(obj).\n') - for ext in extensions: - writer.write('$(obj).$(TOOLSET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD\n' % ext) - writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) - - writer.write('\n# Try building from generated source, too.\n') - for ext in extensions: - writer.write( - '$(obj).$(TOOLSET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD\n' % ext) - writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) - writer.write('\n') - for ext in extensions: - writer.write('$(obj).$(TOOLSET)/%%.o: $(obj)/%%%s FORCE_DO_CMD\n' % ext) - writer.write('\t@$(call do_cmd,%s,1)\n' % COMPILABLE_EXTENSIONS[ext]) - writer.write('\n') - - -SHARED_HEADER_SUFFIX_RULES_COMMENT1 = ("""\ -# Suffix rules, putting all outputs into $(obj). -""") - - -SHARED_HEADER_SUFFIX_RULES_COMMENT2 = ("""\ -# Try building from generated source, too. -""") - - -SHARED_FOOTER = """\ -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - # Rather than include each individual .d file, concatenate them into a - # single file which make is able to load faster. We split this into - # commands that take 1000 files at a time to avoid overflowing the - # command line. - $(shell cat $(wordlist 1,1000,$(d_files)) > $(depsdir)/all.deps) -%(generate_all_deps)s - # make looks for ways to re-generate included makefiles, but in our case, we - # don't have a direct way. Explicitly telling make that it has nothing to do - # for them makes it go faster. - $(depsdir)/all.deps: ; - - include $(depsdir)/all.deps -endif -""" - -header = """\ -# This file is generated by gyp; do not edit. - -""" - -# Maps every compilable file extension to the do_cmd that compiles it. -COMPILABLE_EXTENSIONS = { - '.c': 'cc', - '.cc': 'cxx', - '.cpp': 'cxx', - '.cxx': 'cxx', - '.s': 'cc', - '.S': 'cc', -} - -def Compilable(filename): - """Return true if the file is compilable (should be in OBJS).""" - for res in (filename.endswith(e) for e in COMPILABLE_EXTENSIONS): - if res: - return True - return False - - -def Linkable(filename): - """Return true if the file is linkable (should be on the link line).""" - return filename.endswith('.o') - - -def Target(filename): - """Translate a compilable filename to its .o target.""" - return os.path.splitext(filename)[0] + '.o' - - -def EscapeShellArgument(s): - """Quotes an argument so that it will be interpreted literally by a POSIX - shell. Taken from - http://stackoverflow.com/questions/35817/whats-the-best-way-to-escape-ossystem-calls-in-python - """ - return "'" + s.replace("'", "'\\''") + "'" - - -def EscapeMakeVariableExpansion(s): - """Make has its own variable expansion syntax using $. We must escape it for - string to be interpreted literally.""" - return s.replace('$', '$$') - - -def EscapeCppDefine(s): - """Escapes a CPP define so that it will reach the compiler unaltered.""" - s = EscapeShellArgument(s) - s = EscapeMakeVariableExpansion(s) - return s - - -def QuoteIfNecessary(string): - """TODO: Should this ideally be replaced with one or more of the above - functions?""" - if '"' in string: - string = '"' + string.replace('"', '\\"') + '"' - return string - - -def StringToMakefileVariable(string): - """Convert a string to a value that is acceptable as a make variable name.""" - # TODO: replace other metacharacters that we encounter. - return string.replace(' ', '_') - - -srcdir_prefix = '' -def Sourceify(path): - """Convert a path to its source directory form.""" - if '$(' in path: - return path - if os.path.isabs(path): - return path - return srcdir_prefix + path - - -def QuoteSpaces(s): - return s.replace(' ', r'\ ') - - -def ReplaceQuotedSpaces(s): - return s.replace(r'\ ', SPACE_REPLACEMENT) - - -# Map from qualified target to path to output. -target_outputs = {} -# Map from qualified target to any linkable output. A subset -# of target_outputs. E.g. when mybinary depends on liba, we want to -# include liba in the linker line; when otherbinary depends on -# mybinary, we just want to build mybinary first. -target_link_deps = {} - - -class XcodeSettings(object): - """A class that understands the gyp 'xcode_settings' object.""" - - def __init__(self, spec): - self.spec = spec - - # Per-target 'xcode_settings' are pushed down into configs earlier by gyp. - # This means self.xcode_settings[config] always contains all settings - # for that config -- the per-target settings as well. Settings that are - # the same for all configs are implicitly per-target settings. - self.xcode_settings = {} - configs = spec['configurations'] - for configname, config in configs.iteritems(): - self.xcode_settings[configname] = config.get('xcode_settings', {}) - - # This is only non-None temporarily during the execution of some methods. - self.configname = None - - def _Settings(self): - assert self.configname - return self.xcode_settings[self.configname] - - def _Test(self, test_key, cond_key, default): - return self._Settings().get(test_key, default) == cond_key - - def _Appendf(self, lst, test_key, format_str): - if test_key in self._Settings(): - lst.append(format_str % str(self._Settings()[test_key])) - - def _WarnUnimplemented(self, test_key): - if test_key in self._Settings(): - print 'Warning: Ignoring not yet implemented key "%s".' % test_key - - def _IsBundle(self): - return int(self.spec.get('mac_bundle', 0)) != 0 - - def GetFrameworkVersion(self): - """Returns the framework version of the current target. Only valid for - bundles.""" - assert self._IsBundle() - return self.GetPerTargetSetting('FRAMEWORK_VERSION', default='A') - - def GetWrapperExtension(self): - """Returns the bundle extension (.app, .framework, .plugin, etc). Only - valid for bundles.""" - assert self._IsBundle() - if self.spec['type'] in ('loadable_module', 'shared_library'): - wrapper_extension = self.GetPerTargetSetting( - 'WRAPPER_EXTENSION', default='framework') - return '.' + self.spec.get('product_extension', wrapper_extension) - elif self.spec['type'] == 'executable': - return '.app' - else: - assert False, "Don't know extension for '%s', target '%s'" % ( - self.spec['type'], self.spec['target_name']) - - def GetProductName(self): - """Returns PRODUCT_NAME.""" - return self.spec.get('product_name', self.spec['target_name']) - - def GetWrapperName(self): - """Returns the directory name of the bundle represented by this target. - Only valid for bundles.""" - assert self._IsBundle() - return self.GetProductName() + self.GetWrapperExtension() - - def GetBundleContentsFolderPath(self): - """Returns the qualified path to the bundle's contents folder. E.g. - Chromium.app/Contents or Foo.bundle/Versions/A. Only valid for bundles.""" - assert self._IsBundle() - if self.spec['type'] == 'shared_library': - return os.path.join( - self.GetWrapperName(), 'Versions', self.GetFrameworkVersion()) - else: - # loadable_modules have a 'Contents' folder like executables. - return os.path.join(self.GetWrapperName(), 'Contents') - - def GetBundleResourceFolder(self): - """Returns the qualified path to the bundle's resource folder. E.g. - Chromium.app/Contents/Resources. Only valid for bundles.""" - assert self._IsBundle() - return os.path.join(self.GetBundleContentsFolderPath(), 'Resources') - - def GetBundlePlistPath(self): - """Returns the qualified path to the bundle's plist file. E.g. - Chromium.app/Contents/Info.plist. Only valid for bundles.""" - assert self._IsBundle() - assert self.spec['type'] != 'loadable_modules', ( - "Info.plist files for loadable_modules not yet supported by the " - "make generator (target %s)" % self.spec['target_name']) # Not tested. - if self.spec['type'] == 'executable': - return os.path.join(self.GetBundleContentsFolderPath(), 'Info.plist') - else: - return os.path.join(self.GetBundleContentsFolderPath(), - 'Resources', 'Info.plist') - - def _GetBundleBinaryPath(self): - """Returns the name of the bundle binary of by this target. - E.g. Chromium.app/Contents/MacOS/Chromium. Only valid for bundles.""" - assert self._IsBundle() - if self.spec['type'] in ('loadable_module', 'shared_library'): - path = self.GetBundleContentsFolderPath() - elif self.spec['type'] == 'executable': - path = os.path.join(self.GetBundleContentsFolderPath(), 'MacOS') - return os.path.join(path, self.spec.get('product_name', - self.spec['target_name'])) - - def _GetStandaloneExecutableSuffix(self): - if 'product_extension' in self.spec: - return '.' + self.spec['product_extension'] - return { - 'executable': '', - 'static_library': '.a', - 'shared_library': '.dylib', - 'loadable_module': '.so', - }[self.spec['type']] - - def _GetStandaloneExecutablePrefix(self): - return self.spec.get('product_prefix', { - 'executable': '', - 'static_library': 'lib', - 'shared_library': 'lib', - # Non-bundled loadable_modules are called foo.so for some reason - # (that is, .so and no prefix) with the xcode build -- match that. - 'loadable_module': '', - }[self.spec['type']]) - - def _GetStandaloneBinaryPath(self): - """Returns the name of the non-bundle binary represented by this target. - E.g. hello_world. Only valid for non-bundles.""" - assert not self._IsBundle() - assert self.spec['type'] in ( - 'executable', 'shared_library', 'static_library', 'loadable_module') - target = self.spec['target_name'] - if self.spec['type'] == 'static_library': - if target[:3] == 'lib': - target = target[3:] - elif self.spec['type'] in ('loadable_module', 'shared_library'): - if target[:3] == 'lib': - target = target[3:] - - target_prefix = self._GetStandaloneExecutablePrefix() - target = self.spec.get('product_name', target) - target_ext = self._GetStandaloneExecutableSuffix() - return target_prefix + target + target_ext - - def GetExecutablePath(self): - """Returns the directory name of the bundle represented by this target. E.g. - Chromium.app/Contents/MacOS/Chromium.""" - if self._IsBundle(): - return self._GetBundleBinaryPath() - else: - return self._GetStandaloneBinaryPath() - - def _SdkPath(self): - sdk_root = 'macosx10.5' - if 'SDKROOT' in self._Settings(): - sdk_root = self._Settings()['SDKROOT'] - if sdk_root.startswith('macosx'): - sdk_root = 'MacOSX' + sdk_root[len('macosx'):] - return '/Developer/SDKs/%s.sdk' % sdk_root - - def GetCflags(self, configname): - """Returns flags that need to be added to .c, .cc, .m, and .mm - compilations.""" - # This functions (and the similar ones below) do not offer complete - # emulation of all xcode_settings keys. They're implemented on demand. - - self.configname = configname - cflags = [] - - sdk_root = self._SdkPath() - if 'SDKROOT' in self._Settings(): - cflags.append('-isysroot %s' % sdk_root) - - if self._Test('GCC_CW_ASM_SYNTAX', 'YES', default='YES'): - cflags.append('-fasm-blocks') - - if 'GCC_DYNAMIC_NO_PIC' in self._Settings(): - if self._Settings()['GCC_DYNAMIC_NO_PIC'] == 'YES': - cflags.append('-mdynamic-no-pic') - else: - pass - # TODO: In this case, it depends on the target. xcode passes - # mdynamic-no-pic by default for executable and possibly static lib - # according to mento - - if self._Test('GCC_ENABLE_PASCAL_STRINGS', 'YES', default='YES'): - cflags.append('-mpascal-strings') - - self._Appendf(cflags, 'GCC_OPTIMIZATION_LEVEL', '-O%s') - - if self._Test('GCC_GENERATE_DEBUGGING_SYMBOLS', 'YES', default='YES'): - dbg_format = self._Settings().get('DEBUG_INFORMATION_FORMAT', 'dwarf') - if dbg_format == 'dwarf': - cflags.append('-gdwarf-2') - elif dbg_format == 'stabs': - raise NotImplementedError('stabs debug format is not supported yet.') - elif dbg_format == 'dwarf-with-dsym': - # TODO(thakis): this is needed for mac_breakpad chromium builds, but not - # for regular chromium builds. - # -gdwarf-2 as well, but needs to invoke dsymutil after linking too: - # dsymutil build/Default/TestAppGyp.app/Contents/MacOS/TestAppGyp \ - # -o build/Default/TestAppGyp.app.dSYM - raise NotImplementedError('dsym debug format is not supported yet.') - else: - raise NotImplementedError('Unknown debug format %s' % dbg_format) - - if self._Test('GCC_SYMBOLS_PRIVATE_EXTERN', 'YES', default='NO'): - cflags.append('-fvisibility=hidden') - - if self._Test('GCC_TREAT_WARNINGS_AS_ERRORS', 'YES', default='NO'): - cflags.append('-Werror') - - if self._Test('GCC_WARN_ABOUT_MISSING_NEWLINE', 'YES', default='NO'): - cflags.append('-Wnewline-eof') - - self._Appendf(cflags, 'MACOSX_DEPLOYMENT_TARGET', '-mmacosx-version-min=%s') - - # TODO: - self._WarnUnimplemented('ARCHS') - self._WarnUnimplemented('COPY_PHASE_STRIP') - self._WarnUnimplemented('DEPLOYMENT_POSTPROCESSING') - self._WarnUnimplemented('GCC_DEBUGGING_SYMBOLS') - self._WarnUnimplemented('GCC_ENABLE_OBJC_EXCEPTIONS') - self._WarnUnimplemented('GCC_ENABLE_OBJC_GC') - self._WarnUnimplemented('INFOPLIST_PREPROCESS') - self._WarnUnimplemented('INFOPLIST_PREPROCESSOR_DEFINITIONS') - self._WarnUnimplemented('STRIPFLAGS') - self._WarnUnimplemented('STRIP_INSTALLED_PRODUCT') - - # TODO: Do not hardcode arch. Supporting fat binaries will be annoying. - cflags.append('-arch i386') - - cflags += self._Settings().get('OTHER_CFLAGS', []) - cflags += self._Settings().get('WARNING_CFLAGS', []) - - config = self.spec['configurations'][self.configname] - framework_dirs = config.get('mac_framework_dirs', []) - for directory in framework_dirs: - cflags.append('-F ' + os.path.join(sdk_root, directory)) - - self.configname = None - return cflags - - def GetCflagsC(self, configname): - """Returns flags that need to be added to .c, and .m compilations.""" - self.configname = configname - cflags_c = [] - self._Appendf(cflags_c, 'GCC_C_LANGUAGE_STANDARD', '-std=%s') - self.configname = None - return cflags_c - - def GetCflagsCC(self, configname): - """Returns flags that need to be added to .cc, and .mm compilations.""" - self.configname = configname - cflags_cc = [] - if self._Test('GCC_ENABLE_CPP_RTTI', 'NO', default='YES'): - cflags_cc.append('-fno-rtti') - if self._Test('GCC_ENABLE_CPP_EXCEPTIONS', 'NO', default='YES'): - cflags_cc.append('-fno-exceptions') - if self._Test('GCC_INLINES_ARE_PRIVATE_EXTERN', 'YES', default='NO'): - cflags_cc.append('-fvisibility-inlines-hidden') - if self._Test('GCC_THREADSAFE_STATICS', 'NO', default='YES'): - cflags_cc.append('-fno-threadsafe-statics') - self.configname = None - return cflags_cc - - def GetCflagsObjC(self, configname): - """Returns flags that need to be added to .m compilations.""" - self.configname = configname - self.configname = None - return [] - - def GetCflagsObjCC(self, configname): - """Returns flags that need to be added to .mm compilations.""" - self.configname = configname - cflags_objcc = [] - if self._Test('GCC_OBJC_CALL_CXX_CDTORS', 'YES', default='NO'): - cflags_objcc.append('-fobjc-call-cxx-cdtors') - self.configname = None - return cflags_objcc - - def GetLdflags(self, target, configname): - """Returns flags that need to be passed to the linker.""" - self.configname = configname - ldflags = [] - - # The xcode build is relative to a gyp file's directory, and OTHER_LDFLAGS - # contains two entries that depend on this. Explicitly absolutify for these - # two cases. - def AbsolutifyPrefix(flag, prefix): - if flag.startswith(prefix): - flag = prefix + target.Absolutify(flag[len(prefix):]) - return flag - for ldflag in self._Settings().get('OTHER_LDFLAGS', []): - # Required for ffmpeg (no idea why they don't use LIBRARY_SEARCH_PATHS, - # TODO(thakis): Update ffmpeg.gyp): - ldflag = AbsolutifyPrefix(ldflag, '-L') - # Required for the nacl plugin: - ldflag = AbsolutifyPrefix(ldflag, '-Wl,-exported_symbols_list ') - ldflags.append(ldflag) - - if self._Test('DEAD_CODE_STRIPPING', 'YES', default='NO'): - ldflags.append('-Wl,-dead_strip') - - if self._Test('PREBINDING', 'YES', default='NO'): - ldflags.append('-Wl,-prebind') - - self._Appendf( - ldflags, 'DYLIB_COMPATIBILITY_VERSION', '-compatibility_version %s') - self._Appendf( - ldflags, 'DYLIB_CURRENT_VERSION', '-current_version %s') - self._Appendf( - ldflags, 'MACOSX_DEPLOYMENT_TARGET', '-mmacosx-version-min=%s') - if 'SDKROOT' in self._Settings(): - ldflags.append('-isysroot ' + self._SdkPath()) - - for library_path in self._Settings().get('LIBRARY_SEARCH_PATHS', []): - ldflags.append('-L' + library_path) - - if 'ORDER_FILE' in self._Settings(): - ldflags.append('-Wl,-order_file ' + - '-Wl,' + target.Absolutify(self._Settings()['ORDER_FILE'])) - - # TODO: Do not hardcode arch. Supporting fat binaries will be annoying. - ldflags.append('-arch i386') - - # Xcode adds the product directory by default. - ldflags.append('-L' + generator_default_variables['PRODUCT_DIR']) - - install_name = self.GetPerTargetSetting('LD_DYLIB_INSTALL_NAME') - install_base = self.GetPerTargetSetting('DYLIB_INSTALL_NAME_BASE') - default_install_name = \ - '$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)' - if not install_name and install_base: - install_name = default_install_name - - if install_name: - # Hardcode support for the variables used in chromium for now, to unblock - # people using the make build. - if '$' in install_name: - assert install_name in ('$(DYLIB_INSTALL_NAME_BASE:standardizepath)/' - '$(WRAPPER_NAME)/$(PRODUCT_NAME)', default_install_name), ( - 'Variables in LD_DYLIB_INSTALL_NAME are not generally supported yet' - ' in target \'%s\' (got \'%s\')' % - (self.spec['target_name'], install_name)) - # I'm not quite sure what :standardizepath does. Just call normpath(), - # but don't let @executable_path/../foo collapse to foo. - if '/' in install_base: - prefix, rest = '', install_base - if install_base.startswith('@'): - prefix, rest = install_base.split('/', 1) - rest = os.path.normpath(rest) # :standardizepath - install_base = os.path.join(prefix, rest) - - install_name = install_name.replace( - '$(DYLIB_INSTALL_NAME_BASE:standardizepath)', install_base) - if self._IsBundle(): - # These are only valid for bundles, hence the |if|. - install_name = install_name.replace( - '$(WRAPPER_NAME)', self.GetWrapperName()) - install_name = install_name.replace( - '$(PRODUCT_NAME)', self.GetProductName()) - else: - assert '$(WRAPPER_NAME)' not in install_name - assert '$(PRODUCT_NAME)' not in install_name - - install_name = install_name.replace( - '$(EXECUTABLE_PATH)', self.GetExecutablePath()) - - install_name = QuoteSpaces(install_name) - ldflags.append('-install_name ' + install_name) - - self.configname = None - return ldflags - - def GetPerTargetSettings(self): - """Gets a list of all the per-target settings. This will only fetch keys - whose values are the same across all configurations.""" - first_pass = True - result = {} - for configname in sorted(self.xcode_settings.keys()): - if first_pass: - result = dict(self.xcode_settings[configname]) - first_pass = False - else: - for key, value in self.xcode_settings[configname].iteritems(): - if key not in result: - continue - elif result[key] != value: - del result[key] - return result - - def GetPerTargetSetting(self, setting, default=None): - """Tries to get xcode_settings.setting from spec. Assumes that the setting - has the same value in all configurations and throws otherwise.""" - first_pass = True - result = None - for configname in sorted(self.xcode_settings.keys()): - if first_pass: - result = self.xcode_settings[configname].get(setting, None) - first_pass = False - else: - assert result == self.xcode_settings[configname].get(setting, None), ( - "Expected per-target setting for '%s', got per-config setting " - "(target %s)" % (setting, spec['target_name'])) - if result is None: - return default - return result - - -class MacPrefixHeader(object): - """A class that helps with emulating Xcode's GCC_PREFIX_HEADER feature. If - GCC_PREFIX_HEADER isn't present (in most gyp targets on mac, and always on - non-mac systems), all methods of this class are no-ops.""" - - def __init__(self, path_provider): - # This doesn't support per-configuration prefix headers. Good enough - # for now. - self.header = None - if path_provider.flavor == 'mac': - self.header = path_provider.xcode_settings.GetPerTargetSetting( - 'GCC_PREFIX_HEADER') - self.compiled_headers = {} - if self.header: - self.header = path_provider.Absolutify(self.header) - for lang in ['c', 'cc', 'm', 'mm']: - self.compiled_headers[lang] = path_provider.Pchify(self.header, lang) - - def _Gch(self, lang): - """Returns the actual file name of the prefix header for language |lang|.""" - return self.compiled_headers[lang] + '.gch' - - def WriteObjDependencies(self, compilable, objs, writer): - """Writes dependencies from the object files in |objs| to the corresponding - precompiled header file. |compilable[i]| has to be the source file belonging - to |objs[i]|.""" - if not self.header: - return - - writer.WriteLn('# Dependencies from obj files to their precompiled headers') - for source, obj in zip(compilable, objs): - ext = os.path.splitext(source)[1] - lang = { - '.c': 'c', - '.cpp': 'cc', '.cc': 'cc', '.cxx': 'cc', - '.m': 'm', - '.mm': 'mm', - }.get(ext, None) - if lang: - writer.WriteLn('%s: %s' % (obj, self._Gch(lang))) - writer.WriteLn('# End precompiled header dependencies') - - def GetInclude(self, lang): - """Gets the cflags to include the prefix header for language |lang|.""" - if lang not in self.compiled_headers: - return '' - return '-include %s ' % self.compiled_headers[lang] - - def WritePchTargets(self, writer): - """Writes make rules to compile the prefix headers.""" - if not self.header: - return - - writer.WriteLn(self._Gch('c') + ": GYP_PCH_CFLAGS := " - "-x c-header " - "$(DEFS_$(BUILDTYPE)) " - "$(INCS_$(BUILDTYPE)) " - "$(CFLAGS_$(BUILDTYPE)) " - "$(CFLAGS_C_$(BUILDTYPE))") - - writer.WriteLn(self._Gch('cc') + ": GYP_PCH_CCFLAGS := " - "-x c++-header " - "$(DEFS_$(BUILDTYPE)) " - "$(INCS_$(BUILDTYPE)) " - "$(CFLAGS_$(BUILDTYPE)) " - "$(CFLAGS_CC_$(BUILDTYPE))") - - writer.WriteLn(self._Gch('m') + ": GYP_PCH_OBJCFLAGS := " - "-x objective-c-header " - "$(DEFS_$(BUILDTYPE)) " - "$(INCS_$(BUILDTYPE)) " - "$(CFLAGS_$(BUILDTYPE)) " - "$(CFLAGS_C_$(BUILDTYPE)) " - "$(CFLAGS_OBJC_$(BUILDTYPE))") - - writer.WriteLn(self._Gch('mm') + ": GYP_PCH_OBJCXXFLAGS := " - "-x objective-c++-header " - "$(DEFS_$(BUILDTYPE)) " - "$(INCS_$(BUILDTYPE)) " - "$(CFLAGS_$(BUILDTYPE)) " - "$(CFLAGS_CC_$(BUILDTYPE)) " - "$(CFLAGS_OBJCC_$(BUILDTYPE))") - - for lang in self.compiled_headers: - writer.WriteLn('%s: %s FORCE_DO_CMD' % (self._Gch(lang), self.header)) - writer.WriteLn('\t@$(call do_cmd,pch_%s,1)' % lang) - writer.WriteLn('') - assert ' ' not in self._Gch(lang), ( - "Spaces in gch filenames not supported (%s)" % self._Gch(lang)) - writer.WriteLn('all_deps += %s' % self._Gch(lang)) - writer.WriteLn('') - - -class MakefileWriter: - """MakefileWriter packages up the writing of one target-specific foobar.mk. - - Its only real entry point is Write(), and is mostly used for namespacing. - """ - - def __init__(self, generator_flags, flavor): - self.generator_flags = generator_flags - self.flavor = flavor - # Keep track of the total number of outputs for this makefile. - self._num_outputs = 0 - - self.suffix_rules_srcdir = {} - self.suffix_rules_objdir1 = {} - self.suffix_rules_objdir2 = {} - - # Generate suffix rules for all compilable extensions. - for ext in COMPILABLE_EXTENSIONS.keys(): - # Suffix rules for source folder. - self.suffix_rules_srcdir.update({ext: ("""\ -$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(srcdir)/%%%s FORCE_DO_CMD - @$(call do_cmd,%s,1) -""" % (ext, COMPILABLE_EXTENSIONS[ext]))}) - - # Suffix rules for generated source files. - self.suffix_rules_objdir1.update({ext: ("""\ -$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj).$(TOOLSET)/%%%s FORCE_DO_CMD - @$(call do_cmd,%s,1) -""" % (ext, COMPILABLE_EXTENSIONS[ext]))}) - self.suffix_rules_objdir2.update({ext: ("""\ -$(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD - @$(call do_cmd,%s,1) -""" % (ext, COMPILABLE_EXTENSIONS[ext]))}) - - - def NumOutputs(self): - return self._num_outputs - - - def Write(self, qualified_target, base_path, output_filename, spec, configs, - part_of_all): - """The main entry point: writes a .mk file for a single target. - - Arguments: - qualified_target: target we're generating - base_path: path relative to source root we're building in, used to resolve - target-relative paths - output_filename: output .mk file name to write - spec, configs: gyp info - part_of_all: flag indicating this target is part of 'all' - """ - ensure_directory_exists(output_filename) - - self.fp = open(output_filename, 'w') - - self.fp.write(header) - - self.path = base_path - self.target = spec['target_name'] - self.type = spec['type'] - self.toolset = spec['toolset'] - - # Bundles are directories with a certain subdirectory structure, instead of - # just a single file. Bundle rules do not produce a binary but also package - # resources into that directory. - self.is_mac_bundle = (int(spec.get('mac_bundle', 0)) != 0 and - self.flavor == 'mac') - if self.is_mac_bundle: - assert self.type != 'none', ( - 'mac_bundle targets cannot have type none (target "%s")' % - self.target) - - if self.flavor == 'mac': - self.xcode_settings = XcodeSettings(spec) - - deps, link_deps = self.ComputeDeps(spec) - - # Some of the generation below can add extra output, sources, or - # link dependencies. All of the out params of the functions that - # follow use names like extra_foo. - extra_outputs = [] - extra_sources = [] - extra_link_deps = [] - extra_mac_bundle_resources = [] - mac_bundle_deps = [] - - if self.is_mac_bundle: - self.output = self.ComputeMacBundleOutput(spec) - self.output_binary = self.ComputeMacBundleBinaryOutput(spec) - else: - self.output = self.output_binary = self.ComputeOutput(spec) - - self.output = QuoteSpaces(self.output) - self.output_binary = QuoteSpaces(self.output_binary) - - self._INSTALLABLE_TARGETS = ('executable', 'loadable_module', - 'shared_library') - if self.type in self._INSTALLABLE_TARGETS: - self.alias = os.path.basename(self.output) - install_path = self._InstallableTargetInstallPath() - else: - self.alias = self.output - install_path = self.output - - self.WriteLn("TOOLSET := " + self.toolset) - self.WriteLn("TARGET := " + self.target) - - # Actions must come first, since they can generate more OBJs for use below. - if 'actions' in spec: - self.WriteActions(spec['actions'], extra_sources, extra_outputs, - extra_mac_bundle_resources, part_of_all, spec) - - # Rules must be early like actions. - if 'rules' in spec: - self.WriteRules(spec['rules'], extra_sources, extra_outputs, - extra_mac_bundle_resources, part_of_all) - - if 'copies' in spec: - self.WriteCopies(spec['copies'], extra_outputs, part_of_all, spec) - - # Bundle resources. - if self.is_mac_bundle: - all_mac_bundle_resources = ( - spec.get('mac_bundle_resources', []) + extra_mac_bundle_resources) - if all_mac_bundle_resources: - self.WriteMacBundleResources( - all_mac_bundle_resources, mac_bundle_deps, spec) - info_plist = self.xcode_settings.GetPerTargetSetting('INFOPLIST_FILE') - if info_plist: - self.WriteMacInfoPlist(info_plist, mac_bundle_deps, spec) - - # Sources. - all_sources = spec.get('sources', []) + extra_sources - if all_sources: - self.WriteSources( - configs, deps, all_sources, extra_outputs, - extra_link_deps, part_of_all, MacPrefixHeader(self)) - sources = filter(Compilable, all_sources) - if sources: - self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT1) - extensions = set([os.path.splitext(s)[1] for s in sources]) - for ext in extensions: - if ext in self.suffix_rules_srcdir: - self.WriteLn(self.suffix_rules_srcdir[ext]) - self.WriteLn(SHARED_HEADER_SUFFIX_RULES_COMMENT2) - for ext in extensions: - if ext in self.suffix_rules_objdir1: - self.WriteLn(self.suffix_rules_objdir1[ext]) - for ext in extensions: - if ext in self.suffix_rules_objdir2: - self.WriteLn(self.suffix_rules_objdir2[ext]) - self.WriteLn('# End of this set of suffix rules') - - # Add dependency from bundle to bundle binary. - if self.is_mac_bundle: - mac_bundle_deps.append(self.output_binary) - - self.WriteTarget(spec, configs, deps, extra_link_deps + link_deps, - mac_bundle_deps, extra_outputs, part_of_all) - - # Update global list of target outputs, used in dependency tracking. - target_outputs[qualified_target] = install_path - - # Update global list of link dependencies. - if self.type in ('static_library', 'shared_library'): - target_link_deps[qualified_target] = self.output_binary - - # Currently any versions have the same effect, but in future the behavior - # could be different. - if self.generator_flags.get('android_ndk_version', None): - self.WriteAndroidNdkModuleRule(self.target, all_sources, link_deps) - - self.fp.close() - - - def WriteSubMake(self, output_filename, makefile_path, targets, build_dir): - """Write a "sub-project" Makefile. - - This is a small, wrapper Makefile that calls the top-level Makefile to build - the targets from a single gyp file (i.e. a sub-project). - - Arguments: - output_filename: sub-project Makefile name to write - makefile_path: path to the top-level Makefile - targets: list of "all" targets for this sub-project - build_dir: build output directory, relative to the sub-project - """ - ensure_directory_exists(output_filename) - self.fp = open(output_filename, 'w') - self.fp.write(header) - # For consistency with other builders, put sub-project build output in the - # sub-project dir (see test/subdirectory/gyptest-subdir-all.py). - self.WriteLn('export builddir_name ?= %s' % - os.path.join(os.path.dirname(output_filename), build_dir)) - self.WriteLn('.PHONY: all') - self.WriteLn('all:') - if makefile_path: - makefile_path = ' -C ' + makefile_path - self.WriteLn('\t$(MAKE)%s %s' % (makefile_path, ' '.join(targets))) - self.fp.close() - - - def WriteActions(self, actions, extra_sources, extra_outputs, - extra_mac_bundle_resources, part_of_all, spec): - """Write Makefile code for any 'actions' from the gyp input. - - extra_sources: a list that will be filled in with newly generated source - files, if any - extra_outputs: a list that will be filled in with any outputs of these - actions (used to make other pieces dependent on these - actions) - part_of_all: flag indicating this target is part of 'all' - """ - for action in actions: - name = self.target + '_' + StringToMakefileVariable(action['action_name']) - self.WriteLn('### Rules for action "%s":' % action['action_name']) - inputs = action['inputs'] - outputs = action['outputs'] - - # Build up a list of outputs. - # Collect the output dirs we'll need. - dirs = set() - for out in outputs: - dir = os.path.split(out)[0] - if dir: - dirs.add(dir) - if int(action.get('process_outputs_as_sources', False)): - extra_sources += outputs - if int(action.get('process_outputs_as_mac_bundle_resources', False)): - extra_mac_bundle_resources += outputs - - # Write the actual command. - command = gyp.common.EncodePOSIXShellList(action['action']) - if 'message' in action: - self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, action['message'])) - else: - self.WriteLn('quiet_cmd_%s = ACTION %s $@' % (name, name)) - if len(dirs) > 0: - command = 'mkdir -p %s' % ' '.join(dirs) + '; ' + command - - cd_action = 'cd %s; ' % Sourceify(self.path or '.') - - # Set LD_LIBRARY_PATH in case the action runs an executable from this - # build which links to shared libs from this build. - # actions run on the host, so they should in theory only use host - # libraries, but until everything is made cross-compile safe, also use - # target libraries. - # TODO(piman): when everything is cross-compile safe, remove lib.target - self.WriteLn('cmd_%s = export LD_LIBRARY_PATH=$(builddir)/lib.host:' - '$(builddir)/lib.target:$$LD_LIBRARY_PATH; %s%s' - % (name, cd_action, command)) - self.WriteLn() - outputs = map(self.Absolutify, outputs) - # The makefile rules are all relative to the top dir, but the gyp actions - # are defined relative to their containing dir. This replaces the obj - # variable for the action rule with an absolute version so that the output - # goes in the right place. - # Only write the 'obj' and 'builddir' rules for the "primary" output (:1); - # it's superfluous for the "extra outputs", and this avoids accidentally - # writing duplicate dummy rules for those outputs. - # Same for environment. - self.WriteMakeRule(outputs[:1], ['obj := $(abs_obj)']) - # Needs to be before builddir is redefined in the next line! - self.WriteXcodeEnv(outputs[0], spec, target_relative_path=True) - self.WriteMakeRule(outputs[:1], ['builddir := $(abs_builddir)']) - - for input in inputs: - assert ' ' not in input, ( - "Spaces in action input filenames not supported (%s)" % input) - for output in outputs: - assert ' ' not in output, ( - "Spaces in action output filenames not supported (%s)" % output) - - self.WriteDoCmd(outputs, map(Sourceify, map(self.Absolutify, inputs)), - part_of_all=part_of_all, command=name) - - # Stuff the outputs in a variable so we can refer to them later. - outputs_variable = 'action_%s_outputs' % name - self.WriteLn('%s := %s' % (outputs_variable, ' '.join(outputs))) - extra_outputs.append('$(%s)' % outputs_variable) - self.WriteLn() - - self.WriteLn() - - - def WriteRules(self, rules, extra_sources, extra_outputs, - extra_mac_bundle_resources, part_of_all): - """Write Makefile code for any 'rules' from the gyp input. - - extra_sources: a list that will be filled in with newly generated source - files, if any - extra_outputs: a list that will be filled in with any outputs of these - rules (used to make other pieces dependent on these rules) - part_of_all: flag indicating this target is part of 'all' - """ - for rule in rules: - name = self.target + '_' + StringToMakefileVariable(rule['rule_name']) - count = 0 - self.WriteLn('### Generated for rule %s:' % name) - - all_outputs = [] - - for rule_source in rule.get('rule_sources', []): - dirs = set() - rule_source_basename = os.path.basename(rule_source) - (rule_source_root, rule_source_ext) = \ - os.path.splitext(rule_source_basename) - - outputs = [self.ExpandInputRoot(out, rule_source_root) - for out in rule['outputs']] - for out in outputs: - dir = os.path.dirname(out) - if dir: - dirs.add(dir) - if int(rule.get('process_outputs_as_sources', False)): - extra_sources += outputs - if int(rule.get('process_outputs_as_mac_bundle_resources', False)): - extra_mac_bundle_resources += outputs - all_outputs += outputs - inputs = map(Sourceify, map(self.Absolutify, [rule_source] + - rule.get('inputs', []))) - actions = ['$(call do_cmd,%s_%d)' % (name, count)] - - if name == 'resources_grit': - # HACK: This is ugly. Grit intentionally doesn't touch the - # timestamp of its output file when the file doesn't change, - # which is fine in hash-based dependency systems like scons - # and forge, but not kosher in the make world. After some - # discussion, hacking around it here seems like the least - # amount of pain. - actions += ['@touch --no-create $@'] - - # Only write the 'obj' and 'builddir' rules for the "primary" output - # (:1); it's superfluous for the "extra outputs", and this avoids - # accidentally writing duplicate dummy rules for those outputs. - self.WriteMakeRule(outputs[:1], ['obj := $(abs_obj)']) - self.WriteMakeRule(outputs[:1], ['builddir := $(abs_builddir)']) - self.WriteMakeRule(outputs, inputs + ['FORCE_DO_CMD'], actions) - for output in outputs: - assert ' ' not in output, ( - "Spaces in rule filenames not yet supported (%s)" % output) - self.WriteLn('all_deps += %s' % ' '.join(outputs)) - self._num_outputs += len(outputs) - - action = [self.ExpandInputRoot(ac, rule_source_root) - for ac in rule['action']] - mkdirs = '' - if len(dirs) > 0: - mkdirs = 'mkdir -p %s; ' % ' '.join(dirs) - cd_action = 'cd %s; ' % Sourceify(self.path or '.') - # Set LD_LIBRARY_PATH in case the rule runs an executable from this - # build which links to shared libs from this build. - # rules run on the host, so they should in theory only use host - # libraries, but until everything is made cross-compile safe, also use - # target libraries. - # TODO(piman): when everything is cross-compile safe, remove lib.target - self.WriteLn( - "cmd_%(name)s_%(count)d = export LD_LIBRARY_PATH=" - "$(builddir)/lib.host:$(builddir)/lib.target:$$LD_LIBRARY_PATH; " - "%(cd_action)s%(mkdirs)s%(action)s" % { - 'action': gyp.common.EncodePOSIXShellList(action), - 'cd_action': cd_action, - 'count': count, - 'mkdirs': mkdirs, - 'name': name, - }) - self.WriteLn( - 'quiet_cmd_%(name)s_%(count)d = RULE %(name)s_%(count)d $@' % { - 'count': count, - 'name': name, - }) - self.WriteLn() - count += 1 - - outputs_variable = 'rule_%s_outputs' % name - self.WriteList(all_outputs, outputs_variable) - extra_outputs.append('$(%s)' % outputs_variable) - - self.WriteLn('### Finished generating for rule: %s' % name) - self.WriteLn() - self.WriteLn('### Finished generating for all rules') - self.WriteLn('') - - - def WriteCopies(self, copies, extra_outputs, part_of_all, spec): - """Write Makefile code for any 'copies' from the gyp input. - - extra_outputs: a list that will be filled in with any outputs of this action - (used to make other pieces dependent on this action) - part_of_all: flag indicating this target is part of 'all' - """ - self.WriteLn('### Generated for copy rule.') - - variable = self.target + '_copies' - outputs = [] - for copy in copies: - for path in copy['files']: - path = Sourceify(self.Absolutify(path)) - filename = os.path.split(path)[1] - output = Sourceify(self.Absolutify(os.path.join(copy['destination'], - filename))) - path = QuoteSpaces(path) - output = QuoteSpaces(output) - - # If the output path has variables in it, which happens in practice for - # 'copies', writing the environment as target-local doesn't work, - # because the variables are already needed for the target name. - # Copying the environment variables into global make variables doesn't - # work either, because then the .d files will potentially contain spaces - # after variable expansion, and .d file handling cannot handle spaces. - # As a workaround, manually expand variables at gyp time. Since 'copies' - # can't run scripts, there's no need to write the env then. - # WriteDoCmd() will escape spaces for .d files. - import gyp.generator.xcode as xcode_generator - env = self.GetXcodeEnv(spec) - output = xcode_generator.ExpandXcodeVariables(output, env) - path = xcode_generator.ExpandXcodeVariables(path, env) - self.WriteDoCmd([output], [path], 'copy', part_of_all) - outputs.append(output) - self.WriteLn('%s = %s' % (variable, ' '.join(outputs))) - extra_outputs.append('$(%s)' % variable) - self.WriteLn() - - - def WriteMacBundleResources(self, resources, bundle_deps, spec): - """Writes Makefile code for 'mac_bundle_resources'.""" - self.WriteLn('### Generated for mac_bundle_resources') - variable = self.target + '_mac_bundle_resources' - path = generator_default_variables['PRODUCT_DIR'] - dest = os.path.join(path, self.xcode_settings.GetBundleResourceFolder()) - dest = QuoteSpaces(dest) - for res in resources: - output = dest - - assert ' ' not in res, ( - "Spaces in resource filenames not supported (%s)" % res) - - # Split into (path,file). - path = Sourceify(self.Absolutify(res)) - path_parts = os.path.split(path) - - # Now split the path into (prefix,maybe.lproj). - lproj_parts = os.path.split(path_parts[0]) - # If the resource lives in a .lproj bundle, add that to the destination. - if lproj_parts[1].endswith('.lproj'): - output = os.path.join(output, lproj_parts[1]) - - output = Sourceify(self.Absolutify(os.path.join(output, path_parts[1]))) - # Compiled XIB files are referred to by .nib. - if output.endswith('.xib'): - output = output[0:-3] + 'nib' - - self.WriteDoCmd([output], [path], 'mac_tool,,,copy-bundle-resource', - part_of_all=True) - bundle_deps.append(output) - - - def WriteMacInfoPlist(self, info_plist, bundle_deps, spec): - """Write Makefile code for bundle Info.plist files.""" - assert ' ' not in info_plist, ( - "Spaces in resource filenames not supported (%s)" % info_plist) - info_plist = self.Absolutify(info_plist) - path = generator_default_variables['PRODUCT_DIR'] - dest_plist = os.path.join(path, self.xcode_settings.GetBundlePlistPath()) - dest_plist = QuoteSpaces(dest_plist) - extra_settings = self.xcode_settings.GetPerTargetSettings() - # plists can contain envvars and substitute them into the file.. - self.WriteXcodeEnv(dest_plist, spec, additional_settings=extra_settings) - self.WriteDoCmd([dest_plist], [info_plist], 'mac_tool,,,copy-info-plist', - part_of_all=True) - bundle_deps.append(dest_plist) - - - def WriteSources(self, configs, deps, sources, - extra_outputs, extra_link_deps, - part_of_all, precompiled_header): - """Write Makefile code for any 'sources' from the gyp input. - These are source files necessary to build the current target. - - configs, deps, sources: input from gyp. - extra_outputs: a list of extra outputs this action should be dependent on; - used to serialize action/rules before compilation - extra_link_deps: a list that will be filled in with any outputs of - compilation (to be used in link lines) - part_of_all: flag indicating this target is part of 'all' - """ - - # Write configuration-specific variables for CFLAGS, etc. - for configname in sorted(configs.keys()): - config = configs[configname] - self.WriteList(config.get('defines'), 'DEFS_%s' % configname, prefix='-D', - quoter=EscapeCppDefine) - - if self.flavor == 'mac': - cflags = self.xcode_settings.GetCflags(configname) - cflags_c = self.xcode_settings.GetCflagsC(configname) - cflags_cc = self.xcode_settings.GetCflagsCC(configname) - cflags_objc = self.xcode_settings.GetCflagsObjC(configname) - cflags_objcc = self.xcode_settings.GetCflagsObjCC(configname) - else: - cflags = config.get('cflags') - cflags_c = config.get('cflags_c') - cflags_cc = config.get('cflags_cc') - - self.WriteLn("# Flags passed to all source files."); - self.WriteList(cflags, 'CFLAGS_%s' % configname) - self.WriteLn("# Flags passed to only C files."); - self.WriteList(cflags_c, 'CFLAGS_C_%s' % configname) - self.WriteLn("# Flags passed to only C++ files."); - self.WriteList(cflags_cc, 'CFLAGS_CC_%s' % configname) - if self.flavor == 'mac': - self.WriteLn("# Flags passed to only ObjC files."); - self.WriteList(cflags_objc, 'CFLAGS_OBJC_%s' % configname) - self.WriteLn("# Flags passed to only ObjC++ files."); - self.WriteList(cflags_objcc, 'CFLAGS_OBJCC_%s' % configname) - includes = config.get('include_dirs') - if includes: - includes = map(Sourceify, map(self.Absolutify, includes)) - self.WriteList(includes, 'INCS_%s' % configname, prefix='-I') - - compilable = filter(Compilable, sources) - objs = map(self.Objectify, map(self.Absolutify, map(Target, compilable))) - self.WriteList(objs, 'OBJS') - - for obj in objs: - assert ' ' not in obj, ( - "Spaces in object filenames not supported (%s)" % obj) - self.WriteLn('# Add to the list of files we specially track ' - 'dependencies for.') - self.WriteLn('all_deps += $(OBJS)') - self._num_outputs += len(objs) - self.WriteLn() - - # Make sure our dependencies are built first. - if deps: - self.WriteMakeRule(['$(OBJS)'], deps, - comment = 'Make sure our dependencies are built ' - 'before any of us.', - order_only = True) - - # Make sure the actions and rules run first. - # If they generate any extra headers etc., the per-.o file dep tracking - # will catch the proper rebuilds, so order only is still ok here. - if extra_outputs: - self.WriteMakeRule(['$(OBJS)'], extra_outputs, - comment = 'Make sure our actions/rules run ' - 'before any of us.', - order_only = True) - - precompiled_header.WriteObjDependencies(compilable, objs, self) - - if objs: - extra_link_deps.append('$(OBJS)') - self.WriteLn("""\ -# CFLAGS et al overrides must be target-local. -# See "Target-specific Variable Values" in the GNU Make manual.""") - self.WriteLn("$(OBJS): TOOLSET := $(TOOLSET)") - self.WriteLn("$(OBJS): GYP_CFLAGS := " - "$(DEFS_$(BUILDTYPE)) " - "$(INCS_$(BUILDTYPE)) " - "%s" % precompiled_header.GetInclude('c') + - "$(CFLAGS_$(BUILDTYPE)) " - "$(CFLAGS_C_$(BUILDTYPE))") - self.WriteLn("$(OBJS): GYP_CXXFLAGS := " - "$(DEFS_$(BUILDTYPE)) " - "$(INCS_$(BUILDTYPE)) " - "%s" % precompiled_header.GetInclude('cc') + - "$(CFLAGS_$(BUILDTYPE)) " - "$(CFLAGS_CC_$(BUILDTYPE))") - if self.flavor == 'mac': - self.WriteLn("$(OBJS): GYP_OBJCFLAGS := " - "$(DEFS_$(BUILDTYPE)) " - "$(INCS_$(BUILDTYPE)) " - "%s" % precompiled_header.GetInclude('m') + - "$(CFLAGS_$(BUILDTYPE)) " - "$(CFLAGS_C_$(BUILDTYPE)) " - "$(CFLAGS_OBJC_$(BUILDTYPE))") - self.WriteLn("$(OBJS): GYP_OBJCXXFLAGS := " - "$(DEFS_$(BUILDTYPE)) " - "$(INCS_$(BUILDTYPE)) " - "%s" % precompiled_header.GetInclude('mm') + - "$(CFLAGS_$(BUILDTYPE)) " - "$(CFLAGS_CC_$(BUILDTYPE)) " - "$(CFLAGS_OBJCC_$(BUILDTYPE))") - - precompiled_header.WritePchTargets(self) - - # If there are any object files in our input file list, link them into our - # output. - extra_link_deps += filter(Linkable, sources) - - self.WriteLn() - - - def ComputeOutputBasename(self, spec): - """Return the 'output basename' of a gyp spec. - - E.g., the loadable module 'foobar' in directory 'baz' will produce - 'libfoobar.so' - """ - assert not self.is_mac_bundle - - if self.flavor == 'mac' and self.type in ( - 'static_library', 'executable', 'shared_library', 'loadable_module'): - return self.xcode_settings.GetExecutablePath() - - target = spec['target_name'] - target_prefix = '' - target_ext = '' - if self.type == 'static_library': - if target[:3] == 'lib': - target = target[3:] - target_prefix = 'lib' - target_ext = '.a' - elif self.type in ('loadable_module', 'shared_library'): - if target[:3] == 'lib': - target = target[3:] - target_prefix = 'lib' - target_ext = '.so' - elif self.type == 'none': - target = '%s.stamp' % target - elif self.type != 'executable': - print ("ERROR: What output file should be generated?", - "type", self.type, "target", target) - - target_prefix = spec.get('product_prefix', target_prefix) - target = spec.get('product_name', target) - product_ext = spec.get('product_extension') - if product_ext: - target_ext = '.' + product_ext - - return target_prefix + target + target_ext - - - def _InstallImmediately(self): - return self.toolset == 'target' and self.flavor == 'mac' and self.type in ( - 'static_library', 'executable', 'shared_library', 'loadable_module') - - - def ComputeOutput(self, spec): - """Return the 'output' (full output path) of a gyp spec. - - E.g., the loadable module 'foobar' in directory 'baz' will produce - '$(obj)/baz/libfoobar.so' - """ - assert not self.is_mac_bundle - - if self.type == 'settings': - return '' # Doesn't have any output. - - path = os.path.join('$(obj).' + self.toolset, self.path) - if self.type == 'executable' or self._InstallImmediately(): - path = '$(builddir)' - path = spec.get('product_dir', path) - return os.path.join(path, self.ComputeOutputBasename(spec)) - - - def ComputeMacBundleOutput(self, spec): - """Return the 'output' (full output path) to a bundle output directory.""" - assert self.is_mac_bundle - path = generator_default_variables['PRODUCT_DIR'] - return os.path.join(path, self.xcode_settings.GetWrapperName()) - - - def ComputeMacBundleBinaryOutput(self, spec): - """Return the 'output' (full output path) to the binary in a bundle.""" - path = generator_default_variables['PRODUCT_DIR'] - return os.path.join(path, self.xcode_settings.GetExecutablePath()) - - - def ComputeDeps(self, spec): - """Compute the dependencies of a gyp spec. - - Returns a tuple (deps, link_deps), where each is a list of - filenames that will need to be put in front of make for either - building (deps) or linking (link_deps). - """ - deps = [] - link_deps = [] - if 'dependencies' in spec: - deps.extend([target_outputs[dep] for dep in spec['dependencies'] - if target_outputs[dep]]) - for dep in spec['dependencies']: - if dep in target_link_deps: - link_deps.append(target_link_deps[dep]) - deps.extend(link_deps) - # TODO: It seems we need to transitively link in libraries (e.g. -lfoo)? - # This hack makes it work: - # link_deps.extend(spec.get('libraries', [])) - return (gyp.common.uniquer(deps), gyp.common.uniquer(link_deps)) - - - def WriteDependencyOnExtraOutputs(self, target, extra_outputs): - self.WriteMakeRule([self.output_binary], extra_outputs, - comment = 'Build our special outputs first.', - order_only = True) - - - def WriteTarget(self, spec, configs, deps, link_deps, bundle_deps, - extra_outputs, part_of_all): - """Write Makefile code to produce the final target of the gyp spec. - - spec, configs: input from gyp. - deps, link_deps: dependency lists; see ComputeDeps() - extra_outputs: any extra outputs that our target should depend on - part_of_all: flag indicating this target is part of 'all' - """ - - self.WriteLn('### Rules for final target.') - - if extra_outputs: - self.WriteDependencyOnExtraOutputs(self.output_binary, extra_outputs) - self.WriteMakeRule(extra_outputs, deps, - comment=('Preserve order dependency of ' - 'special output on deps.'), - order_only = True, - multiple_output_trick = False) - - if self.type not in ('settings', 'none'): - for configname in sorted(configs.keys()): - config = configs[configname] - if self.flavor == 'mac': - ldflags = self.xcode_settings.GetLdflags(self, configname) - else: - ldflags = config.get('ldflags', []) - # Compute an rpath for this output if needed. - if any(dep.endswith('.so') for dep in deps): - # We want to get the literal string "$ORIGIN" into the link command, - # so we need lots of escaping. - ldflags.append(r'-Wl,-rpath=\$$ORIGIN/lib.%s/' % self.toolset) - self.WriteList(ldflags, 'LDFLAGS_%s' % configname) - libraries = spec.get('libraries') - if libraries: - # Remove duplicate entries - libraries = gyp.common.uniquer(libraries) - # On Mac, framework libraries need to be passed as '-framework Cocoa'. - if self.flavor == 'mac': - libraries = [ - '-framework ' + os.path.splitext(os.path.basename(library))[0] - if library.endswith('.framework') else library - for library in libraries] - self.WriteList(libraries, 'LIBS') - self.WriteLn( - '%s: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))' % self.output_binary) - self.WriteLn('%s: LIBS := $(LIBS)' % self.output_binary) - - postbuilds = [] - if self.flavor == 'mac': - # Postbuild actions. Like actions, but implicitly depend on the target's - # output. - for postbuild in spec.get('postbuilds', []): - postbuilds.append('echo POSTBUILD\\(%s\\) %s' % ( - self.target, postbuild['postbuild_name'])) - shell_list = postbuild['action'] - # The first element is the command. If it's a relative path, it's - # a script in the source tree relative to the gyp file and needs to be - # absolutified. Else, it's in the PATH (e.g. install_name_tool, ln). - if os.path.sep in shell_list[0]: - shell_list[0] = self.Absolutify(shell_list[0]) - postbuilds.append('%s' % gyp.common.EncodePOSIXShellList(shell_list)) - - # A bundle directory depends on its dependencies such as bundle resources - # and bundle binary. When all dependencies have been built, the bundle - # needs to be packaged. - if self.is_mac_bundle: - self.WriteXcodeEnv(self.output, spec) # For postbuilds - - # If the framework doesn't contain a binary, then nothing depends - # on the actions -- make the framework depend on them directly too. - self.WriteDependencyOnExtraOutputs(self.output, extra_outputs) - - # Bundle dependencies. Note that the code below adds actions to this - # target, so if you move these two lines, move the lines below as well. - self.WriteList(bundle_deps, 'BUNDLE_DEPS') - self.WriteLn('%s: $(BUNDLE_DEPS)' % self.output) - - # After the framework is built, package it. Needs to happen before - # postbuilds, since postbuilds depend on this. - if self.type in ('shared_library', 'loadable_module'): - self.WriteLn('\t@$(call do_cmd,mac_package_framework,,,%s)' % - self.xcode_settings.GetFrameworkVersion()) - - # Bundle postbuilds can depend on the whole bundle, so run them after - # the bundle is packaged, not already after the bundle binary is done. - for postbuild in postbuilds: - self.WriteLn('\t@' + postbuild) - postbuilds = [] # Don't write postbuilds for target's output. - - # Needed by test/mac/gyptest-rebuild.py. - self.WriteLn('\t@true # No-op, used by tests') - - # Since this target depends on binary and resources which are in - # nested subfolders, the framework directory will be older than - # its dependencies usually. To prevent this rule from executing - # on every build (expensive, especially with postbuilds), expliclity - # update the time on the framework directory. - self.WriteLn('\t@touch -c %s' % self.output) - - if postbuilds: - assert not self.is_mac_bundle, ('Postbuilds for bundles should be done ' - 'on the bundle, not the binary (target \'%s\')' % self.target) - assert 'product_dir' not in spec, ('Postbuilds do not work with ' - 'custom product_dir') - self.WriteXcodeEnv(self.output_binary, spec) # For postbuilds - postbuilds = [EscapeShellArgument(p) for p in postbuilds] - self.WriteLn('%s: builddir := $(abs_builddir)' % self.output_binary) - self.WriteLn('%s: POSTBUILDS := %s' % ( - self.output_binary, ' '.join(postbuilds))) - - if self.type == 'executable': - self.WriteLn( - '%s: LD_INPUTS := %s' % (self.output_binary, ' '.join(link_deps))) - self.WriteDoCmd([self.output_binary], link_deps, 'link', part_of_all, - postbuilds=postbuilds) - elif self.type == 'static_library': - for link_dep in link_deps: - assert ' ' not in link_dep, ( - "Spaces in alink input filenames not supported (%s)" % link_dep) - self.WriteDoCmd([self.output_binary], link_deps, 'alink', part_of_all, - postbuilds=postbuilds) - elif self.type == 'shared_library': - self.WriteLn( - '%s: LD_INPUTS := %s' % (self.output_binary, ' '.join(link_deps))) - self.WriteDoCmd([self.output_binary], link_deps, 'solink', part_of_all, - postbuilds=postbuilds) - elif self.type == 'loadable_module': - for link_dep in link_deps: - assert ' ' not in link_dep, ( - "Spaces in module input filenames not supported (%s)" % link_dep) - self.WriteDoCmd( - [self.output_binary], link_deps, 'solink_module', part_of_all, - postbuilds=postbuilds) - elif self.type == 'none': - # Write a stamp line. - self.WriteDoCmd([self.output_binary], deps, 'touch', part_of_all, - postbuilds=postbuilds) - elif self.type == 'settings': - # Only used for passing flags around. - pass - else: - print "WARNING: no output for", self.type, target - - # Add an alias for each target (if there are any outputs). - # Installable target aliases are created below. - if ((self.output and self.output != self.target) and - (self.type not in self._INSTALLABLE_TARGETS)): - self.WriteMakeRule([self.target], [self.output], - comment='Add target alias', phony = True) - if part_of_all: - self.WriteMakeRule(['all'], [self.target], - comment = 'Add target alias to "all" target.', - phony = True) - - # Add special-case rules for our installable targets. - # 1) They need to install to the build dir or "product" dir. - # 2) They get shortcuts for building (e.g. "make chrome"). - # 3) They are part of "make all". - if self.type in self._INSTALLABLE_TARGETS: - if self.type == 'shared_library': - file_desc = 'shared library' - else: - file_desc = 'executable' - install_path = self._InstallableTargetInstallPath() - installable_deps = [self.output] - if self.flavor == 'mac' and not 'product_dir' in spec: - # On mac, products are created in install_path immediately. - assert install_path == self.output, '%s != %s' % ( - install_path, self.output) - - # Point the target alias to the final binary output. - self.WriteMakeRule([self.target], [install_path], - comment='Add target alias', phony = True) - if install_path != self.output: - assert not self.is_mac_bundle # See comment a few lines above. - self.WriteDoCmd([install_path], [self.output], 'copy', - comment = 'Copy this to the %s output path.' % - file_desc, part_of_all=part_of_all) - installable_deps.append(install_path) - if self.output != self.alias and self.alias != self.target: - self.WriteMakeRule([self.alias], installable_deps, - comment = 'Short alias for building this %s.' % - file_desc, phony = True) - if part_of_all: - self.WriteMakeRule(['all'], [install_path], - comment = 'Add %s to "all" target.' % file_desc, - phony = True) - - - def WriteList(self, list, variable=None, prefix='', quoter=QuoteIfNecessary): - """Write a variable definition that is a list of values. - - E.g. WriteList(['a','b'], 'foo', prefix='blah') writes out - foo = blaha blahb - but in a pretty-printed style. - """ - self.fp.write(variable + " := ") - if list: - list = [quoter(prefix + l) for l in list] - self.fp.write(" \\\n\t".join(list)) - self.fp.write("\n\n") - - - def WriteDoCmd(self, outputs, inputs, command, part_of_all, comment=None, - postbuilds=False): - """Write a Makefile rule that uses do_cmd. - - This makes the outputs dependent on the command line that was run, - as well as support the V= make command line flag. - """ - suffix = '' - if postbuilds: - assert ',' not in command - suffix = ',,1' # Tell do_cmd to honor $POSTBUILDS - self.WriteMakeRule(outputs, inputs, - actions = ['$(call do_cmd,%s%s)' % (command, suffix)], - comment = comment, - force = True) - # Add our outputs to the list of targets we read depfiles from. - # all_deps is only used for deps file reading, and for deps files we replace - # spaces with ? because escaping doesn't work with make's $(sort) and - # other functions. - outputs = [ReplaceQuotedSpaces(o) for o in outputs] - self.WriteLn('all_deps += %s' % ' '.join(outputs)) - self._num_outputs += len(outputs) - - - def WriteMakeRule(self, outputs, inputs, actions=None, comment=None, - order_only=False, force=False, phony=False, - multiple_output_trick=True): - """Write a Makefile rule, with some extra tricks. - - outputs: a list of outputs for the rule (note: this is not directly - supported by make; see comments below) - inputs: a list of inputs for the rule - actions: a list of shell commands to run for the rule - comment: a comment to put in the Makefile above the rule (also useful - for making this Python script's code self-documenting) - order_only: if true, makes the dependency order-only - force: if true, include FORCE_DO_CMD as an order-only dep - phony: if true, the rule does not actually generate the named output, the - output is just a name to run the rule - multiple_output_trick: if true (the default), perform tricks such as dummy - rules to avoid problems with multiple outputs. - """ - if comment: - self.WriteLn('# ' + comment) - if phony: - self.WriteLn('.PHONY: ' + ' '.join(outputs)) - # TODO(evanm): just make order_only a list of deps instead of these hacks. - if order_only: - order_insert = '| ' - else: - order_insert = '' - if force: - force_append = ' FORCE_DO_CMD' - else: - force_append = '' - if actions: - self.WriteLn("%s: TOOLSET := $(TOOLSET)" % outputs[0]) - self.WriteLn('%s: %s%s%s' % (outputs[0], order_insert, ' '.join(inputs), - force_append)) - if actions: - for action in actions: - self.WriteLn('\t%s' % action) - if multiple_output_trick and len(outputs) > 1: - # If we have more than one output, a rule like - # foo bar: baz - # that for *each* output we must run the action, potentially - # in parallel. That is not what we're trying to write -- what - # we want is that we run the action once and it generates all - # the files. - # http://www.gnu.org/software/hello/manual/automake/Multiple-Outputs.html - # discusses this problem and has this solution: - # 1) Write the naive rule that would produce parallel runs of - # the action. - # 2) Make the outputs seralized on each other, so we won't start - # a parallel run until the first run finishes, at which point - # we'll have generated all the outputs and we're done. - self.WriteLn('%s: %s' % (' '.join(outputs[1:]), outputs[0])) - # Add a dummy command to the "extra outputs" rule, otherwise make seems to - # think these outputs haven't (couldn't have?) changed, and thus doesn't - # flag them as changed (i.e. include in '$?') when evaluating dependent - # rules, which in turn causes do_cmd() to skip running dependent commands. - self.WriteLn('%s: ;' % (' '.join(outputs[1:]))) - self.WriteLn() - - - def WriteAndroidNdkModuleRule(self, module_name, all_sources, link_deps): - """Write a set of LOCAL_XXX definitions for Android NDK. - - These variable definitions will be used by Android NDK but do nothing for - non-Android applications. - - Arguments: - module_name: Android NDK module name, which must be unique among all - module names. - all_sources: A list of source files (will be filtered by Compilable). - link_deps: A list of link dependencies, which must be sorted in - the order from dependencies to dependents. - """ - if self.type not in ('executable', 'shared_library', 'static_library'): - return - - self.WriteLn('# Variable definitions for Android applications') - self.WriteLn('include $(CLEAR_VARS)') - self.WriteLn('LOCAL_MODULE := ' + module_name) - self.WriteLn('LOCAL_CFLAGS := $(CFLAGS_$(BUILDTYPE)) ' - '$(DEFS_$(BUILDTYPE)) ' - # LOCAL_CFLAGS is applied to both of C and C++. There is - # no way to specify $(CFLAGS_C_$(BUILDTYPE)) only for C - # sources. - '$(CFLAGS_C_$(BUILDTYPE)) ' - # $(INCS_$(BUILDTYPE)) includes the prefix '-I' while - # LOCAL_C_INCLUDES does not expect it. So put it in - # LOCAL_CFLAGS. - '$(INCS_$(BUILDTYPE))') - # LOCAL_CXXFLAGS is obsolete and LOCAL_CPPFLAGS is preferred. - self.WriteLn('LOCAL_CPPFLAGS := $(CFLAGS_CC_$(BUILDTYPE))') - self.WriteLn('LOCAL_C_INCLUDES :=') - self.WriteLn('LOCAL_LDLIBS := $(LDFLAGS_$(BUILDTYPE)) $(LIBS)') - - # Detect the C++ extension. - cpp_ext = {'.cc': 0, '.cpp': 0, '.cxx': 0} - default_cpp_ext = '.cpp' - for filename in all_sources: - ext = os.path.splitext(filename)[1] - if ext in cpp_ext: - cpp_ext[ext] += 1 - if cpp_ext[ext] > cpp_ext[default_cpp_ext]: - default_cpp_ext = ext - self.WriteLn('LOCAL_CPP_EXTENSION := ' + default_cpp_ext) - - self.WriteList(map(self.Absolutify, filter(Compilable, all_sources)), - 'LOCAL_SRC_FILES') - - # Filter out those which do not match prefix and suffix and produce - # the resulting list without prefix and suffix. - def DepsToModules(deps, prefix, suffix): - modules = [] - for filepath in deps: - filename = os.path.basename(filepath) - if filename.startswith(prefix) and filename.endswith(suffix): - modules.append(filename[len(prefix):-len(suffix)]) - return modules - - # Retrieve the default value of 'SHARED_LIB_SUFFIX' - params = {'flavor': 'linux'} - default_variables = {} - CalculateVariables(default_variables, params) - - self.WriteList( - DepsToModules(link_deps, - generator_default_variables['SHARED_LIB_PREFIX'], - default_variables['SHARED_LIB_SUFFIX']), - 'LOCAL_SHARED_LIBRARIES') - self.WriteList( - DepsToModules(link_deps, - generator_default_variables['STATIC_LIB_PREFIX'], - generator_default_variables['STATIC_LIB_SUFFIX']), - 'LOCAL_STATIC_LIBRARIES') - - if self.type == 'executable': - self.WriteLn('include $(BUILD_EXECUTABLE)') - elif self.type == 'shared_library': - self.WriteLn('include $(BUILD_SHARED_LIBRARY)') - elif self.type == 'static_library': - self.WriteLn('include $(BUILD_STATIC_LIBRARY)') - self.WriteLn() - - - def WriteLn(self, text=''): - self.fp.write(text + '\n') - - - def GetXcodeEnv(self, spec, target_relative_path=False): - """Return the environment variables that Xcode would set. See - http://developer.apple.com/library/mac/#documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW153 - for a full list.""" - if self.flavor != 'mac': return {} - - built_products_dir = generator_default_variables['PRODUCT_DIR'] - def StripProductDir(s): - assert s.startswith(built_products_dir), s - return s[len(built_products_dir) + 1:] - - product_name = spec.get('product_name', self.output) - - if self._InstallImmediately(): - if product_name.startswith(built_products_dir): - product_name = StripProductDir(product_name) - - srcroot = self.path - if target_relative_path: - built_products_dir = os.path.relpath(built_products_dir, srcroot) - srcroot = '.' - # These are filled in on a as-needed basis. - env = { - 'BUILT_PRODUCTS_DIR' : built_products_dir, - 'CONFIGURATION' : '$(BUILDTYPE)', - 'PRODUCT_NAME' : product_name, - # See /Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications/MacOSX\ Product\ Types.xcspec for FULL_PRODUCT_NAME - 'FULL_PRODUCT_NAME' : product_name, - 'SRCROOT' : srcroot, - # This is not true for static libraries, but currently the env is only - # written for bundles: - 'TARGET_BUILD_DIR' : built_products_dir, - 'TEMP_DIR' : '$(TMPDIR)', - } - if self.type in ('executable', 'shared_library'): - env['EXECUTABLE_NAME'] = os.path.basename(self.output_binary) - if self.type in ( - 'executable', 'static_library', 'shared_library', 'loadable_module'): - env['EXECUTABLE_PATH'] = self.xcode_settings.GetExecutablePath() - if self.is_mac_bundle: - env['CONTENTS_FOLDER_PATH'] = \ - self.xcode_settings.GetBundleContentsFolderPath() - env['UNLOCALIZED_RESOURCES_FOLDER_PATH'] = \ - self.xcode_settings.GetBundleResourceFolder() - env['INFOPLIST_PATH'] = self.xcode_settings.GetBundlePlistPath() - - # TODO(thakis): Remove this. - env['EXECUTABLE_PATH'] = QuoteSpaces(env['EXECUTABLE_PATH']) - env['CONTENTS_FOLDER_PATH'] = QuoteSpaces(env['CONTENTS_FOLDER_PATH']) - env['INFOPLIST_PATH'] = QuoteSpaces(env['INFOPLIST_PATH']) - - return env - - - def WriteXcodeEnv(self, - target, - spec, - target_relative_path=False, - additional_settings={}): - env = additional_settings - env.update(self.GetXcodeEnv(spec, target_relative_path)) - - # Keys whose values will not have $(builddir) replaced with $(abs_builddir). - # These have special substitution rules in some cases; see above in - # GetXcodeEnv() for the full rationale. - keys_to_not_absolutify = ('PRODUCT_NAME', 'FULL_PRODUCT_NAME') - - # Perform some transformations that are required to mimic Xcode behavior. - for k in env: - # Values that are not strings but are, for example, lists or tuples such - # as LDFLAGS or CFLAGS, should not be written out because they are - # not needed and it's undefined how multi-valued keys should be written. - if not isinstance(env[k], str): - continue - - # For - # foo := a\ b - # the escaped space does the right thing. For - # export foo := a\ b - # it does not -- the backslash is written to the env as literal character. - # Hence, unescape all spaces here. - v = env[k].replace(r'\ ', ' ') - - # Xcode works purely with absolute paths. When writing env variables to - # mimic its usage, replace $(builddir) with $(abs_builddir). - if k not in keys_to_not_absolutify: - v = v.replace('$(builddir)', '$(abs_builddir)') - - self.WriteLn('%s: export %s := %s' % (target, k, v)) - - - def Objectify(self, path): - """Convert a path to its output directory form.""" - if '$(' in path: - path = path.replace('$(obj)/', '$(obj).%s/$(TARGET)/' % self.toolset) - return path - return '$(obj).%s/$(TARGET)/%s' % (self.toolset, path) - - - def Pchify(self, path, lang): - """Convert a prefix header path to its output directory form.""" - if '$(' in path: - path = path.replace('$(obj)/', '$(obj).%s/$(TARGET)/pch-%s' % - (self.toolset, lang)) - return path - return '$(obj).%s/$(TARGET)/pch-%s/%s' % (self.toolset, lang, path) - - - def Absolutify(self, path): - """Convert a subdirectory-relative path into a base-relative path. - Skips over paths that contain variables.""" - if '$(' in path: - return path - return os.path.normpath(os.path.join(self.path, path)) - - - def FixupArgPath(self, arg): - if '/' in arg or '.h.' in arg: - return self.Absolutify(arg) - return arg - - - def ExpandInputRoot(self, template, expansion): - if '%(INPUT_ROOT)s' not in template: - return template - path = template % { 'INPUT_ROOT': expansion } - if not os.path.dirname(path): - # If it's just the file name, turn it into a path so FixupArgPath() - # will know to Absolutify() it. - path = os.path.join('.', path) - return path - - - def _InstallableTargetInstallPath(self): - """Returns the location of the final output for an installable target.""" - # Xcode puts shared_library results into PRODUCT_DIR, and some gyp files - # rely on this. Emulate this behavior for mac. - if self.type == 'shared_library' and self.flavor != 'mac': - # Install all shared libs into a common directory (per toolset) for - # convenient access with LD_LIBRARY_PATH. - return '$(builddir)/lib.%s/%s' % (self.toolset, self.alias) - return '$(builddir)/' + self.alias - - -def WriteAutoRegenerationRule(params, root_makefile, makefile_name, - build_files): - """Write the target to regenerate the Makefile.""" - options = params['options'] - build_files_args = [gyp.common.RelativePath(filename, options.toplevel_dir) - for filename in params['build_files_arg']] - gyp_binary = gyp.common.FixIfRelativePath(params['gyp_binary'], - options.toplevel_dir) - if not gyp_binary.startswith(os.sep): - gyp_binary = os.path.join('.', gyp_binary) - root_makefile.write( - "quiet_cmd_regen_makefile = ACTION Regenerating $@\n" - "cmd_regen_makefile = %(cmd)s\n" - "%(makefile_name)s: %(deps)s\n" - "\t$(call do_cmd,regen_makefile)\n\n" % { - 'makefile_name': makefile_name, - 'deps': ' '.join(map(Sourceify, build_files)), - 'cmd': gyp.common.EncodePOSIXShellList( - [gyp_binary, '-fmake'] + - gyp.RegenerateFlags(options) + - build_files_args)}) - - -def RunSystemTests(flavor): - """Run tests against the system to compute default settings for commands. - - Returns: - dictionary of settings matching the block of command-lines used in - SHARED_HEADER. E.g. the dictionary will contain a ARFLAGS.target - key for the default ARFLAGS for the target ar command. - """ - # Compute flags used for building static archives. - # N.B.: this fallback logic should match the logic in SHARED_HEADER. - # See comment there for more details. - ar_target = os.environ.get('AR.target', os.environ.get('AR', 'ar')) - cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) - arflags_target = 'crs' - # ar -T enables thin archives on Linux. OS X's ar supports a -T flag, but it - # does something useless (it limits filenames in the archive to 15 chars). - if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_target, - cc_command=cc_target): - arflags_target = 'crsT' - - ar_host = os.environ.get('AR.host', 'ar') - cc_host = os.environ.get('CC.host', 'gcc') - arflags_host = 'crs' - # It feels redundant to compute this again given that most builds aren't - # cross-compiles, but due to quirks of history CC.host defaults to 'gcc' - # while CC.target defaults to 'cc', so the commands really are different - # even though they're nearly guaranteed to run the same code underneath. - if flavor != 'mac' and gyp.system_test.TestArSupportsT(ar_command=ar_host, - cc_command=cc_host): - arflags_host = 'crsT' - - link_flags = '' - if gyp.system_test.TestLinkerSupportsThreads(cc_command=cc_target): - # N.B. we don't test for cross-compilation; as currently written, we - # don't even use flock when linking in the cross-compile setup! - # TODO(evan): refactor cross-compilation such that this code can - # be reused. - link_flags = '-Wl,--threads -Wl,--thread-count=4' - - # TODO(evan): cache this output. (But then we'll need to add extra - # flags to gyp to flush the cache, yuk! It's fast enough for now to - # just run it every time.) - - return { 'ARFLAGS.target': arflags_target, - 'ARFLAGS.host': arflags_host, - 'LINK_flags': link_flags } - - -def CopyMacTool(out_path): - """Finds mac_tool.gyp in the gyp directory and copies it to |out_path|.""" - source_path = os.path.join( - os.path.dirname(os.path.abspath(__file__)), '..', 'mac_tool.py') - source_file = open(source_path) - source = source_file.readlines() - source_file.close() - mactool_file = open(out_path, 'w') - mactool_file.write( - ''.join([source[0], '# Generated by gyp. Do not edit.\n'] + source[1:])) - mactool_file.close() - - -def GenerateOutput(target_list, target_dicts, data, params): - options = params['options'] - flavor = GetFlavor(params) - generator_flags = params.get('generator_flags', {}) - builddir_name = generator_flags.get('output_dir', 'out') - android_ndk_version = generator_flags.get('android_ndk_version', None) - - def CalculateMakefilePath(build_file, base_name): - """Determine where to write a Makefile for a given gyp file.""" - # Paths in gyp files are relative to the .gyp file, but we want - # paths relative to the source root for the master makefile. Grab - # the path of the .gyp file as the base to relativize against. - # E.g. "foo/bar" when we're constructing targets for "foo/bar/baz.gyp". - base_path = gyp.common.RelativePath(os.path.dirname(build_file), - options.depth) - # We write the file in the base_path directory. - output_file = os.path.join(options.depth, base_path, base_name) - if options.generator_output: - output_file = os.path.join(options.generator_output, output_file) - base_path = gyp.common.RelativePath(os.path.dirname(build_file), - options.toplevel_dir) - return base_path, output_file - - # TODO: search for the first non-'Default' target. This can go - # away when we add verification that all targets have the - # necessary configurations. - default_configuration = None - toolsets = set([target_dicts[target]['toolset'] for target in target_list]) - for target in target_list: - spec = target_dicts[target] - if spec['default_configuration'] != 'Default': - default_configuration = spec['default_configuration'] - break - if not default_configuration: - default_configuration = 'Default' - - srcdir = '.' - makefile_name = 'Makefile' + options.suffix - makefile_path = os.path.join(options.toplevel_dir, makefile_name) - if options.generator_output: - global srcdir_prefix - makefile_path = os.path.join(options.generator_output, makefile_path) - srcdir = gyp.common.RelativePath(srcdir, options.generator_output) - srcdir_prefix = '$(srcdir)/' - - header_params = { - 'builddir': builddir_name, - 'default_configuration': default_configuration, - 'flock': 'flock', - 'flock_index': 1, - 'link_commands': LINK_COMMANDS_LINUX, - 'mac_commands': '', - 'srcdir': srcdir, - } - if flavor == 'mac': - header_params.update({ - 'flock': './gyp-mac-tool flock', - 'flock_index': 2, - 'link_commands': LINK_COMMANDS_MAC, - 'mac_commands': SHARED_HEADER_MAC_COMMANDS, - }) - header_params.update(RunSystemTests(flavor)) - - build_file, _, _ = gyp.common.ParseQualifiedTarget(target_list[0]) - make_global_settings_dict = data[build_file].get('make_global_settings', {}) - make_global_settings = '' - for key, value in make_global_settings_dict: - if value[0] != '$': - value = '$(abspath %s)' % value - if key == 'LINK': - make_global_settings += '%s ?= $(FLOCK) %s\n' % (key, value) - elif key in ['CC', 'CXX']: - make_global_settings += ( - 'ifneq (,$(filter $(origin %s), undefined default))\n' % key) - # Let gyp-time envvars win over global settings. - if key in os.environ: - value = os.environ[key] - make_global_settings += ' %s = %s\n' % (key, value) - make_global_settings += 'endif\n' - else: - make_global_settings += '%s ?= %s\n' % (key, value) - header_params['make_global_settings'] = make_global_settings - - ensure_directory_exists(makefile_path) - root_makefile = open(makefile_path, 'w') - root_makefile.write(SHARED_HEADER % header_params) - # Currently any versions have the same effect, but in future the behavior - # could be different. - if android_ndk_version: - root_makefile.write( - '# Define LOCAL_PATH for build of Android applications.\n' - 'LOCAL_PATH := $(call my-dir)\n' - '\n') - for toolset in toolsets: - root_makefile.write('TOOLSET := %s\n' % toolset) - WriteRootHeaderSuffixRules(root_makefile) - - # Put mac_tool next to the root Makefile. - if flavor == 'mac': - mactool_path = os.path.join(os.path.dirname(makefile_path), 'gyp-mac-tool') - if os.path.exists(mactool_path): - os.remove(mactool_path) - CopyMacTool(mactool_path) - os.chmod(mactool_path, 0o755) # Make file executable. - - # Find the list of targets that derive from the gyp file(s) being built. - needed_targets = set() - for build_file in params['build_files']: - for target in gyp.common.AllTargets(target_list, target_dicts, build_file): - needed_targets.add(target) - - num_outputs = 0 - build_files = set() - include_list = set() - for qualified_target in target_list: - build_file, target, toolset = gyp.common.ParseQualifiedTarget( - qualified_target) - - this_make_global_settings = data[build_file].get('make_global_settings', {}) - assert make_global_settings_dict == this_make_global_settings, ( - "make_global_settings needs to be the same for all targets.") - - build_files.add(gyp.common.RelativePath(build_file, options.toplevel_dir)) - included_files = data[build_file]['included_files'] - for included_file in included_files: - # The included_files entries are relative to the dir of the build file - # that included them, so we have to undo that and then make them relative - # to the root dir. - relative_include_file = gyp.common.RelativePath( - gyp.common.UnrelativePath(included_file, build_file), - options.toplevel_dir) - abs_include_file = os.path.abspath(relative_include_file) - # If the include file is from the ~/.gyp dir, we should use absolute path - # so that relocating the src dir doesn't break the path. - if (params['home_dot_gyp'] and - abs_include_file.startswith(params['home_dot_gyp'])): - build_files.add(abs_include_file) - else: - build_files.add(relative_include_file) - - base_path, output_file = CalculateMakefilePath(build_file, - target + '.' + toolset + options.suffix + '.mk') - - spec = target_dicts[qualified_target] - configs = spec['configurations'] - - # The xcode generator special-cases global xcode_settings and does something - # that amounts to merging in the global xcode_settings into each local - # xcode_settings dict. - if flavor == 'mac': - global_xcode_settings = data[build_file].get('xcode_settings', {}) - for configname in configs.keys(): - config = configs[configname] - if 'xcode_settings' in config: - new_settings = global_xcode_settings.copy() - new_settings.update(config['xcode_settings']) - config['xcode_settings'] = new_settings - - writer = MakefileWriter(generator_flags, flavor) - writer.Write(qualified_target, base_path, output_file, spec, configs, - part_of_all=qualified_target in needed_targets) - num_outputs += writer.NumOutputs() - - # Our root_makefile lives at the source root. Compute the relative path - # from there to the output_file for including. - mkfile_rel_path = gyp.common.RelativePath(output_file, - os.path.dirname(makefile_path)) - include_list.add(mkfile_rel_path) - - # Write out per-gyp (sub-project) Makefiles. - depth_rel_path = gyp.common.RelativePath(options.depth, os.getcwd()) - for build_file in build_files: - # The paths in build_files were relativized above, so undo that before - # testing against the non-relativized items in target_list and before - # calculating the Makefile path. - build_file = os.path.join(depth_rel_path, build_file) - gyp_targets = [target_dicts[target]['target_name'] for target in target_list - if target.startswith(build_file) and - target in needed_targets] - # Only generate Makefiles for gyp files with targets. - if not gyp_targets: - continue - base_path, output_file = CalculateMakefilePath(build_file, - os.path.splitext(os.path.basename(build_file))[0] + '.Makefile') - makefile_rel_path = gyp.common.RelativePath(os.path.dirname(makefile_path), - os.path.dirname(output_file)) - writer.WriteSubMake(output_file, makefile_rel_path, gyp_targets, - builddir_name) - - - # Write out the sorted list of includes. - root_makefile.write('\n') - for include_file in sorted(include_list): - # We wrap each .mk include in an if statement so users can tell make to - # not load a file by setting NO_LOAD. The below make code says, only - # load the .mk file if the .mk filename doesn't start with a token in - # NO_LOAD. - root_makefile.write( - "ifeq ($(strip $(foreach prefix,$(NO_LOAD),\\\n" - " $(findstring $(join ^,$(prefix)),\\\n" - " $(join ^," + include_file + ")))),)\n") - root_makefile.write(" include " + include_file + "\n") - root_makefile.write("endif\n") - root_makefile.write('\n') - - if generator_flags.get('auto_regeneration', True): - WriteAutoRegenerationRule(params, root_makefile, makefile_name, build_files) - - # Write the rule to load dependencies. We batch 1000 files at a time to - # avoid overflowing the command line. - all_deps = "" - for i in range(1001, num_outputs, 1000): - all_deps += (""" - ifneq ($(word %(start)d,$(d_files)),) - $(shell cat $(wordlist %(start)d,%(end)d,$(d_files)) >> $(depsdir)/all.deps) - endif""" % { 'start': i, 'end': i + 999 }) - - # Add a check to make sure we tried to process all the .d files. - all_deps += """ - ifneq ($(word %(last)d,$(d_files)),) - $(error Found unprocessed dependency files (gyp didn't generate enough rules!)) - endif -""" % { 'last': ((num_outputs / 1000) + 1) * 1000 + 1 } - - root_makefile.write(SHARED_FOOTER % { 'generate_all_deps': all_deps }) - - root_makefile.close() diff --git a/third_party/gyp/pylib/gyp/generator/msvs.py b/third_party/gyp/pylib/gyp/generator/msvs.py deleted file mode 100644 index dfecbda..0000000 --- a/third_party/gyp/pylib/gyp/generator/msvs.py +++ /dev/null @@ -1,2876 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import copy -import ntpath -import os -import posixpath -import re -import subprocess -import sys - -import gyp.common -import gyp.easy_xml as easy_xml -import gyp.MSVSNew as MSVSNew -import gyp.MSVSProject as MSVSProject -import gyp.MSVSSettings as MSVSSettings -import gyp.MSVSToolFile as MSVSToolFile -import gyp.MSVSUserFile as MSVSUserFile -import gyp.MSVSVersion as MSVSVersion - - -# Regular expression for validating Visual Studio GUIDs. If the GUID -# contains lowercase hex letters, MSVS will be fine. However, -# IncrediBuild BuildConsole will parse the solution file, but then -# silently skip building the target causing hard to track down errors. -# Note that this only happens with the BuildConsole, and does not occur -# if IncrediBuild is executed from inside Visual Studio. This regex -# validates that the string looks like a GUID with all uppercase hex -# letters. -VALID_MSVS_GUID_CHARS = re.compile('^[A-F0-9\-]+$') - - -generator_default_variables = { - 'EXECUTABLE_PREFIX': '', - 'EXECUTABLE_SUFFIX': '.exe', - 'STATIC_LIB_PREFIX': '', - 'SHARED_LIB_PREFIX': '', - 'STATIC_LIB_SUFFIX': '.lib', - 'SHARED_LIB_SUFFIX': '.dll', - 'INTERMEDIATE_DIR': '$(IntDir)', - 'SHARED_INTERMEDIATE_DIR': '$(OutDir)/obj/global_intermediate', - 'OS': 'win', - 'PRODUCT_DIR': '$(OutDir)', - - # TODO(jeanluc) The way we currently generate libraries makes Visual - # Studio 2010 unhappy. We get a lot of warnings like: - # warning MSB8012: TargetPath(...\Debug\gles2_c_lib.lib) does not match - # the Library's OutputFile property value (...\Debug\lib\gles2_c_lib.lib). - # This may cause your project to build incorrectly. To correct this, - # please make sure that $(OutDir), $(TargetName) and $(TargetExt) property - # values match the value specified in %(Lib.OutputFile). - # Despite the warnings, this compile correctly. It would be nice to get rid - # of the warnings. - - # TODO(jeanluc) I had: 'LIB_DIR': '$(OutDir)lib', - 'LIB_DIR': '$(OutDir)/lib', - 'RULE_INPUT_ROOT': '$(InputName)', - 'RULE_INPUT_EXT': '$(InputExt)', - 'RULE_INPUT_NAME': '$(InputFileName)', - 'RULE_INPUT_PATH': '$(InputPath)', - 'CONFIGURATION_NAME': '$(ConfigurationName)', -} - - -# The msvs specific sections that hold paths -generator_additional_path_sections = [ - 'msvs_cygwin_dirs', - 'msvs_props', -] - - -generator_additional_non_configuration_keys = [ - 'msvs_cygwin_dirs', - 'msvs_cygwin_shell', - 'msvs_shard', -] - - -# List of precompiled header related keys. -precomp_keys = [ - 'msvs_precompiled_header', - 'msvs_precompiled_source', -] - - -cached_username = None - - -cached_domain = None - - -# TODO(gspencer): Switch the os.environ calls to be -# win32api.GetDomainName() and win32api.GetUserName() once the -# python version in depot_tools has been updated to work on Vista -# 64-bit. -def _GetDomainAndUserName(): - if sys.platform not in ('win32', 'cygwin'): - return ('DOMAIN', 'USERNAME') - global cached_username - global cached_domain - if not cached_domain or not cached_username: - domain = os.environ.get('USERDOMAIN') - username = os.environ.get('USERNAME') - if not domain or not username: - call = subprocess.Popen(['net', 'config', 'Workstation'], - stdout=subprocess.PIPE) - config = call.communicate()[0] - username_re = re.compile('^User name\s+(\S+)', re.MULTILINE) - username_match = username_re.search(config) - if username_match: - username = username_match.group(1) - domain_re = re.compile('^Logon domain\s+(\S+)', re.MULTILINE) - domain_match = domain_re.search(config) - if domain_match: - domain = domain_match.group(1) - cached_domain = domain - cached_username = username - return (cached_domain, cached_username) - -fixpath_prefix = None - - -def _NormalizedSource(source): - """Normalize the path. - - But not if that gets rid of a variable, as this may expand to something - larger than one directory. - - Arguments: - source: The path to be normalize.d - - Returns: - The normalized path. - """ - normalized = os.path.normpath(source) - if source.count('$') == normalized.count('$'): - source = normalized - return source - - -def _FixPath(path): - """Convert paths to a form that will make sense in a vcproj file. - - Arguments: - path: The path to convert, may contain / etc. - Returns: - The path with all slashes made into backslashes. - """ - if fixpath_prefix and path and not os.path.isabs(path) and not path[0] == '$': - path = os.path.join(fixpath_prefix, path) - path = path.replace('/', '\\') - path = _NormalizedSource(path) - if path and path[-1] == '\\': - path = path[:-1] - return path - - -def _FixPaths(paths): - """Fix each of the paths of the list.""" - return [_FixPath(i) for i in paths] - - -def _ConvertSourcesToFilterHierarchy(sources, prefix=None, excluded=None): - """Converts a list split source file paths into a vcproj folder hierarchy. - - Arguments: - sources: A list of source file paths split. - prefix: A list of source file path layers meant to apply to each of sources. - excluded: A set of excluded files. - - Returns: - A hierarchy of filenames and MSVSProject.Filter objects that matches the - layout of the source tree. - For example: - _ConvertSourcesToFilterHierarchy([['a', 'bob1.c'], ['b', 'bob2.c']], - prefix=['joe']) - --> - [MSVSProject.Filter('a', contents=['joe\\a\\bob1.c']), - MSVSProject.Filter('b', contents=['joe\\b\\bob2.c'])] - """ - if not prefix: prefix = [] - result = [] - excluded_result = [] - folders = dict() - # Gather files into the final result, excluded, or folders. - for s in sources: - if len(s) == 1: - filename = _NormalizedSource('\\'.join(prefix + s)) - if filename in excluded: - excluded_result.append(filename) - else: - result.append(filename) - else: - if not folders.get(s[0]): - folders[s[0]] = [] - folders[s[0]].append(s[1:]) - # Add a folder for excluded files. - if excluded_result: - excluded_folder = MSVSProject.Filter('_excluded_files', - contents=excluded_result) - result.append(excluded_folder) - # Populate all the folders. - for f in folders: - contents = _ConvertSourcesToFilterHierarchy(folders[f], prefix=prefix + [f], - excluded=excluded) - contents = MSVSProject.Filter(f, contents=contents) - result.append(contents) - - return result - - -def _ToolAppend(tools, tool_name, setting, value, only_if_unset=False): - if not value: return - # TODO(bradnelson): ugly hack, fix this more generally!!! - if 'Directories' in setting or 'Dependencies' in setting: - if type(value) == str: - value = value.replace('/', '\\') - else: - value = [i.replace('/', '\\') for i in value] - if not tools.get(tool_name): - tools[tool_name] = dict() - tool = tools[tool_name] - if tool.get(setting): - if only_if_unset: return - if type(tool[setting]) == list: - tool[setting] += value - else: - raise TypeError( - 'Appending "%s" to a non-list setting "%s" for tool "%s" is ' - 'not allowed, previous value: %s' % ( - value, setting, tool_name, str(tool[setting]))) - else: - tool[setting] = value - - -def _ConfigPlatform(config_data): - return config_data.get('msvs_configuration_platform', 'Win32') - - -def _ConfigBaseName(config_name, platform_name): - if config_name.endswith('_' + platform_name): - return config_name[0:-len(platform_name)-1] - else: - return config_name - - -def _ConfigFullName(config_name, config_data): - platform_name = _ConfigPlatform(config_data) - return '%s|%s' % (_ConfigBaseName(config_name, platform_name), platform_name) - - -def _BuildCommandLineForRuleRaw(spec, cmd, cygwin_shell, has_input_path, - quote_cmd): - if cygwin_shell: - # Find path to cygwin. - cygwin_dir = _FixPath(spec.get('msvs_cygwin_dirs', ['.'])[0]) - # Prepare command. - direct_cmd = cmd - direct_cmd = [i.replace('$(IntDir)', - '`cygpath -m "${INTDIR}"`') for i in direct_cmd] - direct_cmd = [i.replace('$(OutDir)', - '`cygpath -m "${OUTDIR}"`') for i in direct_cmd] - if has_input_path: - direct_cmd = [i.replace('$(InputPath)', - '`cygpath -m "${INPUTPATH}"`') - for i in direct_cmd] - direct_cmd = ['"%s"' % i for i in direct_cmd] - direct_cmd = [i.replace('"', '\\"') for i in direct_cmd] - #direct_cmd = gyp.common.EncodePOSIXShellList(direct_cmd) - direct_cmd = ' '.join(direct_cmd) - # TODO(quote): regularize quoting path names throughout the module - cmd = ( - 'call "$(ProjectDir)%(cygwin_dir)s\\setup_env.bat" && ' - 'set CYGWIN=nontsec&& ') - if direct_cmd.find('NUMBER_OF_PROCESSORS') >= 0: - cmd += 'set /a NUMBER_OF_PROCESSORS_PLUS_1=%%NUMBER_OF_PROCESSORS%%+1&& ' - if direct_cmd.find('INTDIR') >= 0: - cmd += 'set INTDIR=$(IntDir)&& ' - if direct_cmd.find('OUTDIR') >= 0: - cmd += 'set OUTDIR=$(OutDir)&& ' - if has_input_path and direct_cmd.find('INPUTPATH') >= 0: - cmd += 'set INPUTPATH=$(InputPath) && ' - cmd += 'bash -c "%(cmd)s"' - cmd = cmd % {'cygwin_dir': cygwin_dir, - 'cmd': direct_cmd} - return cmd - else: - # Convert cat --> type to mimic unix. - if cmd[0] == 'cat': - command = ['type'] - else: - command = [cmd[0].replace('/', '\\')] - # Fix the paths - # If the argument starts with a slash, it's probably a command line switch - arguments = [i.startswith('/') and i or _FixPath(i) for i in cmd[1:]] - if quote_cmd: - # Support a mode for using cmd directly. - # Convert any paths to native form (first element is used directly). - # TODO(quote): regularize quoting path names throughout the module - arguments = ['"%s"' % i for i in arguments] - # Collapse into a single command. - return ' '.join(command + arguments) - - -def _BuildCommandLineForRule(spec, rule, has_input_path): - # Find path to cygwin. - cygwin_dir = _FixPath(spec.get('msvs_cygwin_dirs', ['.'])[0]) - - # Currently this weird argument munging is used to duplicate the way a - # python script would need to be run as part of the chrome tree. - # Eventually we should add some sort of rule_default option to set this - # per project. For now the behavior chrome needs is the default. - mcs = rule.get('msvs_cygwin_shell') - if mcs is None: - mcs = int(spec.get('msvs_cygwin_shell', 1)) - elif isinstance(mcs, str): - mcs = int(mcs) - quote_cmd = int(rule.get('msvs_quote_cmd', 1)) - return _BuildCommandLineForRuleRaw(spec, rule['action'], mcs, has_input_path, - quote_cmd) - - -def _AddActionStep(actions_dict, inputs, outputs, description, command): - """Merge action into an existing list of actions. - - Care must be taken so that actions which have overlapping inputs either don't - get assigned to the same input, or get collapsed into one. - - Arguments: - actions_dict: dictionary keyed on input name, which maps to a list of - dicts describing the actions attached to that input file. - inputs: list of inputs - outputs: list of outputs - description: description of the action - command: command line to execute - """ - # Require there to be at least one input (call sites will ensure this). - assert inputs - - action = { - 'inputs': inputs, - 'outputs': outputs, - 'description': description, - 'command': command, - } - - # Pick where to stick this action. - # While less than optimal in terms of build time, attach them to the first - # input for now. - chosen_input = inputs[0] - - # Add it there. - if chosen_input not in actions_dict: - actions_dict[chosen_input] = [] - actions_dict[chosen_input].append(action) - - -def _AddCustomBuildToolForMSVS(p, spec, primary_input, - inputs, outputs, description, cmd): - """Add a custom build tool to execute something. - - Arguments: - p: the target project - spec: the target project dict - primary_input: input file to attach the build tool to - inputs: list of inputs - outputs: list of outputs - description: description of the action - cmd: command line to execute - """ - inputs = _FixPaths(inputs) - outputs = _FixPaths(outputs) - tool = MSVSProject.Tool( - 'VCCustomBuildTool', - {'Description': description, - 'AdditionalDependencies': ';'.join(inputs), - 'Outputs': ';'.join(outputs), - 'CommandLine': cmd, - }) - # Add to the properties of primary input for each config. - for config_name, c_data in spec['configurations'].iteritems(): - p.AddFileConfig(_FixPath(primary_input), - _ConfigFullName(config_name, c_data), tools=[tool]) - - -def _AddAccumulatedActionsToMSVS(p, spec, actions_dict): - """Add actions accumulated into an actions_dict, merging as needed. - - Arguments: - p: the target project - spec: the target project dict - actions_dict: dictionary keyed on input name, which maps to a list of - dicts describing the actions attached to that input file. - """ - for primary_input in actions_dict: - inputs = set() - outputs = set() - descriptions = [] - commands = [] - for action in actions_dict[primary_input]: - inputs.update(set(action['inputs'])) - outputs.update(set(action['outputs'])) - descriptions.append(action['description']) - commands.append(action['command']) - # Add the custom build step for one input file. - description = ', and also '.join(descriptions) - command = '\r\n'.join(commands) - _AddCustomBuildToolForMSVS(p, spec, - primary_input=primary_input, - inputs=inputs, - outputs=outputs, - description=description, - cmd=command) - - -def _RuleExpandPath(path, input_file): - """Given the input file to which a rule applied, string substitute a path. - - Arguments: - path: a path to string expand - input_file: the file to which the rule applied. - Returns: - The string substituted path. - """ - path = path.replace('$(InputName)', - os.path.splitext(os.path.split(input_file)[1])[0]) - path = path.replace('$(InputExt)', - os.path.splitext(os.path.split(input_file)[1])[1]) - path = path.replace('$(InputFileName)', os.path.split(input_file)[1]) - path = path.replace('$(InputPath)', input_file) - return path - - -def _FindRuleTriggerFiles(rule, sources): - """Find the list of files which a particular rule applies to. - - Arguments: - rule: the rule in question - sources: the set of all known source files for this project - Returns: - The list of sources that trigger a particular rule. - """ - rule_ext = rule['extension'] - return [s for s in sources if s.endswith('.' + rule_ext)] - - -def _RuleInputsAndOutputs(rule, trigger_file): - """Find the inputs and outputs generated by a rule. - - Arguments: - rule: the rule in question. - trigger_file: the main trigger for this rule. - Returns: - The pair of (inputs, outputs) involved in this rule. - """ - raw_inputs = _FixPaths(rule.get('inputs', [])) - raw_outputs = _FixPaths(rule.get('outputs', [])) - inputs = set() - outputs = set() - inputs.add(trigger_file) - for i in raw_inputs: - inputs.add(_RuleExpandPath(i, trigger_file)) - for o in raw_outputs: - outputs.add(_RuleExpandPath(o, trigger_file)) - return (inputs, outputs) - - -def _GenerateNativeRulesForMSVS(p, rules, output_dir, spec, options): - """Generate a native rules file. - - Arguments: - p: the target project - rules: the set of rules to include - output_dir: the directory in which the project/gyp resides - spec: the project dict - options: global generator options - """ - rules_filename = '%s%s.rules' % (spec['target_name'], - options.suffix) - rules_file = MSVSToolFile.Writer(os.path.join(output_dir, rules_filename), - spec['target_name']) - # Add each rule. - for r in rules: - rule_name = r['rule_name'] - rule_ext = r['extension'] - inputs = _FixPaths(r.get('inputs', [])) - outputs = _FixPaths(r.get('outputs', [])) - cmd = _BuildCommandLineForRule(spec, r, has_input_path=True) - rules_file.AddCustomBuildRule(name=rule_name, - description=r.get('message', rule_name), - extensions=[rule_ext], - additional_dependencies=inputs, - outputs=outputs, - cmd=cmd) - # Write out rules file. - rules_file.WriteIfChanged() - - # Add rules file to project. - p.AddToolFile(rules_filename) - - -def _Cygwinify(path): - path = path.replace('$(OutDir)', '$(OutDirCygwin)') - path = path.replace('$(IntDir)', '$(IntDirCygwin)') - return path - - -def _GenerateExternalRules(rules, output_dir, spec, - sources, options, actions_to_add): - """Generate an external makefile to do a set of rules. - - Arguments: - rules: the list of rules to include - output_dir: path containing project and gyp files - spec: project specification data - sources: set of sources known - options: global generator options - actions_to_add: The list of actions we will add to. - """ - filename = '%s_rules%s.mk' % (spec['target_name'], options.suffix) - mk_file = gyp.common.WriteOnDiff(os.path.join(output_dir, filename)) - # Find cygwin style versions of some paths. - mk_file.write('OutDirCygwin:=$(shell cygpath -u "$(OutDir)")\n') - mk_file.write('IntDirCygwin:=$(shell cygpath -u "$(IntDir)")\n') - # Gather stuff needed to emit all: target. - all_inputs = set() - all_outputs = set() - all_output_dirs = set() - first_outputs = [] - for rule in rules: - trigger_files = _FindRuleTriggerFiles(rule, sources) - for tf in trigger_files: - inputs, outputs = _RuleInputsAndOutputs(rule, tf) - all_inputs.update(set(inputs)) - all_outputs.update(set(outputs)) - # Only use one target from each rule as the dependency for - # 'all' so we don't try to build each rule multiple times. - first_outputs.append(list(outputs)[0]) - # Get the unique output directories for this rule. - output_dirs = [os.path.split(i)[0] for i in outputs] - for od in output_dirs: - all_output_dirs.add(od) - first_outputs_cyg = [_Cygwinify(i) for i in first_outputs] - # Write out all: target, including mkdir for each output directory. - mk_file.write('all: %s\n' % ' '.join(first_outputs_cyg)) - for od in all_output_dirs: - mk_file.write('\tmkdir -p %s\n' % od) - mk_file.write('\n') - # Define how each output is generated. - for rule in rules: - trigger_files = _FindRuleTriggerFiles(rule, sources) - for tf in trigger_files: - # Get all the inputs and outputs for this rule for this trigger file. - inputs, outputs = _RuleInputsAndOutputs(rule, tf) - inputs = [_Cygwinify(i) for i in inputs] - outputs = [_Cygwinify(i) for i in outputs] - # Prepare the command line for this rule. - cmd = [_RuleExpandPath(c, tf) for c in rule['action']] - cmd = ['"%s"' % i for i in cmd] - cmd = ' '.join(cmd) - # Add it to the makefile. - mk_file.write('%s: %s\n' % (' '.join(outputs), ' '.join(inputs))) - mk_file.write('\t%s\n\n' % cmd) - # Close up the file. - mk_file.close() - - # Add makefile to list of sources. - sources.add(filename) - # Add a build action to call makefile. - cmd = ['make', - 'OutDir=$(OutDir)', - 'IntDir=$(IntDir)', - '-j', '${NUMBER_OF_PROCESSORS_PLUS_1}', - '-f', filename] - cmd = _BuildCommandLineForRuleRaw(spec, cmd, True, False, True) - # Insert makefile as 0'th input, so it gets the action attached there, - # as this is easier to understand from in the IDE. - all_inputs = list(all_inputs) - all_inputs.insert(0, filename) - _AddActionStep(actions_to_add, - inputs=_FixPaths(all_inputs), - outputs=_FixPaths(all_outputs), - description='Running %s' % cmd, - command=cmd) - - -def _EscapeEnvironmentVariableExpansion(s): - """Escapes % characters. - - Escapes any % characters so that Windows-style environment variable - expansions will leave them alone. - See http://connect.microsoft.com/VisualStudio/feedback/details/106127/cl-d-name-text-containing-percentage-characters-doesnt-compile - to understand why we have to do this. - - Args: - s: The string to be escaped. - - Returns: - The escaped string. - """ - s = s.replace('%', '%%') - return s - - -quote_replacer_regex = re.compile(r'(\\*)"') - - -def _EscapeCommandLineArgumentForMSVS(s): - """Escapes a Windows command-line argument. - - So that the Win32 CommandLineToArgv function will turn the escaped result back - into the original string. - See http://msdn.microsoft.com/en-us/library/17w5ykft.aspx - ("Parsing C++ Command-Line Arguments") to understand why we have to do - this. - - Args: - s: the string to be escaped. - Returns: - the escaped string. - """ - - def _Replace(match): - # For a literal quote, CommandLineToArgv requires an odd number of - # backslashes preceding it, and it produces half as many literal backslashes - # (rounded down). So we need to produce 2n+1 backslashes. - return 2 * match.group(1) + '\\"' - - # Escape all quotes so that they are interpreted literally. - s = quote_replacer_regex.sub(_Replace, s) - # Now add unescaped quotes so that any whitespace is interpreted literally. - s = '"' + s + '"' - return s - - -delimiters_replacer_regex = re.compile(r'(\\*)([,;]+)') - - -def _EscapeVCProjCommandLineArgListItem(s): - """Escapes command line arguments for MSVS. - - The VCProj format stores string lists in a single string using commas and - semi-colons as separators, which must be quoted if they are to be - interpreted literally. However, command-line arguments may already have - quotes, and the VCProj parser is ignorant of the backslash escaping - convention used by CommandLineToArgv, so the command-line quotes and the - VCProj quotes may not be the same quotes. So to store a general - command-line argument in a VCProj list, we need to parse the existing - quoting according to VCProj's convention and quote any delimiters that are - not already quoted by that convention. The quotes that we add will also be - seen by CommandLineToArgv, so if backslashes precede them then we also have - to escape those backslashes according to the CommandLineToArgv - convention. - - Args: - s: the string to be escaped. - Returns: - the escaped string. - """ - - def _Replace(match): - # For a non-literal quote, CommandLineToArgv requires an even number of - # backslashes preceding it, and it produces half as many literal - # backslashes. So we need to produce 2n backslashes. - return 2 * match.group(1) + '"' + match.group(2) + '"' - - segments = s.split('"') - # The unquoted segments are at the even-numbered indices. - for i in range(0, len(segments), 2): - segments[i] = delimiters_replacer_regex.sub(_Replace, segments[i]) - # Concatenate back into a single string - s = '"'.join(segments) - if len(segments) % 2 == 0: - # String ends while still quoted according to VCProj's convention. This - # means the delimiter and the next list item that follow this one in the - # .vcproj file will be misinterpreted as part of this item. There is nothing - # we can do about this. Adding an extra quote would correct the problem in - # the VCProj but cause the same problem on the final command-line. Moving - # the item to the end of the list does works, but that's only possible if - # there's only one such item. Let's just warn the user. - print >> sys.stderr, ('Warning: MSVS may misinterpret the odd number of ' + - 'quotes in ' + s) - return s - - -def _EscapeCppDefineForMSVS(s): - """Escapes a CPP define so that it will reach the compiler unaltered.""" - s = _EscapeEnvironmentVariableExpansion(s) - s = _EscapeCommandLineArgumentForMSVS(s) - s = _EscapeVCProjCommandLineArgListItem(s) - return s - - -quote_replacer_regex2 = re.compile(r'(\\+)"') - - -def _EscapeCommandLineArgumentForMSBuild(s): - """Escapes a Windows command-line argument for use by MSBuild.""" - - def _Replace(match): - return (len(match.group(1))/2*4)*'\\' + '\\"' - - # Escape all quotes so that they are interpreted literally. - s = quote_replacer_regex2.sub(_Replace, s) - return s - - -def _EscapeMSBuildSpecialCharacters(s): - escape_dictionary = { - '%': '%25', - '$': '%24', - '@': '%40', - "'": '%27', - ';': '%3B', - '?': '%3F', - '*': '%2A' - } - result = ''.join([escape_dictionary.get(c, c) for c in s]) - return result - - -def _EscapeCppDefineForMSBuild(s): - """Escapes a CPP define so that it will reach the compiler unaltered.""" - s = _EscapeEnvironmentVariableExpansion(s) - s = _EscapeCommandLineArgumentForMSBuild(s) - s = _EscapeMSBuildSpecialCharacters(s) - return s - - -def _GenerateRulesForMSVS(p, output_dir, options, spec, - sources, excluded_sources, - actions_to_add): - """Generate all the rules for a particular project. - - Arguments: - p: the project - output_dir: directory to emit rules to - options: global options passed to the generator - spec: the specification for this project - sources: the set of all known source files in this project - excluded_sources: the set of sources excluded from normal processing - actions_to_add: deferred list of actions to add in - """ - rules = spec.get('rules', []) - rules_native = [r for r in rules if not int(r.get('msvs_external_rule', 0))] - rules_external = [r for r in rules if int(r.get('msvs_external_rule', 0))] - - # Handle rules that use a native rules file. - if rules_native: - _GenerateNativeRulesForMSVS(p, rules_native, output_dir, spec, options) - - # Handle external rules (non-native rules). - if rules_external: - _GenerateExternalRules(rules_external, output_dir, spec, - sources, options, actions_to_add) - _AdjustSourcesForRules(rules, sources, excluded_sources) - - -def _AdjustSourcesForRules(rules, sources, excluded_sources): - # Add outputs generated by each rule (if applicable). - for rule in rules: - # Done if not processing outputs as sources. - if int(rule.get('process_outputs_as_sources', False)): - # Add in the outputs from this rule. - trigger_files = _FindRuleTriggerFiles(rule, sources) - for trigger_file in trigger_files: - inputs, outputs = _RuleInputsAndOutputs(rule, trigger_file) - inputs = set(_FixPaths(inputs)) - outputs = set(_FixPaths(outputs)) - inputs.remove(_FixPath(trigger_file)) - sources.update(inputs) - excluded_sources.update(inputs) - sources.update(outputs) - - -def _FilterActionsFromExcluded(excluded_sources, actions_to_add): - """Take inputs with actions attached out of the list of exclusions. - - Arguments: - excluded_sources: list of source files not to be built. - actions_to_add: dict of actions keyed on source file they're attached to. - Returns: - excluded_sources with files that have actions attached removed. - """ - must_keep = set(_FixPaths(actions_to_add.keys())) - return [s for s in excluded_sources if s not in must_keep] - - -def _GetDefaultConfiguration(spec): - return spec['configurations'][spec['default_configuration']] - - -def _GetGuidOfProject(proj_path, spec): - """Get the guid for the project. - - Arguments: - proj_path: Path of the vcproj or vcxproj file to generate. - spec: The target dictionary containing the properties of the target. - Returns: - the guid. - Raises: - ValueError: if the specified GUID is invalid. - """ - # Pluck out the default configuration. - default_config = _GetDefaultConfiguration(spec) - # Decide the guid of the project. - guid = default_config.get('msvs_guid') - if guid: - if VALID_MSVS_GUID_CHARS.match(guid) is None: - raise ValueError('Invalid MSVS guid: "%s". Must match regex: "%s".' % - (guid, VALID_MSVS_GUID_CHARS.pattern)) - guid = '{%s}' % guid - guid = guid or MSVSNew.MakeGuid(proj_path) - return guid - - -def _GenerateProject(project, options, version): - """Generates a vcproj file. - - Arguments: - project: the MSVSProject object. - options: global generator options. - version: the MSVSVersion object. - """ - default_config = _GetDefaultConfiguration(project.spec) - - # Skip emitting anything if told to with msvs_existing_vcproj option. - if default_config.get('msvs_existing_vcproj'): - return - - if version.UsesVcxproj(): - _GenerateMSBuildProject(project, options, version) - else: - _GenerateMSVSProject(project, options, version) - - -def _GenerateMSVSProject(project, options, version): - """Generates a .vcproj file. It may create .rules and .user files too. - - Arguments: - project: The project object we will generate the file for. - options: Global options passed to the generator. - version: The VisualStudioVersion object. - """ - spec = project.spec - vcproj_dir = os.path.dirname(project.path) - if vcproj_dir and not os.path.exists(vcproj_dir): - os.makedirs(vcproj_dir) - - platforms = _GetUniquePlatforms(spec) - p = MSVSProject.Writer(project.path, version, spec['target_name'], - project.guid, platforms) - - # Get directory project file is in. - gyp_dir = os.path.split(project.path)[0] - gyp_file = posixpath.split(project.build_file)[1] - gyp_path = _NormalizedSource(gyp_file) - relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, gyp_dir) - - config_type = _GetMSVSConfigurationType(spec, project.build_file) - for config_name, config in spec['configurations'].iteritems(): - _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config) - - # Prepare list of sources and excluded sources. - sources, excluded_sources = _PrepareListOfSources(spec, - relative_path_of_gyp_file) - - # Add rules. - actions_to_add = {} - _GenerateRulesForMSVS(p, gyp_dir, options, spec, - sources, excluded_sources, - actions_to_add) - sources, excluded_sources, excluded_idl = ( - _AdjustSourcesAndConvertToFilterHierarchy( - spec, options, gyp_dir, sources, excluded_sources)) - - # Add in files. - _VerifySourcesExist(sources, gyp_dir) - p.AddFiles(sources) - - _AddToolFilesToMSVS(p, spec) - _HandlePreCompileHeaderStubs(p, spec) - _AddActions(actions_to_add, spec, relative_path_of_gyp_file) - _AddCopies(actions_to_add, spec) - _WriteMSVSUserFile(project.path, version, spec) - - # NOTE: this stanza must appear after all actions have been decided. - # Don't excluded sources with actions attached, or they won't run. - excluded_sources = _FilterActionsFromExcluded( - excluded_sources, actions_to_add) - _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl) - _AddAccumulatedActionsToMSVS(p, spec, actions_to_add) - - # Write it out. - p.WriteIfChanged() - - -def _GetUniquePlatforms(spec): - """Returns the list of unique platforms for this spec, e.g ['win32', ...]. - - Arguments: - spec: The target dictionary containing the properties of the target. - Returns: - The MSVSUserFile object created. - """ - # Gather list of unique platforms. - platforms = set() - for configuration in spec['configurations']: - platforms.add(_ConfigPlatform(spec['configurations'][configuration])) - platforms = list(platforms) - return platforms - - -def _CreateMSVSUserFile(proj_path, version, spec): - """Generates a .user file for the user running this Gyp program. - - Arguments: - proj_path: The path of the project file being created. The .user file - shares the same path (with an appropriate suffix). - version: The VisualStudioVersion object. - spec: The target dictionary containing the properties of the target. - Returns: - The MSVSUserFile object created. - """ - (domain, username) = _GetDomainAndUserName() - vcuser_filename = '.'.join([proj_path, domain, username, 'user']) - user_file = MSVSUserFile.Writer(vcuser_filename, version, - spec['target_name']) - return user_file - - -def _GetMSVSConfigurationType(spec, build_file): - """Returns the configuration type for this project. - - It's a number defined by Microsoft. May raise an exception. - - Args: - spec: The target dictionary containing the properties of the target. - build_file: The path of the gyp file. - Returns: - An integer, the configuration type. - """ - try: - config_type = { - 'executable': '1', # .exe - 'shared_library': '2', # .dll - 'loadable_module': '2', # .dll - 'static_library': '4', # .lib - 'none': '10', # Utility type - 'dummy_executable': '1', # .exe - }[spec['type']] - except KeyError: - if spec.get('type'): - raise Exception('Target type %s is not a valid target type for ' - 'target %s in %s.' % - (spec['type'], spec['target_name'], build_file)) - else: - raise Exception('Missing type field for target %s in %s.' % - (spec['target_name'], build_file)) - return config_type - - -def _AddConfigurationToMSVSProject(p, spec, config_type, config_name, config): - """Adds a configuration to the MSVS project. - - Many settings in a vcproj file are specific to a configuration. This - function the main part of the vcproj file that's configuration specific. - - Arguments: - p: The target project being generated. - spec: The target dictionary containing the properties of the target. - config_type: The configuration type, a number as defined by Microsoft. - config_name: The name of the configuration. - config: The dictionnary that defines the special processing to be done - for this configuration. - """ - # Get the information for this configuration - include_dirs, resource_include_dirs = _GetIncludeDirs(config) - libraries = _GetLibraries(spec) - out_file, vc_tool, _ = _GetOutputFilePathAndTool(spec) - defines = _GetDefines(config) - defines = [_EscapeCppDefineForMSVS(d) for d in defines] - disabled_warnings = _GetDisabledWarnings(config) - prebuild = config.get('msvs_prebuild') - postbuild = config.get('msvs_postbuild') - def_file = _GetModuleDefinition(spec) - precompiled_header = config.get('msvs_precompiled_header') - - # Prepare the list of tools as a dictionary. - tools = dict() - # Add in user specified msvs_settings. - msvs_settings = config.get('msvs_settings', {}) - MSVSSettings.ValidateMSVSSettings(msvs_settings) - for tool in msvs_settings: - settings = config['msvs_settings'][tool] - for setting in settings: - _ToolAppend(tools, tool, setting, settings[setting]) - # Add the information to the appropriate tool - _ToolAppend(tools, 'VCCLCompilerTool', - 'AdditionalIncludeDirectories', include_dirs) - _ToolAppend(tools, 'VCResourceCompilerTool', - 'AdditionalIncludeDirectories', resource_include_dirs) - # Add in libraries. - _ToolAppend(tools, 'VCLinkerTool', 'AdditionalDependencies', libraries) - if out_file: - _ToolAppend(tools, vc_tool, 'OutputFile', out_file, only_if_unset=True) - # Add defines. - _ToolAppend(tools, 'VCCLCompilerTool', 'PreprocessorDefinitions', defines) - _ToolAppend(tools, 'VCResourceCompilerTool', 'PreprocessorDefinitions', - defines) - # Change program database directory to prevent collisions. - _ToolAppend(tools, 'VCCLCompilerTool', 'ProgramDataBaseFileName', - '$(IntDir)\\$(ProjectName)\\vc80.pdb') - # Add disabled warnings. - _ToolAppend(tools, 'VCCLCompilerTool', - 'DisableSpecificWarnings', disabled_warnings) - # Add Pre-build. - _ToolAppend(tools, 'VCPreBuildEventTool', 'CommandLine', prebuild) - # Add Post-build. - _ToolAppend(tools, 'VCPostBuildEventTool', 'CommandLine', postbuild) - # Turn on precompiled headers if appropriate. - if precompiled_header: - precompiled_header = os.path.split(precompiled_header)[1] - _ToolAppend(tools, 'VCCLCompilerTool', 'UsePrecompiledHeader', '2') - _ToolAppend(tools, 'VCCLCompilerTool', - 'PrecompiledHeaderThrough', precompiled_header) - _ToolAppend(tools, 'VCCLCompilerTool', - 'ForcedIncludeFiles', precompiled_header) - # Loadable modules don't generate import libraries; - # tell dependent projects to not expect one. - if spec['type'] == 'loadable_module': - _ToolAppend(tools, 'VCLinkerTool', 'IgnoreImportLibrary', 'true') - # Set the module definition file if any. - if def_file: - _ToolAppend(tools, 'VCLinkerTool', 'ModuleDefinitionFile', def_file) - - _AddConfigurationToMSVS(p, spec, tools, config, config_type, config_name) - - -def _GetIncludeDirs(config): - """Returns the list of directories to be used for #include directives. - - Arguments: - config: The dictionnary that defines the special processing to be done - for this configuration. - Returns: - The list of directory paths. - """ - # TODO(bradnelson): include_dirs should really be flexible enough not to - # require this sort of thing. - include_dirs = ( - config.get('include_dirs', []) + - config.get('msvs_system_include_dirs', [])) - resource_include_dirs = config.get('resource_include_dirs', include_dirs) - include_dirs = _FixPaths(include_dirs) - resource_include_dirs = _FixPaths(resource_include_dirs) - return include_dirs, resource_include_dirs - - -def _GetLibraries(spec): - """Returns the list of libraries for this configuration. - - Arguments: - spec: The target dictionary containing the properties of the target. - Returns: - The list of directory paths. - """ - libraries = spec.get('libraries', []) - # Strip out -l, as it is not used on windows (but is needed so we can pass - # in libraries that are assumed to be in the default library path). - # Also remove duplicate entries, leaving only the last duplicate, while - # preserving order. - found = set() - unique_libraries_list = [] - for entry in reversed(libraries): - library = re.sub('^\-l', '', entry) - if library not in found: - found.add(library) - unique_libraries_list.append(library) - unique_libraries_list.reverse() - return unique_libraries_list - - -def _GetOutputFilePathAndTool(spec): - """Returns the path and tool to use for this target. - - Figures out the path of the file this spec will create and the name of - the VC tool that will create it. - - Arguments: - spec: The target dictionary containing the properties of the target. - Returns: - A triple of (file path, name of the vc tool, name of the msbuild tool) - """ - # Select a name for the output file. - out_file = '' - vc_tool = '' - msbuild_tool = '' - output_file_map = { - 'executable': ('VCLinkerTool', 'Link', '$(OutDir)\\', '.exe'), - 'shared_library': ('VCLinkerTool', 'Link', '$(OutDir)\\', '.dll'), - 'loadable_module': ('VCLinkerTool', 'Link', '$(OutDir)\\', '.dll'), - # TODO(jeanluc) If we want to avoid the MSB8012 warnings in - # VisualStudio 2010, we will have to change the value of $(OutDir) - # to contain the \lib suffix, rather than doing it as below. - 'static_library': ('VCLibrarianTool', 'Lib', '$(OutDir)\\lib\\', '.lib'), - 'dummy_executable': ('VCLinkerTool', 'Link', '$(IntDir)\\', '.junk'), - } - output_file_props = output_file_map.get(spec['type']) - if output_file_props and int(spec.get('msvs_auto_output_file', 1)): - vc_tool, msbuild_tool, out_dir, suffix = output_file_props - out_dir = spec.get('product_dir', out_dir) - product_extension = spec.get('product_extension') - if product_extension: - suffix = '.' + product_extension - prefix = spec.get('product_prefix', '') - product_name = spec.get('product_name', '$(ProjectName)') - out_file = ntpath.join(out_dir, prefix + product_name + suffix) - return out_file, vc_tool, msbuild_tool - - -def _GetDefines(config): - """Returns the list of preprocessor definitions for this configuation. - - Arguments: - config: The dictionnary that defines the special processing to be done - for this configuration. - Returns: - The list of preprocessor definitions. - """ - defines = [] - for d in config.get('defines', []): - if type(d) == list: - fd = '='.join([str(dpart) for dpart in d]) - else: - fd = str(d) - defines.append(fd) - return defines - - -def _GetDisabledWarnings(config): - return [str(i) for i in config.get('msvs_disabled_warnings', [])] - - -def _GetModuleDefinition(spec): - def_file = '' - if spec['type'] in ['shared_library', 'loadable_module']: - def_files = [s for s in spec.get('sources', []) if s.endswith('.def')] - if len(def_files) == 1: - def_file = _FixPath(def_files[0]) - elif def_files: - raise ValueError( - 'Multiple module definition files in one target, target %s lists ' - 'multiple .def files: %s' % ( - spec['target_name'], ' '.join(def_files))) - return def_file - - -def _ConvertToolsToExpectedForm(tools): - """Convert tools to a form expected by Visual Studio. - - Arguments: - tools: A dictionnary of settings; the tool name is the key. - Returns: - A list of Tool objects. - """ - tool_list = [] - for tool, settings in tools.iteritems(): - # Collapse settings with lists. - settings_fixed = {} - for setting, value in settings.iteritems(): - if type(value) == list: - if ((tool == 'VCLinkerTool' and - setting == 'AdditionalDependencies') or - setting == 'AdditionalOptions'): - settings_fixed[setting] = ' '.join(value) - else: - settings_fixed[setting] = ';'.join(value) - else: - settings_fixed[setting] = value - # Add in this tool. - tool_list.append(MSVSProject.Tool(tool, settings_fixed)) - return tool_list - - -def _AddConfigurationToMSVS(p, spec, tools, config, config_type, config_name): - """Add to the project file the configuration specified by config. - - Arguments: - p: The target project being generated. - spec: the target project dict. - tools: A dictionnary of settings; the tool name is the key. - config: The dictionnary that defines the special processing to be done - for this configuration. - config_type: The configuration type, a number as defined by Microsoft. - config_name: The name of the configuration. - """ - attributes = _GetMSVSAttributes(spec, config, config_type) - # Add in this configuration. - tool_list = _ConvertToolsToExpectedForm(tools) - p.AddConfig(_ConfigFullName(config_name, config), - attrs=attributes, tools=tool_list) - - -def _GetMSVSAttributes(spec, config, config_type): - # Prepare configuration attributes. - prepared_attrs = {} - source_attrs = config.get('msvs_configuration_attributes', {}) - for a in source_attrs: - prepared_attrs[a] = source_attrs[a] - # Add props files. - vsprops_dirs = config.get('msvs_props', []) - vsprops_dirs = _FixPaths(vsprops_dirs) - if vsprops_dirs: - prepared_attrs['InheritedPropertySheets'] = ';'.join(vsprops_dirs) - # Set configuration type. - prepared_attrs['ConfigurationType'] = config_type - output_dir = prepared_attrs.get('OutputDirectory', - '$(SolutionDir)$(ConfigurationName)') - # TODO(jeanluc) If we want to avoid the MSB8012 warning, we should - # add code like the following to place libraries in their own directory. - # if config_type == '4': - # output_dir = spec.get('product_dir', output_dir + '\\lib') - prepared_attrs['OutputDirectory'] = output_dir - if 'IntermediateDirectory' not in prepared_attrs: - intermediate = '$(ConfigurationName)\\obj\\$(ProjectName)' - prepared_attrs['IntermediateDirectory'] = intermediate - return prepared_attrs - - -def _AddNormalizedSources(sources_set, sources_array): - sources = [_NormalizedSource(s) for s in sources_array] - sources_set.update(set(sources)) - - -def _PrepareListOfSources(spec, relative_path_of_gyp_file): - """Prepare list of sources and excluded sources. - - Besides the sources specified directly in the spec, adds the gyp file so - that a change to it will cause a re-compile. Also adds appropriate sources - for actions and copies. Assumes later stage will un-exclude files which - have custom build steps attached. - - Arguments: - spec: The target dictionary containing the properties of the target. - relative_path_of_gyp_file: The relative path of the gyp file. - Returns: - A pair of (list of sources, list of excluded sources) - """ - sources = set() - _AddNormalizedSources(sources, spec.get('sources', [])) - excluded_sources = set() - # Add in the gyp file. - sources.add(relative_path_of_gyp_file) - - # Add in 'action' inputs and outputs. - for a in spec.get('actions', []): - inputs = a.get('inputs', []) - inputs = [_NormalizedSource(i) for i in inputs] - # Add all inputs to sources and excluded sources. - inputs = set(inputs) - sources.update(inputs) - excluded_sources.update(inputs) - if int(a.get('process_outputs_as_sources', False)): - _AddNormalizedSources(sources, a.get('outputs', [])) - # Add in 'copies' inputs and outputs. - for cpy in spec.get('copies', []): - _AddNormalizedSources(sources, cpy.get('files', [])) - return (sources, excluded_sources) - - -def _AdjustSourcesAndConvertToFilterHierarchy( - spec, options, gyp_dir, sources, excluded_sources): - """Adjusts the list of sources and excluded sources. - - Also converts the sets to lists. - - Arguments: - spec: The target dictionary containing the properties of the target. - options: Global generator options. - gyp_dir: The path to the gyp file being processed. - sources: A set of sources to be included for this project. - excluded_sources: A set of sources to be excluded for this project. - Returns: - A trio of (list of sources, list of excluded sources, - path of excluded IDL file) - """ - # Exclude excluded sources coming into the generator. - excluded_sources.update(set(spec.get('sources_excluded', []))) - # Add excluded sources into sources for good measure. - sources.update(excluded_sources) - # Convert to proper windows form. - # NOTE: sources goes from being a set to a list here. - # NOTE: excluded_sources goes from being a set to a list here. - sources = _FixPaths(sources) - # Convert to proper windows form. - excluded_sources = _FixPaths(excluded_sources) - - excluded_idl = _IdlFilesHandledNonNatively(spec, sources) - - precompiled_related = _GetPrecompileRelatedFiles(spec) - # Find the excluded ones, minus the precompiled header related ones. - fully_excluded = [i for i in excluded_sources if i not in precompiled_related] - - # Convert to folders and the right slashes. - sources = [i.split('\\') for i in sources] - sources = _ConvertSourcesToFilterHierarchy(sources, excluded=fully_excluded) - # Add in dummy file for type none. - if spec['type'] == 'dummy_executable': - # Pull in a dummy main so it can link successfully. - dummy_relpath = gyp.common.RelativePath( - options.depth + '\\tools\\gyp\\gyp_dummy.c', gyp_dir) - sources.append(dummy_relpath) - - return sources, excluded_sources, excluded_idl - - -def _IdlFilesHandledNonNatively(spec, sources): - # If any non-native rules use 'idl' as an extension exclude idl files. - # Gather a list here to use later. - using_idl = False - for rule in spec.get('rules', []): - if rule['extension'] == 'idl' and int(rule.get('msvs_external_rule', 0)): - using_idl = True - break - if using_idl: - excluded_idl = [i for i in sources if i.endswith('.idl')] - else: - excluded_idl = [] - return excluded_idl - - -def _GetPrecompileRelatedFiles(spec): - # Gather a list of precompiled header related sources. - precompiled_related = [] - for _, config in spec['configurations'].iteritems(): - for k in precomp_keys: - f = config.get(k) - if f: - precompiled_related.append(_FixPath(f)) - return precompiled_related - - -def _ExcludeFilesFromBeingBuilt(p, spec, excluded_sources, excluded_idl): - exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) - for file_name, excluded_configs in exclusions.iteritems(): - for config_name, config in excluded_configs: - p.AddFileConfig(file_name, _ConfigFullName(config_name, config), - {'ExcludedFromBuild': 'true'}) - - -def _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl): - exclusions = {} - # Exclude excluded sources from being built. - for f in excluded_sources: - excluded_configs = [] - for config_name, config in spec['configurations'].iteritems(): - precomped = [_FixPath(config.get(i, '')) for i in precomp_keys] - # Don't do this for ones that are precompiled header related. - if f not in precomped: - excluded_configs.append((config_name, config)) - exclusions[f] = excluded_configs - # If any non-native rules use 'idl' as an extension exclude idl files. - # Exclude them now. - for f in excluded_idl: - excluded_configs = [] - for config_name, config in spec['configurations'].iteritems(): - excluded_configs.append((config_name, config)) - exclusions[f] = excluded_configs - return exclusions - - -def _AddToolFilesToMSVS(p, spec): - # Add in tool files (rules). - tool_files = set() - for _, config in spec['configurations'].iteritems(): - for f in config.get('msvs_tool_files', []): - tool_files.add(f) - for f in tool_files: - p.AddToolFile(f) - - -def _HandlePreCompileHeaderStubs(p, spec): - # Handle pre-compiled headers source stubs specially. - for config_name, config in spec['configurations'].iteritems(): - source = config.get('msvs_precompiled_source') - if source: - source = _FixPath(source) - # UsePrecompiledHeader=1 for if using precompiled headers. - tool = MSVSProject.Tool('VCCLCompilerTool', - {'UsePrecompiledHeader': '1'}) - p.AddFileConfig(source, _ConfigFullName(config_name, config), - {}, tools=[tool]) - - -def _AddActions(actions_to_add, spec, relative_path_of_gyp_file): - # Add actions. - actions = spec.get('actions', []) - for a in actions: - cmd = _BuildCommandLineForRule(spec, a, has_input_path=False) - # Attach actions to the gyp file if nothing else is there. - inputs = a.get('inputs') or [relative_path_of_gyp_file] - # Add the action. - _AddActionStep(actions_to_add, - inputs=inputs, - outputs=a.get('outputs', []), - description=a.get('message', a['action_name']), - command=cmd) - - -def _WriteMSVSUserFile(project_path, version, spec): - # Add run_as and test targets. - if 'run_as' in spec: - run_as = spec['run_as'] - action = run_as.get('action', []) - environment = run_as.get('environment', []) - working_directory = run_as.get('working_directory', '.') - elif int(spec.get('test', 0)): - action = ['$(TargetPath)', '--gtest_print_time'] - environment = [] - working_directory = '.' - else: - return # Nothing to add - # Write out the user file. - user_file = _CreateMSVSUserFile(project_path, version, spec) - for config_name, c_data in spec['configurations'].iteritems(): - user_file.AddDebugSettings(_ConfigFullName(config_name, c_data), - action, environment, working_directory) - user_file.WriteIfChanged() - - -def _AddCopies(actions_to_add, spec): - copies = _GetCopies(spec) - for inputs, outputs, cmd, description in copies: - _AddActionStep(actions_to_add, inputs=inputs, outputs=outputs, - description=description, command=cmd) - - -def _GetCopies(spec): - copies = [] - # Add copies. - for cpy in spec.get('copies', []): - for src in cpy.get('files', []): - dst = os.path.join(cpy['destination'], os.path.basename(src)) - # _AddCustomBuildToolForMSVS() will call _FixPath() on the inputs and - # outputs, so do the same for our generated command line. - if src.endswith('/'): - src_bare = src[:-1] - base_dir = posixpath.split(src_bare)[0] - outer_dir = posixpath.split(src_bare)[1] - cmd = 'cd "%s" && xcopy /e /f /y "%s" "%s\\%s\\"' % ( - _FixPath(base_dir), outer_dir, _FixPath(dst), outer_dir) - copies.append(([src], ['dummy_copies', dst], cmd, - 'Copying %s to %s' % (src, dst))) - else: - cmd = 'mkdir "%s" 2>nul & set ERRORLEVEL=0 & copy /Y "%s" "%s"' % ( - _FixPath(cpy['destination']), _FixPath(src), _FixPath(dst)) - copies.append(([src], [dst], cmd, 'Copying %s to %s' % (src, dst))) - return copies - - -def _GetPathDict(root, path): - if not path: - return root - parent, folder = os.path.split(path) - parent_dict = _GetPathDict(root, parent) - if folder not in parent_dict: - parent_dict[folder] = dict() - return parent_dict[folder] - - -def _DictsToFolders(base_path, bucket, flat): - # Convert to folders recursively. - children = [] - for folder, contents in bucket.iteritems(): - if type(contents) == dict: - folder_children = _DictsToFolders(os.path.join(base_path, folder), - contents, flat) - if flat: - children += folder_children - else: - folder_children = MSVSNew.MSVSFolder(os.path.join(base_path, folder), - name='(' + folder + ')', - entries=folder_children) - children.append(folder_children) - else: - children.append(contents) - return children - - -def _CollapseSingles(parent, node): - # Recursively explorer the tree of dicts looking for projects which are - # the sole item in a folder which has the same name as the project. Bring - # such projects up one level. - if (type(node) == dict and - len(node) == 1 and - node.keys()[0] == parent + '.vcproj'): - return node[node.keys()[0]] - if type(node) != dict: - return node - for child in node: - node[child] = _CollapseSingles(child, node[child]) - return node - - -def _GatherSolutionFolders(sln_projects, project_objects, flat): - root = {} - # Convert into a tree of dicts on path. - for p in sln_projects: - gyp_file, target = gyp.common.ParseQualifiedTarget(p)[0:2] - gyp_dir = os.path.dirname(gyp_file) - path_dict = _GetPathDict(root, gyp_dir) - path_dict[target + '.vcproj'] = project_objects[p] - # Walk down from the top until we hit a folder that has more than one entry. - # In practice, this strips the top-level "src/" dir from the hierarchy in - # the solution. - while len(root) == 1 and type(root[root.keys()[0]]) == dict: - root = root[root.keys()[0]] - # Collapse singles. - root = _CollapseSingles('', root) - # Merge buckets until everything is a root entry. - return _DictsToFolders('', root, flat) - - -def _GetPathOfProject(qualified_target, spec, options, msvs_version): - default_config = _GetDefaultConfiguration(spec) - proj_filename = default_config.get('msvs_existing_vcproj') - if not proj_filename: - proj_filename = (spec['target_name'] + options.suffix + - msvs_version.ProjectExtension()) - - build_file = gyp.common.BuildFile(qualified_target) - proj_path = os.path.join(os.path.split(build_file)[0], proj_filename) - fix_prefix = None - if options.generator_output: - project_dir_path = os.path.dirname(os.path.abspath(proj_path)) - proj_path = os.path.join(options.generator_output, proj_path) - fix_prefix = gyp.common.RelativePath(project_dir_path, - os.path.dirname(proj_path)) - return proj_path, fix_prefix - - -def _GetPlatformOverridesOfProject(spec): - # Prepare a dict indicating which project configurations are used for which - # solution configurations for this target. - config_platform_overrides = {} - for config_name, c in spec['configurations'].iteritems(): - config_fullname = _ConfigFullName(config_name, c) - platform = c.get('msvs_target_platform', _ConfigPlatform(c)) - fixed_config_fullname = '%s|%s' % ( - _ConfigBaseName(config_name, _ConfigPlatform(c)), platform) - config_platform_overrides[config_fullname] = fixed_config_fullname - return config_platform_overrides - - -def _CreateProjectObjects(target_list, target_dicts, options, msvs_version): - """Create a MSVSProject object for the targets found in target list. - - Arguments: - target_list: the list of targets to generate project objects for. - target_dicts: the dictionary of specifications. - options: global generator options. - msvs_version: the MSVSVersion object. - Returns: - A set of created projects, keyed by target. - """ - global fixpath_prefix - # Generate each project. - projects = {} - for qualified_target in target_list: - spec = target_dicts[qualified_target] - if spec['toolset'] != 'target': - raise Exception( - 'Multiple toolsets not supported in msvs build (target %s)' % - qualified_target) - proj_path, fixpath_prefix = _GetPathOfProject(qualified_target, spec, - options, msvs_version) - guid = _GetGuidOfProject(proj_path, spec) - overrides = _GetPlatformOverridesOfProject(spec) - build_file = gyp.common.BuildFile(qualified_target) - # Create object for this project. - obj = MSVSNew.MSVSProject( - _FixPath(proj_path), - name=spec['target_name'], - guid=guid, - spec=spec, - build_file=build_file, - config_platform_overrides=overrides, - fixpath_prefix=fixpath_prefix) - projects[qualified_target] = obj - # Set all the dependencies - for project in projects.values(): - deps = project.spec.get('dependencies', []) - deps = [projects[d] for d in deps] - project.set_dependencies(deps) - return projects - - -def CalculateVariables(default_variables, params): - """Generated variables that require params to be known.""" - - generator_flags = params.get('generator_flags', {}) - - # Select project file format version (if unset, default to auto detecting). - msvs_version = MSVSVersion.SelectVisualStudioVersion( - generator_flags.get('msvs_version', 'auto')) - # Stash msvs_version for later (so we don't have to probe the system twice). - params['msvs_version'] = msvs_version - - # Set a variable so conditions can be based on msvs_version. - default_variables['MSVS_VERSION'] = msvs_version.ShortName() - - # To determine processor word size on Windows, in addition to checking - # PROCESSOR_ARCHITECTURE (which reflects the word size of the current - # process), it is also necessary to check PROCESSOR_ARCITEW6432 (which - # contains the actual word size of the system when running thru WOW64). - if (os.environ.get('PROCESSOR_ARCHITECTURE', '').find('64') >= 0 or - os.environ.get('PROCESSOR_ARCHITEW6432', '').find('64') >= 0): - default_variables['MSVS_OS_BITS'] = 64 - else: - default_variables['MSVS_OS_BITS'] = 32 - - -def _ShardName(name, number): - """Add a shard number to the end of a target. - - Arguments: - name: name of the target (foo#target) - number: shard number - Returns: - Target name with shard added (foo_1#target) - """ - parts = name.rsplit('#', 1) - parts[0] = '%s_%d' % (parts[0], number) - return '#'.join(parts) - - -def _ShardTargets(target_list, target_dicts): - """Shard some targets apart to work around the linkers limits. - - Arguments: - target_list: List of target pairs: 'base/base.gyp:base'. - target_dicts: Dict of target properties keyed on target pair. - Returns: - Tuple of the new sharded versions of the inputs. - """ - # Gather the targets to shard, and how many pieces. - targets_to_shard = {} - for t in target_dicts: - shards = int(target_dicts[t].get('msvs_shard', 0)) - if shards: - targets_to_shard[t] = shards - # Shard target_list. - new_target_list = [] - for t in target_list: - if t in targets_to_shard: - for i in range(targets_to_shard[t]): - new_target_list.append(_ShardName(t, i)) - else: - new_target_list.append(t) - # Shard target_dict. - new_target_dicts = {} - for t in target_dicts: - if t in targets_to_shard: - for i in range(targets_to_shard[t]): - name = _ShardName(t, i) - new_target_dicts[name] = copy.copy(target_dicts[t]) - new_target_dicts[name]['target_name'] = _ShardName( - new_target_dicts[name]['target_name'], i) - sources = new_target_dicts[name].get('sources', []) - new_sources = [] - for pos in range(i, len(sources), targets_to_shard[t]): - new_sources.append(sources[pos]) - new_target_dicts[name]['sources'] = new_sources - else: - new_target_dicts[t] = target_dicts[t] - # Shard dependencies. - for t in new_target_dicts: - dependencies = copy.copy(new_target_dicts[t].get('dependencies', [])) - new_dependencies = [] - for d in dependencies: - if d in targets_to_shard: - for i in range(targets_to_shard[d]): - new_dependencies.append(_ShardName(d, i)) - else: - new_dependencies.append(d) - new_target_dicts[t]['dependencies'] = new_dependencies - - return (new_target_list, new_target_dicts) - - -def GenerateOutput(target_list, target_dicts, data, params): - """Generate .sln and .vcproj files. - - This is the entry point for this generator. - Arguments: - target_list: List of target pairs: 'base/base.gyp:base'. - target_dicts: Dict of target properties keyed on target pair. - data: Dictionary containing per .gyp data. - """ - global fixpath_prefix - - options = params['options'] - - # Get the project file format version back out of where we stashed it in - # GeneratorCalculatedVariables. - msvs_version = params['msvs_version'] - - # Optionally shard targets marked with 'msvs_shard': SHARD_COUNT. - (target_list, target_dicts) = _ShardTargets(target_list, target_dicts) - - # Prepare the set of configurations. - configs = set() - for qualified_target in target_list: - spec = target_dicts[qualified_target] - for config_name, config in spec['configurations'].iteritems(): - configs.add(_ConfigFullName(config_name, config)) - configs = list(configs) - - # Figure out all the projects that will be generated and their guids - project_objects = _CreateProjectObjects(target_list, target_dicts, options, - msvs_version) - - # Generate each project. - for project in project_objects.values(): - fixpath_prefix = project.fixpath_prefix - _GenerateProject(project, options, msvs_version) - fixpath_prefix = None - - for build_file in data: - # Validate build_file extension - if build_file[-4:] != '.gyp': - continue - sln_path = build_file[:-4] + options.suffix + '.sln' - if options.generator_output: - sln_path = os.path.join(options.generator_output, sln_path) - # Get projects in the solution, and their dependents. - sln_projects = gyp.common.BuildFileTargets(target_list, build_file) - sln_projects += gyp.common.DeepDependencyTargets(target_dicts, sln_projects) - # Create folder hierarchy. - root_entries = _GatherSolutionFolders( - sln_projects, project_objects, flat=msvs_version.FlatSolution()) - # Create solution. - sln = MSVSNew.MSVSSolution(sln_path, - entries=root_entries, - variants=configs, - websiteProperties=False, - version=msvs_version) - sln.Write() - - -def _GenerateMSBuildFiltersFile(filters_path, source_files, - extension_to_rule_name): - """Generate the filters file. - - This file is used by Visual Studio to organize the presentation of source - files into folders. - - Arguments: - filters_path: The path of the file to be created. - source_files: The hierarchical structure of all the sources. - extension_to_rule_name: A dictionary mapping file extensions to rules. - """ - filter_group = [] - source_group = [] - _AppendFiltersForMSBuild('', source_files, extension_to_rule_name, - filter_group, source_group) - if filter_group: - content = ['Project', - {'ToolsVersion': '4.0', - 'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003' - }, - ['ItemGroup'] + filter_group, - ['ItemGroup'] + source_group - ] - easy_xml.WriteXmlIfChanged(content, filters_path) - elif os.path.exists(filters_path): - # We don't need this filter anymore. Delete the old filter file. - os.unlink(filters_path) - - -def _AppendFiltersForMSBuild(parent_filter_name, sources, - extension_to_rule_name, - filter_group, source_group): - """Creates the list of filters and sources to be added in the filter file. - - Args: - parent_filter_name: The name of the filter under which the sources are - found. - sources: The hierarchy of filters and sources to process. - extension_to_rule_name: A dictionary mapping file extensions to rules. - filter_group: The list to which filter entries will be appended. - source_group: The list to which source entries will be appeneded. - """ - for source in sources: - if isinstance(source, MSVSProject.Filter): - # We have a sub-filter. Create the name of that sub-filter. - if not parent_filter_name: - filter_name = source.name - else: - filter_name = '%s\\%s' % (parent_filter_name, source.name) - # Add the filter to the group. - filter_group.append( - ['Filter', {'Include': filter_name}, - ['UniqueIdentifier', MSVSNew.MakeGuid(source.name)]]) - # Recurse and add its dependents. - _AppendFiltersForMSBuild(filter_name, source.contents, - extension_to_rule_name, - filter_group, source_group) - else: - # It's a source. Create a source entry. - _, element = _MapFileToMsBuildSourceType(source, extension_to_rule_name) - source_entry = [element, {'Include': source}] - # Specify the filter it is part of, if any. - if parent_filter_name: - source_entry.append(['Filter', parent_filter_name]) - source_group.append(source_entry) - - -def _MapFileToMsBuildSourceType(source, extension_to_rule_name): - """Returns the group and element type of the source file. - - Arguments: - source: The source file name. - extension_to_rule_name: A dictionary mapping file extensions to rules. - - Returns: - A pair of (group this file should be part of, the label of element) - """ - _, ext = os.path.splitext(source) - if ext in ['.cc', '.cpp', '.c', '.cxx']: - group = 'compile' - element = 'ClCompile' - elif ext in ['.h', '.hxx']: - group = 'include' - element = 'ClInclude' - elif ext == '.rc': - group = 'resource' - element = 'ResourceCompile' - elif ext == '.idl': - group = 'midl' - element = 'Midl' - elif ext in extension_to_rule_name: - group = 'rule' - element = extension_to_rule_name[ext] - else: - group = 'none' - element = 'None' - return (group, element) - - -def _GenerateRulesForMSBuild(output_dir, options, spec, - sources, excluded_sources, - props_files_of_rules, targets_files_of_rules, - actions_to_add, extension_to_rule_name): - # MSBuild rules are implemented using three files: an XML file, a .targets - # file and a .props file. - # See http://blogs.msdn.com/b/vcblog/archive/2010/04/21/quick-help-on-vs2010-custom-build-rule.aspx - # for more details. - rules = spec.get('rules', []) - rules_native = [r for r in rules if not int(r.get('msvs_external_rule', 0))] - rules_external = [r for r in rules if int(r.get('msvs_external_rule', 0))] - - msbuild_rules = [] - for rule in rules_native: - msbuild_rule = MSBuildRule(rule, spec) - msbuild_rules.append(msbuild_rule) - extension_to_rule_name[msbuild_rule.extension] = msbuild_rule.rule_name - if msbuild_rules: - base = spec['target_name'] + options.suffix - props_name = base + '.props' - targets_name = base + '.targets' - xml_name = base + '.xml' - - props_files_of_rules.add(props_name) - targets_files_of_rules.add(targets_name) - - props_path = os.path.join(output_dir, props_name) - targets_path = os.path.join(output_dir, targets_name) - xml_path = os.path.join(output_dir, xml_name) - - _GenerateMSBuildRulePropsFile(props_path, msbuild_rules) - _GenerateMSBuildRuleTargetsFile(targets_path, msbuild_rules) - _GenerateMSBuildRuleXmlFile(xml_path, msbuild_rules) - - if rules_external: - _GenerateExternalRules(rules_external, output_dir, spec, - sources, options, actions_to_add) - _AdjustSourcesForRules(rules, sources, excluded_sources) - - -class MSBuildRule(object): - """Used to store information used to generate an MSBuild rule. - - Attributes: - rule_name: The rule name, sanitized to use in XML. - target_name: The name of the target. - after_targets: The name of the AfterTargets element. - before_targets: The name of the BeforeTargets element. - depends_on: The name of the DependsOn element. - compute_output: The name of the ComputeOutput element. - dirs_to_make: The name of the DirsToMake element. - tlog: The name of the _tlog element. - extension: The extension this rule applies to. - description: The message displayed when this rule is invoked. - additional_dependencies: A string listing additional dependencies. - outputs: The outputs of this rule. - command: The command used to run the rule. - """ - - def __init__(self, rule, spec): - self.display_name = rule['rule_name'] - # Assure that the rule name is only characters and numbers - self.rule_name = re.sub(r'\W', '_', self.display_name) - # Create the various element names, following the example set by the - # Visual Studio 2008 to 2010 conversion. I don't know if VS2010 - # is sensitive to the exact names. - self.target_name = '_' + self.rule_name - self.after_targets = self.rule_name + 'AfterTargets' - self.before_targets = self.rule_name + 'BeforeTargets' - self.depends_on = self.rule_name + 'DependsOn' - self.compute_output = 'Compute%sOutput' % self.rule_name - self.dirs_to_make = self.rule_name + 'DirsToMake' - self.tlog = self.rule_name + '_tlog' - self.extension = rule['extension'] - if not self.extension.startswith('.'): - self.extension = '.' + self.extension - - self.description = MSVSSettings.ConvertVCMacrosToMSBuild( - rule.get('message', self.rule_name)) - old_additional_dependencies = _FixPaths(rule.get('inputs', [])) - self.additional_dependencies = ( - ';'.join([MSVSSettings.ConvertVCMacrosToMSBuild(i) - for i in old_additional_dependencies])) - old_outputs = _FixPaths(rule.get('outputs', [])) - self.outputs = ';'.join([MSVSSettings.ConvertVCMacrosToMSBuild(i) - for i in old_outputs]) - old_command = _BuildCommandLineForRule(spec, rule, has_input_path=True) - self.command = MSVSSettings.ConvertVCMacrosToMSBuild(old_command) - - -def _GenerateMSBuildRulePropsFile(props_path, msbuild_rules): - """Generate the .props file.""" - content = ['Project', - {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'}] - for rule in msbuild_rules: - content.extend([ - ['PropertyGroup', - {'Condition': "'$(%s)' == '' and '$(%s)' == '' and " - "'$(ConfigurationType)' != 'Makefile'" % (rule.before_targets, - rule.after_targets) - }, - [rule.before_targets, 'Midl'], - [rule.after_targets, 'CustomBuild'], - ], - ['PropertyGroup', - [rule.depends_on, - {'Condition': "'$(ConfigurationType)' != 'Makefile'"}, - '_SelectedFiles;$(%s)' % rule.depends_on - ], - ], - ['ItemDefinitionGroup', - [rule.rule_name, - ['CommandLineTemplate', rule.command], - ['Outputs', rule.outputs], - ['ExecutionDescription', rule.description], - ['AdditionalDependencies', rule.additional_dependencies], - ], - ] - ]) - easy_xml.WriteXmlIfChanged(content, props_path) - - -def _GenerateMSBuildRuleTargetsFile(targets_path, msbuild_rules): - """Generate the .targets file.""" - content = ['Project', - {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003' - } - ] - item_group = [ - 'ItemGroup', - ['PropertyPageSchema', - {'Include': '$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml'} - ] - ] - for rule in msbuild_rules: - item_group.append( - ['AvailableItemName', - {'Include': rule.rule_name}, - ['Targets', rule.target_name], - ]) - content.append(item_group) - - for rule in msbuild_rules: - content.append( - ['UsingTask', - {'TaskName': rule.rule_name, - 'TaskFactory': 'XamlTaskFactory', - 'AssemblyName': 'Microsoft.Build.Tasks.v4.0' - }, - ['Task', '$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml'], - ]) - for rule in msbuild_rules: - rule_name = rule.rule_name - target_outputs = '%%(%s.Outputs)' % rule_name - target_inputs = ('%%(%s.Identity);%%(%s.AdditionalDependencies);' - '$(MSBuildProjectFile)') % (rule_name, rule_name) - rule_inputs = '%%(%s.Identity)' % rule_name - extension_condition = ("'%(Extension)'=='.obj' or " - "'%(Extension)'=='.res' or " - "'%(Extension)'=='.rsc' or " - "'%(Extension)'=='.lib'") - remove_section = [ - 'ItemGroup', - {'Condition': "'@(SelectedFiles)' != ''"}, - [rule_name, - {'Remove': '@(%s)' % rule_name, - 'Condition': "'%(Identity)' != '@(SelectedFiles)'" - } - ] - ] - logging_section = [ - 'ItemGroup', - [rule.tlog, - {'Include': '%%(%s.Outputs)' % rule_name, - 'Condition': ("'%%(%s.Outputs)' != '' and " - "'%%(%s.ExcludedFromBuild)' != 'true'" % - (rule_name, rule_name)) - }, - ['Source', "@(%s, '|')" % rule_name], - ], - ] - message_section = [ - 'Message', - {'Importance': 'High', - 'Text': '%%(%s.ExecutionDescription)' % rule_name - } - ] - write_lines_section = [ - 'WriteLinesToFile', - {'Condition': "'@(%s)' != '' and '%%(%s.ExcludedFromBuild)' != " - "'true'" % (rule.tlog, rule.tlog), - 'File': '$(IntDir)$(ProjectName).write.1.tlog', - 'Lines': "^%%(%s.Source);@(%s->'%%(Fullpath)')" % (rule.tlog, - rule.tlog) - } - ] - command_and_input_section = [ - rule_name, - {'Condition': "'@(%s)' != '' and '%%(%s.ExcludedFromBuild)' != " - "'true'" % (rule_name, rule_name), - 'CommandLineTemplate': '%%(%s.CommandLineTemplate)' % rule_name, - 'AdditionalOptions': '%%(%s.AdditionalOptions)' % rule_name, - 'Inputs': rule_inputs - } - ] - content.extend([ - ['Target', - {'Name': rule.target_name, - 'BeforeTargets': '$(%s)' % rule.before_targets, - 'AfterTargets': '$(%s)' % rule.after_targets, - 'Condition': "'@(%s)' != ''" % rule_name, - 'DependsOnTargets': '$(%s);%s' % (rule.depends_on, - rule.compute_output), - 'Outputs': target_outputs, - 'Inputs': target_inputs - }, - remove_section, - logging_section, - message_section, - write_lines_section, - command_and_input_section, - ], - ['PropertyGroup', - ['ComputeLinkInputsTargets', - '$(ComputeLinkInputsTargets);', - '%s;' % rule.compute_output - ], - ['ComputeLibInputsTargets', - '$(ComputeLibInputsTargets);', - '%s;' % rule.compute_output - ], - ], - ['Target', - {'Name': rule.compute_output, - 'Condition': "'@(%s)' != ''" % rule_name - }, - ['ItemGroup', - [rule.dirs_to_make, - {'Condition': "'@(%s)' != '' and " - "'%%(%s.ExcludedFromBuild)' != 'true'" % (rule_name, rule_name), - 'Include': '%%(%s.Outputs)' % rule_name - } - ], - ['Link', - {'Include': '%%(%s.Identity)' % rule.dirs_to_make, - 'Condition': extension_condition - } - ], - ['Lib', - {'Include': '%%(%s.Identity)' % rule.dirs_to_make, - 'Condition': extension_condition - } - ], - ['ImpLib', - {'Include': '%%(%s.Identity)' % rule.dirs_to_make, - 'Condition': extension_condition - } - ], - ], - ['MakeDir', - {'Directories': ("@(%s->'%%(RootDir)%%(Directory)')" % - rule.dirs_to_make) - } - ] - ], - ]) - easy_xml.WriteXmlIfChanged(content, targets_path) - - -def _GenerateMSBuildRuleXmlFile(xml_path, msbuild_rules): - # Generate the .xml file - content = [ - 'ProjectSchemaDefinitions', - {'xmlns': ('clr-namespace:Microsoft.Build.Framework.XamlTypes;' - 'assembly=Microsoft.Build.Framework'), - 'xmlns:x': 'http://schemas.microsoft.com/winfx/2006/xaml', - 'xmlns:sys': 'clr-namespace:System;assembly=mscorlib', - 'xmlns:transformCallback': - 'Microsoft.Cpp.Dev10.ConvertPropertyCallback' - } - ] - for rule in msbuild_rules: - content.extend([ - ['Rule', - {'Name': rule.rule_name, - 'PageTemplate': 'tool', - 'DisplayName': rule.display_name, - 'Order': '200' - }, - ['Rule.DataSource', - ['DataSource', - {'Persistence': 'ProjectFile', - 'ItemType': rule.rule_name - } - ] - ], - ['Rule.Categories', - ['Category', - {'Name': 'General'}, - ['Category.DisplayName', - ['sys:String', 'General'], - ], - ], - ['Category', - {'Name': 'Command Line', - 'Subtype': 'CommandLine' - }, - ['Category.DisplayName', - ['sys:String', 'Command Line'], - ], - ], - ], - ['StringListProperty', - {'Name': 'Inputs', - 'Category': 'Command Line', - 'IsRequired': 'true', - 'Switch': ' ' - }, - ['StringListProperty.DataSource', - ['DataSource', - {'Persistence': 'ProjectFile', - 'ItemType': rule.rule_name, - 'SourceType': 'Item' - } - ] - ], - ], - ['StringProperty', - {'Name': 'CommandLineTemplate', - 'DisplayName': 'Command Line', - 'Visible': 'False', - 'IncludeInCommandLine': 'False' - } - ], - ['DynamicEnumProperty', - {'Name': rule.before_targets, - 'Category': 'General', - 'EnumProvider': 'Targets', - 'IncludeInCommandLine': 'False' - }, - ['DynamicEnumProperty.DisplayName', - ['sys:String', 'Execute Before'], - ], - ['DynamicEnumProperty.Description', - ['sys:String', 'Specifies the targets for the build customization' - ' to run before.' - ], - ], - ['DynamicEnumProperty.ProviderSettings', - ['NameValuePair', - {'Name': 'Exclude', - 'Value': '^%s|^Compute' % rule.before_targets - } - ] - ], - ['DynamicEnumProperty.DataSource', - ['DataSource', - {'Persistence': 'ProjectFile', - 'HasConfigurationCondition': 'true' - } - ] - ], - ], - ['DynamicEnumProperty', - {'Name': rule.after_targets, - 'Category': 'General', - 'EnumProvider': 'Targets', - 'IncludeInCommandLine': 'False' - }, - ['DynamicEnumProperty.DisplayName', - ['sys:String', 'Execute After'], - ], - ['DynamicEnumProperty.Description', - ['sys:String', ('Specifies the targets for the build customization' - ' to run after.') - ], - ], - ['DynamicEnumProperty.ProviderSettings', - ['NameValuePair', - {'Name': 'Exclude', - 'Value': '^%s|^Compute' % rule.after_targets - } - ] - ], - ['DynamicEnumProperty.DataSource', - ['DataSource', - {'Persistence': 'ProjectFile', - 'ItemType': '', - 'HasConfigurationCondition': 'true' - } - ] - ], - ], - ['StringListProperty', - {'Name': 'Outputs', - 'DisplayName': 'Outputs', - 'Visible': 'False', - 'IncludeInCommandLine': 'False' - } - ], - ['StringProperty', - {'Name': 'ExecutionDescription', - 'DisplayName': 'Execution Description', - 'Visible': 'False', - 'IncludeInCommandLine': 'False' - } - ], - ['StringListProperty', - {'Name': 'AdditionalDependencies', - 'DisplayName': 'Additional Dependencies', - 'IncludeInCommandLine': 'False', - 'Visible': 'false' - } - ], - ['StringProperty', - {'Subtype': 'AdditionalOptions', - 'Name': 'AdditionalOptions', - 'Category': 'Command Line' - }, - ['StringProperty.DisplayName', - ['sys:String', 'Additional Options'], - ], - ['StringProperty.Description', - ['sys:String', 'Additional Options'], - ], - ], - ], - ['ItemType', - {'Name': rule.rule_name, - 'DisplayName': rule.display_name - } - ], - ['FileExtension', - {'Name': '*' + rule.extension, - 'ContentType': rule.rule_name - } - ], - ['ContentType', - {'Name': rule.rule_name, - 'DisplayName': '', - 'ItemType': rule.rule_name - } - ] - ]) - easy_xml.WriteXmlIfChanged(content, xml_path) - - -def _GetConfigurationAndPlatform(name, settings): - configuration = name.rsplit('_', 1)[0] - platform = settings.get('msvs_configuration_platform', 'Win32') - return (configuration, platform) - - -def _GetConfigurationCondition(name, settings): - return (r"'$(Configuration)|$(Platform)'=='%s|%s'" % - _GetConfigurationAndPlatform(name, settings)) - - -def _GetMSBuildProjectConfigurations(configurations): - group = ['ItemGroup', {'Label': 'ProjectConfigurations'}] - for (name, settings) in sorted(configurations.iteritems()): - configuration, platform = _GetConfigurationAndPlatform(name, settings) - designation = '%s|%s' % (configuration, platform) - group.append( - ['ProjectConfiguration', {'Include': designation}, - ['Configuration', configuration], - ['Platform', platform]]) - return [group] - - -def _GetMSBuildGlobalProperties(spec, guid, gyp_file_name): - prefix = spec.get('product_prefix', '') - product_name = spec.get('product_name', '$(ProjectName)') - target_name = prefix + product_name - namespace = os.path.splitext(gyp_file_name)[0] - return [ - ['PropertyGroup', {'Label': 'Globals'}, - ['ProjectGuid', guid], - ['Keyword', 'Win32Proj'], - ['RootNamespace', namespace], - ['TargetName', target_name], - ] - ] - - -def _GetMSBuildConfigurationDetails(spec, build_file): - properties = {} - for name, settings in spec['configurations'].iteritems(): - msbuild_attributes = _GetMSBuildAttributes(spec, settings, build_file) - condition = _GetConfigurationCondition(name, settings) - character_set = msbuild_attributes.get('CharacterSet') - _AddConditionalProperty(properties, condition, 'ConfigurationType', - msbuild_attributes['ConfigurationType']) - if character_set: - _AddConditionalProperty(properties, condition, 'CharacterSet', - character_set) - return _GetMSBuildPropertyGroup(spec, 'Configuration', properties) - - -def _GetMSBuildPropertySheets(configurations): - user_props = r'$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props' - return [ - ['ImportGroup', - {'Label': 'PropertySheets'}, - ['Import', - {'Project': user_props, - 'Condition': "exists('%s')" % user_props, - 'Label': 'LocalAppDataPlatform' - } - ] - ] - ] - - -def _GetMSBuildAttributes(spec, config, build_file): - # Use the MSVS attributes and convert them. In the future, we may want to - # support Gyp files specifying 'msbuild_configuration_attributes' directly. - config_type = _GetMSVSConfigurationType(spec, build_file) - msvs_attributes = _GetMSVSAttributes(spec, config, config_type) - msbuild_attributes = {} - for a in msvs_attributes: - if a in ['IntermediateDirectory', 'OutputDirectory']: - directory = MSVSSettings.ConvertVCMacrosToMSBuild(msvs_attributes[a]) - if not directory.endswith('\\'): - directory += '\\' - msbuild_attributes[a] = directory - elif a == 'CharacterSet': - msbuild_attributes[a] = { - '0': 'MultiByte', - '1': 'Unicode' - }[msvs_attributes[a]] - elif a == 'ConfigurationType': - msbuild_attributes[a] = { - '1': 'Application', - '2': 'DynamicLibrary', - '4': 'StaticLibrary', - '10': 'Utility' - }[msvs_attributes[a]] - else: - print 'Warning: Do not know how to convert MSVS attribute ' + a - return msbuild_attributes - - -def _GetMSBuildConfigurationGlobalProperties(spec, configurations, build_file): - # TODO(jeanluc) We could optimize out the following and do it only if - # there are actions. - # TODO(jeanluc) Handle the equivalent of setting 'CYGWIN=nontsec'. - new_paths = [] - cygwin_dirs = spec.get('msvs_cygwin_dirs', ['.'])[0] - if cygwin_dirs: - cyg_path = '$(MSBuildProjectDirectory)\\%s\\bin\\' % _FixPath(cygwin_dirs) - new_paths.append(cyg_path) - # TODO(jeanluc) Change the convention to have both a cygwin_dir and a - # python_dir. - python_path = cyg_path.replace('cygwin\\bin', 'python_26') - new_paths.append(python_path) - if new_paths: - new_paths = '$(ExecutablePath);' + ';'.join(new_paths) - - properties = {} - for (name, configuration) in sorted(configurations.iteritems()): - condition = _GetConfigurationCondition(name, configuration) - attributes = _GetMSBuildAttributes(spec, configuration, build_file) - msbuild_settings = configuration['finalized_msbuild_settings'] - _AddConditionalProperty(properties, condition, 'IntDir', - attributes['IntermediateDirectory']) - _AddConditionalProperty(properties, condition, 'OutDir', - attributes['OutputDirectory']) - if new_paths: - _AddConditionalProperty(properties, condition, 'ExecutablePath', - new_paths) - tool_settings = msbuild_settings.get('', {}) - for name, value in sorted(tool_settings.iteritems()): - formatted_value = _GetValueFormattedForMSBuild('', name, value) - _AddConditionalProperty(properties, condition, name, formatted_value) - return _GetMSBuildPropertyGroup(spec, None, properties) - - -def _AddConditionalProperty(properties, condition, name, value): - """Adds a property / conditional value pair to a dictionary. - - Arguments: - properties: The dictionary to be modified. The key is the name of the - property. The value is itself a dictionary; its key is the value and - the value a list of condition for which this value is true. - condition: The condition under which the named property has the value. - name: The name of the property. - value: The value of the property. - """ - if name not in properties: - properties[name] = {} - values = properties[name] - if value not in values: - values[value] = [] - conditions = values[value] - conditions.append(condition) - - -def _GetMSBuildPropertyGroup(spec, label, properties): - """Returns a PropertyGroup definition for the specified properties. - - Arguments: - spec: The target project dict. - label: An optional label for the PropertyGroup. - properties: The dictionary to be converted. The key is the name of the - property. The value is itself a dictionary; its key is the value and - the value a list of condition for which this value is true. - """ - group = ['PropertyGroup'] - if label: - group.append({'Label': label}) - num_configurations = len(spec['configurations']) - for name, values in sorted(properties.iteritems()): - for value, conditions in sorted(values.iteritems()): - if len(conditions) == num_configurations: - # If the value is the same all configurations, - # just add one unconditional entry. - group.append([name, value]) - else: - for condition in conditions: - group.append([name, {'Condition': condition}, value]) - return [group] - - -def _GetMSBuildToolSettingsSections(spec, configurations): - groups = [] - for (name, configuration) in sorted(configurations.iteritems()): - msbuild_settings = configuration['finalized_msbuild_settings'] - group = ['ItemDefinitionGroup', - {'Condition': _GetConfigurationCondition(name, configuration)} - ] - for tool_name, tool_settings in sorted(msbuild_settings.iteritems()): - # Skip the tool named '' which is a holder of global settings handled - # by _GetMSBuildConfigurationGlobalProperties. - if tool_name: - if tool_settings: - tool = [tool_name] - for name, value in sorted(tool_settings.iteritems()): - formatted_value = _GetValueFormattedForMSBuild(tool_name, name, - value) - tool.append([name, formatted_value]) - group.append(tool) - groups.append(group) - return groups - - -def _FinalizeMSBuildSettings(spec, configuration): - if 'msbuild_settings' in configuration: - converted = False - msbuild_settings = configuration['msbuild_settings'] - MSVSSettings.ValidateMSBuildSettings(msbuild_settings) - else: - converted = True - msvs_settings = configuration.get('msvs_settings', {}) - msbuild_settings = MSVSSettings.ConvertToMSBuildSettings(msvs_settings) - include_dirs, resource_include_dirs = _GetIncludeDirs(configuration) - libraries = _GetLibraries(spec) - out_file, _, msbuild_tool = _GetOutputFilePathAndTool(spec) - defines = _GetDefines(configuration) - if converted: - # Visual Studio 2010 has TR1 - defines = [d for d in defines if d != '_HAS_TR1=0'] - # Warn of ignored settings - ignored_settings = ['msvs_prebuild', 'msvs_postbuild', 'msvs_tool_files'] - for ignored_setting in ignored_settings: - value = configuration.get(ignored_setting) - if value: - print ('Warning: The automatic conversion to MSBuild does not handle ' - '%s. Ignoring setting of %s' % (ignored_setting, str(value))) - - defines = [_EscapeCppDefineForMSBuild(d) for d in defines] - disabled_warnings = _GetDisabledWarnings(configuration) - # TODO(jeanluc) Validate & warn that we don't translate - # prebuild = configuration.get('msvs_prebuild') - # postbuild = configuration.get('msvs_postbuild') - def_file = _GetModuleDefinition(spec) - precompiled_header = configuration.get('msvs_precompiled_header') - - # Add the information to the appropriate tool - # TODO(jeanluc) We could optimize and generate these settings only if - # the corresponding files are found, e.g. don't generate ResourceCompile - # if you don't have any resources. - _ToolAppend(msbuild_settings, 'ClCompile', - 'AdditionalIncludeDirectories', include_dirs) - _ToolAppend(msbuild_settings, 'ResourceCompile', - 'AdditionalIncludeDirectories', resource_include_dirs) - # Add in libraries. - _ToolAppend(msbuild_settings, 'Link', 'AdditionalDependencies', libraries) - if out_file: - _ToolAppend(msbuild_settings, msbuild_tool, 'OutputFile', out_file, - only_if_unset=True) - # Add defines. - _ToolAppend(msbuild_settings, 'ClCompile', - 'PreprocessorDefinitions', defines) - _ToolAppend(msbuild_settings, 'ResourceCompile', - 'PreprocessorDefinitions', defines) - # Add disabled warnings. - _ToolAppend(msbuild_settings, 'ClCompile', - 'DisableSpecificWarnings', disabled_warnings) - # Turn on precompiled headers if appropriate. - if precompiled_header: - precompiled_header = os.path.split(precompiled_header)[1] - _ToolAppend(msbuild_settings, 'ClCompile', 'PrecompiledHeader', 'Use') - _ToolAppend(msbuild_settings, 'ClCompile', - 'PrecompiledHeaderFile', precompiled_header) - _ToolAppend(msbuild_settings, 'ClCompile', - 'ForcedIncludeFiles', precompiled_header) - # Loadable modules don't generate import libraries; - # tell dependent projects to not expect one. - if spec['type'] == 'loadable_module': - _ToolAppend(msbuild_settings, '', 'IgnoreImportLibrary', 'true') - # Set the module definition file if any. - if def_file: - _ToolAppend(msbuild_settings, 'Link', 'ModuleDefinitionFile', def_file) - configuration['finalized_msbuild_settings'] = msbuild_settings - - -def _GetValueFormattedForMSBuild(tool_name, name, value): - if type(value) == list: - # For some settings, VS2010 does not automatically extends the settings - # TODO(jeanluc) Is this what we want? - if name in ['AdditionalDependencies', - 'AdditionalIncludeDirectories', - 'AdditionalLibraryDirectories', - 'AdditionalOptions', - 'DelayLoadDLLs', - 'DisableSpecificWarnings', - 'PreprocessorDefinitions']: - value.append('%%(%s)' % name) - # For most tools, entries in a list should be separated with ';' but some - # settings use a space. Check for those first. - exceptions = { - 'ClCompile': ['AdditionalOptions'], - 'Link': ['AdditionalOptions'], - 'Lib': ['AdditionalOptions']} - if tool_name in exceptions and name in exceptions[tool_name]: - char = ' ' - else: - char = ';' - formatted_value = char.join( - [MSVSSettings.ConvertVCMacrosToMSBuild(i) for i in value]) - else: - formatted_value = MSVSSettings.ConvertVCMacrosToMSBuild(value) - return formatted_value - - -def _VerifySourcesExist(sources, root_dir): - """Verifies that all source files exist on disk. - - Checks that all regular source files, i.e. not created at run time, - exist on disk. Missing files cause needless recompilation but no otherwise - visible errors. - - Arguments: - sources: A recursive list of Filter/file names. - root_dir: The root directory for the relative path names. - """ - for source in sources: - if isinstance(source, MSVSProject.Filter): - _VerifySourcesExist(source.contents, root_dir) - else: - if '$' not in source: - full_path = os.path.join(root_dir, source) - if not os.path.exists(full_path): - print 'Error: Missing input file ' + full_path - - -def _GetMSBuildSources(spec, sources, exclusions, extension_to_rule_name, - actions_spec, sources_handled_by_action): - groups = ['none', 'midl', 'include', 'compile', 'resource', 'rule'] - grouped_sources = {} - for g in groups: - grouped_sources[g] = [] - - _AddSources2(spec, sources, exclusions, grouped_sources, - extension_to_rule_name, sources_handled_by_action) - sources = [] - for g in groups: - if grouped_sources[g]: - sources.append(['ItemGroup'] + grouped_sources[g]) - if actions_spec: - sources.append(['ItemGroup'] + actions_spec) - return sources - - -def _AddSources2(spec, sources, exclusions, grouped_sources, - extension_to_rule_name, sources_handled_by_action): - extensions_excluded_from_precompile = [] - for source in sources: - if isinstance(source, MSVSProject.Filter): - _AddSources2(spec, source.contents, exclusions, grouped_sources, - extension_to_rule_name, sources_handled_by_action) - else: - if not source in sources_handled_by_action: - detail = [] - excluded_configurations = exclusions.get(source, []) - if len(excluded_configurations) == len(spec['configurations']): - detail.append(['ExcludedFromBuild', 'true']) - else: - for config_name, configuration in sorted(excluded_configurations): - condition = _GetConfigurationCondition(config_name, configuration) - detail.append(['ExcludedFromBuild', - {'Condition': condition}, - 'true']) - # Add precompile if needed - for config_name, configuration in spec['configurations'].iteritems(): - precompiled_source = configuration.get('msvs_precompiled_source', '') - precompiled_source = _FixPath(precompiled_source) - if not extensions_excluded_from_precompile: - # If the precompiled header is generated by a C source, we must - # not try to use it for C++ sources, and vice versa. - basename, extension = os.path.splitext(precompiled_source) - if extension == '.c': - extensions_excluded_from_precompile = ['.cc', '.cpp', '.cxx'] - else: - extensions_excluded_from_precompile = ['.c'] - - if precompiled_source == source: - condition = _GetConfigurationCondition(config_name, configuration) - detail.append(['PrecompiledHeader', - {'Condition': condition}, - 'Create' - ]) - else: - # Turn off precompiled header usage for source files of a - # different type than the file that generated the - # precompiled header. - for extension in extensions_excluded_from_precompile: - if source.endswith(extension): - detail.append(['PrecompiledHeader', '']) - detail.append(['ForcedIncludeFiles', '']) - - group, element = _MapFileToMsBuildSourceType(source, - extension_to_rule_name) - grouped_sources[group].append([element, {'Include': source}] + detail) - - -def _GetMSBuildProjectReferences(project): - references = [] - if project.dependencies: - group = ['ItemGroup'] - for dependency in project.dependencies: - guid = dependency.guid - project_dir = os.path.split(project.path)[0] - relative_path = gyp.common.RelativePath(dependency.path, project_dir) - group.append( - ['ProjectReference', - {'Include': relative_path}, - ['Project', guid], - ['ReferenceOutputAssembly', 'false'] - ]) - references.append(group) - return references - - -def _GenerateMSBuildProject(project, options, version): - spec = project.spec - configurations = spec['configurations'] - gyp_dir, gyp_file_name = os.path.split(project.path) - msbuildproj_dir = os.path.dirname(project.path) - if msbuildproj_dir and not os.path.exists(msbuildproj_dir): - os.makedirs(msbuildproj_dir) - # Prepare list of sources and excluded sources. - gyp_dir = os.path.split(project.path)[0] - gyp_file = posixpath.split(project.build_file)[1] - gyp_path = _NormalizedSource(gyp_file) - relative_path_of_gyp_file = gyp.common.RelativePath(gyp_path, gyp_dir) - - sources, excluded_sources = _PrepareListOfSources(spec, - relative_path_of_gyp_file) - # Add rules. - actions_to_add = {} - props_files_of_rules = set() - targets_files_of_rules = set() - extension_to_rule_name = {} - _GenerateRulesForMSBuild(gyp_dir, options, spec, - sources, excluded_sources, - props_files_of_rules, targets_files_of_rules, - actions_to_add, extension_to_rule_name) - sources, excluded_sources, excluded_idl = ( - _AdjustSourcesAndConvertToFilterHierarchy(spec, options, - gyp_dir, sources, - excluded_sources)) - _AddActions(actions_to_add, spec, project.build_file) - _AddCopies(actions_to_add, spec) - - # NOTE: this stanza must appear after all actions have been decided. - # Don't excluded sources with actions attached, or they won't run. - excluded_sources = _FilterActionsFromExcluded( - excluded_sources, actions_to_add) - - exclusions = _GetExcludedFilesFromBuild(spec, excluded_sources, excluded_idl) - actions_spec, sources_handled_by_action = _GenerateActionsForMSBuild( - spec, actions_to_add) - - _GenerateMSBuildFiltersFile(project.path + '.filters', sources, - extension_to_rule_name) - _VerifySourcesExist(sources, gyp_dir) - - for (_, configuration) in configurations.iteritems(): - _FinalizeMSBuildSettings(spec, configuration) - - # Add attributes to root element - - import_default_section = [ - ['Import', {'Project': r'$(VCTargetsPath)\Microsoft.Cpp.Default.props'}]] - import_cpp_props_section = [ - ['Import', {'Project': r'$(VCTargetsPath)\Microsoft.Cpp.props'}]] - import_cpp_targets_section = [ - ['Import', {'Project': r'$(VCTargetsPath)\Microsoft.Cpp.targets'}]] - macro_section = [['PropertyGroup', {'Label': 'UserMacros'}]] - - content = [ - 'Project', - {'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003', - 'ToolsVersion': version.ProjectVersion(), - 'DefaultTargets': 'Build' - }] - - content += _GetMSBuildProjectConfigurations(configurations) - content += _GetMSBuildGlobalProperties(spec, project.guid, gyp_file_name) - content += import_default_section - content += _GetMSBuildConfigurationDetails(spec, project.build_file) - content += import_cpp_props_section - content += _GetMSBuildExtensions(props_files_of_rules) - content += _GetMSBuildPropertySheets(configurations) - content += macro_section - content += _GetMSBuildConfigurationGlobalProperties(spec, configurations, - project.build_file) - content += _GetMSBuildToolSettingsSections(spec, configurations) - content += _GetMSBuildSources( - spec, sources, exclusions, extension_to_rule_name, actions_spec, - sources_handled_by_action) - content += _GetMSBuildProjectReferences(project) - content += import_cpp_targets_section - content += _GetMSBuildExtensionTargets(targets_files_of_rules) - - # TODO(jeanluc) File a bug to get rid of runas. We had in MSVS: - # has_run_as = _WriteMSVSUserFile(project.path, version, spec) - - easy_xml.WriteXmlIfChanged(content, project.path) - - -def _GetMSBuildExtensions(props_files_of_rules): - extensions = ['ImportGroup', {'Label': 'ExtensionSettings'}] - for props_file in props_files_of_rules: - extensions.append(['Import', {'Project': props_file}]) - return [extensions] - - -def _GetMSBuildExtensionTargets(targets_files_of_rules): - targets_node = ['ImportGroup', {'Label': 'ExtensionTargets'}] - for targets_file in sorted(targets_files_of_rules): - targets_node.append(['Import', {'Project': targets_file}]) - return [targets_node] - - -def _GenerateActionsForMSBuild(spec, actions_to_add): - """Add actions accumulated into an actions_to_add, merging as needed. - - Arguments: - spec: the target project dict - actions_to_add: dictionary keyed on input name, which maps to a list of - dicts describing the actions attached to that input file. - - Returns: - A pair of (action specification, the sources handled by this action). - """ - sources_handled_by_action = set() - actions_spec = [] - for primary_input, actions in actions_to_add.iteritems(): - inputs = set() - outputs = set() - descriptions = [] - commands = [] - for action in actions: - inputs.update(set(action['inputs'])) - outputs.update(set(action['outputs'])) - descriptions.append(action['description']) - cmd = action['command'] - # For most actions, add 'call' so that actions that invoke batch files - # return and continue executing. msbuild_use_call provides a way to - # disable this but I have not seen any adverse effect from doing that - # for everything. - if action.get('msbuild_use_call', True): - cmd = 'call ' + cmd - commands.append(cmd) - # Add the custom build action for one input file. - description = ', and also '.join(descriptions) - command = ' && '.join(commands) - _AddMSBuildAction(spec, - primary_input, - inputs, - outputs, - command, - description, - sources_handled_by_action, - actions_spec) - return actions_spec, sources_handled_by_action - - -def _AddMSBuildAction(spec, primary_input, inputs, outputs, cmd, description, - sources_handled_by_action, actions_spec): - command = MSVSSettings.ConvertVCMacrosToMSBuild(cmd) - primary_input = _FixPath(primary_input) - inputs_array = _FixPaths(inputs) - outputs_array = _FixPaths(outputs) - additional_inputs = ';'.join([i for i in inputs_array - if i != primary_input]) - outputs = ';'.join(outputs_array) - sources_handled_by_action.add(primary_input) - action_spec = ['CustomBuild', {'Include': primary_input}] - action_spec.extend( - # TODO(jeanluc) 'Document' for all or just if as_sources? - [['FileType', 'Document'], - ['Command', command], - ['Message', description], - ['Outputs', outputs] - ]) - if additional_inputs: - action_spec.append(['AdditionalInputs', additional_inputs]) - actions_spec.append(action_spec) diff --git a/third_party/gyp/pylib/gyp/generator/msvs_test.py b/third_party/gyp/pylib/gyp/generator/msvs_test.py deleted file mode 100644 index 60d25ab..0000000 --- a/third_party/gyp/pylib/gyp/generator/msvs_test.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -""" Unit tests for the msvs.py file. """ - -import gyp.generator.msvs as msvs -import unittest -import StringIO - - -class TestSequenceFunctions(unittest.TestCase): - - def setUp(self): - self.stderr = StringIO.StringIO() - - def test_GetLibraries(self): - self.assertEqual( - msvs._GetLibraries({}), - []) - self.assertEqual( - msvs._GetLibraries({'libraries': []}), - []) - self.assertEqual( - msvs._GetLibraries({'other':'foo', 'libraries': ['a.lib']}), - ['a.lib']) - self.assertEqual( - msvs._GetLibraries({'libraries': ['a.lib', 'b.lib', 'c.lib', '-lb.lib', - '-lb.lib', 'd.lib', 'a.lib']}), - ['c.lib', 'b.lib', 'd.lib', 'a.lib']) - -if __name__ == '__main__': - unittest.main() diff --git a/third_party/gyp/pylib/gyp/generator/ninja.py b/third_party/gyp/pylib/gyp/generator/ninja.py deleted file mode 100644 index b63e42c..0000000 --- a/third_party/gyp/pylib/gyp/generator/ninja.py +++ /dev/null @@ -1,713 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import gyp -import gyp.common -import gyp.system_test -import os.path -import pprint -import subprocess -import sys - -import gyp.ninja_syntax as ninja_syntax - -generator_default_variables = { - 'OS': 'linux', - - 'EXECUTABLE_PREFIX': '', - 'EXECUTABLE_SUFFIX': '', - 'STATIC_LIB_PREFIX': '', - 'STATIC_LIB_SUFFIX': '.a', - 'SHARED_LIB_PREFIX': 'lib', - 'SHARED_LIB_SUFFIX': '.so', - - # Gyp expects the following variables to be expandable by the build - # system to the appropriate locations. Ninja prefers paths to be - # known at compile time. To resolve this, introduce special - # variables starting with $! (which begin with a $ so gyp knows it - # should be treated as a path, but is otherwise an invalid - # ninja/shell variable) that are passed to gyp here but expanded - # before writing out into the target .ninja files; see - # ExpandSpecial. - 'INTERMEDIATE_DIR': '$!INTERMEDIATE_DIR', - 'SHARED_INTERMEDIATE_DIR': '$!PRODUCT_DIR/gen', - 'PRODUCT_DIR': '$!PRODUCT_DIR', - 'SHARED_LIB_DIR': '$!PRODUCT_DIR/lib', - 'LIB_DIR': '', - - # Special variables that may be used by gyp 'rule' targets. - # We generate definitions for these variables on the fly when processing a - # rule. - 'RULE_INPUT_ROOT': '$root', - 'RULE_INPUT_PATH': '$source', - 'RULE_INPUT_EXT': '$ext', - 'RULE_INPUT_NAME': '$name', -} - -# TODO: enable cross compiling once we figure out: -# - how to not build extra host objects in the non-cross-compile case. -# - how to decide what the host compiler is (should not just be $cc). -# - need ld_host as well. -generator_supports_multiple_toolsets = False - - -def StripPrefix(arg, prefix): - if arg.startswith(prefix): - return arg[len(prefix):] - return arg - - -def QuoteShellArgument(arg): - return "'" + arg.replace("'", "'" + '"\'"' + "'") + "'" - - -def MaybeQuoteShellArgument(arg): - if '"' in arg or ' ' in arg: - return QuoteShellArgument(arg) - return arg - - -def InvertRelativePath(path): - """Given a relative path like foo/bar, return the inverse relative path: - the path from the relative path back to the origin dir. - - E.g. os.path.normpath(os.path.join(path, InvertRelativePath(path))) - should always produce the empty string.""" - - if not path: - return path - # Only need to handle relative paths into subdirectories for now. - assert '..' not in path, path - depth = len(path.split('/')) - return '/'.join(['..'] * depth) - - -# A small discourse on paths as used within the Ninja build: -# All files we produce (both at gyp and at build time) appear in the -# build directory (e.g. out/Debug). -# -# Paths within a given .gyp file are always relative to the directory -# containing the .gyp file. Call these "gyp paths". This includes -# sources as well as the starting directory a given gyp rule/action -# expects to be run from. We call the path from the source root to -# the gyp file the "base directory" within the per-.gyp-file -# NinjaWriter code. -# -# All paths as written into the .ninja files are relative to the build -# directory. Call these paths "ninja paths". -# -# We translate between these two notions of paths with two helper -# functions: -# -# - GypPathToNinja translates a gyp path (i.e. relative to the .gyp file) -# into the equivalent ninja path. -# -# - GypPathToUniqueOutput translates a gyp path into a ninja path to write -# an output file; the result can be namespaced such that is unique -# to the input file name as well as the output target name. - -class NinjaWriter: - def __init__(self, target_outputs, base_dir, build_dir, output_file): - """ - base_dir: path from source root to directory containing this gyp file, - by gyp semantics, all input paths are relative to this - build_dir: path from source root to build output - """ - - self.target_outputs = target_outputs - self.base_dir = base_dir - self.build_dir = build_dir - self.ninja = ninja_syntax.Writer(output_file) - - # Relative path from build output dir to base dir. - self.build_to_base = os.path.join(InvertRelativePath(build_dir), base_dir) - # Relative path from base dir to build dir. - self.base_to_build = os.path.join(InvertRelativePath(base_dir), build_dir) - - def ExpandSpecial(self, path, product_dir=None): - """Expand specials like $!PRODUCT_DIR in |path|. - - If |product_dir| is None, assumes the cwd is already the product - dir. Otherwise, |product_dir| is the relative path to the product - dir. - """ - - PRODUCT_DIR = '$!PRODUCT_DIR' - if PRODUCT_DIR in path: - if product_dir: - path = path.replace(PRODUCT_DIR, product_dir) - else: - path = path.replace(PRODUCT_DIR + '/', '') - path = path.replace(PRODUCT_DIR, '.') - - INTERMEDIATE_DIR = '$!INTERMEDIATE_DIR' - if INTERMEDIATE_DIR in path: - int_dir = self.GypPathToUniqueOutput('gen') - # GypPathToUniqueOutput generates a path relative to the product dir, - # so insert product_dir in front if it is provided. - path = path.replace(INTERMEDIATE_DIR, - os.path.join(product_dir or '', int_dir)) - - return path - - def GypPathToNinja(self, path): - """Translate a gyp path to a ninja path. - - See the above discourse on path conversions.""" - if path.startswith('$!'): - return self.ExpandSpecial(path) - assert '$' not in path, path - return os.path.normpath(os.path.join(self.build_to_base, path)) - - def GypPathToUniqueOutput(self, path, qualified=True): - """Translate a gyp path to a ninja path for writing output. - - If qualified is True, qualify the resulting filename with the name - of the target. This is necessary when e.g. compiling the same - path twice for two separate output targets. - - See the above discourse on path conversions.""" - - path = self.ExpandSpecial(path) - assert not path.startswith('$'), path - - # Translate the path following this scheme: - # Input: foo/bar.gyp, target targ, references baz/out.o - # Output: obj/foo/baz/targ.out.o (if qualified) - # obj/foo/baz/out.o (otherwise) - # (and obj.host instead of obj for cross-compiles) - # - # Why this scheme and not some other one? - # 1) for a given input, you can compute all derived outputs by matching - # its path, even if the input is brought via a gyp file with '..'. - # 2) simple files like libraries and stamps have a simple filename. - - obj = 'obj' - if self.toolset != 'target': - obj += '.' + self.toolset - - path_dir, path_basename = os.path.split(path) - if qualified: - path_basename = self.name + '.' + path_basename - return os.path.normpath(os.path.join(obj, self.base_dir, path_dir, - path_basename)) - - def StampPath(self, name): - """Return a path for a stamp file with a particular name. - - Stamp files are used to collapse a dependency on a bunch of files - into a single file.""" - return self.GypPathToUniqueOutput(name + '.stamp') - - def WriteSpec(self, spec, config): - """The main entry point for NinjaWriter: write the build rules for a spec. - - Returns the path to the build output, or None.""" - - if spec['type'] == 'settings': - # TODO: 'settings' is not actually part of gyp; it was - # accidentally introduced somehow into just the Linux build files. - return None - - self.name = spec['target_name'] - self.toolset = spec['toolset'] - - # Compute predepends for all rules. - # prebuild is the dependencies this target depends on before - # running any of its internal steps. - prebuild = [] - if 'dependencies' in spec: - prebuild_deps = [] - for dep in spec['dependencies']: - if dep in self.target_outputs: - prebuild_deps.append(self.target_outputs[dep][0]) - if prebuild_deps: - stamp = self.StampPath('predepends') - prebuild = self.ninja.build(stamp, 'stamp', prebuild_deps) - self.ninja.newline() - - # Write out actions, rules, and copies. These must happen before we - # compile any sources, so compute a list of predependencies for sources - # while we do it. - extra_sources = [] - sources_predepends = self.WriteActionsRulesCopies(spec, extra_sources, - prebuild) - - # Write out the compilation steps, if any. - link_deps = [] - sources = spec.get('sources', []) + extra_sources - if sources: - link_deps = self.WriteSources(config, sources, - sources_predepends or prebuild) - # Some actions/rules output 'sources' that are already object files. - link_deps += [self.GypPathToNinja(f) for f in sources if f.endswith('.o')] - - # The final output of our target depends on the last output of the - # above steps. - output = None - final_deps = link_deps or sources_predepends or prebuild - if final_deps: - output = self.WriteTarget(spec, config, final_deps) - if self.name != output and self.toolset == 'target': - # Write a short name to build this target. This benefits both the - # "build chrome" case as well as the gyp tests, which expect to be - # able to run actions and build libraries by their short name. - self.ninja.build(self.name, 'phony', output) - return output - - def WriteActionsRulesCopies(self, spec, extra_sources, prebuild): - """Write out the Actions, Rules, and Copies steps. Return any outputs - of these steps (or a stamp file if there are lots of outputs).""" - outputs = [] - - if 'actions' in spec: - outputs += self.WriteActions(spec['actions'], extra_sources, prebuild) - if 'rules' in spec: - outputs += self.WriteRules(spec['rules'], extra_sources, prebuild) - if 'copies' in spec: - outputs += self.WriteCopies(spec['copies'], prebuild) - - # To simplify downstream build edges, ensure we generate a single - # stamp file that represents the results of all of the above. - if len(outputs) > 1: - stamp = self.StampPath('actions_rules_copies') - outputs = self.ninja.build(stamp, 'stamp', outputs) - - return outputs - - def GenerateDescription(self, verb, message, fallback): - """Generate and return a description of a build step. - - |verb| is the short summary, e.g. ACTION or RULE. - |message| is a hand-written description, or None if not available. - |fallback| is the gyp-level name of the step, usable as a fallback. - """ - if self.toolset != 'target': - verb += '(%s)' % self.toolset - if message: - return '%s %s' % (verb, self.ExpandSpecial(message)) - else: - return '%s %s: %s' % (verb, self.name, fallback) - - def WriteActions(self, actions, extra_sources, prebuild): - all_outputs = [] - for action in actions: - # First write out a rule for the action. - name = action['action_name'] - description = self.GenerateDescription('ACTION', - action.get('message', None), - name) - rule_name = self.WriteNewNinjaRule(name, action['action'], description) - - inputs = [self.GypPathToNinja(i) for i in action['inputs']] - if int(action.get('process_outputs_as_sources', False)): - extra_sources += action['outputs'] - outputs = [self.GypPathToNinja(o) for o in action['outputs']] - - # Then write out an edge using the rule. - self.ninja.build(outputs, rule_name, inputs, - order_only=prebuild) - all_outputs += outputs - - self.ninja.newline() - - return all_outputs - - def WriteRules(self, rules, extra_sources, prebuild): - all_outputs = [] - for rule in rules: - # First write out a rule for the rule action. - name = rule['rule_name'] - args = rule['action'] - description = self.GenerateDescription('RULE', - rule.get('message', None), - '%s $source' % name) - rule_name = self.WriteNewNinjaRule(name, args, description) - - # TODO: if the command references the outputs directly, we should - # simplify it to just use $out. - - # Rules can potentially make use of some special variables which - # must vary per source file. - # Compute the list of variables we'll need to provide. - special_locals = ('source', 'root', 'ext', 'name') - needed_variables = set(['source']) - for argument in args: - for var in special_locals: - if '$' + var in argument: - needed_variables.add(var) - - # For each source file, write an edge that generates all the outputs. - for source in rule.get('rule_sources', []): - basename = os.path.basename(source) - root, ext = os.path.splitext(basename) - - # Gather the list of outputs, expanding $vars if possible. - outputs = [] - for output in rule['outputs']: - outputs.append(output.replace('$root', root)) - - if int(rule.get('process_outputs_as_sources', False)): - extra_sources += outputs - - extra_bindings = [] - for var in needed_variables: - if var == 'root': - extra_bindings.append(('root', root)) - elif var == 'source': - # '$source' is a parameter to the rule action, which means - # it shouldn't be converted to a Ninja path. But we don't - # want $!PRODUCT_DIR in there either. - source_expanded = self.ExpandSpecial(source, self.base_to_build) - extra_bindings.append(('source', source_expanded)) - elif var == 'ext': - extra_bindings.append(('ext', ext)) - elif var == 'name': - extra_bindings.append(('name', basename)) - else: - assert var == None, repr(var) - - inputs = map(self.GypPathToNinja, rule.get('inputs', [])) - outputs = map(self.GypPathToNinja, outputs) - self.ninja.build(outputs, rule_name, self.GypPathToNinja(source), - implicit=inputs, - order_only=prebuild, - variables=extra_bindings) - - all_outputs.extend(outputs) - - return all_outputs - - def WriteCopies(self, copies, prebuild): - outputs = [] - for copy in copies: - for path in copy['files']: - # Normalize the path so trailing slashes don't confuse us. - path = os.path.normpath(path) - basename = os.path.split(path)[1] - src = self.GypPathToNinja(path) - dst = self.GypPathToNinja(os.path.join(copy['destination'], basename)) - outputs += self.ninja.build(dst, 'copy', src, - order_only=prebuild) - - return outputs - - def WriteSources(self, config, sources, predepends): - """Write build rules to compile all of |sources|.""" - if self.toolset == 'host': - self.ninja.variable('cc', '$cc_host') - self.ninja.variable('cxx', '$cxx_host') - - self.WriteVariableList('defines', - ['-D' + MaybeQuoteShellArgument(ninja_syntax.escape(d)) - for d in config.get('defines', [])]) - self.WriteVariableList('includes', - ['-I' + self.GypPathToNinja(i) - for i in config.get('include_dirs', [])]) - self.WriteVariableList('cflags', config.get('cflags')) - self.WriteVariableList('cflags_c', config.get('cflags_c')) - self.WriteVariableList('cflags_cc', config.get('cflags_cc')) - self.ninja.newline() - outputs = [] - for source in sources: - filename, ext = os.path.splitext(source) - ext = ext[1:] - if ext in ('cc', 'cpp', 'cxx'): - command = 'cxx' - elif ext in ('c', 's', 'S'): - command = 'cc' - else: - # TODO: should we assert here on unexpected extensions? - continue - input = self.GypPathToNinja(source) - output = self.GypPathToUniqueOutput(filename + '.o') - self.ninja.build(output, command, input, - order_only=predepends) - outputs.append(output) - self.ninja.newline() - return outputs - - def WriteTarget(self, spec, config, final_deps): - if spec['type'] == 'none': - # This target doesn't have any explicit final output, but is instead - # used for its effects before the final output (e.g. copies steps). - # Reuse the existing output if it's easy. - if len(final_deps) == 1: - return final_deps[0] - # Otherwise, fall through to writing out a stamp file. - - output = self.ComputeOutput(spec) - - output_uses_linker = spec['type'] in ('executable', 'loadable_module', - 'shared_library') - - implicit_deps = set() - if 'dependencies' in spec: - # Two kinds of dependencies: - # - Linkable dependencies (like a .a or a .so): add them to the link line. - # - Non-linkable dependencies (like a rule that generates a file - # and writes a stamp file): add them to implicit_deps - if output_uses_linker: - extra_deps = set() - for dep in spec['dependencies']: - input, linkable = self.target_outputs.get(dep, (None, False)) - if not input: - continue - if linkable: - extra_deps.add(input) - else: - # TODO: Chrome-specific HACK. Chrome runs this lastchange rule on - # every build, but we don't want to rebuild when it runs. - if 'lastchange' not in input: - implicit_deps.add(input) - final_deps.extend(list(extra_deps)) - command_map = { - 'executable': 'link', - 'static_library': 'alink', - 'loadable_module': 'solink', - 'shared_library': 'solink', - 'none': 'stamp', - } - command = command_map[spec['type']] - - if output_uses_linker: - self.WriteVariableList('ldflags', - gyp.common.uniquer(map(self.ExpandSpecial, - config.get('ldflags', [])))) - self.WriteVariableList('libs', - gyp.common.uniquer(map(self.ExpandSpecial, - spec.get('libraries', [])))) - - extra_bindings = [] - if command == 'solink': - extra_bindings.append(('soname', os.path.split(output)[1])) - - self.ninja.build(output, command, final_deps, - implicit=list(implicit_deps), - variables=extra_bindings) - - return output - - def ComputeOutputFileName(self, spec): - """Compute the filename of the final output for the current target.""" - - # Compute filename prefix: the product prefix, or a default for - # the product type. - DEFAULT_PREFIX = { - 'loadable_module': 'lib', - 'shared_library': 'lib', - } - prefix = spec.get('product_prefix', DEFAULT_PREFIX.get(spec['type'], '')) - - # Compute filename extension: the product extension, or a default - # for the product type. - DEFAULT_EXTENSION = { - 'static_library': 'a', - 'loadable_module': 'so', - 'shared_library': 'so', - } - extension = spec.get('product_extension', - DEFAULT_EXTENSION.get(spec['type'], '')) - if extension: - extension = '.' + extension - - if 'product_name' in spec: - # If we were given an explicit name, use that. - target = spec['product_name'] - else: - # Otherwise, derive a name from the target name. - target = spec['target_name'] - if prefix == 'lib': - # Snip out an extra 'lib' from libs if appropriate. - target = StripPrefix(target, 'lib') - - if spec['type'] in ('static_library', 'loadable_module', 'shared_library', - 'executable'): - return '%s%s%s' % (prefix, target, extension) - elif spec['type'] == 'none': - return '%s.stamp' % target - elif spec['type'] == 'settings': - return None - else: - raise 'Unhandled output type', spec['type'] - - def ComputeOutput(self, spec): - """Compute the path for the final output of the spec.""" - - filename = self.ComputeOutputFileName(spec) - - if 'product_dir' in spec: - path = os.path.join(spec['product_dir'], filename) - return self.ExpandSpecial(path) - - # Executables and loadable modules go into the output root, - # libraries go into shared library dir, and everything else - # goes into the normal place. - if spec['type'] in ('executable', 'loadable_module'): - return filename - elif spec['type'] == 'shared_library': - libdir = 'lib' - if self.toolset != 'target': - libdir = 'lib/%s' % self.toolset - return os.path.join(libdir, filename) - else: - return self.GypPathToUniqueOutput(filename, qualified=False) - - def WriteVariableList(self, var, values): - if values is None: - values = [] - self.ninja.variable(var, ' '.join(values)) - - def WriteNewNinjaRule(self, name, args, description): - """Write out a new ninja "rule" statement for a given command. - - Returns the name of the new rule.""" - - # TODO: we shouldn't need to qualify names; we do it because - # currently the ninja rule namespace is global, but it really - # should be scoped to the subninja. - rule_name = self.name - if self.toolset == 'target': - rule_name += '.' + self.toolset - rule_name += '.' + name - rule_name = rule_name.replace(' ', '_') - - args = args[:] - - # gyp dictates that commands are run from the base directory. - # cd into the directory before running, and adjust paths in - # the arguments to point to the proper locations. - cd = 'cd %s; ' % self.build_to_base - args = [self.ExpandSpecial(arg, self.base_to_build) for arg in args] - - command = cd + gyp.common.EncodePOSIXShellList(args) - self.ninja.rule(rule_name, command, description) - self.ninja.newline() - - return rule_name - - -def CalculateVariables(default_variables, params): - """Calculate additional variables for use in the build (called by gyp).""" - cc_target = os.environ.get('CC.target', os.environ.get('CC', 'cc')) - default_variables['LINKER_SUPPORTS_ICF'] = \ - gyp.system_test.TestLinkerSupportsICF(cc_command=cc_target) - - -def OpenOutput(path): - """Open |path| for writing, creating directories if necessary.""" - try: - os.makedirs(os.path.dirname(path)) - except OSError: - pass - return open(path, 'w') - - -def GenerateOutput(target_list, target_dicts, data, params): - options = params['options'] - generator_flags = params.get('generator_flags', {}) - - if options.generator_output: - raise NotImplementedError, "--generator_output not implemented for ninja" - - config_name = generator_flags.get('config', None) - if config_name is None: - # Guess which config we want to use: pick the first one from the - # first target. - config_name = target_dicts[target_list[0]]['default_configuration'] - - # builddir: relative path from source root to our output files. - # e.g. "out/Debug" - builddir = os.path.join(generator_flags.get('output_dir', 'out'), config_name) - - master_ninja = ninja_syntax.Writer( - OpenOutput(os.path.join(options.toplevel_dir, builddir, 'build.ninja')), - width=120) - - # TODO: compute cc/cxx/ld/etc. by command-line arguments and system tests. - master_ninja.variable('cc', os.environ.get('CC', 'gcc')) - master_ninja.variable('cxx', os.environ.get('CXX', 'g++')) - master_ninja.variable('ld', '$cxx -Wl,--threads -Wl,--thread-count=4') - master_ninja.variable('cc_host', '$cc') - master_ninja.variable('cxx_host', '$cxx') - master_ninja.newline() - - master_ninja.rule( - 'cc', - description='CC $out', - command=('$cc -MMD -MF $out.d $defines $includes $cflags $cflags_c ' - '-c $in -o $out'), - depfile='$out.d') - master_ninja.rule( - 'cxx', - description='CXX $out', - command=('$cxx -MMD -MF $out.d $defines $includes $cflags $cflags_cc ' - '-c $in -o $out'), - depfile='$out.d') - master_ninja.rule( - 'alink', - description='AR $out', - command='rm -f $out && ar rcsT $out $in') - master_ninja.rule( - 'solink', - description='SOLINK $out', - command=('$ld -shared $ldflags -o $out -Wl,-soname=$soname ' - '-Wl,--whole-archive $in -Wl,--no-whole-archive $libs')) - master_ninja.rule( - 'link', - description='LINK $out', - command=('$ld $ldflags -o $out -Wl,-rpath=\$$ORIGIN/lib ' - '-Wl,--start-group $in -Wl,--end-group $libs')) - master_ninja.rule( - 'stamp', - description='STAMP $out', - command='touch $out') - master_ninja.rule( - 'copy', - description='COPY $in $out', - command='ln -f $in $out 2>/dev/null || cp -af $in $out') - master_ninja.newline() - - all_targets = set() - for build_file in params['build_files']: - for target in gyp.common.AllTargets(target_list, target_dicts, build_file): - all_targets.add(target) - all_outputs = set() - - target_outputs = {} - for qualified_target in target_list: - # qualified_target is like: third_party/icu/icu.gyp:icui18n#target - build_file, name, toolset = \ - gyp.common.ParseQualifiedTarget(qualified_target) - - # TODO: what is options.depth and how is it different than - # options.toplevel_dir? - build_file = gyp.common.RelativePath(build_file, options.depth) - - base_path = os.path.dirname(build_file) - obj = 'obj' - if toolset != 'target': - obj += '.' + toolset - output_file = os.path.join(obj, base_path, name + '.ninja') - spec = target_dicts[qualified_target] - config = spec['configurations'][config_name] - - writer = NinjaWriter(target_outputs, base_path, builddir, - OpenOutput(os.path.join(options.toplevel_dir, - builddir, - output_file))) - master_ninja.subninja(output_file) - - output = writer.WriteSpec(spec, config) - if output: - linkable = spec['type'] in ('static_library', 'shared_library') - target_outputs[qualified_target] = (output, linkable) - - if qualified_target in all_targets: - all_outputs.add(output) - - if all_outputs: - master_ninja.build('all', 'phony', list(all_outputs)) diff --git a/third_party/gyp/pylib/gyp/generator/scons.py b/third_party/gyp/pylib/gyp/generator/scons.py deleted file mode 100644 index 073f9e0..0000000 --- a/third_party/gyp/pylib/gyp/generator/scons.py +++ /dev/null @@ -1,1045 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import gyp -import gyp.common -import gyp.SCons as SCons -import os.path -import pprint -import re - - -# TODO: remove when we delete the last WriteList() call in this module -WriteList = SCons.WriteList - - -generator_default_variables = { - 'EXECUTABLE_PREFIX': '', - 'EXECUTABLE_SUFFIX': '', - 'STATIC_LIB_PREFIX': '${LIBPREFIX}', - 'SHARED_LIB_PREFIX': '${SHLIBPREFIX}', - 'STATIC_LIB_SUFFIX': '${LIBSUFFIX}', - 'SHARED_LIB_SUFFIX': '${SHLIBSUFFIX}', - 'INTERMEDIATE_DIR': '${INTERMEDIATE_DIR}', - 'SHARED_INTERMEDIATE_DIR': '${SHARED_INTERMEDIATE_DIR}', - 'OS': 'linux', - 'PRODUCT_DIR': '$TOP_BUILDDIR', - 'SHARED_LIB_DIR': '$LIB_DIR', - 'LIB_DIR': '$LIB_DIR', - 'RULE_INPUT_ROOT': '${SOURCE.filebase}', - 'RULE_INPUT_EXT': '${SOURCE.suffix}', - 'RULE_INPUT_NAME': '${SOURCE.file}', - 'RULE_INPUT_PATH': '${SOURCE.abspath}', - 'CONFIGURATION_NAME': '${CONFIG_NAME}', -} - -# Tell GYP how to process the input for us. -generator_handles_variants = True -generator_wants_absolute_build_file_paths = True - - -def FixPath(path, prefix): - if not os.path.isabs(path) and not path[0] == '$': - path = prefix + path - return path - - -header = """\ -# This file is generated; do not edit. -""" - - -_alias_template = """ -if GetOption('verbose'): - _action = Action([%(action)s]) -else: - _action = Action([%(action)s], %(message)s) -_outputs = env.Alias( - ['_%(target_name)s_action'], - %(inputs)s, - _action -) -env.AlwaysBuild(_outputs) -""" - -_run_as_template = """ -if GetOption('verbose'): - _action = Action([%(action)s]) -else: - _action = Action([%(action)s], %(message)s) -""" - -_run_as_template_suffix = """ -_run_as_target = env.Alias('run_%(target_name)s', target_files, _action) -env.Requires(_run_as_target, [ - Alias('%(target_name)s'), -]) -env.AlwaysBuild(_run_as_target) -""" - -_command_template = """ -if GetOption('verbose'): - _action = Action([%(action)s]) -else: - _action = Action([%(action)s], %(message)s) -_outputs = env.Command( - %(outputs)s, - %(inputs)s, - _action -) -""" - -# This is copied from the default SCons action, updated to handle symlinks. -_copy_action_template = """ -import shutil -import SCons.Action - -def _copy_files_or_dirs_or_symlinks(dest, src): - SCons.Node.FS.invalidate_node_memos(dest) - if SCons.Util.is_List(src) and os.path.isdir(dest): - for file in src: - shutil.copy2(file, dest) - return 0 - elif os.path.islink(src): - linkto = os.readlink(src) - os.symlink(linkto, dest) - return 0 - elif os.path.isfile(src): - return shutil.copy2(src, dest) - else: - return shutil.copytree(src, dest, 1) - -def _copy_files_or_dirs_or_symlinks_str(dest, src): - return 'Copying %s to %s ...' % (src, dest) - -GYPCopy = SCons.Action.ActionFactory(_copy_files_or_dirs_or_symlinks, - _copy_files_or_dirs_or_symlinks_str, - convert=str) -""" - -_rule_template = """ -%(name)s_additional_inputs = %(inputs)s -%(name)s_outputs = %(outputs)s -def %(name)s_emitter(target, source, env): - return (%(name)s_outputs, source + %(name)s_additional_inputs) -if GetOption('verbose'): - %(name)s_action = Action([%(action)s]) -else: - %(name)s_action = Action([%(action)s], %(message)s) -env['BUILDERS']['%(name)s'] = Builder(action=%(name)s_action, - emitter=%(name)s_emitter) - -_outputs = [] -_processed_input_files = [] -for infile in input_files: - if (type(infile) == type('') - and not os.path.isabs(infile) - and not infile[0] == '$'): - infile = %(src_dir)r + infile - if str(infile).endswith('.%(extension)s'): - _generated = env.%(name)s(infile) - env.Precious(_generated) - _outputs.append(_generated) - %(process_outputs_as_sources_line)s - else: - _processed_input_files.append(infile) -prerequisites.extend(_outputs) -input_files = _processed_input_files -""" - -_spawn_hack = """ -import re -import SCons.Platform.posix -needs_shell = re.compile('["\\'>= 2.5: - return os.sysconf('SC_NPROCESSORS_ONLN') - else: # Mac OS X with Python < 2.5: - return int(os.popen2("sysctl -n hw.ncpu")[1].read()) - # Windows: - if os.environ.has_key('NUMBER_OF_PROCESSORS'): - return max(int(os.environ.get('NUMBER_OF_PROCESSORS', '1')), 1) - return 1 # Default - -# Support PROGRESS= to show progress in different ways. -p = ARGUMENTS.get('PROGRESS') -if p == 'spinner': - Progress(['/\\r', '|\\r', '\\\\\\r', '-\\r'], - interval=5, - file=open('/dev/tty', 'w')) -elif p == 'name': - Progress('$TARGET\\r', overwrite=True, file=open('/dev/tty', 'w')) - -# Set the default -j value based on the number of processors. -SetOption('num_jobs', GetProcessorCount() + 1) - -# Have SCons use its cached dependency information. -SetOption('implicit_cache', 1) - -# Only re-calculate MD5 checksums if a timestamp has changed. -Decider('MD5-timestamp') - -# Since we set the -j value by default, suppress SCons warnings about being -# unable to support parallel build on versions of Python with no threading. -default_warnings = ['no-no-parallel-support'] -SetOption('warn', default_warnings + GetOption('warn')) - -AddOption('--mode', nargs=1, dest='conf_list', default=[], - action='append', help='Configuration to build.') - -AddOption('--verbose', dest='verbose', default=False, - action='store_true', help='Verbose command-line output.') - - -# -sconscript_file_map = %(sconscript_files)s - -class LoadTarget: - ''' - Class for deciding if a given target sconscript is to be included - based on a list of included target names, optionally prefixed with '-' - to exclude a target name. - ''' - def __init__(self, load): - ''' - Initialize a class with a list of names for possible loading. - - Arguments: - load: list of elements in the LOAD= specification - ''' - self.included = set([c for c in load if not c.startswith('-')]) - self.excluded = set([c[1:] for c in load if c.startswith('-')]) - - if not self.included: - self.included = set(['all']) - - def __call__(self, target): - ''' - Returns True if the specified target's sconscript file should be - loaded, based on the initialized included and excluded lists. - ''' - return (target in self.included or - ('all' in self.included and not target in self.excluded)) - -if 'LOAD' in ARGUMENTS: - load = ARGUMENTS['LOAD'].split(',') -else: - load = [] -load_target = LoadTarget(load) - -sconscript_files = [] -for target, sconscript in sconscript_file_map.iteritems(): - if load_target(target): - sconscript_files.append(sconscript) - - -target_alias_list= [] - -conf_list = GetOption('conf_list') -if conf_list: - # In case the same --mode= value was specified multiple times. - conf_list = list(set(conf_list)) -else: - conf_list = [%(default_configuration)r] - -sconsbuild_dir = Dir(%(sconsbuild_dir)s) - - -def FilterOut(self, **kw): - kw = SCons.Environment.copy_non_reserved_keywords(kw) - for key, val in kw.items(): - envval = self.get(key, None) - if envval is None: - # No existing variable in the environment, so nothing to delete. - continue - - for vremove in val: - # Use while not if, so we can handle duplicates. - while vremove in envval: - envval.remove(vremove) - - self[key] = envval - - # TODO(sgk): SCons.Environment.Append() has much more logic to deal - # with various types of values. We should handle all those cases in here - # too. (If variable is a dict, etc.) - - -non_compilable_suffixes = { - 'LINUX' : set([ - '.bdic', - '.css', - '.dat', - '.fragment', - '.gperf', - '.h', - '.hh', - '.hpp', - '.html', - '.hxx', - '.idl', - '.in', - '.in0', - '.in1', - '.js', - '.mk', - '.rc', - '.sigs', - '', - ]), - 'WINDOWS' : set([ - '.h', - '.hh', - '.hpp', - '.dat', - '.idl', - '.in', - '.in0', - '.in1', - ]), -} - -def compilable(env, file): - base, ext = os.path.splitext(str(file)) - if ext in non_compilable_suffixes[env['TARGET_PLATFORM']]: - return False - return True - -def compilable_files(env, sources): - return [x for x in sources if compilable(env, x)] - -def GypProgram(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.Program(target, source, *args, **kw) - if env.get('INCREMENTAL'): - env.Precious(result) - return result - -def GypTestProgram(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.Program(target, source, *args, **kw) - if env.get('INCREMENTAL'): - env.Precious(*result) - return result - -def GypLibrary(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.Library(target, source, *args, **kw) - return result - -def GypLoadableModule(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.LoadableModule(target, source, *args, **kw) - return result - -def GypStaticLibrary(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.StaticLibrary(target, source, *args, **kw) - return result - -def GypSharedLibrary(env, target, source, *args, **kw): - source = compilable_files(env, source) - result = env.SharedLibrary(target, source, *args, **kw) - if env.get('INCREMENTAL'): - env.Precious(result) - return result - -def add_gyp_methods(env): - env.AddMethod(GypProgram) - env.AddMethod(GypTestProgram) - env.AddMethod(GypLibrary) - env.AddMethod(GypLoadableModule) - env.AddMethod(GypStaticLibrary) - env.AddMethod(GypSharedLibrary) - - env.AddMethod(FilterOut) - - env.AddMethod(compilable) - - -base_env = Environment( - tools = %(scons_tools)s, - INTERMEDIATE_DIR='$OBJ_DIR/${COMPONENT_NAME}/_${TARGET_NAME}_intermediate', - LIB_DIR='$TOP_BUILDDIR/lib', - OBJ_DIR='$TOP_BUILDDIR/obj', - SCONSBUILD_DIR=sconsbuild_dir.abspath, - SHARED_INTERMEDIATE_DIR='$OBJ_DIR/_global_intermediate', - SRC_DIR=Dir(%(src_dir)r), - TARGET_PLATFORM='LINUX', - TOP_BUILDDIR='$SCONSBUILD_DIR/$CONFIG_NAME', - LIBPATH=['$LIB_DIR'], -) - -if not GetOption('verbose'): - base_env.SetDefault( - ARCOMSTR='Creating library $TARGET', - ASCOMSTR='Assembling $TARGET', - CCCOMSTR='Compiling $TARGET', - CONCATSOURCECOMSTR='ConcatSource $TARGET', - CXXCOMSTR='Compiling $TARGET', - LDMODULECOMSTR='Building loadable module $TARGET', - LINKCOMSTR='Linking $TARGET', - MANIFESTCOMSTR='Updating manifest for $TARGET', - MIDLCOMSTR='Compiling IDL $TARGET', - PCHCOMSTR='Precompiling $TARGET', - RANLIBCOMSTR='Indexing $TARGET', - RCCOMSTR='Compiling resource $TARGET', - SHCCCOMSTR='Compiling $TARGET', - SHCXXCOMSTR='Compiling $TARGET', - SHLINKCOMSTR='Linking $TARGET', - SHMANIFESTCOMSTR='Updating manifest for $TARGET', - ) - -add_gyp_methods(base_env) - -for conf in conf_list: - env = base_env.Clone(CONFIG_NAME=conf) - SConsignFile(env.File('$TOP_BUILDDIR/.sconsign').abspath) - for sconscript in sconscript_files: - target_alias = env.SConscript(sconscript, exports=['env']) - if target_alias: - target_alias_list.extend(target_alias) - -Default(Alias('all', target_alias_list)) - -help_fmt = ''' -Usage: hammer [SCONS_OPTIONS] [VARIABLES] [TARGET] ... - -Local command-line build options: - --mode=CONFIG Configuration to build: - --mode=Debug [default] - --mode=Release - --verbose Print actual executed command lines. - -Supported command-line build variables: - LOAD=[module,...] Comma-separated list of components to load in the - dependency graph ('-' prefix excludes) - PROGRESS=type Display a progress indicator: - name: print each evaluated target name - spinner: print a spinner every 5 targets - -The following TARGET names can also be used as LOAD= module names: - -%%s -''' - -if GetOption('help'): - def columnar_text(items, width=78, indent=2, sep=2): - result = [] - colwidth = max(map(len, items)) + sep - cols = (width - indent) / colwidth - if cols < 1: - cols = 1 - rows = (len(items) + cols - 1) / cols - indent = '%%*s' %% (indent, '') - sep = indent - for row in xrange(0, rows): - result.append(sep) - for i in xrange(row, len(items), rows): - result.append('%%-*s' %% (colwidth, items[i])) - sep = '\\n' + indent - result.append('\\n') - return ''.join(result) - - load_list = set(sconscript_file_map.keys()) - target_aliases = set(map(str, target_alias_list)) - - common = load_list and target_aliases - load_only = load_list - common - target_only = target_aliases - common - help_text = [help_fmt %% columnar_text(sorted(list(common)))] - if target_only: - fmt = "The following are additional TARGET names:\\n\\n%%s\\n" - help_text.append(fmt %% columnar_text(sorted(list(target_only)))) - if load_only: - fmt = "The following are additional LOAD= module names:\\n\\n%%s\\n" - help_text.append(fmt %% columnar_text(sorted(list(load_only)))) - Help(''.join(help_text)) -""" - -# TEMPLATE END -############################################################################# - - -def GenerateSConscriptWrapper(build_file, build_file_data, name, - output_filename, sconscript_files, - default_configuration): - """ - Generates the "wrapper" SConscript file (analogous to the Visual Studio - solution) that calls all the individual target SConscript files. - """ - output_dir = os.path.dirname(output_filename) - src_dir = build_file_data['_DEPTH'] - src_dir_rel = gyp.common.RelativePath(src_dir, output_dir) - if not src_dir_rel: - src_dir_rel = '.' - scons_settings = build_file_data.get('scons_settings', {}) - sconsbuild_dir = scons_settings.get('sconsbuild_dir', '#') - scons_tools = scons_settings.get('tools', ['default']) - - sconscript_file_lines = ['dict('] - for target in sorted(sconscript_files.keys()): - sconscript = sconscript_files[target] - sconscript_file_lines.append(' %s = %r,' % (target, sconscript)) - sconscript_file_lines.append(')') - - fp = open(output_filename, 'w') - fp.write(header) - fp.write(_wrapper_template % { - 'default_configuration' : default_configuration, - 'name' : name, - 'scons_tools' : repr(scons_tools), - 'sconsbuild_dir' : repr(sconsbuild_dir), - 'sconscript_files' : '\n'.join(sconscript_file_lines), - 'src_dir' : src_dir_rel, - }) - fp.close() - - # Generate the SConstruct file that invokes the wrapper SConscript. - dir, fname = os.path.split(output_filename) - SConstruct = os.path.join(dir, 'SConstruct') - fp = open(SConstruct, 'w') - fp.write(header) - fp.write('SConscript(%s)\n' % repr(fname)) - fp.close() - - -def TargetFilename(target, build_file=None, output_suffix=''): - """Returns the .scons file name for the specified target. - """ - if build_file is None: - build_file, target = gyp.common.ParseQualifiedTarget(target)[:2] - output_file = os.path.join(os.path.dirname(build_file), - target + output_suffix + '.scons') - return output_file - - -def GenerateOutput(target_list, target_dicts, data, params): - """ - Generates all the output files for the specified targets. - """ - options = params['options'] - - if options.generator_output: - def output_path(filename): - return filename.replace(params['cwd'], options.generator_output) - else: - def output_path(filename): - return filename - - default_configuration = None - - for qualified_target in target_list: - spec = target_dicts[qualified_target] - if spec['toolset'] != 'target': - raise Exception( - 'Multiple toolsets not supported in scons build (target %s)' % - qualified_target) - scons_target = SCons.Target(spec) - if scons_target.is_ignored: - continue - - # TODO: assumes the default_configuration of the first target - # non-Default target is the correct default for all targets. - # Need a better model for handle variation between targets. - if (not default_configuration and - spec['default_configuration'] != 'Default'): - default_configuration = spec['default_configuration'] - - build_file, target = gyp.common.ParseQualifiedTarget(qualified_target)[:2] - output_file = TargetFilename(target, build_file, options.suffix) - if options.generator_output: - output_file = output_path(output_file) - - if not spec.has_key('libraries'): - spec['libraries'] = [] - - # Add dependent static library targets to the 'libraries' value. - deps = spec.get('dependencies', []) - spec['scons_dependencies'] = [] - for d in deps: - td = target_dicts[d] - target_name = td['target_name'] - spec['scons_dependencies'].append("Alias('%s')" % target_name) - if td['type'] in ('static_library', 'shared_library'): - libname = td.get('product_name', target_name) - spec['libraries'].append('lib' + libname) - if td['type'] == 'loadable_module': - prereqs = spec.get('scons_prerequisites', []) - # TODO: parameterize with <(SHARED_LIBRARY_*) variables? - td_target = SCons.Target(td) - td_target.target_prefix = '${SHLIBPREFIX}' - td_target.target_suffix = '${SHLIBSUFFIX}' - - GenerateSConscript(output_file, spec, build_file, data[build_file]) - - if not default_configuration: - default_configuration = 'Default' - - for build_file in sorted(data.keys()): - path, ext = os.path.splitext(build_file) - if ext != '.gyp': - continue - output_dir, basename = os.path.split(path) - output_filename = path + '_main' + options.suffix + '.scons' - - all_targets = gyp.common.AllTargets(target_list, target_dicts, build_file) - sconscript_files = {} - for t in all_targets: - scons_target = SCons.Target(target_dicts[t]) - if scons_target.is_ignored: - continue - bf, target = gyp.common.ParseQualifiedTarget(t)[:2] - target_filename = TargetFilename(target, bf, options.suffix) - tpath = gyp.common.RelativePath(target_filename, output_dir) - sconscript_files[target] = tpath - - output_filename = output_path(output_filename) - if sconscript_files: - GenerateSConscriptWrapper(build_file, data[build_file], basename, - output_filename, sconscript_files, - default_configuration) diff --git a/third_party/gyp/pylib/gyp/generator/xcode.py b/third_party/gyp/pylib/gyp/generator/xcode.py deleted file mode 100644 index 0429b80..0000000 --- a/third_party/gyp/pylib/gyp/generator/xcode.py +++ /dev/null @@ -1,1204 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import filecmp -import gyp.common -import gyp.xcodeproj_file -import errno -import os -import posixpath -import re -import shutil -import subprocess -import tempfile - - -# Project files generated by this module will use _intermediate_var as a -# custom Xcode setting whose value is a DerivedSources-like directory that's -# project-specific and configuration-specific. The normal choice, -# DERIVED_FILE_DIR, is target-specific, which is thought to be too restrictive -# as it is likely that multiple targets within a single project file will want -# to access the same set of generated files. The other option, -# PROJECT_DERIVED_FILE_DIR, is unsuitable because while it is project-specific, -# it is not configuration-specific. INTERMEDIATE_DIR is defined as -# $(PROJECT_DERIVED_FILE_DIR)/$(CONFIGURATION). -_intermediate_var = 'INTERMEDIATE_DIR' - -# SHARED_INTERMEDIATE_DIR is the same, except that it is shared among all -# targets that share the same BUILT_PRODUCTS_DIR. -_shared_intermediate_var = 'SHARED_INTERMEDIATE_DIR' - -_library_search_paths_var = 'LIBRARY_SEARCH_PATHS' - -generator_default_variables = { - 'EXECUTABLE_PREFIX': '', - 'EXECUTABLE_SUFFIX': '', - 'STATIC_LIB_PREFIX': 'lib', - 'SHARED_LIB_PREFIX': 'lib', - 'STATIC_LIB_SUFFIX': '.a', - 'SHARED_LIB_SUFFIX': '.dylib', - # INTERMEDIATE_DIR is a place for targets to build up intermediate products. - # It is specific to each build environment. It is only guaranteed to exist - # and be constant within the context of a project, corresponding to a single - # input file. Some build environments may allow their intermediate directory - # to be shared on a wider scale, but this is not guaranteed. - 'INTERMEDIATE_DIR': '$(%s)' % _intermediate_var, - 'OS': 'mac', - 'PRODUCT_DIR': '$(BUILT_PRODUCTS_DIR)', - 'LIB_DIR': '$(BUILT_PRODUCTS_DIR)', - 'RULE_INPUT_ROOT': '$(INPUT_FILE_BASE)', - 'RULE_INPUT_EXT': '$(INPUT_FILE_SUFFIX)', - 'RULE_INPUT_NAME': '$(INPUT_FILE_NAME)', - 'RULE_INPUT_PATH': '$(INPUT_FILE_PATH)', - 'SHARED_INTERMEDIATE_DIR': '$(%s)' % _shared_intermediate_var, - 'CONFIGURATION_NAME': '$(CONFIGURATION)', -} - -# The Xcode-specific sections that hold paths. -generator_additional_path_sections = [ - 'mac_bundle_resources', - 'mac_framework_headers', - 'mac_framework_private_headers', - # 'mac_framework_dirs', input already handles _dirs endings. -] - -# The Xcode-specific keys that exist on targets and aren't moved down to -# configurations. -generator_additional_non_configuration_keys = [ - 'mac_bundle', - 'mac_bundle_resources', - 'mac_framework_headers', - 'mac_framework_private_headers', - 'xcode_create_dependents_test_runner', -] - -# We want to let any rules apply to files that are resources also. -generator_extra_sources_for_rules = [ - 'mac_bundle_resources', - 'mac_framework_headers', - 'mac_framework_private_headers', -] - -# Xcode's standard set of library directories, which don't need to be duplicated -# in LIBRARY_SEARCH_PATHS. This list is not exhaustive, but that's okay. -xcode_standard_library_dirs = frozenset([ - '$(SDKROOT)/usr/lib', - '$(SDKROOT)/usr/local/lib', -]) - -def CreateXCConfigurationList(configuration_names): - xccl = gyp.xcodeproj_file.XCConfigurationList({'buildConfigurations': []}) - if len(configuration_names) == 0: - configuration_names = ['Default'] - for configuration_name in configuration_names: - xcbc = gyp.xcodeproj_file.XCBuildConfiguration({ - 'name': configuration_name}) - xccl.AppendProperty('buildConfigurations', xcbc) - xccl.SetProperty('defaultConfigurationName', configuration_names[0]) - return xccl - - -class XcodeProject(object): - def __init__(self, gyp_path, path, build_file_dict): - self.gyp_path = gyp_path - self.path = path - self.project = gyp.xcodeproj_file.PBXProject(path=path) - projectDirPath = gyp.common.RelativePath( - os.path.dirname(os.path.abspath(self.gyp_path)), - os.path.dirname(path) or '.') - self.project.SetProperty('projectDirPath', projectDirPath) - self.project_file = \ - gyp.xcodeproj_file.XCProjectFile({'rootObject': self.project}) - self.build_file_dict = build_file_dict - - # TODO(mark): add destructor that cleans up self.path if created_dir is - # True and things didn't complete successfully. Or do something even - # better with "try"? - self.created_dir = False - try: - os.makedirs(self.path) - self.created_dir = True - except OSError, e: - if e.errno != errno.EEXIST: - raise - - def Finalize1(self, xcode_targets, serialize_all_tests): - # Collect a list of all of the build configuration names used by the - # various targets in the file. It is very heavily advised to keep each - # target in an entire project (even across multiple project files) using - # the same set of configuration names. - configurations = [] - for xct in self.project.GetProperty('targets'): - xccl = xct.GetProperty('buildConfigurationList') - xcbcs = xccl.GetProperty('buildConfigurations') - for xcbc in xcbcs: - name = xcbc.GetProperty('name') - if name not in configurations: - configurations.append(name) - - # Replace the XCConfigurationList attached to the PBXProject object with - # a new one specifying all of the configuration names used by the various - # targets. - try: - xccl = CreateXCConfigurationList(configurations) - self.project.SetProperty('buildConfigurationList', xccl) - except: - import sys - sys.stderr.write("Problem with gyp file %s\n" % self.gyp_path) - raise - - # The need for this setting is explained above where _intermediate_var is - # defined. The comments below about wanting to avoid project-wide build - # settings apply here too, but this needs to be set on a project-wide basis - # so that files relative to the _intermediate_var setting can be displayed - # properly in the Xcode UI. - # - # Note that for configuration-relative files such as anything relative to - # _intermediate_var, for the purposes of UI tree view display, Xcode will - # only resolve the configuration name once, when the project file is - # opened. If the active build configuration is changed, the project file - # must be closed and reopened if it is desired for the tree view to update. - # This is filed as Apple radar 6588391. - xccl.SetBuildSetting(_intermediate_var, - '$(PROJECT_DERIVED_FILE_DIR)/$(CONFIGURATION)') - xccl.SetBuildSetting(_shared_intermediate_var, - '$(SYMROOT)/DerivedSources/$(CONFIGURATION)') - - # Set user-specified project-wide build settings and config files. This - # is intended to be used very sparingly. Really, almost everything should - # go into target-specific build settings sections. The project-wide - # settings are only intended to be used in cases where Xcode attempts to - # resolve variable references in a project context as opposed to a target - # context, such as when resolving sourceTree references while building up - # the tree tree view for UI display. - # Any values set globally are applied to all configurations, then any - # per-configuration values are applied. - for xck, xcv in self.build_file_dict.get('xcode_settings', {}).iteritems(): - xccl.SetBuildSetting(xck, xcv) - if 'xcode_config_file' in self.build_file_dict: - config_ref = self.project.AddOrGetFileInRootGroup( - self.build_file_dict['xcode_config_file']) - xccl.SetBaseConfiguration(config_ref) - build_file_configurations = self.build_file_dict.get('configurations', {}) - if build_file_configurations: - for config_name in configurations: - build_file_configuration_named = \ - build_file_configurations.get(config_name, {}) - if build_file_configuration_named: - xcc = xccl.ConfigurationNamed(config_name) - for xck, xcv in build_file_configuration_named.get('xcode_settings', - {}).iteritems(): - xcc.SetBuildSetting(xck, xcv) - if 'xcode_config_file' in build_file_configuration_named: - config_ref = self.project.AddOrGetFileInRootGroup( - build_file_configurations[config_name]['xcode_config_file']) - xcc.SetBaseConfiguration(config_ref) - - # Sort the targets based on how they appeared in the input. - # TODO(mark): Like a lot of other things here, this assumes internal - # knowledge of PBXProject - in this case, of its "targets" property. - - # ordinary_targets are ordinary targets that are already in the project - # file. run_test_targets are the targets that run unittests and should be - # used for the Run All Tests target. support_targets are the action/rule - # targets used by GYP file targets, just kept for the assert check. - ordinary_targets = [] - run_test_targets = [] - support_targets = [] - - # targets is full list of targets in the project. - targets = [] - - # does the it define it's own "all"? - has_custom_all = False - - # targets_for_all is the list of ordinary_targets that should be listed - # in this project's "All" target. It includes each non_runtest_target - # that does not have suppress_wildcard set. - targets_for_all = [] - - for target in self.build_file_dict['targets']: - target_name = target['target_name'] - toolset = target['toolset'] - qualified_target = gyp.common.QualifiedTarget(self.gyp_path, target_name, - toolset) - xcode_target = xcode_targets[qualified_target] - # Make sure that the target being added to the sorted list is already in - # the unsorted list. - assert xcode_target in self.project._properties['targets'] - targets.append(xcode_target) - ordinary_targets.append(xcode_target) - if xcode_target.support_target: - support_targets.append(xcode_target.support_target) - targets.append(xcode_target.support_target) - - if not int(target.get('suppress_wildcard', False)): - targets_for_all.append(xcode_target) - - if target_name.lower() == 'all': - has_custom_all = True; - - # If this target has a 'run_as' attribute, add its target to the - # targets, and add it to the test targets. - if target.get('run_as'): - # Make a target to run something. It should have one - # dependency, the parent xcode target. - xccl = CreateXCConfigurationList(configurations) - run_target = gyp.xcodeproj_file.PBXAggregateTarget({ - 'name': 'Run ' + target_name, - 'productName': xcode_target.GetProperty('productName'), - 'buildConfigurationList': xccl, - }, - parent=self.project) - run_target.AddDependency(xcode_target) - - command = target['run_as'] - script = '' - if command.get('working_directory'): - script = script + 'cd "%s"\n' % \ - gyp.xcodeproj_file.ConvertVariablesToShellSyntax( - command.get('working_directory')) - - if command.get('environment'): - script = script + "\n".join( - ['export %s="%s"' % - (key, gyp.xcodeproj_file.ConvertVariablesToShellSyntax(val)) - for (key, val) in command.get('environment').iteritems()]) + "\n" - - # Some test end up using sockets, files on disk, etc. and can get - # confused if more then one test runs at a time. The generator - # flag 'xcode_serialize_all_test_runs' controls the forcing of all - # tests serially. It defaults to True. To get serial runs this - # little bit of python does the same as the linux flock utility to - # make sure only one runs at a time. - command_prefix = '' - if serialize_all_tests: - command_prefix = \ -"""python -c "import fcntl, subprocess, sys -file = open('$TMPDIR/GYP_serialize_test_runs', 'a') -fcntl.flock(file.fileno(), fcntl.LOCK_EX) -sys.exit(subprocess.call(sys.argv[1:]))" """ - - # If we were unable to exec for some reason, we want to exit - # with an error, and fixup variable references to be shell - # syntax instead of xcode syntax. - script = script + 'exec ' + command_prefix + '%s\nexit 1\n' % \ - gyp.xcodeproj_file.ConvertVariablesToShellSyntax( - gyp.common.EncodePOSIXShellList(command.get('action'))) - - ssbp = gyp.xcodeproj_file.PBXShellScriptBuildPhase({ - 'shellScript': script, - 'showEnvVarsInLog': 0, - }) - run_target.AppendProperty('buildPhases', ssbp) - - # Add the run target to the project file. - targets.append(run_target) - run_test_targets.append(run_target) - xcode_target.test_runner = run_target - - - # Make sure that the list of targets being replaced is the same length as - # the one replacing it, but allow for the added test runner targets. - assert len(self.project._properties['targets']) == \ - len(ordinary_targets) + len(support_targets) - - self.project._properties['targets'] = targets - - # Get rid of unnecessary levels of depth in groups like the Source group. - self.project.RootGroupsTakeOverOnlyChildren(True) - - # Sort the groups nicely. Do this after sorting the targets, because the - # Products group is sorted based on the order of the targets. - self.project.SortGroups() - - # Create an "All" target if there's more than one target in this project - # file and the project didn't define its own "All" target. Put a generated - # "All" target first so that people opening up the project for the first - # time will build everything by default. - if len(targets_for_all) > 1 and not has_custom_all: - xccl = CreateXCConfigurationList(configurations) - all_target = gyp.xcodeproj_file.PBXAggregateTarget( - { - 'buildConfigurationList': xccl, - 'name': 'All', - }, - parent=self.project) - - for target in targets_for_all: - all_target.AddDependency(target) - - # TODO(mark): This is evil because it relies on internal knowledge of - # PBXProject._properties. It's important to get the "All" target first, - # though. - self.project._properties['targets'].insert(0, all_target) - - # The same, but for run_test_targets. - if len(run_test_targets) > 1: - xccl = CreateXCConfigurationList(configurations) - run_all_tests_target = gyp.xcodeproj_file.PBXAggregateTarget( - { - 'buildConfigurationList': xccl, - 'name': 'Run All Tests', - }, - parent=self.project) - for run_test_target in run_test_targets: - run_all_tests_target.AddDependency(run_test_target) - - # Insert after the "All" target, which must exist if there is more than - # one run_test_target. - self.project._properties['targets'].insert(1, run_all_tests_target) - - def Finalize2(self, xcode_targets, xcode_target_to_target_dict): - # Finalize2 needs to happen in a separate step because the process of - # updating references to other projects depends on the ordering of targets - # within remote project files. Finalize1 is responsible for sorting duty, - # and once all project files are sorted, Finalize2 can come in and update - # these references. - - # To support making a "test runner" target that will run all the tests - # that are direct dependents of any given target, we look for - # xcode_create_dependents_test_runner being set on an Aggregate target, - # and generate a second target that will run the tests runners found under - # the marked target. - for bf_tgt in self.build_file_dict['targets']: - if int(bf_tgt.get('xcode_create_dependents_test_runner', 0)): - tgt_name = bf_tgt['target_name'] - toolset = bf_tgt['toolset'] - qualified_target = gyp.common.QualifiedTarget(self.gyp_path, - tgt_name, toolset) - xcode_target = xcode_targets[qualified_target] - if isinstance(xcode_target, gyp.xcodeproj_file.PBXAggregateTarget): - # Collect all the run test targets. - all_run_tests = [] - pbxtds = xcode_target.GetProperty('dependencies') - for pbxtd in pbxtds: - pbxcip = pbxtd.GetProperty('targetProxy') - dependency_xct = pbxcip.GetProperty('remoteGlobalIDString') - if hasattr(dependency_xct, 'test_runner'): - all_run_tests.append(dependency_xct.test_runner) - - # Directly depend on all the runners as they depend on the target - # that builds them. - if len(all_run_tests) > 0: - run_all_target = gyp.xcodeproj_file.PBXAggregateTarget({ - 'name': 'Run %s Tests' % tgt_name, - 'productName': tgt_name, - }, - parent=self.project) - for run_test_target in all_run_tests: - run_all_target.AddDependency(run_test_target) - - # Insert the test runner after the related target. - idx = self.project._properties['targets'].index(xcode_target) - self.project._properties['targets'].insert(idx + 1, run_all_target) - - # Update all references to other projects, to make sure that the lists of - # remote products are complete. Otherwise, Xcode will fill them in when - # it opens the project file, which will result in unnecessary diffs. - # TODO(mark): This is evil because it relies on internal knowledge of - # PBXProject._other_pbxprojects. - for other_pbxproject in self.project._other_pbxprojects.keys(): - self.project.AddOrGetProjectReference(other_pbxproject) - - self.project.SortRemoteProductReferences() - - # Give everything an ID. - self.project_file.ComputeIDs() - - # Make sure that no two objects in the project file have the same ID. If - # multiple objects wind up with the same ID, upon loading the file, Xcode - # will only recognize one object (the last one in the file?) and the - # results are unpredictable. - self.project_file.EnsureNoIDCollisions() - - def Write(self): - # Write the project file to a temporary location first. Xcode watches for - # changes to the project file and presents a UI sheet offering to reload - # the project when it does change. However, in some cases, especially when - # multiple projects are open or when Xcode is busy, things don't work so - # seamlessly. Sometimes, Xcode is able to detect that a project file has - # changed but can't unload it because something else is referencing it. - # To mitigate this problem, and to avoid even having Xcode present the UI - # sheet when an open project is rewritten for inconsequential changes, the - # project file is written to a temporary file in the xcodeproj directory - # first. The new temporary file is then compared to the existing project - # file, if any. If they differ, the new file replaces the old; otherwise, - # the new project file is simply deleted. Xcode properly detects a file - # being renamed over an open project file as a change and so it remains - # able to present the "project file changed" sheet under this system. - # Writing to a temporary file first also avoids the possible problem of - # Xcode rereading an incomplete project file. - (output_fd, new_pbxproj_path) = \ - tempfile.mkstemp(suffix='.tmp', prefix='project.pbxproj.gyp.', - dir=self.path) - - try: - output_file = os.fdopen(output_fd, 'wb') - - self.project_file.Print(output_file) - output_file.close() - - pbxproj_path = os.path.join(self.path, 'project.pbxproj') - - same = False - try: - same = filecmp.cmp(pbxproj_path, new_pbxproj_path, False) - except OSError, e: - if e.errno != errno.ENOENT: - raise - - if same: - # The new file is identical to the old one, just get rid of the new - # one. - os.unlink(new_pbxproj_path) - else: - # The new file is different from the old one, or there is no old one. - # Rename the new file to the permanent name. - # - # tempfile.mkstemp uses an overly restrictive mode, resulting in a - # file that can only be read by the owner, regardless of the umask. - # There's no reason to not respect the umask here, which means that - # an extra hoop is required to fetch it and reset the new file's mode. - # - # No way to get the umask without setting a new one? Set a safe one - # and then set it back to the old value. - umask = os.umask(077) - os.umask(umask) - - os.chmod(new_pbxproj_path, 0666 & ~umask) - os.rename(new_pbxproj_path, pbxproj_path) - - except Exception: - # Don't leave turds behind. In fact, if this code was responsible for - # creating the xcodeproj directory, get rid of that too. - os.unlink(new_pbxproj_path) - if self.created_dir: - shutil.rmtree(self.path, True) - raise - - -cached_xcode_version = None -def InstalledXcodeVersion(): - """Fetches the installed version of Xcode, returns empty string if it is - unable to figure it out.""" - - global cached_xcode_version - if not cached_xcode_version is None: - return cached_xcode_version - - # Default to an empty string - cached_xcode_version = '' - - # Collect the xcodebuild's version information. - try: - import subprocess - cmd = ['/usr/bin/xcodebuild', '-version'] - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) - xcodebuild_version_info = proc.communicate()[0] - # Any error, return empty string - if proc.returncode: - xcodebuild_version_info = '' - except OSError: - # We failed to launch the tool - xcodebuild_version_info = '' - - # Pull out the Xcode version itself. - match_line = re.search('^Xcode (.*)$', xcodebuild_version_info, re.MULTILINE) - if match_line: - cached_xcode_version = match_line.group(1) - # Done! - return cached_xcode_version - - -def AddSourceToTarget(source, pbxp, xct): - # TODO(mark): Perhaps source_extensions and library_extensions can be made a - # little bit fancier. - source_extensions = ['c', 'cc', 'cpp', 'cxx', 'm', 'mm', 's'] - - # .o is conceptually more of a "source" than a "library," but Xcode thinks - # of "sources" as things to compile and "libraries" (or "frameworks") as - # things to link with. Adding an object file to an Xcode target's frameworks - # phase works properly. - library_extensions = ['a', 'dylib', 'framework', 'o'] - - basename = posixpath.basename(source) - (root, ext) = posixpath.splitext(basename) - if ext != '': - ext = ext[1:].lower() - - if ext in source_extensions: - xct.SourcesPhase().AddFile(source) - elif ext in library_extensions: - xct.FrameworksPhase().AddFile(source) - else: - # Files that aren't added to a sources or frameworks build phase can still - # go into the project file, just not as part of a build phase. - pbxp.AddOrGetFileInRootGroup(source) - - -def AddResourceToTarget(resource, pbxp, xct): - # TODO(mark): Combine with AddSourceToTarget above? Or just inline this call - # where it's used. - xct.ResourcesPhase().AddFile(resource) - - -def AddHeaderToTarget(header, pbxp, xct, is_public): - # TODO(mark): Combine with AddSourceToTarget above? Or just inline this call - # where it's used. - settings = '{ATTRIBUTES = (%s, ); }' % ('Private', 'Public')[is_public] - xct.HeadersPhase().AddFile(header, settings) - - -_xcode_variable_re = re.compile('(\$\((.*?)\))') -def ExpandXcodeVariables(string, expansions): - """Expands Xcode-style $(VARIABLES) in string per the expansions dict. - - In some rare cases, it is appropriate to expand Xcode variables when a - project file is generated. For any substring $(VAR) in string, if VAR is a - key in the expansions dict, $(VAR) will be replaced with expansions[VAR]. - Any $(VAR) substring in string for which VAR is not a key in the expansions - dict will remain in the returned string. - """ - - matches = _xcode_variable_re.findall(string) - if matches == None: - return string - - matches.reverse() - for match in matches: - (to_replace, variable) = match - if not variable in expansions: - continue - - replacement = expansions[variable] - string = re.sub(re.escape(to_replace), replacement, string) - - return string - - -def EscapeXCodeArgument(s): - """We must escape the arguments that we give to XCode so that it knows not to - split on spaces and to respect backslash and quote literals.""" - s = s.replace('\\', '\\\\') - s = s.replace('"', '\\"') - return '"' + s + '"' - - -def GenerateOutput(target_list, target_dicts, data, params): - options = params['options'] - generator_flags = params.get('generator_flags', {}) - parallel_builds = generator_flags.get('xcode_parallel_builds', True) - serialize_all_tests = \ - generator_flags.get('xcode_serialize_all_test_runs', True) - project_version = generator_flags.get('xcode_project_version', None) - skip_excluded_files = \ - not generator_flags.get('xcode_list_excluded_files', True) - xcode_projects = {} - for build_file, build_file_dict in data.iteritems(): - (build_file_root, build_file_ext) = os.path.splitext(build_file) - if build_file_ext != '.gyp': - continue - xcodeproj_path = build_file_root + options.suffix + '.xcodeproj' - if options.generator_output: - xcodeproj_path = os.path.join(options.generator_output, xcodeproj_path) - xcp = XcodeProject(build_file, xcodeproj_path, build_file_dict) - xcode_projects[build_file] = xcp - pbxp = xcp.project - - if parallel_builds: - pbxp.SetProperty('attributes', - {'BuildIndependentTargetsInParallel': 'YES'}) - if project_version: - xcp.project_file.SetXcodeVersion(project_version) - - main_group = pbxp.GetProperty('mainGroup') - build_group = gyp.xcodeproj_file.PBXGroup({'name': 'Build'}) - main_group.AppendChild(build_group) - for included_file in build_file_dict['included_files']: - build_group.AddOrGetFileByPath(included_file, False) - - xcode_targets = {} - xcode_target_to_target_dict = {} - for qualified_target in target_list: - [build_file, target_name, toolset] = \ - gyp.common.ParseQualifiedTarget(qualified_target) - - spec = target_dicts[qualified_target] - if spec['toolset'] != 'target': - raise Exception( - 'Multiple toolsets not supported in xcode build (target %s)' % - qualified_target) - configuration_names = [spec['default_configuration']] - for configuration_name in sorted(spec['configurations'].keys()): - if configuration_name not in configuration_names: - configuration_names.append(configuration_name) - xcp = xcode_projects[build_file] - pbxp = xcp.project - - # Set up the configurations for the target according to the list of names - # supplied. - xccl = CreateXCConfigurationList(configuration_names) - - # Create an XCTarget subclass object for the target. The type with - # "+bundle" appended will be used if the target has "mac_bundle" set. - # loadable_modules not in a mac_bundle are mapped to - # com.googlecode.gyp.xcode.bundle, a pseudo-type that xcode.py interprets - # to create a single-file mh_bundle. - _types = { - 'executable': 'com.apple.product-type.tool', - 'loadable_module': 'com.googlecode.gyp.xcode.bundle', - 'shared_library': 'com.apple.product-type.library.dynamic', - 'static_library': 'com.apple.product-type.library.static', - 'executable+bundle': 'com.apple.product-type.application', - 'loadable_module+bundle': 'com.apple.product-type.bundle', - 'shared_library+bundle': 'com.apple.product-type.framework', - } - - target_properties = { - 'buildConfigurationList': xccl, - 'name': target_name, - } - - type = spec['type'] - is_bundle = int(spec.get('mac_bundle', 0)) - if type != 'none': - type_bundle_key = type - if is_bundle: - type_bundle_key += '+bundle' - xctarget_type = gyp.xcodeproj_file.PBXNativeTarget - try: - target_properties['productType'] = _types[type_bundle_key] - except KeyError, e: - gyp.common.ExceptionAppend(e, "-- unknown product type while " - "writing target %s" % target_name) - raise - else: - xctarget_type = gyp.xcodeproj_file.PBXAggregateTarget - assert not is_bundle, ( - 'mac_bundle targets cannot have type none (target "%s")' % - target_name) - - target_product_name = spec.get('product_name') - if target_product_name is not None: - target_properties['productName'] = target_product_name - - xct = xctarget_type(target_properties, parent=pbxp, - force_outdir=spec.get('product_dir'), - force_prefix=spec.get('product_prefix'), - force_extension=spec.get('product_extension')) - pbxp.AppendProperty('targets', xct) - xcode_targets[qualified_target] = xct - xcode_target_to_target_dict[xct] = spec - - spec_actions = spec.get('actions', []) - spec_rules = spec.get('rules', []) - - # Xcode has some "issues" with checking dependencies for the "Compile - # sources" step with any source files/headers generated by actions/rules. - # To work around this, if a target is building anything directly (not - # type "none"), then a second target as used to run the GYP actions/rules - # and is made a dependency of this target. This way the work is done - # before the dependency checks for what should be recompiled. - support_xct = None - if type != 'none' and (spec_actions or spec_rules): - support_xccl = CreateXCConfigurationList(configuration_names); - support_target_properties = { - 'buildConfigurationList': support_xccl, - 'name': target_name + ' Support', - } - if target_product_name: - support_target_properties['productName'] = \ - target_product_name + ' Support' - support_xct = \ - gyp.xcodeproj_file.PBXAggregateTarget(support_target_properties, - parent=pbxp) - pbxp.AppendProperty('targets', support_xct) - xct.AddDependency(support_xct) - # Hang the support target off the main target so it can be tested/found - # by the generator during Finalize. - xct.support_target = support_xct - - prebuild_index = 0 - - # Add custom shell script phases for "actions" sections. - for action in spec_actions: - # There's no need to write anything into the script to ensure that the - # output directories already exist, because Xcode will look at the - # declared outputs and automatically ensure that they exist for us. - - # Do we have a message to print when this action runs? - message = action.get('message') - if message: - message = 'echo note: ' + gyp.common.EncodePOSIXShellArgument(message) - else: - message = '' - - # Turn the list into a string that can be passed to a shell. - action_string = gyp.common.EncodePOSIXShellList(action['action']) - - # Convert Xcode-type variable references to sh-compatible environment - # variable references. - message_sh = gyp.xcodeproj_file.ConvertVariablesToShellSyntax(message) - action_string_sh = gyp.xcodeproj_file.ConvertVariablesToShellSyntax( - action_string) - - script = '' - # Include the optional message - if message_sh: - script += message_sh + '\n' - # Be sure the script runs in exec, and that if exec fails, the script - # exits signalling an error. - script += 'exec ' + action_string_sh + '\nexit 1\n' - ssbp = gyp.xcodeproj_file.PBXShellScriptBuildPhase({ - 'inputPaths': action['inputs'], - 'name': 'Action "' + action['action_name'] + '"', - 'outputPaths': action['outputs'], - 'shellScript': script, - 'showEnvVarsInLog': 0, - }) - - if support_xct: - support_xct.AppendProperty('buildPhases', ssbp) - else: - # TODO(mark): this assumes too much knowledge of the internals of - # xcodeproj_file; some of these smarts should move into xcodeproj_file - # itself. - xct._properties['buildPhases'].insert(prebuild_index, ssbp) - prebuild_index = prebuild_index + 1 - - # TODO(mark): Should verify that at most one of these is specified. - if int(action.get('process_outputs_as_sources', False)): - for output in action['outputs']: - AddSourceToTarget(output, pbxp, xct) - - if int(action.get('process_outputs_as_mac_bundle_resources', False)): - for output in action['outputs']: - AddResourceToTarget(output, pbxp, xct) - - # tgt_mac_bundle_resources holds the list of bundle resources so - # the rule processing can check against it. - if is_bundle: - tgt_mac_bundle_resources = spec.get('mac_bundle_resources', []) - else: - tgt_mac_bundle_resources = [] - - # Add custom shell script phases driving "make" for "rules" sections. - # - # Xcode's built-in rule support is almost powerful enough to use directly, - # but there are a few significant deficiencies that render them unusable. - # There are workarounds for some of its inadequacies, but in aggregate, - # the workarounds added complexity to the generator, and some workarounds - # actually require input files to be crafted more carefully than I'd like. - # Consequently, until Xcode rules are made more capable, "rules" input - # sections will be handled in Xcode output by shell script build phases - # performed prior to the compilation phase. - # - # The following problems with Xcode rules were found. The numbers are - # Apple radar IDs. I hope that these shortcomings are addressed, I really - # liked having the rules handled directly in Xcode during the period that - # I was prototyping this. - # - # 6588600 Xcode compiles custom script rule outputs too soon, compilation - # fails. This occurs when rule outputs from distinct inputs are - # interdependent. The only workaround is to put rules and their - # inputs in a separate target from the one that compiles the rule - # outputs. This requires input file cooperation and it means that - # process_outputs_as_sources is unusable. - # 6584932 Need to declare that custom rule outputs should be excluded from - # compilation. A possible workaround is to lie to Xcode about a - # rule's output, giving it a dummy file it doesn't know how to - # compile. The rule action script would need to touch the dummy. - # 6584839 I need a way to declare additional inputs to a custom rule. - # A possible workaround is a shell script phase prior to - # compilation that touches a rule's primary input files if any - # would-be additional inputs are newer than the output. Modifying - # the source tree - even just modification times - feels dirty. - # 6564240 Xcode "custom script" build rules always dump all environment - # variables. This is a low-prioroty problem and is not a - # show-stopper. - rules_by_ext = {} - for rule in spec_rules: - rules_by_ext[rule['extension']] = rule - - # First, some definitions: - # - # A "rule source" is a file that was listed in a target's "sources" - # list and will have a rule applied to it on the basis of matching the - # rule's "extensions" attribute. Rule sources are direct inputs to - # rules. - # - # Rule definitions may specify additional inputs in their "inputs" - # attribute. These additional inputs are used for dependency tracking - # purposes. - # - # A "concrete output" is a rule output with input-dependent variables - # resolved. For example, given a rule with: - # 'extension': 'ext', 'outputs': ['$(INPUT_FILE_BASE).cc'], - # if the target's "sources" list contained "one.ext" and "two.ext", - # the "concrete output" for rule input "two.ext" would be "two.cc". If - # a rule specifies multiple outputs, each input file that the rule is - # applied to will have the same number of concrete outputs. - # - # If any concrete outputs are outdated or missing relative to their - # corresponding rule_source or to any specified additional input, the - # rule action must be performed to generate the concrete outputs. - - # concrete_outputs_by_rule_source will have an item at the same index - # as the rule['rule_sources'] that it corresponds to. Each item is a - # list of all of the concrete outputs for the rule_source. - concrete_outputs_by_rule_source = [] - - # concrete_outputs_all is a flat list of all concrete outputs that this - # rule is able to produce, given the known set of input files - # (rule_sources) that apply to it. - concrete_outputs_all = [] - - # messages & actions are keyed by the same indices as rule['rule_sources'] - # and concrete_outputs_by_rule_source. They contain the message and - # action to perform after resolving input-dependent variables. The - # message is optional, in which case None is stored for each rule source. - messages = [] - actions = [] - - for rule_source in rule.get('rule_sources', []): - rule_source_basename = posixpath.basename(rule_source) - (rule_source_root, rule_source_ext) = \ - posixpath.splitext(rule_source_basename) - - # These are the same variable names that Xcode uses for its own native - # rule support. Because Xcode's rule engine is not being used, they - # need to be expanded as they are written to the makefile. - rule_input_dict = { - 'INPUT_FILE_BASE': rule_source_root, - 'INPUT_FILE_SUFFIX': rule_source_ext, - 'INPUT_FILE_NAME': rule_source_basename, - 'INPUT_FILE_PATH': rule_source, - } - - concrete_outputs_for_this_rule_source = [] - for output in rule.get('outputs', []): - # Fortunately, Xcode and make both use $(VAR) format for their - # variables, so the expansion is the only transformation necessary. - # Any remaning $(VAR)-type variables in the string can be given - # directly to make, which will pick up the correct settings from - # what Xcode puts into the environment. - concrete_output = ExpandXcodeVariables(output, rule_input_dict) - concrete_outputs_for_this_rule_source.append(concrete_output) - - # Add all concrete outputs to the project. - pbxp.AddOrGetFileInRootGroup(concrete_output) - - concrete_outputs_by_rule_source.append( \ - concrete_outputs_for_this_rule_source) - concrete_outputs_all.extend(concrete_outputs_for_this_rule_source) - - # TODO(mark): Should verify that at most one of these is specified. - if int(rule.get('process_outputs_as_sources', False)): - for output in concrete_outputs_for_this_rule_source: - AddSourceToTarget(output, pbxp, xct) - - # If the file came from the mac_bundle_resources list or if the rule - # is marked to process outputs as bundle resource, do so. - was_mac_bundle_resource = rule_source in tgt_mac_bundle_resources - if was_mac_bundle_resource or \ - int(rule.get('process_outputs_as_mac_bundle_resources', False)): - for output in concrete_outputs_for_this_rule_source: - AddResourceToTarget(output, pbxp, xct) - - # Do we have a message to print when this rule runs? - message = rule.get('message') - if message: - message = gyp.common.EncodePOSIXShellArgument(message) - message = ExpandXcodeVariables(message, rule_input_dict) - messages.append(message) - - # Turn the list into a string that can be passed to a shell. - action_string = gyp.common.EncodePOSIXShellList(rule['action']) - - action = ExpandXcodeVariables(action_string, rule_input_dict) - actions.append(action) - - if len(concrete_outputs_all) > 0: - # TODO(mark): There's a possibilty for collision here. Consider - # target "t" rule "A_r" and target "t_A" rule "r". - makefile_name = '%s_%s.make' % (target_name, rule['rule_name']) - makefile_path = os.path.join(xcode_projects[build_file].path, - makefile_name) - # TODO(mark): try/close? Write to a temporary file and swap it only - # if it's got changes? - makefile = open(makefile_path, 'wb') - - # make will build the first target in the makefile by default. By - # convention, it's called "all". List all (or at least one) - # concrete output for each rule source as a prerequisite of the "all" - # target. - makefile.write('all: \\\n') - for concrete_output_index in \ - xrange(0, len(concrete_outputs_by_rule_source)): - # Only list the first (index [0]) concrete output of each input - # in the "all" target. Otherwise, a parallel make (-j > 1) would - # attempt to process each input multiple times simultaneously. - # Otherwise, "all" could just contain the entire list of - # concrete_outputs_all. - concrete_output = \ - concrete_outputs_by_rule_source[concrete_output_index][0] - if concrete_output_index == len(concrete_outputs_by_rule_source) - 1: - eol = '' - else: - eol = ' \\' - makefile.write(' %s%s\n' % (concrete_output, eol)) - - for (rule_source, concrete_outputs, message, action) in \ - zip(rule['rule_sources'], concrete_outputs_by_rule_source, - messages, actions): - makefile.write('\n') - - # Add a rule that declares it can build each concrete output of a - # rule source. Collect the names of the directories that are - # required. - concrete_output_dirs = [] - for concrete_output_index in xrange(0, len(concrete_outputs)): - concrete_output = concrete_outputs[concrete_output_index] - if concrete_output_index == 0: - bol = '' - else: - bol = ' ' - makefile.write('%s%s \\\n' % (bol, concrete_output)) - - concrete_output_dir = posixpath.dirname(concrete_output) - if (concrete_output_dir and - concrete_output_dir not in concrete_output_dirs): - concrete_output_dirs.append(concrete_output_dir) - - makefile.write(' : \\\n') - - # The prerequisites for this rule are the rule source itself and - # the set of additional rule inputs, if any. - prerequisites = [rule_source] - prerequisites.extend(rule.get('inputs', [])) - for prerequisite_index in xrange(0, len(prerequisites)): - prerequisite = prerequisites[prerequisite_index] - if prerequisite_index == len(prerequisites) - 1: - eol = '' - else: - eol = ' \\' - makefile.write(' %s%s\n' % (prerequisite, eol)) - - # Make sure that output directories exist before executing the rule - # action. - if len(concrete_output_dirs) > 0: - makefile.write('\t@mkdir -p "%s"\n' % - '" "'.join(concrete_output_dirs)) - - # The rule message and action have already had the necessary variable - # substitutions performed. - if message: - # Mark it with note: so Xcode picks it up in build output. - makefile.write('\t@echo note: %s\n' % message) - makefile.write('\t%s\n' % action) - - makefile.close() - - # It might be nice to ensure that needed output directories exist - # here rather than in each target in the Makefile, but that wouldn't - # work if there ever was a concrete output that had an input-dependent - # variable anywhere other than in the leaf position. - - # Don't declare any inputPaths or outputPaths. If they're present, - # Xcode will provide a slight optimization by only running the script - # phase if any output is missing or outdated relative to any input. - # Unfortunately, it will also assume that all outputs are touched by - # the script, and if the outputs serve as files in a compilation - # phase, they will be unconditionally rebuilt. Since make might not - # rebuild everything that could be declared here as an output, this - # extra compilation activity is unnecessary. With inputPaths and - # outputPaths not supplied, make will always be called, but it knows - # enough to not do anything when everything is up-to-date. - - # To help speed things up, pass -j COUNT to make so it does some work - # in parallel. Don't use ncpus because Xcode will build ncpus targets - # in parallel and if each target happens to have a rules step, there - # would be ncpus^2 things going. With a machine that has 2 quad-core - # Xeons, a build can quickly run out of processes based on - # scheduling/other tasks, and randomly failing builds are no good. - script = \ -"""JOB_COUNT="$(/usr/sbin/sysctl -n hw.ncpu)" -if [ "${JOB_COUNT}" -gt 4 ]; then - JOB_COUNT=4 -fi -exec "${DEVELOPER_BIN_DIR}/make" -f "${PROJECT_FILE_PATH}/%s" -j "${JOB_COUNT}" -exit 1 -""" % makefile_name - ssbp = gyp.xcodeproj_file.PBXShellScriptBuildPhase({ - 'name': 'Rule "' + rule['rule_name'] + '"', - 'shellScript': script, - 'showEnvVarsInLog': 0, - }) - - if support_xct: - support_xct.AppendProperty('buildPhases', ssbp) - else: - # TODO(mark): this assumes too much knowledge of the internals of - # xcodeproj_file; some of these smarts should move into xcodeproj_file - # itself. - xct._properties['buildPhases'].insert(prebuild_index, ssbp) - prebuild_index = prebuild_index + 1 - - # Extra rule inputs also go into the project file. Concrete outputs were - # already added when they were computed. - groups = ['inputs', 'inputs_excluded'] - if skip_excluded_files: - groups = [x for x in groups if not x.endswith('_excluded')] - for group in groups: - for item in rule.get(group, []): - pbxp.AddOrGetFileInRootGroup(item) - - # Add "sources". - for source in spec.get('sources', []): - (source_root, source_extension) = posixpath.splitext(source) - if source_extension[1:] not in rules_by_ext: - # AddSourceToTarget will add the file to a root group if it's not - # already there. - AddSourceToTarget(source, pbxp, xct) - else: - pbxp.AddOrGetFileInRootGroup(source) - - # Add "mac_bundle_resources", "mac_framework_headers", and - # "mac_framework_private_headers" if it's a bundle of any type. - if is_bundle: - for resource in tgt_mac_bundle_resources: - (resource_root, resource_extension) = posixpath.splitext(resource) - if resource_extension[1:] not in rules_by_ext: - AddResourceToTarget(resource, pbxp, xct) - else: - pbxp.AddOrGetFileInRootGroup(resource) - - for header in spec.get('mac_framework_headers', []): - AddHeaderToTarget(header, pbxp, xct, True) - - for header in spec.get('mac_framework_private_headers', []): - AddHeaderToTarget(header, pbxp, xct, False) - - # Add "copies". - for copy_group in spec.get('copies', []): - pbxcp = gyp.xcodeproj_file.PBXCopyFilesBuildPhase({ - 'name': 'Copy to ' + copy_group['destination'] - }, - parent=xct) - dest = copy_group['destination'] - if dest[0] not in ('/', '$'): - # Relative paths are relative to $(SRCROOT). - dest = '$(SRCROOT)/' + dest - pbxcp.SetDestination(dest) - - # TODO(mark): The usual comment about this knowing too much about - # gyp.xcodeproj_file internals applies. - xct._properties['buildPhases'].insert(prebuild_index, pbxcp) - - for file in copy_group['files']: - pbxcp.AddFile(file) - - # Excluded files can also go into the project file. - if not skip_excluded_files: - for key in ['sources', 'mac_bundle_resources', 'mac_framework_headers', - 'mac_framework_private_headers']: - excluded_key = key + '_excluded' - for item in spec.get(excluded_key, []): - pbxp.AddOrGetFileInRootGroup(item) - - # So can "inputs" and "outputs" sections of "actions" groups. - groups = ['inputs', 'inputs_excluded', 'outputs', 'outputs_excluded'] - if skip_excluded_files: - groups = [x for x in groups if not x.endswith('_excluded')] - for action in spec.get('actions', []): - for group in groups: - for item in action.get(group, []): - # Exclude anything in BUILT_PRODUCTS_DIR. They're products, not - # sources. - if not item.startswith('$(BUILT_PRODUCTS_DIR)/'): - pbxp.AddOrGetFileInRootGroup(item) - - for postbuild in spec.get('postbuilds', []): - action_string_sh = gyp.common.EncodePOSIXShellList(postbuild['action']) - script = 'exec ' + action_string_sh + '\nexit 1\n' - - # Make the postbuild step depend on the output of ld or ar from this - # target. Apparently putting the script step after the link step isn't - # sufficient to ensure proper ordering in all cases. With an input - # declared but no outputs, the script step should run every time, as - # desired. - ssbp = gyp.xcodeproj_file.PBXShellScriptBuildPhase({ - 'inputPaths': ['$(BUILT_PRODUCTS_DIR)/$(EXECUTABLE_PATH)'], - 'name': 'Postbuild "' + postbuild['postbuild_name'] + '"', - 'shellScript': script, - 'showEnvVarsInLog': 0, - }) - xct.AppendProperty('buildPhases', ssbp) - - # Add dependencies before libraries, because adding a dependency may imply - # adding a library. It's preferable to keep dependencies listed first - # during a link phase so that they can override symbols that would - # otherwise be provided by libraries, which will usually include system - # libraries. On some systems, ld is finicky and even requires the - # libraries to be ordered in such a way that unresolved symbols in - # earlier-listed libraries may only be resolved by later-listed libraries. - # The Mac linker doesn't work that way, but other platforms do, and so - # their linker invocations need to be constructed in this way. There's - # no compelling reason for Xcode's linker invocations to differ. - - if 'dependencies' in spec: - for dependency in spec['dependencies']: - xct.AddDependency(xcode_targets[dependency]) - # The support project also gets the dependencies (in case they are - # needed for the actions/rules to work). - if support_xct: - support_xct.AddDependency(xcode_targets[dependency]) - - if 'libraries' in spec: - for library in spec['libraries']: - xct.FrameworksPhase().AddFile(library) - # Add the library's directory to LIBRARY_SEARCH_PATHS if necessary. - # I wish Xcode handled this automatically. - library_dir = posixpath.dirname(library) - if library_dir not in xcode_standard_library_dirs and ( - not xct.HasBuildSetting(_library_search_paths_var) or - library_dir not in xct.GetBuildSetting(_library_search_paths_var)): - xct.AppendBuildSetting(_library_search_paths_var, library_dir) - - for configuration_name in configuration_names: - configuration = spec['configurations'][configuration_name] - xcbc = xct.ConfigurationNamed(configuration_name) - for include_dir in configuration.get('mac_framework_dirs', []): - xcbc.AppendBuildSetting('FRAMEWORK_SEARCH_PATHS', include_dir) - for include_dir in configuration.get('include_dirs', []): - xcbc.AppendBuildSetting('HEADER_SEARCH_PATHS', include_dir) - if 'defines' in configuration: - for define in configuration['defines']: - set_define = EscapeXCodeArgument(define) - xcbc.AppendBuildSetting('GCC_PREPROCESSOR_DEFINITIONS', set_define) - if 'xcode_settings' in configuration: - for xck, xcv in configuration['xcode_settings'].iteritems(): - xcbc.SetBuildSetting(xck, xcv) - if 'xcode_config_file' in configuration: - config_ref = pbxp.AddOrGetFileInRootGroup( - configuration['xcode_config_file']) - xcbc.SetBaseConfiguration(config_ref) - - build_files = [] - for build_file, build_file_dict in data.iteritems(): - if build_file.endswith('.gyp'): - build_files.append(build_file) - - for build_file in build_files: - xcode_projects[build_file].Finalize1(xcode_targets, serialize_all_tests) - - for build_file in build_files: - xcode_projects[build_file].Finalize2(xcode_targets, - xcode_target_to_target_dict) - - for build_file in build_files: - xcode_projects[build_file].Write() diff --git a/third_party/gyp/pylib/gyp/input.py b/third_party/gyp/pylib/gyp/input.py deleted file mode 100644 index d4eeebc..0000000 --- a/third_party/gyp/pylib/gyp/input.py +++ /dev/null @@ -1,2361 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from compiler.ast import Const -from compiler.ast import Dict -from compiler.ast import Discard -from compiler.ast import List -from compiler.ast import Module -from compiler.ast import Node -from compiler.ast import Stmt -import compiler -import copy -import gyp.common -import optparse -import os.path -import re -import shlex -import subprocess -import sys - - -# A list of types that are treated as linkable. -linkable_types = ['executable', 'shared_library', 'loadable_module'] - -# A list of sections that contain links to other targets. -dependency_sections = ['dependencies', 'export_dependent_settings'] - -# base_path_sections is a list of sections defined by GYP that contain -# pathnames. The generators can provide more keys, the two lists are merged -# into path_sections, but you should call IsPathSection instead of using either -# list directly. -base_path_sections = [ - 'destination', - 'files', - 'include_dirs', - 'inputs', - 'libraries', - 'outputs', - 'sources', -] -path_sections = [] - - -def IsPathSection(section): - # If section ends in one of these characters, it's applied to a section - # without the trailing characters. '/' is notably absent from this list, - # because there's no way for a regular expression to be treated as a path. - while section[-1:] in ('=', '+', '?', '!'): - section = section[0:-1] - - if section in path_sections or \ - section.endswith('_dir') or section.endswith('_dirs') or \ - section.endswith('_file') or section.endswith('_files') or \ - section.endswith('_path') or section.endswith('_paths'): - return True - return False - - -# base_non_configuraiton_keys is a list of key names that belong in the target -# itself and should not be propagated into its configurations. It is merged -# with a list that can come from the generator to -# create non_configuration_keys. -base_non_configuration_keys = [ - # Sections that must exist inside targets and not configurations. - 'actions', - 'configurations', - 'copies', - 'default_configuration', - 'dependencies', - 'dependencies_original', - 'link_languages', - 'libraries', - 'postbuilds', - 'product_dir', - 'product_extension', - 'product_name', - 'product_prefix', - 'rules', - 'run_as', - 'sources', - 'suppress_wildcard', - 'target_name', - 'toolset', - 'toolsets', - 'type', - 'variants', - - # Sections that can be found inside targets or configurations, but that - # should not be propagated from targets into their configurations. - 'variables', -] -non_configuration_keys = [] - -# Keys that do not belong inside a configuration dictionary. -invalid_configuration_keys = [ - 'actions', - 'all_dependent_settings', - 'configurations', - 'dependencies', - 'direct_dependent_settings', - 'libraries', - 'link_settings', - 'sources', - 'target_name', - 'type', -] - -# Controls how the generator want the build file paths. -absolute_build_file_paths = False - -# Controls whether or not the generator supports multiple toolsets. -multiple_toolsets = False - - -def GetIncludedBuildFiles(build_file_path, aux_data, included=None): - """Return a list of all build files included into build_file_path. - - The returned list will contain build_file_path as well as all other files - that it included, either directly or indirectly. Note that the list may - contain files that were included into a conditional section that evaluated - to false and was not merged into build_file_path's dict. - - aux_data is a dict containing a key for each build file or included build - file. Those keys provide access to dicts whose "included" keys contain - lists of all other files included by the build file. - - included should be left at its default None value by external callers. It - is used for recursion. - - The returned list will not contain any duplicate entries. Each build file - in the list will be relative to the current directory. - """ - - if included == None: - included = [] - - if build_file_path in included: - return included - - included.append(build_file_path) - - for included_build_file in aux_data[build_file_path].get('included', []): - GetIncludedBuildFiles(included_build_file, aux_data, included) - - return included - - -def CheckedEval(file_contents): - """Return the eval of a gyp file. - - The gyp file is restricted to dictionaries and lists only, and - repeated keys are not allowed. - - Note that this is slower than eval() is. - """ - - ast = compiler.parse(file_contents) - assert isinstance(ast, Module) - c1 = ast.getChildren() - assert c1[0] is None - assert isinstance(c1[1], Stmt) - c2 = c1[1].getChildren() - assert isinstance(c2[0], Discard) - c3 = c2[0].getChildren() - assert len(c3) == 1 - return CheckNode(c3[0], []) - - -def CheckNode(node, keypath): - if isinstance(node, Dict): - c = node.getChildren() - dict = {} - for n in range(0, len(c), 2): - assert isinstance(c[n], Const) - key = c[n].getChildren()[0] - if key in dict: - raise KeyError, "Key '" + key + "' repeated at level " + \ - repr(len(keypath) + 1) + " with key path '" + \ - '.'.join(keypath) + "'" - kp = list(keypath) # Make a copy of the list for descending this node. - kp.append(key) - dict[key] = CheckNode(c[n + 1], kp) - return dict - elif isinstance(node, List): - c = node.getChildren() - children = [] - for index, child in enumerate(c): - kp = list(keypath) # Copy list. - kp.append(repr(index)) - children.append(CheckNode(child, kp)) - return children - elif isinstance(node, Const): - return node.getChildren()[0] - else: - raise TypeError, "Unknown AST node at key path '" + '.'.join(keypath) + \ - "': " + repr(node) - - -def LoadOneBuildFile(build_file_path, data, aux_data, variables, includes, - is_target, check): - if build_file_path in data: - return data[build_file_path] - - if os.path.exists(build_file_path): - build_file_contents = open(build_file_path).read() - else: - raise Exception("%s not found (cwd: %s)" % (build_file_path, os.getcwd())) - - build_file_data = None - try: - if check: - build_file_data = CheckedEval(build_file_contents) - else: - build_file_data = eval(build_file_contents, {'__builtins__': None}, - None) - except SyntaxError, e: - e.filename = build_file_path - raise - except Exception, e: - gyp.common.ExceptionAppend(e, 'while reading ' + build_file_path) - raise - - data[build_file_path] = build_file_data - aux_data[build_file_path] = {} - - # Scan for includes and merge them in. - try: - if is_target: - LoadBuildFileIncludesIntoDict(build_file_data, build_file_path, data, - aux_data, variables, includes, check) - else: - LoadBuildFileIncludesIntoDict(build_file_data, build_file_path, data, - aux_data, variables, None, check) - except Exception, e: - gyp.common.ExceptionAppend(e, - 'while reading includes of ' + build_file_path) - raise - - return build_file_data - - -def LoadBuildFileIncludesIntoDict(subdict, subdict_path, data, aux_data, - variables, includes, check): - includes_list = [] - if includes != None: - includes_list.extend(includes) - if 'includes' in subdict: - for include in subdict['includes']: - # "include" is specified relative to subdict_path, so compute the real - # path to include by appending the provided "include" to the directory - # in which subdict_path resides. - relative_include = \ - os.path.normpath(os.path.join(os.path.dirname(subdict_path), include)) - includes_list.append(relative_include) - # Unhook the includes list, it's no longer needed. - del subdict['includes'] - - # Merge in the included files. - for include in includes_list: - if not 'included' in aux_data[subdict_path]: - aux_data[subdict_path]['included'] = [] - aux_data[subdict_path]['included'].append(include) - - gyp.DebugOutput(gyp.DEBUG_INCLUDES, "Loading Included File: '%s'" % include) - - MergeDicts(subdict, - LoadOneBuildFile(include, data, aux_data, variables, None, - False, check), - subdict_path, include) - - # Recurse into subdictionaries. - for k, v in subdict.iteritems(): - if v.__class__ == dict: - LoadBuildFileIncludesIntoDict(v, subdict_path, data, aux_data, variables, - None, check) - elif v.__class__ == list: - LoadBuildFileIncludesIntoList(v, subdict_path, data, aux_data, variables, - check) - - -# This recurses into lists so that it can look for dicts. -def LoadBuildFileIncludesIntoList(sublist, sublist_path, data, aux_data, - variables, check): - for item in sublist: - if item.__class__ == dict: - LoadBuildFileIncludesIntoDict(item, sublist_path, data, aux_data, - variables, None, check) - elif item.__class__ == list: - LoadBuildFileIncludesIntoList(item, sublist_path, data, aux_data, - variables, check) - -# Processes toolsets in all the targets. This recurses into condition entries -# since they can contain toolsets as well. -def ProcessToolsetsInDict(data): - if 'targets' in data: - target_list = data['targets'] - new_target_list = [] - for target in target_list: - # If this target already has an explicit 'toolset', and no 'toolsets' - # list, don't modify it further. - if 'toolset' in target and 'toolsets' not in target: - new_target_list.append(target) - continue - global multiple_toolsets - if multiple_toolsets: - toolsets = target.get('toolsets', ['target']) - else: - toolsets = ['target'] - # Make sure this 'toolsets' definition is only processed once. - if 'toolsets' in target: - del target['toolsets'] - if len(toolsets) > 0: - # Optimization: only do copies if more than one toolset is specified. - for build in toolsets[1:]: - new_target = copy.deepcopy(target) - new_target['toolset'] = build - new_target_list.append(new_target) - target['toolset'] = toolsets[0] - new_target_list.append(target) - data['targets'] = new_target_list - if 'conditions' in data: - for condition in data['conditions']: - if isinstance(condition, list): - for condition_dict in condition[1:]: - ProcessToolsetsInDict(condition_dict) - - -# TODO(mark): I don't love this name. It just means that it's going to load -# a build file that contains targets and is expected to provide a targets dict -# that contains the targets... -def LoadTargetBuildFile(build_file_path, data, aux_data, variables, includes, - depth, check): - global absolute_build_file_paths - - # If depth is set, predefine the DEPTH variable to be a relative path from - # this build file's directory to the directory identified by depth. - if depth: - # TODO(dglazkov) The backslash/forward-slash replacement at the end is a - # temporary measure. This should really be addressed by keeping all paths - # in POSIX until actual project generation. - d = gyp.common.RelativePath(depth, os.path.dirname(build_file_path)) - if d == '': - variables['DEPTH'] = '.' - else: - variables['DEPTH'] = d.replace('\\', '/') - - # If the generator needs absolue paths, then do so. - if absolute_build_file_paths: - build_file_path = os.path.abspath(build_file_path) - - if build_file_path in data['target_build_files']: - # Already loaded. - return - data['target_build_files'].add(build_file_path) - - gyp.DebugOutput(gyp.DEBUG_INCLUDES, - "Loading Target Build File '%s'" % build_file_path) - - build_file_data = LoadOneBuildFile(build_file_path, data, aux_data, variables, - includes, True, check) - - # Store DEPTH for later use in generators. - build_file_data['_DEPTH'] = depth - - # Set up the included_files key indicating which .gyp files contributed to - # this target dict. - if 'included_files' in build_file_data: - raise KeyError, build_file_path + ' must not contain included_files key' - - included = GetIncludedBuildFiles(build_file_path, aux_data) - build_file_data['included_files'] = [] - for included_file in included: - # included_file is relative to the current directory, but it needs to - # be made relative to build_file_path's directory. - included_relative = \ - gyp.common.RelativePath(included_file, - os.path.dirname(build_file_path)) - build_file_data['included_files'].append(included_relative) - - # Do a first round of toolsets expansion so that conditions can be defined - # per toolset. - ProcessToolsetsInDict(build_file_data) - - # Apply "pre"/"early" variable expansions and condition evaluations. - ProcessVariablesAndConditionsInDict(build_file_data, False, variables, - build_file_path) - - # Since some toolsets might have been defined conditionally, perform - # a second round of toolsets expansion now. - ProcessToolsetsInDict(build_file_data) - - # Look at each project's target_defaults dict, and merge settings into - # targets. - if 'target_defaults' in build_file_data: - index = 0 - if 'targets' in build_file_data: - while index < len(build_file_data['targets']): - # This procedure needs to give the impression that target_defaults is - # used as defaults, and the individual targets inherit from that. - # The individual targets need to be merged into the defaults. Make - # a deep copy of the defaults for each target, merge the target dict - # as found in the input file into that copy, and then hook up the - # copy with the target-specific data merged into it as the replacement - # target dict. - old_target_dict = build_file_data['targets'][index] - new_target_dict = copy.deepcopy(build_file_data['target_defaults']) - MergeDicts(new_target_dict, old_target_dict, - build_file_path, build_file_path) - build_file_data['targets'][index] = new_target_dict - index = index + 1 - else: - raise Exception, \ - "Unable to find targets in build file %s" % build_file_path - - # No longer needed. - del build_file_data['target_defaults'] - - # Look for dependencies. This means that dependency resolution occurs - # after "pre" conditionals and variable expansion, but before "post" - - # in other words, you can't put a "dependencies" section inside a "post" - # conditional within a target. - - if 'targets' in build_file_data: - for target_dict in build_file_data['targets']: - if 'dependencies' not in target_dict: - continue - for dependency in target_dict['dependencies']: - other_build_file = \ - gyp.common.ResolveTarget(build_file_path, dependency, None)[0] - try: - LoadTargetBuildFile(other_build_file, data, aux_data, variables, - includes, depth, check) - except Exception, e: - gyp.common.ExceptionAppend( - e, 'while loading dependencies of %s' % build_file_path) - raise - - return data - - -# Look for the bracket that matches the first bracket seen in a -# string, and return the start and end as a tuple. For example, if -# the input is something like "<(foo <(bar)) blah", then it would -# return (1, 13), indicating the entire string except for the leading -# "<" and trailing " blah". -def FindEnclosingBracketGroup(input): - brackets = { '}': '{', - ']': '[', - ')': '(', } - stack = [] - count = 0 - start = -1 - for char in input: - if char in brackets.values(): - stack.append(char) - if start == -1: - start = count - if char in brackets.keys(): - try: - last_bracket = stack.pop() - except IndexError: - return (-1, -1) - if last_bracket != brackets[char]: - return (-1, -1) - if len(stack) == 0: - return (start, count + 1) - count = count + 1 - return (-1, -1) - - -canonical_int_re = re.compile('^(0|-?[1-9][0-9]*)$') - - -def IsStrCanonicalInt(string): - """Returns True if |string| is in its canonical integer form. - - The canonical form is such that str(int(string)) == string. - """ - if not isinstance(string, str) or not canonical_int_re.match(string): - return False - - return True - - -# This matches things like "<(asdf)", "(?P<(?:(?:!?@?)|\|)?)' - '(?P[-a-zA-Z0-9_.]+)?' - '\((?P\s*\[?)' - '(?P.*?)(\]?)\))') - -# This matches the same as early_variable_re, but with '>' instead of '<'. -late_variable_re = re.compile( - '(?P(?P>(?:(?:!?@?)|\|)?)' - '(?P[-a-zA-Z0-9_.]+)?' - '\((?P\s*\[?)' - '(?P.*?)(\]?)\))') - -# Global cache of results from running commands so they don't have to be run -# more then once. -cached_command_results = {} - - -def FixupPlatformCommand(cmd): - if sys.platform == 'win32': - if type(cmd) == list: - cmd = [re.sub('^cat ', 'type ', cmd[0])] + cmd[1:] - else: - cmd = re.sub('^cat ', 'type ', cmd) - return cmd - - -def ExpandVariables(input, is_late, variables, build_file): - # Look for the pattern that gets expanded into variables - if not is_late: - variable_re = early_variable_re - expansion_symbol = '<' - else: - variable_re = late_variable_re - expansion_symbol = '>' - - input_str = str(input) - # Do a quick scan to determine if an expensive regex search is warranted. - if expansion_symbol in input_str: - # Get the entire list of matches as a list of MatchObject instances. - # (using findall here would return strings instead of MatchObjects). - matches = [match for match in variable_re.finditer(input_str)] - else: - matches = None - - output = input_str - if matches: - # Reverse the list of matches so that replacements are done right-to-left. - # That ensures that earlier replacements won't mess up the string in a - # way that causes later calls to find the earlier substituted text instead - # of what's intended for replacement. - matches.reverse() - for match_group in matches: - match = match_group.groupdict() - gyp.DebugOutput(gyp.DEBUG_VARIABLES, - "Matches: %s" % repr(match)) - # match['replace'] is the substring to look for, match['type'] - # is the character code for the replacement type (< > ! <| >| <@ - # >@ !@), match['is_array'] contains a '[' for command - # arrays, and match['content'] is the name of the variable (< >) - # or command to run (!). match['command_string'] is an optional - # command string. Currently, only 'pymod_do_main' is supported. - - # run_command is true if a ! variant is used. - run_command = '!' in match['type'] - command_string = match['command_string'] - - # file_list is true if a | variant is used. - file_list = '|' in match['type'] - - # Capture these now so we can adjust them later. - replace_start = match_group.start('replace') - replace_end = match_group.end('replace') - - # Find the ending paren, and re-evaluate the contained string. - (c_start, c_end) = FindEnclosingBracketGroup(input_str[replace_start:]) - - # Adjust the replacement range to match the entire command - # found by FindEnclosingBracketGroup (since the variable_re - # probably doesn't match the entire command if it contained - # nested variables). - replace_end = replace_start + c_end - - # Find the "real" replacement, matching the appropriate closing - # paren, and adjust the replacement start and end. - replacement = input_str[replace_start:replace_end] - - # Figure out what the contents of the variable parens are. - contents_start = replace_start + c_start + 1 - contents_end = replace_end - 1 - contents = input_str[contents_start:contents_end] - - # Do filter substitution now for <|(). - # Admittedly, this is different than the evaluation order in other - # contexts. However, since filtration has no chance to run on <|(), - # this seems like the only obvious way to give them access to filters. - if file_list: - processed_variables = copy.deepcopy(variables) - ProcessListFiltersInDict(contents, processed_variables) - # Recurse to expand variables in the contents - contents = ExpandVariables(contents, is_late, - processed_variables, build_file) - else: - # Recurse to expand variables in the contents - contents = ExpandVariables(contents, is_late, variables, build_file) - - # Strip off leading/trailing whitespace so that variable matches are - # simpler below (and because they are rarely needed). - contents = contents.strip() - - # expand_to_list is true if an @ variant is used. In that case, - # the expansion should result in a list. Note that the caller - # is to be expecting a list in return, and not all callers do - # because not all are working in list context. Also, for list - # expansions, there can be no other text besides the variable - # expansion in the input string. - expand_to_list = '@' in match['type'] and input_str == replacement - - if run_command or file_list: - # Find the build file's directory, so commands can be run or file lists - # generated relative to it. - build_file_dir = os.path.dirname(build_file) - if build_file_dir == '': - # If build_file is just a leaf filename indicating a file in the - # current directory, build_file_dir might be an empty string. Set - # it to None to signal to subprocess.Popen that it should run the - # command in the current directory. - build_file_dir = None - - # Support <|(listfile.txt ...) which generates a file - # containing items from a gyp list, generated at gyp time. - # This works around actions/rules which have more inputs than will - # fit on the command line. - if file_list: - if type(contents) == list: - contents_list = contents - else: - contents_list = contents.split(' ') - replacement = contents_list[0] - path = replacement - if not os.path.isabs(path): - path = os.path.join(build_file_dir, path) - f = gyp.common.WriteOnDiff(path) - for i in contents_list[1:]: - f.write('%s\n' % i) - f.close() - - elif run_command: - use_shell = True - if match['is_array']: - contents = eval(contents) - use_shell = False - - # Check for a cached value to avoid executing commands, or generating - # file lists more than once. - # TODO(http://code.google.com/p/gyp/issues/detail?id=112): It is - # possible that the command being invoked depends on the current - # directory. For that case the syntax needs to be extended so that the - # directory is also used in cache_key (it becomes a tuple). - # TODO(http://code.google.com/p/gyp/issues/detail?id=111): In theory, - # someone could author a set of GYP files where each time the command - # is invoked it produces different output by design. When the need - # arises, the syntax should be extended to support no caching off a - # command's output so it is run every time. - cache_key = str(contents) - cached_value = cached_command_results.get(cache_key, None) - if cached_value is None: - gyp.DebugOutput(gyp.DEBUG_VARIABLES, - "Executing command '%s' in directory '%s'" % - (contents,build_file_dir)) - - replacement = '' - - if command_string == 'pymod_do_main': - # ', 'eval') - - if eval(ast_code, {'__builtins__': None}, variables): - merge_dict = true_dict - else: - merge_dict = false_dict - except SyntaxError, e: - syntax_error = SyntaxError('%s while evaluating condition \'%s\' in %s ' - 'at character %d.' % - (str(e.args[0]), e.text, build_file, e.offset), - e.filename, e.lineno, e.offset, e.text) - raise syntax_error - except NameError, e: - gyp.common.ExceptionAppend(e, 'while evaluating condition \'%s\' in %s' % - (cond_expr_expanded, build_file)) - raise - - if merge_dict != None: - # Expand variables and nested conditinals in the merge_dict before - # merging it. - ProcessVariablesAndConditionsInDict(merge_dict, is_late, - variables, build_file) - - MergeDicts(the_dict, merge_dict, build_file, build_file) - - -def LoadAutomaticVariablesFromDict(variables, the_dict): - # Any keys with plain string values in the_dict become automatic variables. - # The variable name is the key name with a "_" character prepended. - for key, value in the_dict.iteritems(): - if isinstance(value, str) or isinstance(value, int) or \ - isinstance(value, list): - variables['_' + key] = value - - -def LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key): - # Any keys in the_dict's "variables" dict, if it has one, becomes a - # variable. The variable name is the key name in the "variables" dict. - # Variables that end with the % character are set only if they are unset in - # the variables dict. the_dict_key is the name of the key that accesses - # the_dict in the_dict's parent dict. If the_dict's parent is not a dict - # (it could be a list or it could be parentless because it is a root dict), - # the_dict_key will be None. - for key, value in the_dict.get('variables', {}).iteritems(): - if not isinstance(value, str) and not isinstance(value, int) and \ - not isinstance(value, list): - continue - - if key.endswith('%'): - variable_name = key[:-1] - if variable_name in variables: - # If the variable is already set, don't set it. - continue - if the_dict_key is 'variables' and variable_name in the_dict: - # If the variable is set without a % in the_dict, and the_dict is a - # variables dict (making |variables| a varaibles sub-dict of a - # variables dict), use the_dict's definition. - value = the_dict[variable_name] - else: - variable_name = key - - variables[variable_name] = value - - -def ProcessVariablesAndConditionsInDict(the_dict, is_late, variables_in, - build_file, the_dict_key=None): - """Handle all variable and command expansion and conditional evaluation. - - This function is the public entry point for all variable expansions and - conditional evaluations. The variables_in dictionary will not be modified - by this function. - """ - - # Make a copy of the variables_in dict that can be modified during the - # loading of automatics and the loading of the variables dict. - variables = variables_in.copy() - LoadAutomaticVariablesFromDict(variables, the_dict) - - if 'variables' in the_dict: - # Make sure all the local variables are added to the variables - # list before we process them so that you can reference one - # variable from another. They will be fully expanded by recursion - # in ExpandVariables. - for key, value in the_dict['variables'].iteritems(): - variables[key] = value - - # Handle the associated variables dict first, so that any variable - # references within can be resolved prior to using them as variables. - # Pass a copy of the variables dict to avoid having it be tainted. - # Otherwise, it would have extra automatics added for everything that - # should just be an ordinary variable in this scope. - ProcessVariablesAndConditionsInDict(the_dict['variables'], is_late, - variables, build_file, 'variables') - - LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key) - - for key, value in the_dict.iteritems(): - # Skip "variables", which was already processed if present. - if key != 'variables' and isinstance(value, str): - expanded = ExpandVariables(value, is_late, variables, build_file) - if not isinstance(expanded, str) and not isinstance(expanded, int): - raise ValueError, \ - 'Variable expansion in this context permits str and int ' + \ - 'only, found ' + expanded.__class__.__name__ + ' for ' + key - the_dict[key] = expanded - - # Variable expansion may have resulted in changes to automatics. Reload. - # TODO(mark): Optimization: only reload if no changes were made. - variables = variables_in.copy() - LoadAutomaticVariablesFromDict(variables, the_dict) - LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key) - - # Process conditions in this dict. This is done after variable expansion - # so that conditions may take advantage of expanded variables. For example, - # if the_dict contains: - # {'type': '<(library_type)', - # 'conditions': [['_type=="static_library"', { ... }]]}, - # _type, as used in the condition, will only be set to the value of - # library_type if variable expansion is performed before condition - # processing. However, condition processing should occur prior to recursion - # so that variables (both automatic and "variables" dict type) may be - # adjusted by conditions sections, merged into the_dict, and have the - # intended impact on contained dicts. - # - # This arrangement means that a "conditions" section containing a "variables" - # section will only have those variables effective in subdicts, not in - # the_dict. The workaround is to put a "conditions" section within a - # "variables" section. For example: - # {'conditions': [['os=="mac"', {'variables': {'define': 'IS_MAC'}}]], - # 'defines': ['<(define)'], - # 'my_subdict': {'defines': ['<(define)']}}, - # will not result in "IS_MAC" being appended to the "defines" list in the - # current scope but would result in it being appended to the "defines" list - # within "my_subdict". By comparison: - # {'variables': {'conditions': [['os=="mac"', {'define': 'IS_MAC'}]]}, - # 'defines': ['<(define)'], - # 'my_subdict': {'defines': ['<(define)']}}, - # will append "IS_MAC" to both "defines" lists. - - # Evaluate conditions sections, allowing variable expansions within them - # as well as nested conditionals. This will process a 'conditions' or - # 'target_conditions' section, perform appropriate merging and recursive - # conditional and variable processing, and then remove the conditions section - # from the_dict if it is present. - ProcessConditionsInDict(the_dict, is_late, variables, build_file) - - # Conditional processing may have resulted in changes to automatics or the - # variables dict. Reload. - variables = variables_in.copy() - LoadAutomaticVariablesFromDict(variables, the_dict) - LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key) - - # Recurse into child dicts, or process child lists which may result in - # further recursion into descendant dicts. - for key, value in the_dict.iteritems(): - # Skip "variables" and string values, which were already processed if - # present. - if key == 'variables' or isinstance(value, str): - continue - if isinstance(value, dict): - # Pass a copy of the variables dict so that subdicts can't influence - # parents. - ProcessVariablesAndConditionsInDict(value, is_late, variables, - build_file, key) - elif isinstance(value, list): - # The list itself can't influence the variables dict, and - # ProcessVariablesAndConditionsInList will make copies of the variables - # dict if it needs to pass it to something that can influence it. No - # copy is necessary here. - ProcessVariablesAndConditionsInList(value, is_late, variables, - build_file) - elif not isinstance(value, int): - raise TypeError, 'Unknown type ' + value.__class__.__name__ + \ - ' for ' + key - - -def ProcessVariablesAndConditionsInList(the_list, is_late, variables, - build_file): - # Iterate using an index so that new values can be assigned into the_list. - index = 0 - while index < len(the_list): - item = the_list[index] - if isinstance(item, dict): - # Make a copy of the variables dict so that it won't influence anything - # outside of its own scope. - ProcessVariablesAndConditionsInDict(item, is_late, variables, build_file) - elif isinstance(item, list): - ProcessVariablesAndConditionsInList(item, is_late, variables, build_file) - elif isinstance(item, str): - expanded = ExpandVariables(item, is_late, variables, build_file) - if isinstance(expanded, str) or isinstance(expanded, int): - the_list[index] = expanded - elif isinstance(expanded, list): - del the_list[index] - for expanded_item in expanded: - the_list.insert(index, expanded_item) - index = index + 1 - - # index now identifies the next item to examine. Continue right now - # without falling into the index increment below. - continue - else: - raise ValueError, \ - 'Variable expansion in this context permits strings and ' + \ - 'lists only, found ' + expanded.__class__.__name__ + ' at ' + \ - index - elif not isinstance(item, int): - raise TypeError, 'Unknown type ' + item.__class__.__name__ + \ - ' at index ' + index - index = index + 1 - - -def BuildTargetsDict(data): - """Builds a dict mapping fully-qualified target names to their target dicts. - - |data| is a dict mapping loaded build files by pathname relative to the - current directory. Values in |data| are build file contents. For each - |data| value with a "targets" key, the value of the "targets" key is taken - as a list containing target dicts. Each target's fully-qualified name is - constructed from the pathname of the build file (|data| key) and its - "target_name" property. These fully-qualified names are used as the keys - in the returned dict. These keys provide access to the target dicts, - the dicts in the "targets" lists. - """ - - targets = {} - for build_file in data['target_build_files']: - for target in data[build_file].get('targets', []): - target_name = gyp.common.QualifiedTarget(build_file, - target['target_name'], - target['toolset']) - if target_name in targets: - raise KeyError, 'Duplicate target definitions for ' + target_name - targets[target_name] = target - - return targets - - -def QualifyDependencies(targets): - """Make dependency links fully-qualified relative to the current directory. - - |targets| is a dict mapping fully-qualified target names to their target - dicts. For each target in this dict, keys known to contain dependency - links are examined, and any dependencies referenced will be rewritten - so that they are fully-qualified and relative to the current directory. - All rewritten dependencies are suitable for use as keys to |targets| or a - similar dict. - """ - - all_dependency_sections = [dep + op - for dep in dependency_sections - for op in ('', '!', '/')] - - for target, target_dict in targets.iteritems(): - target_build_file = gyp.common.BuildFile(target) - toolset = target_dict['toolset'] - for dependency_key in all_dependency_sections: - dependencies = target_dict.get(dependency_key, []) - for index in xrange(0, len(dependencies)): - dep_file, dep_target, dep_toolset = gyp.common.ResolveTarget( - target_build_file, dependencies[index], toolset) - global multiple_toolsets - if not multiple_toolsets: - # Ignore toolset specification in the dependency if it is specified. - dep_toolset = toolset - dependency = gyp.common.QualifiedTarget(dep_file, - dep_target, - dep_toolset) - dependencies[index] = dependency - - # Make sure anything appearing in a list other than "dependencies" also - # appears in the "dependencies" list. - if dependency_key != 'dependencies' and \ - dependency not in target_dict['dependencies']: - raise KeyError, 'Found ' + dependency + ' in ' + dependency_key + \ - ' of ' + target + ', but not in dependencies' - - -def ExpandWildcardDependencies(targets, data): - """Expands dependencies specified as build_file:*. - - For each target in |targets|, examines sections containing links to other - targets. If any such section contains a link of the form build_file:*, it - is taken as a wildcard link, and is expanded to list each target in - build_file. The |data| dict provides access to build file dicts. - - Any target that does not wish to be included by wildcard can provide an - optional "suppress_wildcard" key in its target dict. When present and - true, a wildcard dependency link will not include such targets. - - All dependency names, including the keys to |targets| and the values in each - dependency list, must be qualified when this function is called. - """ - - for target, target_dict in targets.iteritems(): - toolset = target_dict['toolset'] - target_build_file = gyp.common.BuildFile(target) - for dependency_key in dependency_sections: - dependencies = target_dict.get(dependency_key, []) - - # Loop this way instead of "for dependency in" or "for index in xrange" - # because the dependencies list will be modified within the loop body. - index = 0 - while index < len(dependencies): - (dependency_build_file, dependency_target, dependency_toolset) = \ - gyp.common.ParseQualifiedTarget(dependencies[index]) - if dependency_target != '*' and dependency_toolset != '*': - # Not a wildcard. Keep it moving. - index = index + 1 - continue - - if dependency_build_file == target_build_file: - # It's an error for a target to depend on all other targets in - # the same file, because a target cannot depend on itself. - raise KeyError, 'Found wildcard in ' + dependency_key + ' of ' + \ - target + ' referring to same build file' - - # Take the wildcard out and adjust the index so that the next - # dependency in the list will be processed the next time through the - # loop. - del dependencies[index] - index = index - 1 - - # Loop through the targets in the other build file, adding them to - # this target's list of dependencies in place of the removed - # wildcard. - dependency_target_dicts = data[dependency_build_file]['targets'] - for dependency_target_dict in dependency_target_dicts: - if int(dependency_target_dict.get('suppress_wildcard', False)): - continue - dependency_target_name = dependency_target_dict['target_name'] - if (dependency_target != '*' and - dependency_target != dependency_target_name): - continue - dependency_target_toolset = dependency_target_dict['toolset'] - if (dependency_toolset != '*' and - dependency_toolset != dependency_target_toolset): - continue - dependency = gyp.common.QualifiedTarget(dependency_build_file, - dependency_target_name, - dependency_target_toolset) - index = index + 1 - dependencies.insert(index, dependency) - - index = index + 1 - - -class DependencyGraphNode(object): - """ - - Attributes: - ref: A reference to an object that this DependencyGraphNode represents. - dependencies: List of DependencyGraphNodes on which this one depends. - dependents: List of DependencyGraphNodes that depend on this one. - """ - - class CircularException(Exception): - pass - - def __init__(self, ref): - self.ref = ref - self.dependencies = [] - self.dependents = [] - - def FlattenToList(self): - # flat_list is the sorted list of dependencies - actually, the list items - # are the "ref" attributes of DependencyGraphNodes. Every target will - # appear in flat_list after all of its dependencies, and before all of its - # dependents. - flat_list = [] - - # in_degree_zeros is the list of DependencyGraphNodes that have no - # dependencies not in flat_list. Initially, it is a copy of the children - # of this node, because when the graph was built, nodes with no - # dependencies were made implicit dependents of the root node. - in_degree_zeros = self.dependents[:] - - while in_degree_zeros: - # Nodes in in_degree_zeros have no dependencies not in flat_list, so they - # can be appended to flat_list. Take these nodes out of in_degree_zeros - # as work progresses, so that the next node to process from the list can - # always be accessed at a consistent position. - node = in_degree_zeros.pop(0) - flat_list.append(node.ref) - - # Look at dependents of the node just added to flat_list. Some of them - # may now belong in in_degree_zeros. - for node_dependent in node.dependents: - is_in_degree_zero = True - for node_dependent_dependency in node_dependent.dependencies: - if not node_dependent_dependency.ref in flat_list: - # The dependent one or more dependencies not in flat_list. There - # will be more chances to add it to flat_list when examining - # it again as a dependent of those other dependencies, provided - # that there are no cycles. - is_in_degree_zero = False - break - - if is_in_degree_zero: - # All of the dependent's dependencies are already in flat_list. Add - # it to in_degree_zeros where it will be processed in a future - # iteration of the outer loop. - in_degree_zeros.append(node_dependent) - - return flat_list - - def DirectDependencies(self, dependencies=None): - """Returns a list of just direct dependencies.""" - if dependencies == None: - dependencies = [] - - for dependency in self.dependencies: - # Check for None, corresponding to the root node. - if dependency.ref != None and dependency.ref not in dependencies: - dependencies.append(dependency.ref) - - return dependencies - - def _AddImportedDependencies(self, targets, dependencies=None): - """Given a list of direct dependencies, adds indirect dependencies that - other dependencies have declared to export their settings. - - This method does not operate on self. Rather, it operates on the list - of dependencies in the |dependencies| argument. For each dependency in - that list, if any declares that it exports the settings of one of its - own dependencies, those dependencies whose settings are "passed through" - are added to the list. As new items are added to the list, they too will - be processed, so it is possible to import settings through multiple levels - of dependencies. - - This method is not terribly useful on its own, it depends on being - "primed" with a list of direct dependencies such as one provided by - DirectDependencies. DirectAndImportedDependencies is intended to be the - public entry point. - """ - - if dependencies == None: - dependencies = [] - - index = 0 - while index < len(dependencies): - dependency = dependencies[index] - dependency_dict = targets[dependency] - # Add any dependencies whose settings should be imported to the list - # if not already present. Newly-added items will be checked for - # their own imports when the list iteration reaches them. - # Rather than simply appending new items, insert them after the - # dependency that exported them. This is done to more closely match - # the depth-first method used by DeepDependencies. - add_index = 1 - for imported_dependency in \ - dependency_dict.get('export_dependent_settings', []): - if imported_dependency not in dependencies: - dependencies.insert(index + add_index, imported_dependency) - add_index = add_index + 1 - index = index + 1 - - return dependencies - - def DirectAndImportedDependencies(self, targets, dependencies=None): - """Returns a list of a target's direct dependencies and all indirect - dependencies that a dependency has advertised settings should be exported - through the dependency for. - """ - - dependencies = self.DirectDependencies(dependencies) - return self._AddImportedDependencies(targets, dependencies) - - def DeepDependencies(self, dependencies=None): - """Returns a list of all of a target's dependencies, recursively.""" - if dependencies == None: - dependencies = [] - - for dependency in self.dependencies: - # Check for None, corresponding to the root node. - if dependency.ref != None and dependency.ref not in dependencies: - dependencies.append(dependency.ref) - dependency.DeepDependencies(dependencies) - - return dependencies - - def LinkDependencies(self, targets, dependencies=None, initial=True): - """Returns a list of dependency targets that are linked into this target. - - This function has a split personality, depending on the setting of - |initial|. Outside callers should always leave |initial| at its default - setting. - - When adding a target to the list of dependencies, this function will - recurse into itself with |initial| set to False, to collect depenedencies - that are linked into the linkable target for which the list is being built. - """ - if dependencies == None: - dependencies = [] - - # Check for None, corresponding to the root node. - if self.ref == None: - return dependencies - - # It's kind of sucky that |targets| has to be passed into this function, - # but that's presently the easiest way to access the target dicts so that - # this function can find target types. - - if not 'target_name' in targets[self.ref]: - raise Exception("Missing 'target_name' field in target.") - - try: - target_type = targets[self.ref]['type'] - except KeyError, e: - raise Exception("Missing 'type' field in target %s" % - targets[self.ref]['target_name']) - - is_linkable = target_type in linkable_types - - if initial and not is_linkable: - # If this is the first target being examined and it's not linkable, - # return an empty list of link dependencies, because the link - # dependencies are intended to apply to the target itself (initial is - # True) and this target won't be linked. - return dependencies - - # Executables and loadable modules are already fully and finally linked. - # Nothing else can be a link dependency of them, there can only be - # dependencies in the sense that a dependent target might run an - # executable or load the loadable_module. - if not initial and target_type in ('executable', 'loadable_module'): - return dependencies - - # The target is linkable, add it to the list of link dependencies. - if self.ref not in dependencies: - if target_type != 'none': - # Special case: "none" type targets don't produce any linkable products - # and shouldn't be exposed as link dependencies, although dependencies - # of "none" type targets may still be link dependencies. - dependencies.append(self.ref) - if initial or not is_linkable: - # If this is a subsequent target and it's linkable, don't look any - # further for linkable dependencies, as they'll already be linked into - # this target linkable. Always look at dependencies of the initial - # target, and always look at dependencies of non-linkables. - for dependency in self.dependencies: - dependency.LinkDependencies(targets, dependencies, False) - - return dependencies - - -def BuildDependencyList(targets): - # Create a DependencyGraphNode for each target. Put it into a dict for easy - # access. - dependency_nodes = {} - for target, spec in targets.iteritems(): - if not target in dependency_nodes: - dependency_nodes[target] = DependencyGraphNode(target) - - # Set up the dependency links. Targets that have no dependencies are treated - # as dependent on root_node. - root_node = DependencyGraphNode(None) - for target, spec in targets.iteritems(): - target_node = dependency_nodes[target] - target_build_file = gyp.common.BuildFile(target) - if not 'dependencies' in spec or len(spec['dependencies']) == 0: - target_node.dependencies = [root_node] - root_node.dependents.append(target_node) - else: - dependencies = spec['dependencies'] - for index in xrange(0, len(dependencies)): - try: - dependency = dependencies[index] - dependency_node = dependency_nodes[dependency] - target_node.dependencies.append(dependency_node) - dependency_node.dependents.append(target_node) - except KeyError, e: - gyp.common.ExceptionAppend(e, - 'while trying to load target %s' % target) - raise - - flat_list = root_node.FlattenToList() - - # If there's anything left unvisited, there must be a circular dependency - # (cycle). If you need to figure out what's wrong, look for elements of - # targets that are not in flat_list. - if len(flat_list) != len(targets): - raise DependencyGraphNode.CircularException, \ - 'Some targets not reachable, cycle in dependency graph detected' - - return [dependency_nodes, flat_list] - - -def VerifyNoGYPFileCircularDependencies(targets): - # Create a DependencyGraphNode for each gyp file containing a target. Put - # it into a dict for easy access. - dependency_nodes = {} - for target in targets.iterkeys(): - build_file = gyp.common.BuildFile(target) - if not build_file in dependency_nodes: - dependency_nodes[build_file] = DependencyGraphNode(build_file) - - # Set up the dependency links. - for target, spec in targets.iteritems(): - build_file = gyp.common.BuildFile(target) - build_file_node = dependency_nodes[build_file] - target_dependencies = spec.get('dependencies', []) - for dependency in target_dependencies: - try: - dependency_build_file = gyp.common.BuildFile(dependency) - if dependency_build_file == build_file: - # A .gyp file is allowed to refer back to itself. - continue - dependency_node = dependency_nodes[dependency_build_file] - if dependency_node not in build_file_node.dependencies: - build_file_node.dependencies.append(dependency_node) - dependency_node.dependents.append(build_file_node) - except KeyError, e: - gyp.common.ExceptionAppend( - e, 'while computing dependencies of .gyp file %s' % build_file) - raise - - # Files that have no dependencies are treated as dependent on root_node. - root_node = DependencyGraphNode(None) - for build_file_node in dependency_nodes.itervalues(): - if len(build_file_node.dependencies) == 0: - build_file_node.dependencies.append(root_node) - root_node.dependents.append(build_file_node) - - flat_list = root_node.FlattenToList() - - # If there's anything left unvisited, there must be a circular dependency - # (cycle). - if len(flat_list) != len(dependency_nodes): - bad_files = [] - for file in dependency_nodes.iterkeys(): - if not file in flat_list: - bad_files.append(file) - raise DependencyGraphNode.CircularException, \ - 'Some files not reachable, cycle in .gyp file dependency graph ' + \ - 'detected involving some or all of: ' + \ - ' '.join(bad_files) - - -def DoDependentSettings(key, flat_list, targets, dependency_nodes): - # key should be one of all_dependent_settings, direct_dependent_settings, - # or link_settings. - - for target in flat_list: - target_dict = targets[target] - build_file = gyp.common.BuildFile(target) - - if key == 'all_dependent_settings': - dependencies = dependency_nodes[target].DeepDependencies() - elif key == 'direct_dependent_settings': - dependencies = \ - dependency_nodes[target].DirectAndImportedDependencies(targets) - elif key == 'link_settings': - dependencies = dependency_nodes[target].LinkDependencies(targets) - else: - raise KeyError, "DoDependentSettings doesn't know how to determine " + \ - 'dependencies for ' + key - - for dependency in dependencies: - dependency_dict = targets[dependency] - if not key in dependency_dict: - continue - dependency_build_file = gyp.common.BuildFile(dependency) - MergeDicts(target_dict, dependency_dict[key], - build_file, dependency_build_file) - - -def AdjustStaticLibraryDependencies(flat_list, targets, dependency_nodes, - sort_dependencies): - # Recompute target "dependencies" properties. For each static library - # target, remove "dependencies" entries referring to other static libraries, - # unless the dependency has the "hard_dependency" attribute set. For each - # linkable target, add a "dependencies" entry referring to all of the - # target's computed list of link dependencies (including static libraries - # if no such entry is already present. - for target in flat_list: - target_dict = targets[target] - target_type = target_dict['type'] - - if target_type == 'static_library': - if not 'dependencies' in target_dict: - continue - - target_dict['dependencies_original'] = target_dict.get( - 'dependencies', [])[:] - - # A static library should not depend on another static library unless - # the dependency relationship is "hard," which should only be done when - # a dependent relies on some side effect other than just the build - # product, like a rule or action output. Further, if a target has a - # non-hard dependency, but that dependency exports a hard dependency, - # the non-hard dependency can safely be removed, but the exported hard - # dependency must be added to the target to keep the same dependency - # ordering. - dependencies = \ - dependency_nodes[target].DirectAndImportedDependencies(targets) - index = 0 - while index < len(dependencies): - dependency = dependencies[index] - dependency_dict = targets[dependency] - - # Remove every non-hard static library dependency and remove every - # non-static library dependency that isn't a direct dependency. - if (dependency_dict['type'] == 'static_library' and \ - not dependency_dict.get('hard_dependency', False)) or \ - (dependency_dict['type'] != 'static_library' and \ - not dependency in target_dict['dependencies']): - # Take the dependency out of the list, and don't increment index - # because the next dependency to analyze will shift into the index - # formerly occupied by the one being removed. - del dependencies[index] - else: - index = index + 1 - - # Update the dependencies. If the dependencies list is empty, it's not - # needed, so unhook it. - if len(dependencies) > 0: - target_dict['dependencies'] = dependencies - else: - del target_dict['dependencies'] - - elif target_type in linkable_types: - # Get a list of dependency targets that should be linked into this - # target. Add them to the dependencies list if they're not already - # present. - - link_dependencies = dependency_nodes[target].LinkDependencies(targets) - for dependency in link_dependencies: - if dependency == target: - continue - if not 'dependencies' in target_dict: - target_dict['dependencies'] = [] - if not dependency in target_dict['dependencies']: - target_dict['dependencies'].append(dependency) - # Sort the dependencies list in the order from dependents to dependencies. - # e.g. If A and B depend on C and C depends on D, sort them in A, B, C, D. - # Note: flat_list is already sorted in the order from dependencies to - # dependents. - if sort_dependencies and 'dependencies' in target_dict: - target_dict['dependencies'] = [dep for dep in reversed(flat_list) - if dep in target_dict['dependencies']] - - -# Initialize this here to speed up MakePathRelative. -exception_re = re.compile(r'''["']?[-/$<>]''') - - -def MakePathRelative(to_file, fro_file, item): - # If item is a relative path, it's relative to the build file dict that it's - # coming from. Fix it up to make it relative to the build file dict that - # it's going into. - # Exception: any |item| that begins with these special characters is - # returned without modification. - # / Used when a path is already absolute (shortcut optimization; - # such paths would be returned as absolute anyway) - # $ Used for build environment variables - # - Used for some build environment flags (such as -lapr-1 in a - # "libraries" section) - # < Used for our own variable and command expansions (see ExpandVariables) - # > Used for our own variable and command expansions (see ExpandVariables) - # - # "/' Used when a value is quoted. If these are present, then we - # check the second character instead. - # - if to_file == fro_file or exception_re.match(item): - return item - else: - # TODO(dglazkov) The backslash/forward-slash replacement at the end is a - # temporary measure. This should really be addressed by keeping all paths - # in POSIX until actual project generation. - ret = os.path.normpath(os.path.join( - gyp.common.RelativePath(os.path.dirname(fro_file), - os.path.dirname(to_file)), - item)).replace('\\', '/') - if item[-1] == '/': - ret += '/' - return ret - -def MergeLists(to, fro, to_file, fro_file, is_paths=False, append=True): - def is_hashable(x): - try: - hash(x) - except TypeError: - return False - return True - # If x is hashable, returns whether x is in s. Else returns whether x is in l. - def is_in_set_or_list(x, s, l): - if is_hashable(x): - return x in s - return x in l - - prepend_index = 0 - - # Make membership testing of hashables in |to| (in particular, strings) - # faster. - hashable_to_set = set([x for x in to if is_hashable(x)]) - - for item in fro: - singleton = False - if isinstance(item, str) or isinstance(item, int): - # The cheap and easy case. - if is_paths: - to_item = MakePathRelative(to_file, fro_file, item) - else: - to_item = item - - if not isinstance(item, str) or not item.startswith('-'): - # Any string that doesn't begin with a "-" is a singleton - it can - # only appear once in a list, to be enforced by the list merge append - # or prepend. - singleton = True - elif isinstance(item, dict): - # Make a copy of the dictionary, continuing to look for paths to fix. - # The other intelligent aspects of merge processing won't apply because - # item is being merged into an empty dict. - to_item = {} - MergeDicts(to_item, item, to_file, fro_file) - elif isinstance(item, list): - # Recurse, making a copy of the list. If the list contains any - # descendant dicts, path fixing will occur. Note that here, custom - # values for is_paths and append are dropped; those are only to be - # applied to |to| and |fro|, not sublists of |fro|. append shouldn't - # matter anyway because the new |to_item| list is empty. - to_item = [] - MergeLists(to_item, item, to_file, fro_file) - else: - raise TypeError, \ - 'Attempt to merge list item of unsupported type ' + \ - item.__class__.__name__ - - if append: - # If appending a singleton that's already in the list, don't append. - # This ensures that the earliest occurrence of the item will stay put. - if not singleton or not is_in_set_or_list(to_item, hashable_to_set, to): - to.append(to_item) - if is_hashable(to_item): - hashable_to_set.add(to_item) - else: - # If prepending a singleton that's already in the list, remove the - # existing instance and proceed with the prepend. This ensures that the - # item appears at the earliest possible position in the list. - while singleton and to_item in to: - to.remove(to_item) - - # Don't just insert everything at index 0. That would prepend the new - # items to the list in reverse order, which would be an unwelcome - # surprise. - to.insert(prepend_index, to_item) - if is_hashable(to_item): - hashable_to_set.add(to_item) - prepend_index = prepend_index + 1 - - -def MergeDicts(to, fro, to_file, fro_file): - # I wanted to name the parameter "from" but it's a Python keyword... - for k, v in fro.iteritems(): - # It would be nice to do "if not k in to: to[k] = v" but that wouldn't give - # copy semantics. Something else may want to merge from the |fro| dict - # later, and having the same dict ref pointed to twice in the tree isn't - # what anyone wants considering that the dicts may subsequently be - # modified. - if k in to: - bad_merge = False - if isinstance(v, str) or isinstance(v, int): - if not (isinstance(to[k], str) or isinstance(to[k], int)): - bad_merge = True - elif v.__class__ != to[k].__class__: - bad_merge = True - - if bad_merge: - raise TypeError, \ - 'Attempt to merge dict value of type ' + v.__class__.__name__ + \ - ' into incompatible type ' + to[k].__class__.__name__ + \ - ' for key ' + k - if isinstance(v, str) or isinstance(v, int): - # Overwrite the existing value, if any. Cheap and easy. - is_path = IsPathSection(k) - if is_path: - to[k] = MakePathRelative(to_file, fro_file, v) - else: - to[k] = v - elif isinstance(v, dict): - # Recurse, guaranteeing copies will be made of objects that require it. - if not k in to: - to[k] = {} - MergeDicts(to[k], v, to_file, fro_file) - elif isinstance(v, list): - # Lists in dicts can be merged with different policies, depending on - # how the key in the "from" dict (k, the from-key) is written. - # - # If the from-key has ...the to-list will have this action - # this character appended:... applied when receiving the from-list: - # = replace - # + prepend - # ? set, only if to-list does not yet exist - # (none) append - # - # This logic is list-specific, but since it relies on the associated - # dict key, it's checked in this dict-oriented function. - ext = k[-1] - append = True - if ext == '=': - list_base = k[:-1] - lists_incompatible = [list_base, list_base + '?'] - to[list_base] = [] - elif ext == '+': - list_base = k[:-1] - lists_incompatible = [list_base + '=', list_base + '?'] - append = False - elif ext == '?': - list_base = k[:-1] - lists_incompatible = [list_base, list_base + '=', list_base + '+'] - else: - list_base = k - lists_incompatible = [list_base + '=', list_base + '?'] - - # Some combinations of merge policies appearing together are meaningless. - # It's stupid to replace and append simultaneously, for example. Append - # and prepend are the only policies that can coexist. - for list_incompatible in lists_incompatible: - if list_incompatible in fro: - raise KeyError, 'Incompatible list policies ' + k + ' and ' + \ - list_incompatible - - if list_base in to: - if ext == '?': - # If the key ends in "?", the list will only be merged if it doesn't - # already exist. - continue - if not isinstance(to[list_base], list): - # This may not have been checked above if merging in a list with an - # extension character. - raise TypeError, \ - 'Attempt to merge dict value of type ' + v.__class__.__name__ + \ - ' into incompatible type ' + to[list_base].__class__.__name__ + \ - ' for key ' + list_base + '(' + k + ')' - else: - to[list_base] = [] - - # Call MergeLists, which will make copies of objects that require it. - # MergeLists can recurse back into MergeDicts, although this will be - # to make copies of dicts (with paths fixed), there will be no - # subsequent dict "merging" once entering a list because lists are - # always replaced, appended to, or prepended to. - is_paths = IsPathSection(list_base) - MergeLists(to[list_base], v, to_file, fro_file, is_paths, append) - else: - raise TypeError, \ - 'Attempt to merge dict value of unsupported type ' + \ - v.__class__.__name__ + ' for key ' + k - - -def MergeConfigWithInheritance(new_configuration_dict, build_file, - target_dict, configuration, visited): - # Skip if previously visted. - if configuration in visited: - return - - # Look at this configuration. - configuration_dict = target_dict['configurations'][configuration] - - # Merge in parents. - for parent in configuration_dict.get('inherit_from', []): - MergeConfigWithInheritance(new_configuration_dict, build_file, - target_dict, parent, visited + [configuration]) - - # Merge it into the new config. - MergeDicts(new_configuration_dict, configuration_dict, - build_file, build_file) - - # Drop abstract. - if 'abstract' in new_configuration_dict: - del new_configuration_dict['abstract'] - - -def SetUpConfigurations(target, target_dict): - global non_configuration_keys - # key_suffixes is a list of key suffixes that might appear on key names. - # These suffixes are handled in conditional evaluations (for =, +, and ?) - # and rules/exclude processing (for ! and /). Keys with these suffixes - # should be treated the same as keys without. - key_suffixes = ['=', '+', '?', '!', '/'] - - build_file = gyp.common.BuildFile(target) - - # Provide a single configuration by default if none exists. - # TODO(mark): Signal an error if default_configurations exists but - # configurations does not. - if not 'configurations' in target_dict: - target_dict['configurations'] = {'Default': {}} - if not 'default_configuration' in target_dict: - concrete = [i for i in target_dict['configurations'].keys() - if not target_dict['configurations'][i].get('abstract')] - target_dict['default_configuration'] = sorted(concrete)[0] - - for configuration in target_dict['configurations'].keys(): - old_configuration_dict = target_dict['configurations'][configuration] - # Skip abstract configurations (saves work only). - if old_configuration_dict.get('abstract'): - continue - # Configurations inherit (most) settings from the enclosing target scope. - # Get the inheritance relationship right by making a copy of the target - # dict. - new_configuration_dict = copy.deepcopy(target_dict) - - # Take out the bits that don't belong in a "configurations" section. - # Since configuration setup is done before conditional, exclude, and rules - # processing, be careful with handling of the suffix characters used in - # those phases. - delete_keys = [] - for key in new_configuration_dict: - key_ext = key[-1:] - if key_ext in key_suffixes: - key_base = key[:-1] - else: - key_base = key - if key_base in non_configuration_keys: - delete_keys.append(key) - - for key in delete_keys: - del new_configuration_dict[key] - - # Merge in configuration (with all its parents first). - MergeConfigWithInheritance(new_configuration_dict, build_file, - target_dict, configuration, []) - - # Put the new result back into the target dict as a configuration. - target_dict['configurations'][configuration] = new_configuration_dict - - # Now drop all the abstract ones. - for configuration in target_dict['configurations'].keys(): - old_configuration_dict = target_dict['configurations'][configuration] - if old_configuration_dict.get('abstract'): - del target_dict['configurations'][configuration] - - # Now that all of the target's configurations have been built, go through - # the target dict's keys and remove everything that's been moved into a - # "configurations" section. - delete_keys = [] - for key in target_dict: - key_ext = key[-1:] - if key_ext in key_suffixes: - key_base = key[:-1] - else: - key_base = key - if not key_base in non_configuration_keys: - delete_keys.append(key) - for key in delete_keys: - del target_dict[key] - - # Check the configurations to see if they contain invalid keys. - for configuration in target_dict['configurations'].keys(): - configuration_dict = target_dict['configurations'][configuration] - for key in configuration_dict.keys(): - if key in invalid_configuration_keys: - raise KeyError, ('%s not allowed in the %s configuration, found in ' - 'target %s' % (key, configuration, target)) - - - -def ProcessListFiltersInDict(name, the_dict): - """Process regular expression and exclusion-based filters on lists. - - An exclusion list is in a dict key named with a trailing "!", like - "sources!". Every item in such a list is removed from the associated - main list, which in this example, would be "sources". Removed items are - placed into a "sources_excluded" list in the dict. - - Regular expression (regex) filters are contained in dict keys named with a - trailing "/", such as "sources/" to operate on the "sources" list. Regex - filters in a dict take the form: - 'sources/': [ ['exclude', '_(linux|mac|win)\\.cc$'], - ['include', '_mac\\.cc$'] ], - The first filter says to exclude all files ending in _linux.cc, _mac.cc, and - _win.cc. The second filter then includes all files ending in _mac.cc that - are now or were once in the "sources" list. Items matching an "exclude" - filter are subject to the same processing as would occur if they were listed - by name in an exclusion list (ending in "!"). Items matching an "include" - filter are brought back into the main list if previously excluded by an - exclusion list or exclusion regex filter. Subsequent matching "exclude" - patterns can still cause items to be excluded after matching an "include". - """ - - # Look through the dictionary for any lists whose keys end in "!" or "/". - # These are lists that will be treated as exclude lists and regular - # expression-based exclude/include lists. Collect the lists that are - # needed first, looking for the lists that they operate on, and assemble - # then into |lists|. This is done in a separate loop up front, because - # the _included and _excluded keys need to be added to the_dict, and that - # can't be done while iterating through it. - - lists = [] - del_lists = [] - for key, value in the_dict.iteritems(): - operation = key[-1] - if operation != '!' and operation != '/': - continue - - if not isinstance(value, list): - raise ValueError, name + ' key ' + key + ' must be list, not ' + \ - value.__class__.__name__ - - list_key = key[:-1] - if list_key not in the_dict: - # This happens when there's a list like "sources!" but no corresponding - # "sources" list. Since there's nothing for it to operate on, queue up - # the "sources!" list for deletion now. - del_lists.append(key) - continue - - if not isinstance(the_dict[list_key], list): - raise ValueError, name + ' key ' + list_key + \ - ' must be list, not ' + \ - value.__class__.__name__ + ' when applying ' + \ - {'!': 'exclusion', '/': 'regex'}[operation] - - if not list_key in lists: - lists.append(list_key) - - # Delete the lists that are known to be unneeded at this point. - for del_list in del_lists: - del the_dict[del_list] - - for list_key in lists: - the_list = the_dict[list_key] - - # Initialize the list_actions list, which is parallel to the_list. Each - # item in list_actions identifies whether the corresponding item in - # the_list should be excluded, unconditionally preserved (included), or - # whether no exclusion or inclusion has been applied. Items for which - # no exclusion or inclusion has been applied (yet) have value -1, items - # excluded have value 0, and items included have value 1. Includes and - # excludes override previous actions. All items in list_actions are - # initialized to -1 because no excludes or includes have been processed - # yet. - list_actions = list((-1,) * len(the_list)) - - exclude_key = list_key + '!' - if exclude_key in the_dict: - for exclude_item in the_dict[exclude_key]: - for index in xrange(0, len(the_list)): - if exclude_item == the_list[index]: - # This item matches the exclude_item, so set its action to 0 - # (exclude). - list_actions[index] = 0 - - # The "whatever!" list is no longer needed, dump it. - del the_dict[exclude_key] - - regex_key = list_key + '/' - if regex_key in the_dict: - for regex_item in the_dict[regex_key]: - [action, pattern] = regex_item - pattern_re = re.compile(pattern) - - if action == 'exclude': - # This item matches an exclude regex, so set its value to 0 (exclude). - action_value = 0 - elif action == 'include': - # This item matches an include regex, so set its value to 1 (include). - action_value = 1 - else: - # This is an action that doesn't make any sense. - raise ValueError, 'Unrecognized action ' + action + ' in ' + name + \ - ' key ' + key - - for index in xrange(0, len(the_list)): - list_item = the_list[index] - if list_actions[index] == action_value: - # Even if the regex matches, nothing will change so continue (regex - # searches are expensive). - continue - if pattern_re.search(list_item): - # Regular expression match. - list_actions[index] = action_value - - # The "whatever/" list is no longer needed, dump it. - del the_dict[regex_key] - - # Add excluded items to the excluded list. - # - # Note that exclude_key ("sources!") is different from excluded_key - # ("sources_excluded"). The exclude_key list is input and it was already - # processed and deleted; the excluded_key list is output and it's about - # to be created. - excluded_key = list_key + '_excluded' - if excluded_key in the_dict: - raise KeyError, \ - name + ' key ' + excluded_key + ' must not be present prior ' + \ - ' to applying exclusion/regex filters for ' + list_key - - excluded_list = [] - - # Go backwards through the list_actions list so that as items are deleted, - # the indices of items that haven't been seen yet don't shift. That means - # that things need to be prepended to excluded_list to maintain them in the - # same order that they existed in the_list. - for index in xrange(len(list_actions) - 1, -1, -1): - if list_actions[index] == 0: - # Dump anything with action 0 (exclude). Keep anything with action 1 - # (include) or -1 (no include or exclude seen for the item). - excluded_list.insert(0, the_list[index]) - del the_list[index] - - # If anything was excluded, put the excluded list into the_dict at - # excluded_key. - if len(excluded_list) > 0: - the_dict[excluded_key] = excluded_list - - # Now recurse into subdicts and lists that may contain dicts. - for key, value in the_dict.iteritems(): - if isinstance(value, dict): - ProcessListFiltersInDict(key, value) - elif isinstance(value, list): - ProcessListFiltersInList(key, value) - - -def ProcessListFiltersInList(name, the_list): - for item in the_list: - if isinstance(item, dict): - ProcessListFiltersInDict(name, item) - elif isinstance(item, list): - ProcessListFiltersInList(name, item) - - -def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules): - """Ensures that the rules sections in target_dict are valid and consistent, - and determines which sources they apply to. - - Arguments: - target: string, name of target. - target_dict: dict, target spec containing "rules" and "sources" lists. - extra_sources_for_rules: a list of keys to scan for rule matches in - addition to 'sources'. - """ - - # Dicts to map between values found in rules' 'rule_name' and 'extension' - # keys and the rule dicts themselves. - rule_names = {} - rule_extensions = {} - - rules = target_dict.get('rules', []) - for rule in rules: - # Make sure that there's no conflict among rule names and extensions. - rule_name = rule['rule_name'] - if rule_name in rule_names: - raise KeyError, 'rule %s exists in duplicate, target %s' % \ - (rule_name, target) - rule_names[rule_name] = rule - - rule_extension = rule['extension'] - if rule_extension in rule_extensions: - raise KeyError, ('extension %s associated with multiple rules, ' + - 'target %s rules %s and %s') % \ - (rule_extension, target, - rule_extensions[rule_extension]['rule_name'], - rule_name) - rule_extensions[rule_extension] = rule - - # Make sure rule_sources isn't already there. It's going to be - # created below if needed. - if 'rule_sources' in rule: - raise KeyError, \ - 'rule_sources must not exist in input, target %s rule %s' % \ - (target, rule_name) - extension = rule['extension'] - - rule_sources = [] - source_keys = ['sources'] - source_keys.extend(extra_sources_for_rules) - for source_key in source_keys: - for source in target_dict.get(source_key, []): - (source_root, source_extension) = os.path.splitext(source) - if source_extension.startswith('.'): - source_extension = source_extension[1:] - if source_extension == extension: - rule_sources.append(source) - - if len(rule_sources) > 0: - rule['rule_sources'] = rule_sources - - -def ValidateActionsInTarget(target, target_dict, build_file): - '''Validates the inputs to the actions in a target.''' - target_name = target_dict.get('target_name') - actions = target_dict.get('actions', []) - for action in actions: - action_name = action.get('action_name') - if not action_name: - raise Exception("Anonymous action in target %s. " - "An action must have an 'action_name' field." % - target_name) - inputs = action.get('inputs', []) - - -def ValidateRunAsInTarget(target, target_dict, build_file): - target_name = target_dict.get('target_name') - run_as = target_dict.get('run_as') - if not run_as: - return - if not isinstance(run_as, dict): - raise Exception("The 'run_as' in target %s from file %s should be a " - "dictionary." % - (target_name, build_file)) - action = run_as.get('action') - if not action: - raise Exception("The 'run_as' in target %s from file %s must have an " - "'action' section." % - (target_name, build_file)) - if not isinstance(action, list): - raise Exception("The 'action' for 'run_as' in target %s from file %s " - "must be a list." % - (target_name, build_file)) - working_directory = run_as.get('working_directory') - if working_directory and not isinstance(working_directory, str): - raise Exception("The 'working_directory' for 'run_as' in target %s " - "in file %s should be a string." % - (target_name, build_file)) - environment = run_as.get('environment') - if environment and not isinstance(environment, dict): - raise Exception("The 'environment' for 'run_as' in target %s " - "in file %s should be a dictionary." % - (target_name, build_file)) - - -def TurnIntIntoStrInDict(the_dict): - """Given dict the_dict, recursively converts all integers into strings. - """ - # Use items instead of iteritems because there's no need to try to look at - # reinserted keys and their associated values. - for k, v in the_dict.items(): - if isinstance(v, int): - v = str(v) - the_dict[k] = v - elif isinstance(v, dict): - TurnIntIntoStrInDict(v) - elif isinstance(v, list): - TurnIntIntoStrInList(v) - - if isinstance(k, int): - the_dict[str(k)] = v - del the_dict[k] - - -def TurnIntIntoStrInList(the_list): - """Given list the_list, recursively converts all integers into strings. - """ - for index in xrange(0, len(the_list)): - item = the_list[index] - if isinstance(item, int): - the_list[index] = str(item) - elif isinstance(item, dict): - TurnIntIntoStrInDict(item) - elif isinstance(item, list): - TurnIntIntoStrInList(item) - - -def VerifyNoCollidingTargets(targets): - """Verify that no two targets in the same directory share the same name. - - Arguments: - targets: A list of targets in the form 'path/to/file.gyp:target_name'. - """ - # Keep a dict going from 'subdirectory:target_name' to 'foo.gyp'. - used = {} - for target in targets: - # Separate out 'path/to/file.gyp, 'target_name' from - # 'path/to/file.gyp:target_name'. - path, name = target.rsplit(':', 1) - # Separate out 'path/to', 'file.gyp' from 'path/to/file.gyp'. - subdir, gyp = os.path.split(path) - # Use '.' for the current directory '', so that the error messages make - # more sense. - if not subdir: - subdir = '.' - # Prepare a key like 'path/to:target_name'. - key = subdir + ':' + name - if key in used: - # Complain if this target is already used. - raise Exception('Duplicate target name "%s" in directory "%s" used both ' - 'in "%s" and "%s".' % (name, subdir, gyp, used[key])) - used[key] = gyp - - -def Load(build_files, variables, includes, depth, generator_input_info, check, - circular_check): - # Set up path_sections and non_configuration_keys with the default data plus - # the generator-specifc data. - global path_sections - path_sections = base_path_sections[:] - path_sections.extend(generator_input_info['path_sections']) - - global non_configuration_keys - non_configuration_keys = base_non_configuration_keys[:] - non_configuration_keys.extend(generator_input_info['non_configuration_keys']) - - # TODO(mark) handle variants if the generator doesn't want them directly. - generator_handles_variants = \ - generator_input_info['generator_handles_variants'] - - global absolute_build_file_paths - absolute_build_file_paths = \ - generator_input_info['generator_wants_absolute_build_file_paths'] - - global multiple_toolsets - multiple_toolsets = generator_input_info[ - 'generator_supports_multiple_toolsets'] - - # A generator can have other lists (in addition to sources) be processed - # for rules. - extra_sources_for_rules = generator_input_info['extra_sources_for_rules'] - - # Load build files. This loads every target-containing build file into - # the |data| dictionary such that the keys to |data| are build file names, - # and the values are the entire build file contents after "early" or "pre" - # processing has been done and includes have been resolved. - # NOTE: data contains both "target" files (.gyp) and "includes" (.gypi), as - # well as meta-data (e.g. 'included_files' key). 'target_build_files' keeps - # track of the keys corresponding to "target" files. - data = {'target_build_files': set()} - aux_data = {} - for build_file in build_files: - # Normalize paths everywhere. This is important because paths will be - # used as keys to the data dict and for references between input files. - build_file = os.path.normpath(build_file) - try: - LoadTargetBuildFile(build_file, data, aux_data, variables, includes, - depth, check) - except Exception, e: - gyp.common.ExceptionAppend(e, 'while trying to load %s' % build_file) - raise - - # Build a dict to access each target's subdict by qualified name. - targets = BuildTargetsDict(data) - - # Fully qualify all dependency links. - QualifyDependencies(targets) - - # Expand dependencies specified as build_file:*. - ExpandWildcardDependencies(targets, data) - - # Apply exclude (!) and regex (/) list filters only for dependency_sections. - for target_name, target_dict in targets.iteritems(): - tmp_dict = {} - for key_base in dependency_sections: - for op in ('', '!', '/'): - key = key_base + op - if key in target_dict: - tmp_dict[key] = target_dict[key] - del target_dict[key] - ProcessListFiltersInDict(target_name, tmp_dict) - # Write the results back to |target_dict|. - for key in tmp_dict: - target_dict[key] = tmp_dict[key] - - if circular_check: - # Make sure that any targets in a.gyp don't contain dependencies in other - # .gyp files that further depend on a.gyp. - VerifyNoGYPFileCircularDependencies(targets) - - [dependency_nodes, flat_list] = BuildDependencyList(targets) - - # Check that no two targets in the same directory have the same name. - VerifyNoCollidingTargets(flat_list) - - # Handle dependent settings of various types. - for settings_type in ['all_dependent_settings', - 'direct_dependent_settings', - 'link_settings']: - DoDependentSettings(settings_type, flat_list, targets, dependency_nodes) - - # Take out the dependent settings now that they've been published to all - # of the targets that require them. - for target in flat_list: - if settings_type in targets[target]: - del targets[target][settings_type] - - # Make sure static libraries don't declare dependencies on other static - # libraries, but that linkables depend on all unlinked static libraries - # that they need so that their link steps will be correct. - gii = generator_input_info - if gii['generator_wants_static_library_dependencies_adjusted']: - AdjustStaticLibraryDependencies(flat_list, targets, dependency_nodes, - gii['generator_wants_sorted_dependencies']) - - # Apply "post"/"late"/"target" variable expansions and condition evaluations. - for target in flat_list: - target_dict = targets[target] - build_file = gyp.common.BuildFile(target) - ProcessVariablesAndConditionsInDict(target_dict, True, variables, - build_file) - - # Move everything that can go into a "configurations" section into one. - for target in flat_list: - target_dict = targets[target] - SetUpConfigurations(target, target_dict) - - # Apply exclude (!) and regex (/) list filters. - for target in flat_list: - target_dict = targets[target] - ProcessListFiltersInDict(target, target_dict) - - # Make sure that the rules make sense, and build up rule_sources lists as - # needed. Not all generators will need to use the rule_sources lists, but - # some may, and it seems best to build the list in a common spot. - # Also validate actions and run_as elements in targets. - for target in flat_list: - target_dict = targets[target] - build_file = gyp.common.BuildFile(target) - ValidateRulesInTarget(target, target_dict, extra_sources_for_rules) - ValidateRunAsInTarget(target, target_dict, build_file) - ValidateActionsInTarget(target, target_dict, build_file) - - # Generators might not expect ints. Turn them into strs. - TurnIntIntoStrInDict(data) - - # TODO(mark): Return |data| for now because the generator needs a list of - # build files that came in. In the future, maybe it should just accept - # a list, and not the whole data dict. - return [flat_list, targets, data] diff --git a/third_party/gyp/pylib/gyp/mac_tool.py b/third_party/gyp/pylib/gyp/mac_tool.py deleted file mode 100644 index b3333c7..0000000 --- a/third_party/gyp/pylib/gyp/mac_tool.py +++ /dev/null @@ -1,187 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Utility functions to perform Xcode-style build steps. - -These functions are executed via gyp-mac-tool when using the Makefile generator. -""" - -import os -import fcntl -import plistlib -import shutil -import string -import subprocess -import sys - -def main(args): - executor = MacTool() - executor.Dispatch(args) - -class MacTool(object): - """This class performs all the Mac tooling steps. The methods can either be - executed directly, or dispatched from an argument list.""" - - def Dispatch(self, args): - """Dispatches a string command to a method.""" - if len(args) < 1: - raise Exception("Not enough arguments") - - method = "Exec%s" % self._CommandifyName(args[0]) - getattr(self, method)(*args[1:]) - - def _CommandifyName(self, name_string): - """Transforms a tool name like copy-info-plist to CopyInfoPlist""" - return name_string.title().replace('-', '') - - def ExecFlock(self, lockfile, *cmd_list): - """Emulates the most basic behavior of Linux's flock(1).""" - # Rely on exception handling to report errors. - fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) - fcntl.flock(fd, fcntl.LOCK_EX) - return subprocess.call(cmd_list) - - def ExecCopyInfoPlist(self, source, dest): - """Copies the |source| Info.plist to the destination directory |dest|.""" - # Read the source Info.plist into memory. - fd = open(source, 'r') - lines = fd.read() - fd.close() - - # Go through all the environment variables and replace them as variables in - # the file. - for key in os.environ: - if key.startswith('_'): - continue - evar = '${%s}' % key - lines = string.replace(lines, evar, os.environ[key]) - - # Write out the file with variables replaced. - fd = open(dest, 'w') - fd.write(lines) - fd.close() - - # Now write out PkgInfo file now that the Info.plist file has been - # "compiled". - self._WritePkgInfo(dest) - - def _WritePkgInfo(self, info_plist): - """This writes the PkgInfo file from the data stored in Info.plist.""" - plist = plistlib.readPlist(info_plist) - if not plist: - return - - # The format of PkgInfo is eight characters, representing the bundle type - # and bundle signature, each four characters. If either is missing, four - # '?' characters are used instead. - package_type = plist['CFBundlePackageType'] - if len(package_type) != 4: - package_type = '?' * 4 - signature_code = plist['CFBundleSignature'] - if len(signature_code) != 4: - signature_code = '?' * 4 - - dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo') - fp = open(dest, 'w') - fp.write('%s%s' % (package_type, signature_code)) - fp.close() - - def ExecPackageFramework(self, framework, version): - """Takes a path to Something.framework and the Current version of that and - sets up all the symlinks.""" - # Find the name of the binary based on the part before the ".framework". - binary = os.path.basename(framework).split('.')[0] - - CURRENT = 'Current' - RESOURCES = 'Resources' - VERSIONS = 'Versions' - - if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): - # Binary-less frameworks don't seem to contain symlinks (see e.g. - # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). - return - - # Move into the framework directory to set the symlinks correctly. - pwd = os.getcwd() - os.chdir(framework) - - # Set up the Current version. - self._Relink(version, os.path.join(VERSIONS, CURRENT)) - - # Set up the root symlinks. - self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary) - self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) - - # Back to where we were before! - os.chdir(pwd) - - def _Relink(self, dest, link): - """Creates a symlink to |dest| named |link|. If |link| already exists, - it is overwritten.""" - if os.path.lexists(link): - os.remove(link) - os.symlink(dest, link) - - def ExecCopyBundleResource(self, source, dest): - """Copies a resource file to the bundle/Resources directory, performing any - necessary compilation on each resource.""" - extension = os.path.splitext(source)[1].lower() - if os.path.isdir(source): - # Copy tree. - if os.path.exists(dest): - shutil.rmtree(dest) - shutil.copytree(source, dest) - elif extension == '.xib': - self._CopyXIBFile(source, dest) - elif extension == '.strings': - self._CopyStringsFile(source, dest) - # TODO: Given that files with arbitrary extensions can be copied to the - # bundle, we will want to get rid of this whitelist eventually. - elif extension in [ - '.icns', '.manifest', '.pak', '.pdf', '.png', '.sb', '.sh', - '.ttf', '.sdef']: - shutil.copyfile(source, dest) - else: - raise NotImplementedError( - "Don't know how to copy bundle resources of type %s while copying " - "%s to %s)" % (extension, source, dest)) - - def _CopyXIBFile(self, source, dest): - """Compiles a XIB file with ibtool into a binary plist in the bundle.""" - args = ['/Developer/usr/bin/ibtool', '--errors', '--warnings', - '--notices', '--output-format', 'human-readable-text', '--compile', - dest, source] - subprocess.call(args) - - def _CopyStringsFile(self, source, dest): - """Copies a .strings file using iconv to reconvert the input into UTF-16.""" - input_code = self._DetectInputEncoding(source) or "UTF-8" - fp = open(dest, 'w') - args = ['/usr/bin/iconv', '--from-code', input_code, '--to-code', - 'UTF-16', source] - subprocess.call(args, stdout=fp) - fp.close() - - def _DetectInputEncoding(self, file_name): - """Reads the first few bytes from file_name and tries to guess the text - encoding. Returns None as a guess if it can't detect it.""" - fp = open(file_name, 'rb') - try: - header = fp.read(3) - except e: - fp.close() - return None - fp.close() - if header.startswith("\xFE\xFF"): - return "UTF-16BE" - elif header.startswith("\xFF\xFE"): - return "UTF-16LE" - elif header.startswith("\xEF\xBB\xBF"): - return "UTF-8" - else: - return None - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/third_party/gyp/pylib/gyp/ninja_syntax.py b/third_party/gyp/pylib/gyp/ninja_syntax.py deleted file mode 100644 index a873522..0000000 --- a/third_party/gyp/pylib/gyp/ninja_syntax.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/python - -# This file comes from -# https://github.com/martine/ninja/blob/master/misc/ninja_syntax.py -# Do not edit! Edit the upstream one instead. - -"""Python module for generating .ninja files. - -Note that this is emphatically not a required piece of Ninja; it's -just a helpful utility for build-file-generation systems that already -use Python. -""" - -import textwrap - -class Writer(object): - def __init__(self, output, width=78): - self.output = output - self.width = width - - def newline(self): - self.output.write('\n') - - def comment(self, text): - for line in textwrap.wrap(text, self.width - 2): - self.output.write('# ' + line + '\n') - - def variable(self, key, value, indent=0): - self._line('%s = %s' % (key, value), indent) - - def rule(self, name, command, description=None, depfile=None): - self._line('rule %s' % name) - self.variable('command', command, indent=1) - if description: - self.variable('description', description, indent=1) - if depfile: - self.variable('depfile', depfile, indent=1) - - def build(self, outputs, rule, inputs=None, implicit=None, order_only=None, - variables=None): - outputs = self._as_list(outputs) - all_inputs = self._as_list(inputs)[:] - - if implicit: - all_inputs.append('|') - all_inputs.extend(self._as_list(implicit)) - if order_only: - all_inputs.append('||') - all_inputs.extend(self._as_list(order_only)) - - self._line('build %s: %s %s' % (' '.join(outputs), - rule, - ' '.join(all_inputs))) - - if variables: - for key, val in variables: - self.variable(key, val, indent=1) - - return outputs - - def include(self, path): - self._line('include %s' % path) - - def subninja(self, path): - self._line('subninja %s' % path) - - def _line(self, text, indent=0): - """Write 'text' word-wrapped at self.width characters.""" - leading_space = ' ' * indent - while len(text) > self.width: - # The text is too wide; wrap if possible. - - # Find the rightmost space that would obey our width constraint. - available_space = self.width - len(leading_space) - len(' $') - space = text.rfind(' ', 0, available_space) - if space < 0: - # No such space; just use the first space we can find. - space = text.find(' ', available_space) - if space < 0: - # Give up on breaking. - break - - self.output.write(leading_space + text[0:space] + ' $\n') - text = text[space+1:] - - # Subsequent lines are continuations, so indent them. - leading_space = ' ' * (indent+2) - - self.output.write(leading_space + text + '\n') - - def _as_list(self, input): - if input is None: - return [] - if isinstance(input, list): - return input - return [input] - - -def escape(string): - """Escape a string such that it can be embedded into a Ninja file without - further interpretation.""" - assert '\n' not in string, 'Ninja syntax does not allow newlines' - # We only have one special metacharacter: '$'. - return string.replace('$', '$$') diff --git a/third_party/gyp/pylib/gyp/system_test.py b/third_party/gyp/pylib/gyp/system_test.py deleted file mode 100644 index 887d57d..0000000 --- a/third_party/gyp/pylib/gyp/system_test.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import os -import tempfile -import shutil -import subprocess - -def TestCommands(commands, files={}, env={}): - """Run commands in a temporary directory, returning true if they all succeed. - Return false on failures or if any commands produce output. - - Arguments: - commands: an array of shell-interpretable commands, e.g. ['ls -l', 'pwd'] - each will be expanded with Python %-expansion using env first. - files: a dictionary mapping filename to contents; - files will be created in the temporary directory before running - the command. - env: a dictionary of strings to expand commands with. - """ - tempdir = tempfile.mkdtemp() - try: - for name, contents in files.items(): - f = open(os.path.join(tempdir, name), 'wb') - f.write(contents) - f.close() - for command in commands: - proc = subprocess.Popen(command % env, shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - cwd=tempdir) - output = proc.communicate()[0] - if proc.returncode != 0 or output: - return False - return True - finally: - shutil.rmtree(tempdir) - return False - - -def TestArSupportsT(ar_command='ar', cc_command='cc'): - """Test whether 'ar' supports the 'T' flag.""" - return TestCommands(['%(cc)s -c test.c', - '%(ar)s crsT test.a test.o', - '%(cc)s test.a'], - files={'test.c': 'int main(){}'}, - env={'ar': ar_command, 'cc': cc_command}) - - -def TestLinkerSupportsThreads(cc_command='cc'): - """Test whether the linker supports the --threads flag.""" - return TestCommands(['%(cc)s -Wl,--threads test.c'], - files={'test.c': 'int main(){}'}, - env={'cc': cc_command}) - - -def TestLinkerSupportsICF(cc_command='cc'): - """Test whether the linker supports identical code folding.""" - return TestCommands(['%(cc)s -Wl,--icf=safe test.c'], - files={'test.c': 'int main(){}'}, - env={'cc': cc_command}) - - -if __name__ == '__main__': - # Run the various test functions and print the results. - def RunTest(description, function, **kwargs): - print "Testing " + description + ':', - if function(**kwargs): - print 'ok' - else: - print 'fail' - RunTest("ar 'T' flag", TestArSupportsT) - RunTest("ar 'T' flag with ccache", TestArSupportsT, cc_command='ccache cc') - RunTest("ld --threads", TestLinkerSupportsThreads) diff --git a/third_party/gyp/pylib/gyp/xcodeproj_file.py b/third_party/gyp/pylib/gyp/xcodeproj_file.py deleted file mode 100644 index fcf9abf..0000000 --- a/third_party/gyp/pylib/gyp/xcodeproj_file.py +++ /dev/null @@ -1,2840 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Xcode project file generator. - -This module is both an Xcode project file generator and a documentation of the -Xcode project file format. Knowledge of the project file format was gained -based on extensive experience with Xcode, and by making changes to projects in -Xcode.app and observing the resultant changes in the associated project files. - -XCODE PROJECT FILES - -The generator targets the file format as written by Xcode 3.1 (specifically, -3.1.2), but past experience has taught that the format has not changed -significantly in the past several years, and future versions of Xcode are able -to read older project files. - -Xcode project files are "bundled": the project "file" from an end-user's -perspective is actually a directory with an ".xcodeproj" extension. The -project file from this module's perspective is actually a file inside this -directory, always named "project.pbxproj". This file contains a complete -description of the project and is all that is needed to use the xcodeproj. -Other files contained in the xcodeproj directory are simply used to store -per-user settings, such as the state of various UI elements in the Xcode -application. - -The project.pbxproj file is a property list, stored in a format almost -identical to the NeXTstep property list format. The file is able to carry -Unicode data, and is encoded in UTF-8. The root element in the property list -is a dictionary that contains several properties of minimal interest, and two -properties of immense interest. The most important property is a dictionary -named "objects". The entire structure of the project is represented by the -children of this property. The objects dictionary is keyed by unique 96-bit -values represented by 24 uppercase hexadecimal characters. Each value in the -objects dictionary is itself a dictionary, describing an individual object. - -Each object in the dictionary is a member of a class, which is identified by -the "isa" property of each object. A variety of classes are represented in a -project file. Objects can refer to other objects by ID, using the 24-character -hexadecimal object key. A project's objects form a tree, with a root object -of class PBXProject at the root. As an example, the PBXProject object serves -as parent to an XCConfigurationList object defining the build configurations -used in the project, a PBXGroup object serving as a container for all files -referenced in the project, and a list of target objects, each of which defines -a target in the project. There are several different types of target object, -such as PBXNativeTarget and PBXAggregateTarget. In this module, this -relationship is expressed by having each target type derive from an abstract -base named XCTarget. - -The project.pbxproj file's root dictionary also contains a property, sibling to -the "objects" dictionary, named "rootObject". The value of rootObject is a -24-character object key referring to the root PBXProject object in the -objects dictionary. - -In Xcode, every file used as input to a target or produced as a final product -of a target must appear somewhere in the hierarchy rooted at the PBXGroup -object referenced by the PBXProject's mainGroup property. A PBXGroup is -generally represented as a folder in the Xcode application. PBXGroups can -contain other PBXGroups as well as PBXFileReferences, which are pointers to -actual files. - -Each XCTarget contains a list of build phases, represented in this module by -the abstract base XCBuildPhase. Examples of concrete XCBuildPhase derivations -are PBXSourcesBuildPhase and PBXFrameworksBuildPhase, which correspond to the -"Compile Sources" and "Link Binary With Libraries" phases displayed in the -Xcode application. Files used as input to these phases (for example, source -files in the former case and libraries and frameworks in the latter) are -represented by PBXBuildFile objects, referenced by elements of "files" lists -in XCTarget objects. Each PBXBuildFile object refers to a PBXBuildFile -object as a "weak" reference: it does not "own" the PBXBuildFile, which is -owned by the root object's mainGroup or a descendant group. In most cases, the -layer of indirection between an XCBuildPhase and a PBXFileReference via a -PBXBuildFile appears extraneous, but there's actually one reason for this: -file-specific compiler flags are added to the PBXBuildFile object so as to -allow a single file to be a member of multiple targets while having distinct -compiler flags for each. These flags can be modified in the Xcode applciation -in the "Build" tab of a File Info window. - -When a project is open in the Xcode application, Xcode will rewrite it. As -such, this module is careful to adhere to the formatting used by Xcode, to -avoid insignificant changes appearing in the file when it is used in the -Xcode application. This will keep version control repositories happy, and -makes it possible to compare a project file used in Xcode to one generated by -this module to determine if any significant changes were made in the -application. - -Xcode has its own way of assigning 24-character identifiers to each object, -which is not duplicated here. Because the identifier only is only generated -once, when an object is created, and is then left unchanged, there is no need -to attempt to duplicate Xcode's behavior in this area. The generator is free -to select any identifier, even at random, to refer to the objects it creates, -and Xcode will retain those identifiers and use them when subsequently -rewriting the project file. However, the generator would choose new random -identifiers each time the project files are generated, leading to difficulties -comparing "used" project files to "pristine" ones produced by this module, -and causing the appearance of changes as every object identifier is changed -when updated projects are checked in to a version control repository. To -mitigate this problem, this module chooses identifiers in a more deterministic -way, by hashing a description of each object as well as its parent and ancestor -objects. This strategy should result in minimal "shift" in IDs as successive -generations of project files are produced. - -THIS MODULE - -This module introduces several classes, all derived from the XCObject class. -Nearly all of the "brains" are built into the XCObject class, which understands -how to create and modify objects, maintain the proper tree structure, compute -identifiers, and print objects. For the most part, classes derived from -XCObject need only provide a _schema class object, a dictionary that -expresses what properties objects of the class may contain. - -Given this structure, it's possible to build a minimal project file by creating -objects of the appropriate types and making the proper connections: - - config_list = XCConfigurationList() - group = PBXGroup() - project = PBXProject({'buildConfigurationList': config_list, - 'mainGroup': group}) - -With the project object set up, it can be added to an XCProjectFile object. -XCProjectFile is a pseudo-class in the sense that it is a concrete XCObject -subclass that does not actually correspond to a class type found in a project -file. Rather, it is used to represent the project file's root dictionary. -Printing an XCProjectFile will print the entire project file, including the -full "objects" dictionary. - - project_file = XCProjectFile({'rootObject': project}) - project_file.ComputeIDs() - project_file.Print() - -Xcode project files are always encoded in UTF-8. This module will accept -strings of either the str class or the unicode class. Strings of class str -are assumed to already be encoded in UTF-8. Obviously, if you're just using -ASCII, you won't encounter difficulties because ASCII is a UTF-8 subset. -Strings of class unicode are handled properly and encoded in UTF-8 when -a project file is output. -""" - -import gyp.common -import posixpath -import re -import struct -import sys - -# hashlib is supplied as of Python 2.5 as the replacement interface for sha -# and other secure hashes. In 2.6, sha is deprecated. Import hashlib if -# available, avoiding a deprecation warning under 2.6. Import sha otherwise, -# preserving 2.4 compatibility. -try: - import hashlib - _new_sha1 = hashlib.sha1 -except ImportError: - import sha - _new_sha1 = sha.new - - -# See XCObject._EncodeString. This pattern is used to determine when a string -# can be printed unquoted. Strings that match this pattern may be printed -# unquoted. Strings that do not match must be quoted and may be further -# transformed to be properly encoded. Note that this expression matches the -# characters listed with "+", for 1 or more occurrences: if a string is empty, -# it must not match this pattern, because it needs to be encoded as "". -_unquoted = re.compile('^[A-Za-z0-9$./_]+$') - -# Strings that match this pattern are quoted regardless of what _unquoted says. -# Oddly, Xcode will quote any string with a run of three or more underscores. -_quoted = re.compile('___') - -# This pattern should match any character that needs to be escaped by -# XCObject._EncodeString. See that function. -_escaped = re.compile('[\\\\"]|[^ -~]') - - -# Used by SourceTreeAndPathFromPath -_path_leading_variable = re.compile('^\$\((.*?)\)(/(.*))?$') - -def SourceTreeAndPathFromPath(input_path): - """Given input_path, returns a tuple with sourceTree and path values. - - Examples: - input_path (source_tree, output_path) - '$(VAR)/path' ('VAR', 'path') - '$(VAR)' ('VAR', None) - 'path' (None, 'path') - """ - - source_group_match = _path_leading_variable.match(input_path) - if source_group_match: - source_tree = source_group_match.group(1) - output_path = source_group_match.group(3) # This may be None. - else: - source_tree = None - output_path = input_path - - return (source_tree, output_path) - -def ConvertVariablesToShellSyntax(input_string): - return re.sub('\$\((.*?)\)', '${\\1}', input_string) - -class XCObject(object): - """The abstract base of all class types used in Xcode project files. - - Class variables: - _schema: A dictionary defining the properties of this class. The keys to - _schema are string property keys as used in project files. Values - are a list of four or five elements: - [ is_list, property_type, is_strong, is_required, default ] - is_list: True if the property described is a list, as opposed - to a single element. - property_type: The type to use as the value of the property, - or if is_list is True, the type to use for each - element of the value's list. property_type must - be an XCObject subclass, or one of the built-in - types str, int, or dict. - is_strong: If property_type is an XCObject subclass, is_strong - is True to assert that this class "owns," or serves - as parent, to the property value (or, if is_list is - True, values). is_strong must be False if - property_type is not an XCObject subclass. - is_required: True if the property is required for the class. - Note that is_required being True does not preclude - an empty string ("", in the case of property_type - str) or list ([], in the case of is_list True) from - being set for the property. - default: Optional. If is_requried is True, default may be set - to provide a default value for objects that do not supply - their own value. If is_required is True and default - is not provided, users of the class must supply their own - value for the property. - Note that although the values of the array are expressed in - boolean terms, subclasses provide values as integers to conserve - horizontal space. - _should_print_single_line: False in XCObject. Subclasses whose objects - should be written to the project file in the - alternate single-line format, such as - PBXFileReference and PBXBuildFile, should - set this to True. - _encode_transforms: Used by _EncodeString to encode unprintable characters. - The index into this list is the ordinal of the - character to transform; each value is a string - used to represent the character in the output. XCObject - provides an _encode_transforms list suitable for most - XCObject subclasses. - _alternate_encode_transforms: Provided for subclasses that wish to use - the alternate encoding rules. Xcode seems - to use these rules when printing objects in - single-line format. Subclasses that desire - this behavior should set _encode_transforms - to _alternate_encode_transforms. - _hashables: A list of XCObject subclasses that can be hashed by ComputeIDs - to construct this object's ID. Most classes that need custom - hashing behavior should do it by overriding Hashables, - but in some cases an object's parent may wish to push a - hashable value into its child, and it can do so by appending - to _hashables. - Attribues: - id: The object's identifier, a 24-character uppercase hexadecimal string. - Usually, objects being created should not set id until the entire - project file structure is built. At that point, UpdateIDs() should - be called on the root object to assign deterministic values for id to - each object in the tree. - parent: The object's parent. This is set by a parent XCObject when a child - object is added to it. - _properties: The object's property dictionary. An object's properties are - described by its class' _schema variable. - """ - - _schema = {} - _should_print_single_line = False - - # See _EncodeString. - _encode_transforms = [] - i = 0 - while i < ord(' '): - _encode_transforms.append('\\U%04x' % i) - i = i + 1 - _encode_transforms[7] = '\\a' - _encode_transforms[8] = '\\b' - _encode_transforms[9] = '\\t' - _encode_transforms[10] = '\\n' - _encode_transforms[11] = '\\v' - _encode_transforms[12] = '\\f' - _encode_transforms[13] = '\\n' - - _alternate_encode_transforms = list(_encode_transforms) - _alternate_encode_transforms[9] = chr(9) - _alternate_encode_transforms[10] = chr(10) - _alternate_encode_transforms[11] = chr(11) - - def __init__(self, properties=None, id=None, parent=None): - self.id = id - self.parent = parent - self._properties = {} - self._hashables = [] - self._SetDefaultsFromSchema() - self.UpdateProperties(properties) - - def __repr__(self): - try: - name = self.Name() - except NotImplementedError: - return '<%s at 0x%x>' % (self.__class__.__name__, id(self)) - return '<%s %r at 0x%x>' % (self.__class__.__name__, name, id(self)) - - def Copy(self): - """Make a copy of this object. - - The new object will have its own copy of lists and dicts. Any XCObject - objects owned by this object (marked "strong") will be copied in the - new object, even those found in lists. If this object has any weak - references to other XCObjects, the same references are added to the new - object without making a copy. - """ - - that = self.__class__(id=self.id, parent=self.parent) - for key, value in self._properties.iteritems(): - is_strong = self._schema[key][2] - - if isinstance(value, XCObject): - if is_strong: - new_value = value.Copy() - new_value.parent = that - that._properties[key] = new_value - else: - that._properties[key] = value - elif isinstance(value, str) or isinstance(value, unicode) or \ - isinstance(value, int): - that._properties[key] = value - elif isinstance(value, list): - if is_strong: - # If is_strong is True, each element is an XCObject, so it's safe to - # call Copy. - that._properties[key] = [] - for item in value: - new_item = item.Copy() - new_item.parent = that - that._properties[key].append(new_item) - else: - that._properties[key] = value[:] - elif isinstance(value, dict): - # dicts are never strong. - if is_strong: - raise TypeError, 'Strong dict for key ' + key + ' in ' + \ - self.__class__.__name__ - else: - that._properties[key] = value.copy() - else: - raise TypeError, 'Unexpected type ' + value.__class__.__name__ + \ - ' for key ' + key + ' in ' + self.__class__.__name__ - - return that - - def Name(self): - """Return the name corresponding to an object. - - Not all objects necessarily need to be nameable, and not all that do have - a "name" property. Override as needed. - """ - - # If the schema indicates that "name" is required, try to access the - # property even if it doesn't exist. This will result in a KeyError - # being raised for the property that should be present, which seems more - # appropriate than NotImplementedError in this case. - if 'name' in self._properties or \ - ('name' in self._schema and self._schema['name'][3]): - return self._properties['name'] - - raise NotImplementedError, \ - self.__class__.__name__ + ' must implement Name' - - def Comment(self): - """Return a comment string for the object. - - Most objects just use their name as the comment, but PBXProject uses - different values. - - The returned comment is not escaped and does not have any comment marker - strings applied to it. - """ - - return self.Name() - - def Hashables(self): - hashables = [self.__class__.__name__] - - name = self.Name() - if name != None: - hashables.append(name) - - hashables.extend(self._hashables) - - return hashables - - def ComputeIDs(self, recursive=True, overwrite=True, hash=None): - """Set "id" properties deterministically. - - An object's "id" property is set based on a hash of its class type and - name, as well as the class type and name of all ancestor objects. As - such, it is only advisable to call ComputeIDs once an entire project file - tree is built. - - If recursive is True, recurse into all descendant objects and update their - hashes. - - If overwrite is True, any existing value set in the "id" property will be - replaced. - """ - - def _HashUpdate(hash, data): - """Update hash with data's length and contents. - - If the hash were updated only with the value of data, it would be - possible for clowns to induce collisions by manipulating the names of - their objects. By adding the length, it's exceedingly less likely that - ID collisions will be encountered, intentionally or not. - """ - - hash.update(struct.pack('>i', len(data))) - hash.update(data) - - if hash == None: - hash = _new_sha1() - - hashables = self.Hashables() - assert len(hashables) > 0 - for hashable in hashables: - _HashUpdate(hash, hashable) - - if recursive: - for child in self.Children(): - child.ComputeIDs(recursive, overwrite, hash.copy()) - - if overwrite or self.id == None: - # Xcode IDs are only 96 bits (24 hex characters), but a SHA-1 digest is - # is 160 bits. Instead of throwing out 64 bits of the digest, xor them - # into the portion that gets used. - assert hash.digest_size % 4 == 0 - digest_int_count = hash.digest_size / 4 - digest_ints = struct.unpack('>' + 'I' * digest_int_count, hash.digest()) - id_ints = [0, 0, 0] - for index in xrange(0, digest_int_count): - id_ints[index % 3] ^= digest_ints[index] - self.id = '%08X%08X%08X' % tuple(id_ints) - - def EnsureNoIDCollisions(self): - """Verifies that no two objects have the same ID. Checks all descendants. - """ - - ids = {} - descendants = self.Descendants() - for descendant in descendants: - if descendant.id in ids: - other = ids[descendant.id] - raise KeyError, \ - 'Duplicate ID %s, objects "%s" and "%s" in "%s"' % \ - (descendant.id, str(descendant._properties), - str(other._properties), self._properties['rootObject'].Name()) - ids[descendant.id] = descendant - - def Children(self): - """Returns a list of all of this object's owned (strong) children.""" - - children = [] - for property, attributes in self._schema.iteritems(): - (is_list, property_type, is_strong) = attributes[0:3] - if is_strong and property in self._properties: - if not is_list: - children.append(self._properties[property]) - else: - children.extend(self._properties[property]) - return children - - def Descendants(self): - """Returns a list of all of this object's descendants, including this - object. - """ - - children = self.Children() - descendants = [self] - for child in children: - descendants.extend(child.Descendants()) - return descendants - - def PBXProjectAncestor(self): - # The base case for recursion is defined at PBXProject.PBXProjectAncestor. - if self.parent: - return self.parent.PBXProjectAncestor() - return None - - def _EncodeComment(self, comment): - """Encodes a comment to be placed in the project file output, mimicing - Xcode behavior. - """ - - # This mimics Xcode behavior by wrapping the comment in "/*" and "*/". If - # the string already contains a "*/", it is turned into "(*)/". This keeps - # the file writer from outputting something that would be treated as the - # end of a comment in the middle of something intended to be entirely a - # comment. - - return '/* ' + comment.replace('*/', '(*)/') + ' */' - - def _EncodeTransform(self, match): - # This function works closely with _EncodeString. It will only be called - # by re.sub with match.group(0) containing a character matched by the - # the _escaped expression. - char = match.group(0) - - # Backslashes (\) and quotation marks (") are always replaced with a - # backslash-escaped version of the same. Everything else gets its - # replacement from the class' _encode_transforms array. - if char == '\\': - return '\\\\' - if char == '"': - return '\\"' - return self._encode_transforms[ord(char)] - - def _EncodeString(self, value): - """Encodes a string to be placed in the project file output, mimicing - Xcode behavior. - """ - - # Use quotation marks when any character outside of the range A-Z, a-z, 0-9, - # $ (dollar sign), . (period), and _ (underscore) is present. Also use - # quotation marks to represent empty strings. - # - # Escape " (double-quote) and \ (backslash) by preceding them with a - # backslash. - # - # Some characters below the printable ASCII range are encoded specially: - # 7 ^G BEL is encoded as "\a" - # 8 ^H BS is encoded as "\b" - # 11 ^K VT is encoded as "\v" - # 12 ^L NP is encoded as "\f" - # 127 ^? DEL is passed through as-is without escaping - # - In PBXFileReference and PBXBuildFile objects: - # 9 ^I HT is passed through as-is without escaping - # 10 ^J NL is passed through as-is without escaping - # 13 ^M CR is passed through as-is without escaping - # - In other objects: - # 9 ^I HT is encoded as "\t" - # 10 ^J NL is encoded as "\n" - # 13 ^M CR is encoded as "\n" rendering it indistinguishable from - # 10 ^J NL - # All other nonprintable characters within the ASCII range (0 through 127 - # inclusive) are encoded as "\U001f" referring to the Unicode code point in - # hexadecimal. For example, character 14 (^N SO) is encoded as "\U000e". - # Characters above the ASCII range are passed through to the output encoded - # as UTF-8 without any escaping. These mappings are contained in the - # class' _encode_transforms list. - - if _unquoted.search(value) and not _quoted.search(value): - return value - - return '"' + _escaped.sub(self._EncodeTransform, value) + '"' - - def _XCPrint(self, file, tabs, line): - file.write('\t' * tabs + line) - - def _XCPrintableValue(self, tabs, value, flatten_list=False): - """Returns a representation of value that may be printed in a project file, - mimicing Xcode's behavior. - - _XCPrintableValue can handle str and int values, XCObjects (which are - made printable by returning their id property), and list and dict objects - composed of any of the above types. When printing a list or dict, and - _should_print_single_line is False, the tabs parameter is used to determine - how much to indent the lines corresponding to the items in the list or - dict. - - If flatten_list is True, single-element lists will be transformed into - strings. - """ - - printable = '' - comment = None - - if self._should_print_single_line: - sep = ' ' - element_tabs = '' - end_tabs = '' - else: - sep = '\n' - element_tabs = '\t' * (tabs + 1) - end_tabs = '\t' * tabs - - if isinstance(value, XCObject): - printable += value.id - comment = value.Comment() - elif isinstance(value, str): - printable += self._EncodeString(value) - elif isinstance(value, unicode): - printable += self._EncodeString(value.encode('utf-8')) - elif isinstance(value, int): - printable += str(value) - elif isinstance(value, list): - if flatten_list and len(value) <= 1: - if len(value) == 0: - printable += self._EncodeString('') - else: - printable += self._EncodeString(value[0]) - else: - printable = '(' + sep - for item in value: - printable += element_tabs + \ - self._XCPrintableValue(tabs + 1, item, flatten_list) + \ - ',' + sep - printable += end_tabs + ')' - elif isinstance(value, dict): - printable = '{' + sep - for item_key, item_value in sorted(value.iteritems()): - printable += element_tabs + \ - self._XCPrintableValue(tabs + 1, item_key, flatten_list) + ' = ' + \ - self._XCPrintableValue(tabs + 1, item_value, flatten_list) + ';' + \ - sep - printable += end_tabs + '}' - else: - raise TypeError, "Can't make " + value.__class__.__name__ + ' printable' - - if comment != None: - printable += ' ' + self._EncodeComment(comment) - - return printable - - def _XCKVPrint(self, file, tabs, key, value): - """Prints a key and value, members of an XCObject's _properties dictionary, - to file. - - tabs is an int identifying the indentation level. If the class' - _should_print_single_line variable is True, tabs is ignored and the - key-value pair will be followed by a space insead of a newline. - """ - - if self._should_print_single_line: - printable = '' - after_kv = ' ' - else: - printable = '\t' * tabs - after_kv = '\n' - - # Xcode usually prints remoteGlobalIDString values in PBXContainerItemProxy - # objects without comments. Sometimes it prints them with comments, but - # the majority of the time, it doesn't. To avoid unnecessary changes to - # the project file after Xcode opens it, don't write comments for - # remoteGlobalIDString. This is a sucky hack and it would certainly be - # cleaner to extend the schema to indicate whether or not a comment should - # be printed, but since this is the only case where the problem occurs and - # Xcode itself can't seem to make up its mind, the hack will suffice. - # - # Also see PBXContainerItemProxy._schema['remoteGlobalIDString']. - if key == 'remoteGlobalIDString' and isinstance(self, - PBXContainerItemProxy): - value_to_print = value.id - else: - value_to_print = value - - # PBXBuildFile's settings property is represented in the output as a dict, - # but a hack here has it represented as a string. Arrange to strip off the - # quotes so that it shows up in the output as expected. - if key == 'settings' and isinstance(self, PBXBuildFile): - strip_value_quotes = True - else: - strip_value_quotes = False - - # In another one-off, let's set flatten_list on buildSettings properties - # of XCBuildConfiguration objects, because that's how Xcode treats them. - if key == 'buildSettings' and isinstance(self, XCBuildConfiguration): - flatten_list = True - else: - flatten_list = False - - try: - printable_key = self._XCPrintableValue(tabs, key, flatten_list) - printable_value = self._XCPrintableValue(tabs, value_to_print, - flatten_list) - if strip_value_quotes and len(printable_value) > 1 and \ - printable_value[0] == '"' and printable_value[-1] == '"': - printable_value = printable_value[1:-1] - printable += printable_key + ' = ' + printable_value + ';' + after_kv - except TypeError, e: - gyp.common.ExceptionAppend(e, - 'while printing key "%s"' % key) - raise - - self._XCPrint(file, 0, printable) - - def Print(self, file=sys.stdout): - """Prints a reprentation of this object to file, adhering to Xcode output - formatting. - """ - - self.VerifyHasRequiredProperties() - - if self._should_print_single_line: - # When printing an object in a single line, Xcode doesn't put any space - # between the beginning of a dictionary (or presumably a list) and the - # first contained item, so you wind up with snippets like - # ...CDEF = {isa = PBXFileReference; fileRef = 0123... - # If it were me, I would have put a space in there after the opening - # curly, but I guess this is just another one of those inconsistencies - # between how Xcode prints PBXFileReference and PBXBuildFile objects as - # compared to other objects. Mimic Xcode's behavior here by using an - # empty string for sep. - sep = '' - end_tabs = 0 - else: - sep = '\n' - end_tabs = 2 - - # Start the object. For example, '\t\tPBXProject = {\n'. - self._XCPrint(file, 2, self._XCPrintableValue(2, self) + ' = {' + sep) - - # "isa" isn't in the _properties dictionary, it's an intrinsic property - # of the class which the object belongs to. Xcode always outputs "isa" - # as the first element of an object dictionary. - self._XCKVPrint(file, 3, 'isa', self.__class__.__name__) - - # The remaining elements of an object dictionary are sorted alphabetically. - for property, value in sorted(self._properties.iteritems()): - self._XCKVPrint(file, 3, property, value) - - # End the object. - self._XCPrint(file, end_tabs, '};\n') - - def UpdateProperties(self, properties, do_copy=False): - """Merge the supplied properties into the _properties dictionary. - - The input properties must adhere to the class schema or a KeyError or - TypeError exception will be raised. If adding an object of an XCObject - subclass and the schema indicates a strong relationship, the object's - parent will be set to this object. - - If do_copy is True, then lists, dicts, strong-owned XCObjects, and - strong-owned XCObjects in lists will be copied instead of having their - references added. - """ - - if properties == None: - return - - for property, value in properties.iteritems(): - # Make sure the property is in the schema. - if not property in self._schema: - raise KeyError, property + ' not in ' + self.__class__.__name__ - - # Make sure the property conforms to the schema. - (is_list, property_type, is_strong) = self._schema[property][0:3] - if is_list: - if value.__class__ != list: - raise TypeError, \ - property + ' of ' + self.__class__.__name__ + \ - ' must be list, not ' + value.__class__.__name__ - for item in value: - if not isinstance(item, property_type) and \ - not (item.__class__ == unicode and property_type == str): - # Accept unicode where str is specified. str is treated as - # UTF-8-encoded. - raise TypeError, \ - 'item of ' + property + ' of ' + self.__class__.__name__ + \ - ' must be ' + property_type.__name__ + ', not ' + \ - item.__class__.__name__ - elif not isinstance(value, property_type) and \ - not (value.__class__ == unicode and property_type == str): - # Accept unicode where str is specified. str is treated as - # UTF-8-encoded. - raise TypeError, \ - property + ' of ' + self.__class__.__name__ + ' must be ' + \ - property_type.__name__ + ', not ' + value.__class__.__name__ - - # Checks passed, perform the assignment. - if do_copy: - if isinstance(value, XCObject): - if is_strong: - self._properties[property] = value.Copy() - else: - self._properties[property] = value - elif isinstance(value, str) or isinstance(value, unicode) or \ - isinstance(value, int): - self._properties[property] = value - elif isinstance(value, list): - if is_strong: - # If is_strong is True, each element is an XCObject, so it's safe - # to call Copy. - self._properties[property] = [] - for item in value: - self._properties[property].append(item.Copy()) - else: - self._properties[property] = value[:] - elif isinstance(value, dict): - self._properties[property] = value.copy() - else: - raise TypeError, "Don't know how to copy a " + \ - value.__class__.__name__ + ' object for ' + \ - property + ' in ' + self.__class__.__name__ - else: - self._properties[property] = value - - # Set up the child's back-reference to this object. Don't use |value| - # any more because it may not be right if do_copy is true. - if is_strong: - if not is_list: - self._properties[property].parent = self - else: - for item in self._properties[property]: - item.parent = self - - def HasProperty(self, key): - return key in self._properties - - def GetProperty(self, key): - return self._properties[key] - - def SetProperty(self, key, value): - self.UpdateProperties({key: value}) - - def DelProperty(self, key): - if key in self._properties: - del self._properties[key] - - def AppendProperty(self, key, value): - # TODO(mark): Support ExtendProperty too (and make this call that)? - - # Schema validation. - if not key in self._schema: - raise KeyError, key + ' not in ' + self.__class__.__name__ - - (is_list, property_type, is_strong) = self._schema[key][0:3] - if not is_list: - raise TypeError, key + ' of ' + self.__class__.__name__ + ' must be list' - if not isinstance(value, property_type): - raise TypeError, 'item of ' + key + ' of ' + self.__class__.__name__ + \ - ' must be ' + property_type.__name__ + ', not ' + \ - value.__class__.__name__ - - # If the property doesn't exist yet, create a new empty list to receive the - # item. - if not key in self._properties: - self._properties[key] = [] - - # Set up the ownership link. - if is_strong: - value.parent = self - - # Store the item. - self._properties[key].append(value) - - def VerifyHasRequiredProperties(self): - """Ensure that all properties identified as required by the schema are - set. - """ - - # TODO(mark): A stronger verification mechanism is needed. Some - # subclasses need to perform validation beyond what the schema can enforce. - for property, attributes in self._schema.iteritems(): - (is_list, property_type, is_strong, is_required) = attributes[0:4] - if is_required and not property in self._properties: - raise KeyError, self.__class__.__name__ + ' requires ' + property - - def _SetDefaultsFromSchema(self): - """Assign object default values according to the schema. This will not - overwrite properties that have already been set.""" - - defaults = {} - for property, attributes in self._schema.iteritems(): - (is_list, property_type, is_strong, is_required) = attributes[0:4] - if is_required and len(attributes) >= 5 and \ - not property in self._properties: - default = attributes[4] - - defaults[property] = default - - if len(defaults) > 0: - # Use do_copy=True so that each new object gets its own copy of strong - # objects, lists, and dicts. - self.UpdateProperties(defaults, do_copy=True) - - -class XCHierarchicalElement(XCObject): - """Abstract base for PBXGroup and PBXFileReference. Not represented in a - project file.""" - - # TODO(mark): Do name and path belong here? Probably so. - # If path is set and name is not, name may have a default value. Name will - # be set to the basename of path, if the basename of path is different from - # the full value of path. If path is already just a leaf name, name will - # not be set. - _schema = XCObject._schema.copy() - _schema.update({ - 'comments': [0, str, 0, 0], - 'fileEncoding': [0, str, 0, 0], - 'includeInIndex': [0, int, 0, 0], - 'indentWidth': [0, int, 0, 0], - 'lineEnding': [0, int, 0, 0], - 'sourceTree': [0, str, 0, 1, ''], - 'tabWidth': [0, int, 0, 0], - 'usesTabs': [0, int, 0, 0], - 'wrapsLines': [0, int, 0, 0], - }) - - def __init__(self, properties=None, id=None, parent=None): - # super - XCObject.__init__(self, properties, id, parent) - if 'path' in self._properties and not 'name' in self._properties: - path = self._properties['path'] - name = posixpath.basename(path) - if name != '' and path != name: - self.SetProperty('name', name) - - if 'path' in self._properties and \ - (not 'sourceTree' in self._properties or \ - self._properties['sourceTree'] == ''): - # If the pathname begins with an Xcode variable like "$(SDKROOT)/", take - # the variable out and make the path be relative to that variable by - # assigning the variable name as the sourceTree. - (source_tree, path) = SourceTreeAndPathFromPath(self._properties['path']) - if source_tree != None: - self._properties['sourceTree'] = source_tree - if path != None: - self._properties['path'] = path - if source_tree != None and path == None and \ - not 'name' in self._properties: - # The path was of the form "$(SDKROOT)" with no path following it. - # This object is now relative to that variable, so it has no path - # attribute of its own. It does, however, keep a name. - del self._properties['path'] - self._properties['name'] = source_tree - - def Name(self): - if 'name' in self._properties: - return self._properties['name'] - elif 'path' in self._properties: - return self._properties['path'] - else: - # This happens in the case of the root PBXGroup. - return None - - def Hashables(self): - """Custom hashables for XCHierarchicalElements. - - XCHierarchicalElements are special. Generally, their hashes shouldn't - change if the paths don't change. The normal XCObject implementation of - Hashables adds a hashable for each object, which means that if - the hierarchical structure changes (possibly due to changes caused when - TakeOverOnlyChild runs and encounters slight changes in the hierarchy), - the hashes will change. For example, if a project file initially contains - a/b/f1 and a/b becomes collapsed into a/b, f1 will have a single parent - a/b. If someone later adds a/f2 to the project file, a/b can no longer be - collapsed, and f1 winds up with parent b and grandparent a. That would - be sufficient to change f1's hash. - - To counteract this problem, hashables for all XCHierarchicalElements except - for the main group (which has neither a name nor a path) are taken to be - just the set of path components. Because hashables are inherited from - parents, this provides assurance that a/b/f1 has the same set of hashables - whether its parent is b or a/b. - - The main group is a special case. As it is permitted to have no name or - path, it is permitted to use the standard XCObject hash mechanism. This - is not considered a problem because there can be only one main group. - """ - - if self == self.PBXProjectAncestor()._properties['mainGroup']: - # super - return XCObject.Hashables(self) - - hashables = [] - - # Put the name in first, ensuring that if TakeOverOnlyChild collapses - # children into a top-level group like "Source", the name always goes - # into the list of hashables without interfering with path components. - if 'name' in self._properties: - # Make it less likely for people to manipulate hashes by following the - # pattern of always pushing an object type value onto the list first. - hashables.append(self.__class__.__name__ + '.name') - hashables.append(self._properties['name']) - - # NOTE: This still has the problem that if an absolute path is encountered, - # including paths with a sourceTree, they'll still inherit their parents' - # hashables, even though the paths aren't relative to their parents. This - # is not expected to be much of a problem in practice. - path = self.PathFromSourceTreeAndPath() - if path != None: - components = path.split(posixpath.sep) - for component in components: - hashables.append(self.__class__.__name__ + '.path') - hashables.append(component) - - hashables.extend(self._hashables) - - return hashables - - def Compare(self, other): - # Allow comparison of these types. PBXGroup has the highest sort rank; - # PBXVariantGroup is treated as equal to PBXFileReference. - valid_class_types = { - PBXFileReference: 'file', - PBXGroup: 'group', - PBXVariantGroup: 'file', - } - self_type = valid_class_types[self.__class__] - other_type = valid_class_types[other.__class__] - - if self_type == other_type: - # If the two objects are of the same sort rank, compare their names. - return cmp(self.Name(), other.Name()) - - # Otherwise, sort groups before everything else. - if self_type == 'group': - return -1 - return 1 - - def CompareRootGroup(self, other): - # This function should be used only to compare direct children of the - # containing PBXProject's mainGroup. These groups should appear in the - # listed order. - # TODO(mark): "Build" is used by gyp.generator.xcode, perhaps the - # generator should have a way of influencing this list rather than having - # to hardcode for the generator here. - order = ['Source', 'Intermediates', 'Projects', 'Frameworks', 'Products', - 'Build'] - - # If the groups aren't in the listed order, do a name comparison. - # Otherwise, groups in the listed order should come before those that - # aren't. - self_name = self.Name() - other_name = other.Name() - self_in = isinstance(self, PBXGroup) and self_name in order - other_in = isinstance(self, PBXGroup) and other_name in order - if not self_in and not other_in: - return self.Compare(other) - if self_name in order and not other_name in order: - return -1 - if other_name in order and not self_name in order: - return 1 - - # If both groups are in the listed order, go by the defined order. - self_index = order.index(self_name) - other_index = order.index(other_name) - if self_index < other_index: - return -1 - if self_index > other_index: - return 1 - return 0 - - def PathFromSourceTreeAndPath(self): - # Turn the object's sourceTree and path properties into a single flat - # string of a form comparable to the path parameter. If there's a - # sourceTree property other than "", wrap it in $(...) for the - # comparison. - components = [] - if self._properties['sourceTree'] != '': - components.append('$(' + self._properties['sourceTree'] + ')') - if 'path' in self._properties: - components.append(self._properties['path']) - - if len(components) > 0: - return posixpath.join(*components) - - return None - - def FullPath(self): - # Returns a full path to self relative to the project file, or relative - # to some other source tree. Start with self, and walk up the chain of - # parents prepending their paths, if any, until no more parents are - # available (project-relative path) or until a path relative to some - # source tree is found. - xche = self - path = None - while isinstance(xche, XCHierarchicalElement) and \ - (path == None or \ - (not path.startswith('/') and not path.startswith('$'))): - this_path = xche.PathFromSourceTreeAndPath() - if this_path != None and path != None: - path = posixpath.join(this_path, path) - elif this_path != None: - path = this_path - xche = xche.parent - - return path - - -class PBXGroup(XCHierarchicalElement): - """ - Attributes: - _children_by_path: Maps pathnames of children of this PBXGroup to the - actual child XCHierarchicalElement objects. - _variant_children_by_name_and_path: Maps (name, path) tuples of - PBXVariantGroup children to the actual child PBXVariantGroup objects. - """ - - _schema = XCHierarchicalElement._schema.copy() - _schema.update({ - 'children': [1, XCHierarchicalElement, 1, 1, []], - 'name': [0, str, 0, 0], - 'path': [0, str, 0, 0], - }) - - def __init__(self, properties=None, id=None, parent=None): - # super - XCHierarchicalElement.__init__(self, properties, id, parent) - self._children_by_path = {} - self._variant_children_by_name_and_path = {} - for child in self._properties.get('children', []): - self._AddChildToDicts(child) - - def _AddChildToDicts(self, child): - # Sets up this PBXGroup object's dicts to reference the child properly. - child_path = child.PathFromSourceTreeAndPath() - if child_path: - if child_path in self._children_by_path: - raise ValueError, 'Found multiple children with path ' + child_path - self._children_by_path[child_path] = child - - if isinstance(child, PBXVariantGroup): - child_name = child._properties.get('name', None) - key = (child_name, child_path) - if key in self._variant_children_by_name_and_path: - raise ValueError, 'Found multiple PBXVariantGroup children with ' + \ - 'name ' + str(child_name) + ' and path ' + \ - str(child_path) - self._variant_children_by_name_and_path[key] = child - - def AppendChild(self, child): - # Callers should use this instead of calling - # AppendProperty('children', child) directly because this function - # maintains the group's dicts. - self.AppendProperty('children', child) - self._AddChildToDicts(child) - - def GetChildByName(self, name): - # This is not currently optimized with a dict as GetChildByPath is because - # it has few callers. Most callers probably want GetChildByPath. This - # function is only useful to get children that have names but no paths, - # which is rare. The children of the main group ("Source", "Products", - # etc.) is pretty much the only case where this likely to come up. - # - # TODO(mark): Maybe this should raise an error if more than one child is - # present with the same name. - if not 'children' in self._properties: - return None - - for child in self._properties['children']: - if child.Name() == name: - return child - - return None - - def GetChildByPath(self, path): - if not path: - return None - - if path in self._children_by_path: - return self._children_by_path[path] - - return None - - def GetChildByRemoteObject(self, remote_object): - # This method is a little bit esoteric. Given a remote_object, which - # should be a PBXFileReference in another project file, this method will - # return this group's PBXReferenceProxy object serving as a local proxy - # for the remote PBXFileReference. - # - # This function might benefit from a dict optimization as GetChildByPath - # for some workloads, but profiling shows that it's not currently a - # problem. - if not 'children' in self._properties: - return None - - for child in self._properties['children']: - if not isinstance(child, PBXReferenceProxy): - continue - - container_proxy = child._properties['remoteRef'] - if container_proxy._properties['remoteGlobalIDString'] == remote_object: - return child - - return None - - def AddOrGetFileByPath(self, path, hierarchical): - """Returns an existing or new file reference corresponding to path. - - If hierarchical is True, this method will create or use the necessary - hierarchical group structure corresponding to path. Otherwise, it will - look in and create an item in the current group only. - - If an existing matching reference is found, it is returned, otherwise, a - new one will be created, added to the correct group, and returned. - - If path identifies a directory by virtue of carrying a trailing slash, - this method returns a PBXFileReference of "folder" type. If path - identifies a variant, by virtue of it identifying a file inside a directory - with an ".lproj" extension, this method returns a PBXVariantGroup - containing the variant named by path, and possibly other variants. For - all other paths, a "normal" PBXFileReference will be returned. - """ - - # Adding or getting a directory? Directories end with a trailing slash. - is_dir = False - if path.endswith('/'): - is_dir = True - normpath = posixpath.normpath(path) - if is_dir: - normpath = path + '/' - else: - normpath = path - - # Adding or getting a variant? Variants are files inside directories - # with an ".lproj" extension. Xcode uses variants for localization. For - # a variant path/to/Language.lproj/MainMenu.nib, put a variant group named - # MainMenu.nib inside path/to, and give it a variant named Language. In - # this example, grandparent would be set to path/to and parent_root would - # be set to Language. - variant_name = None - parent = posixpath.dirname(path) - grandparent = posixpath.dirname(parent) - parent_basename = posixpath.basename(parent) - (parent_root, parent_ext) = posixpath.splitext(parent_basename) - if parent_ext == '.lproj': - variant_name = parent_root - if grandparent == '': - grandparent = None - - # Putting a directory inside a variant group is not currently supported. - assert not is_dir or variant_name == None - - path_split = path.split(posixpath.sep) - if len(path_split) == 1 or \ - ((is_dir or variant_name != None) and len(path_split) == 2) or \ - not hierarchical: - # The PBXFileReference or PBXVariantGroup will be added to or gotten from - # this PBXGroup, no recursion necessary. - if variant_name == None: - # Add or get a PBXFileReference. - file_ref = self.GetChildByPath(normpath) - if file_ref != None: - assert file_ref.__class__ == PBXFileReference - else: - file_ref = PBXFileReference({'path': path}) - self.AppendChild(file_ref) - else: - # Add or get a PBXVariantGroup. The variant group name is the same - # as the basename (MainMenu.nib in the example above). grandparent - # specifies the path to the variant group itself, and path_split[-2:] - # is the path of the specific variant relative to its group. - variant_group_name = posixpath.basename(path) - variant_group_ref = self.AddOrGetVariantGroupByNameAndPath( - variant_group_name, grandparent) - variant_path = posixpath.sep.join(path_split[-2:]) - variant_ref = variant_group_ref.GetChildByPath(variant_path) - if variant_ref != None: - assert variant_ref.__class__ == PBXFileReference - else: - variant_ref = PBXFileReference({'name': variant_name, - 'path': variant_path}) - variant_group_ref.AppendChild(variant_ref) - # The caller is interested in the variant group, not the specific - # variant file. - file_ref = variant_group_ref - return file_ref - else: - # Hierarchical recursion. Add or get a PBXGroup corresponding to the - # outermost path component, and then recurse into it, chopping off that - # path component. - next_dir = path_split[0] - group_ref = self.GetChildByPath(next_dir) - if group_ref != None: - assert group_ref.__class__ == PBXGroup - else: - group_ref = PBXGroup({'path': next_dir}) - self.AppendChild(group_ref) - return group_ref.AddOrGetFileByPath(posixpath.sep.join(path_split[1:]), - hierarchical) - - def AddOrGetVariantGroupByNameAndPath(self, name, path): - """Returns an existing or new PBXVariantGroup for name and path. - - If a PBXVariantGroup identified by the name and path arguments is already - present as a child of this object, it is returned. Otherwise, a new - PBXVariantGroup with the correct properties is created, added as a child, - and returned. - - This method will generally be called by AddOrGetFileByPath, which knows - when to create a variant group based on the structure of the pathnames - passed to it. - """ - - key = (name, path) - if key in self._variant_children_by_name_and_path: - variant_group_ref = self._variant_children_by_name_and_path[key] - assert variant_group_ref.__class__ == PBXVariantGroup - return variant_group_ref - - variant_group_properties = {'name': name} - if path != None: - variant_group_properties['path'] = path - variant_group_ref = PBXVariantGroup(variant_group_properties) - self.AppendChild(variant_group_ref) - - return variant_group_ref - - def TakeOverOnlyChild(self, recurse=False): - """If this PBXGroup has only one child and it's also a PBXGroup, take - it over by making all of its children this object's children. - - This function will continue to take over only children when those children - are groups. If there are three PBXGroups representing a, b, and c, with - c inside b and b inside a, and a and b have no other children, this will - result in a taking over both b and c, forming a PBXGroup for a/b/c. - - If recurse is True, this function will recurse into children and ask them - to collapse themselves by taking over only children as well. Assuming - an example hierarchy with files at a/b/c/d1, a/b/c/d2, and a/b/c/d3/e/f - (d1, d2, and f are files, the rest are groups), recursion will result in - a group for a/b/c containing a group for d3/e. - """ - - # At this stage, check that child class types are PBXGroup exactly, - # instead of using isinstance. The only subclass of PBXGroup, - # PBXVariantGroup, should not participate in reparenting in the same way: - # reparenting by merging different object types would be wrong. - while len(self._properties['children']) == 1 and \ - self._properties['children'][0].__class__ == PBXGroup: - # Loop to take over the innermost only-child group possible. - - child = self._properties['children'][0] - - # Assume the child's properties, including its children. Save a copy - # of this object's old properties, because they'll still be needed. - # This object retains its existing id and parent attributes. - old_properties = self._properties - self._properties = child._properties - self._children_by_path = child._children_by_path - - if not 'sourceTree' in self._properties or \ - self._properties['sourceTree'] == '': - # The child was relative to its parent. Fix up the path. Note that - # children with a sourceTree other than "" are not relative to - # their parents, so no path fix-up is needed in that case. - if 'path' in old_properties: - if 'path' in self._properties: - # Both the original parent and child have paths set. - self._properties['path'] = posixpath.join(old_properties['path'], - self._properties['path']) - else: - # Only the original parent has a path, use it. - self._properties['path'] = old_properties['path'] - if 'sourceTree' in old_properties: - # The original parent had a sourceTree set, use it. - self._properties['sourceTree'] = old_properties['sourceTree'] - - # If the original parent had a name set, keep using it. If the original - # parent didn't have a name but the child did, let the child's name - # live on. If the name attribute seems unnecessary now, get rid of it. - if 'name' in old_properties and old_properties['name'] != None and \ - old_properties['name'] != self.Name(): - self._properties['name'] = old_properties['name'] - if 'name' in self._properties and 'path' in self._properties and \ - self._properties['name'] == self._properties['path']: - del self._properties['name'] - - # Notify all children of their new parent. - for child in self._properties['children']: - child.parent = self - - # If asked to recurse, recurse. - if recurse: - for child in self._properties['children']: - if child.__class__ == PBXGroup: - child.TakeOverOnlyChild(recurse) - - def SortGroup(self): - self._properties['children'] = \ - sorted(self._properties['children'], cmp=lambda x,y: x.Compare(y)) - - # Recurse. - for child in self._properties['children']: - if isinstance(child, PBXGroup): - child.SortGroup() - - -class XCFileLikeElement(XCHierarchicalElement): - # Abstract base for objects that can be used as the fileRef property of - # PBXBuildFile. - - def PathHashables(self): - # A PBXBuildFile that refers to this object will call this method to - # obtain additional hashables specific to this XCFileLikeElement. Don't - # just use this object's hashables, they're not specific and unique enough - # on their own (without access to the parent hashables.) Instead, provide - # hashables that identify this object by path by getting its hashables as - # well as the hashables of ancestor XCHierarchicalElement objects. - - hashables = [] - xche = self - while xche != None and isinstance(xche, XCHierarchicalElement): - xche_hashables = xche.Hashables() - for index in xrange(0, len(xche_hashables)): - hashables.insert(index, xche_hashables[index]) - xche = xche.parent - return hashables - - -class XCContainerPortal(XCObject): - # Abstract base for objects that can be used as the containerPortal property - # of PBXContainerItemProxy. - pass - - -class XCRemoteObject(XCObject): - # Abstract base for objects that can be used as the remoteGlobalIDString - # property of PBXContainerItemProxy. - pass - - -class PBXFileReference(XCFileLikeElement, XCContainerPortal, XCRemoteObject): - _schema = XCFileLikeElement._schema.copy() - _schema.update({ - 'explicitFileType': [0, str, 0, 0], - 'lastKnownFileType': [0, str, 0, 0], - 'name': [0, str, 0, 0], - 'path': [0, str, 0, 1], - }) - - # Weird output rules for PBXFileReference. - _should_print_single_line = True - # super - _encode_transforms = XCFileLikeElement._alternate_encode_transforms - - def __init__(self, properties=None, id=None, parent=None): - # super - XCFileLikeElement.__init__(self, properties, id, parent) - if 'path' in self._properties and self._properties['path'].endswith('/'): - self._properties['path'] = self._properties['path'][:-1] - is_dir = True - else: - is_dir = False - - if 'path' in self._properties and \ - not 'lastKnownFileType' in self._properties and \ - not 'explicitFileType' in self._properties: - # TODO(mark): This is the replacement for a replacement for a quick hack. - # It is no longer incredibly sucky, but this list needs to be extended. - extension_map = { - 'a': 'archive.ar', - 'app': 'wrapper.application', - 'bdic': 'file', - 'bundle': 'wrapper.cfbundle', - 'c': 'sourcecode.c.c', - 'cc': 'sourcecode.cpp.cpp', - 'cpp': 'sourcecode.cpp.cpp', - 'css': 'text.css', - 'cxx': 'sourcecode.cpp.cpp', - 'dylib': 'compiled.mach-o.dylib', - 'framework': 'wrapper.framework', - 'h': 'sourcecode.c.h', - 'hxx': 'sourcecode.cpp.h', - 'icns': 'image.icns', - 'java': 'sourcecode.java', - 'js': 'sourcecode.javascript', - 'm': 'sourcecode.c.objc', - 'mm': 'sourcecode.cpp.objcpp', - 'nib': 'wrapper.nib', - 'o': 'compiled.mach-o.objfile', - 'pdf': 'image.pdf', - 'pl': 'text.script.perl', - 'plist': 'text.plist.xml', - 'pm': 'text.script.perl', - 'png': 'image.png', - 'py': 'text.script.python', - 'r': 'sourcecode.rez', - 'rez': 'sourcecode.rez', - 's': 'sourcecode.asm', - 'strings': 'text.plist.strings', - 'ttf': 'file', - 'xcconfig': 'text.xcconfig', - 'xib': 'file.xib', - 'y': 'sourcecode.yacc', - } - - if is_dir: - file_type = 'folder' - else: - basename = posixpath.basename(self._properties['path']) - (root, ext) = posixpath.splitext(basename) - # Check the map using a lowercase extension. - # TODO(mark): Maybe it should try with the original case first and fall - # back to lowercase, in case there are any instances where case - # matters. There currently aren't. - if ext != '': - ext = ext[1:].lower() - - # TODO(mark): "text" is the default value, but "file" is appropriate - # for unrecognized files not containing text. Xcode seems to choose - # based on content. - file_type = extension_map.get(ext, 'text') - - self._properties['lastKnownFileType'] = file_type - - -class PBXVariantGroup(PBXGroup, XCFileLikeElement): - """PBXVariantGroup is used by Xcode to represent localizations.""" - # No additions to the schema relative to PBXGroup. - pass - - -# PBXReferenceProxy is also an XCFileLikeElement subclass. It is defined below -# because it uses PBXContainerItemProxy, defined below. - - -class XCBuildConfiguration(XCObject): - _schema = XCObject._schema.copy() - _schema.update({ - 'baseConfigurationReference': [0, PBXFileReference, 0, 0], - 'buildSettings': [0, dict, 0, 1, {}], - 'name': [0, str, 0, 1], - }) - - def HasBuildSetting(self, key): - return key in self._properties['buildSettings'] - - def GetBuildSetting(self, key): - return self._properties['buildSettings'][key] - - def SetBuildSetting(self, key, value): - # TODO(mark): If a list, copy? - self._properties['buildSettings'][key] = value - - def AppendBuildSetting(self, key, value): - if not key in self._properties['buildSettings']: - self._properties['buildSettings'][key] = [] - self._properties['buildSettings'][key].append(value) - - def DelBuildSetting(self, key): - if key in self._properties['buildSettings']: - del self._properties['buildSettings'][key] - - def SetBaseConfiguration(self, value): - self._properties['baseConfigurationReference'] = value - -class XCConfigurationList(XCObject): - # _configs is the default list of configurations. - _configs = [ XCBuildConfiguration({'name': 'Debug'}), - XCBuildConfiguration({'name': 'Release'}) ] - - _schema = XCObject._schema.copy() - _schema.update({ - 'buildConfigurations': [1, XCBuildConfiguration, 1, 1, _configs], - 'defaultConfigurationIsVisible': [0, int, 0, 1, 1], - 'defaultConfigurationName': [0, str, 0, 1, 'Release'], - }) - - def Name(self): - return 'Build configuration list for ' + \ - self.parent.__class__.__name__ + ' "' + self.parent.Name() + '"' - - def ConfigurationNamed(self, name): - """Convenience accessor to obtain an XCBuildConfiguration by name.""" - for configuration in self._properties['buildConfigurations']: - if configuration._properties['name'] == name: - return configuration - - raise KeyError, name - - def DefaultConfiguration(self): - """Convenience accessor to obtain the default XCBuildConfiguration.""" - return self.ConfigurationNamed(self._properties['defaultConfigurationName']) - - def HasBuildSetting(self, key): - """Determines the state of a build setting in all XCBuildConfiguration - child objects. - - If all child objects have key in their build settings, and the value is the - same in all child objects, returns 1. - - If no child objects have the key in their build settings, returns 0. - - If some, but not all, child objects have the key in their build settings, - or if any children have different values for the key, returns -1. - """ - - has = None - value = None - for configuration in self._properties['buildConfigurations']: - configuration_has = configuration.HasBuildSetting(key) - if has == None: - has = configuration_has - elif has != configuration_has: - return -1 - - if configuration_has: - configuration_value = configuration.GetBuildSetting(key) - if value == None: - value = configuration_value - elif value != configuration_value: - return -1 - - if not has: - return 0 - - return 1 - - def GetBuildSetting(self, key): - """Gets the build setting for key. - - All child XCConfiguration objects must have the same value set for the - setting, or a ValueError will be raised. - """ - - # TODO(mark): This is wrong for build settings that are lists. The list - # contents should be compared (and a list copy returned?) - - value = None - for configuration in self._properties['buildConfigurations']: - configuration_value = configuration.GetBuildSetting(key) - if value == None: - value = configuration_value - else: - if value != configuration_value: - raise ValueError, 'Variant values for ' + key - - return value - - def SetBuildSetting(self, key, value): - """Sets the build setting for key to value in all child - XCBuildConfiguration objects. - """ - - for configuration in self._properties['buildConfigurations']: - configuration.SetBuildSetting(key, value) - - def AppendBuildSetting(self, key, value): - """Appends value to the build setting for key, which is treated as a list, - in all child XCBuildConfiguration objects. - """ - - for configuration in self._properties['buildConfigurations']: - configuration.AppendBuildSetting(key, value) - - def DelBuildSetting(self, key): - """Deletes the build setting key from all child XCBuildConfiguration - objects. - """ - - for configuration in self._properties['buildConfigurations']: - configuration.DelBuildSetting(key) - - def SetBaseConfiguration(self, value): - """Sets the build configuration in all child XCBuildConfiguration objects. - """ - - for configuration in self._properties['buildConfigurations']: - configuration.SetBaseConfiguration(value) - - -class PBXBuildFile(XCObject): - _schema = XCObject._schema.copy() - _schema.update({ - 'fileRef': [0, XCFileLikeElement, 0, 1], - 'settings': [0, str, 0, 0], # hack, it's a dict - }) - - # Weird output rules for PBXBuildFile. - _should_print_single_line = True - _encode_transforms = XCObject._alternate_encode_transforms - - def Name(self): - # Example: "main.cc in Sources" - return self._properties['fileRef'].Name() + ' in ' + self.parent.Name() - - def Hashables(self): - # super - hashables = XCObject.Hashables(self) - - # It is not sufficient to just rely on Name() to get the - # XCFileLikeElement's name, because that is not a complete pathname. - # PathHashables returns hashables unique enough that no two - # PBXBuildFiles should wind up with the same set of hashables, unless - # someone adds the same file multiple times to the same target. That - # would be considered invalid anyway. - hashables.extend(self._properties['fileRef'].PathHashables()) - - return hashables - - -class XCBuildPhase(XCObject): - """Abstract base for build phase classes. Not represented in a project - file. - - Attributes: - _files_by_path: A dict mapping each path of a child in the files list by - path (keys) to the corresponding PBXBuildFile children (values). - _files_by_xcfilelikeelement: A dict mapping each XCFileLikeElement (keys) - to the corresponding PBXBuildFile children (values). - """ - - # TODO(mark): Some build phase types, like PBXShellScriptBuildPhase, don't - # actually have a "files" list. XCBuildPhase should not have "files" but - # another abstract subclass of it should provide this, and concrete build - # phase types that do have "files" lists should be derived from that new - # abstract subclass. XCBuildPhase should only provide buildActionMask and - # runOnlyForDeploymentPostprocessing, and not files or the various - # file-related methods and attributes. - - _schema = XCObject._schema.copy() - _schema.update({ - 'buildActionMask': [0, int, 0, 1, 0x7fffffff], - 'files': [1, PBXBuildFile, 1, 1, []], - 'runOnlyForDeploymentPostprocessing': [0, int, 0, 1, 0], - }) - - def __init__(self, properties=None, id=None, parent=None): - # super - XCObject.__init__(self, properties, id, parent) - - self._files_by_path = {} - self._files_by_xcfilelikeelement = {} - for pbxbuildfile in self._properties.get('files', []): - self._AddBuildFileToDicts(pbxbuildfile) - - def FileGroup(self, path): - # Subclasses must override this by returning a two-element tuple. The - # first item in the tuple should be the PBXGroup to which "path" should be - # added, either as a child or deeper descendant. The second item should - # be a boolean indicating whether files should be added into hierarchical - # groups or one single flat group. - raise NotImplementedError, \ - self.__class__.__name__ + ' must implement FileGroup' - - def _AddPathToDict(self, pbxbuildfile, path): - """Adds path to the dict tracking paths belonging to this build phase. - - If the path is already a member of this build phase, raises an exception. - """ - - if path in self._files_by_path: - raise ValueError, 'Found multiple build files with path ' + path - self._files_by_path[path] = pbxbuildfile - - def _AddBuildFileToDicts(self, pbxbuildfile, path=None): - """Maintains the _files_by_path and _files_by_xcfilelikeelement dicts. - - If path is specified, then it is the path that is being added to the - phase, and pbxbuildfile must contain either a PBXFileReference directly - referencing that path, or it must contain a PBXVariantGroup that itself - contains a PBXFileReference referencing the path. - - If path is not specified, either the PBXFileReference's path or the paths - of all children of the PBXVariantGroup are taken as being added to the - phase. - - If the path is already present in the phase, raises an exception. - - If the PBXFileReference or PBXVariantGroup referenced by pbxbuildfile - are already present in the phase, referenced by a different PBXBuildFile - object, raises an exception. This does not raise an exception when - a PBXFileReference or PBXVariantGroup reappear and are referenced by the - same PBXBuildFile that has already introduced them, because in the case - of PBXVariantGroup objects, they may correspond to multiple paths that are - not all added simultaneously. When this situation occurs, the path needs - to be added to _files_by_path, but nothing needs to change in - _files_by_xcfilelikeelement, and the caller should have avoided adding - the PBXBuildFile if it is already present in the list of children. - """ - - xcfilelikeelement = pbxbuildfile._properties['fileRef'] - - paths = [] - if path != None: - # It's best when the caller provides the path. - if isinstance(xcfilelikeelement, PBXVariantGroup): - paths.append(path) - else: - # If the caller didn't provide a path, there can be either multiple - # paths (PBXVariantGroup) or one. - if isinstance(xcfilelikeelement, PBXVariantGroup): - for variant in xcfilelikeelement._properties['children']: - paths.append(variant.FullPath()) - else: - paths.append(xcfilelikeelement.FullPath()) - - # Add the paths first, because if something's going to raise, the - # messages provided by _AddPathToDict are more useful owing to its - # having access to a real pathname and not just an object's Name(). - for a_path in paths: - self._AddPathToDict(pbxbuildfile, a_path) - - # If another PBXBuildFile references this XCFileLikeElement, there's a - # problem. - if xcfilelikeelement in self._files_by_xcfilelikeelement and \ - self._files_by_xcfilelikeelement[xcfilelikeelement] != pbxbuildfile: - raise ValueError, 'Found multiple build files for ' + \ - xcfilelikeelement.Name() - self._files_by_xcfilelikeelement[xcfilelikeelement] = pbxbuildfile - - def AppendBuildFile(self, pbxbuildfile, path=None): - # Callers should use this instead of calling - # AppendProperty('files', pbxbuildfile) directly because this function - # maintains the object's dicts. Better yet, callers can just call AddFile - # with a pathname and not worry about building their own PBXBuildFile - # objects. - self.AppendProperty('files', pbxbuildfile) - self._AddBuildFileToDicts(pbxbuildfile, path) - - def AddFile(self, path, settings=None): - (file_group, hierarchical) = self.FileGroup(path) - file_ref = file_group.AddOrGetFileByPath(path, hierarchical) - - if file_ref in self._files_by_xcfilelikeelement and \ - isinstance(file_ref, PBXVariantGroup): - # There's already a PBXBuildFile in this phase corresponding to the - # PBXVariantGroup. path just provides a new variant that belongs to - # the group. Add the path to the dict. - pbxbuildfile = self._files_by_xcfilelikeelement[file_ref] - self._AddBuildFileToDicts(pbxbuildfile, path) - else: - # Add a new PBXBuildFile to get file_ref into the phase. - if settings is None: - pbxbuildfile = PBXBuildFile({'fileRef': file_ref}) - else: - pbxbuildfile = PBXBuildFile({'fileRef': file_ref, 'settings': settings}) - self.AppendBuildFile(pbxbuildfile, path) - - -class PBXHeadersBuildPhase(XCBuildPhase): - # No additions to the schema relative to XCBuildPhase. - - def Name(self): - return 'Headers' - - def FileGroup(self, path): - return self.PBXProjectAncestor().RootGroupForPath(path) - - -class PBXResourcesBuildPhase(XCBuildPhase): - # No additions to the schema relative to XCBuildPhase. - - def Name(self): - return 'Resources' - - def FileGroup(self, path): - return self.PBXProjectAncestor().RootGroupForPath(path) - - -class PBXSourcesBuildPhase(XCBuildPhase): - # No additions to the schema relative to XCBuildPhase. - - def Name(self): - return 'Sources' - - def FileGroup(self, path): - return self.PBXProjectAncestor().RootGroupForPath(path) - - -class PBXFrameworksBuildPhase(XCBuildPhase): - # No additions to the schema relative to XCBuildPhase. - - def Name(self): - return 'Frameworks' - - def FileGroup(self, path): - (root, ext) = posixpath.splitext(path) - if ext != '': - ext = ext[1:].lower() - if ext == 'o': - # .o files are added to Xcode Frameworks phases, but conceptually aren't - # frameworks, they're more like sources or intermediates. Redirect them - # to show up in one of those other groups. - return self.PBXProjectAncestor().RootGroupForPath(path) - else: - return (self.PBXProjectAncestor().FrameworksGroup(), False) - - -class PBXShellScriptBuildPhase(XCBuildPhase): - _schema = XCBuildPhase._schema.copy() - _schema.update({ - 'inputPaths': [1, str, 0, 1, []], - 'name': [0, str, 0, 0], - 'outputPaths': [1, str, 0, 1, []], - 'shellPath': [0, str, 0, 1, '/bin/sh'], - 'shellScript': [0, str, 0, 1], - 'showEnvVarsInLog': [0, int, 0, 0], - }) - - def Name(self): - if 'name' in self._properties: - return self._properties['name'] - - return 'ShellScript' - - -class PBXCopyFilesBuildPhase(XCBuildPhase): - _schema = XCBuildPhase._schema.copy() - _schema.update({ - 'dstPath': [0, str, 0, 1], - 'dstSubfolderSpec': [0, int, 0, 1], - 'name': [0, str, 0, 0], - }) - - # path_tree_re matches "$(DIR)/path" or just "$(DIR)". Match group 1 is - # "DIR", match group 3 is "path" or None. - path_tree_re = re.compile('^\\$\\((.*)\\)(/(.*)|)$') - - # path_tree_to_subfolder maps names of Xcode variables to the associated - # dstSubfolderSpec property value used in a PBXCopyFilesBuildPhase object. - path_tree_to_subfolder = { - 'BUILT_PRODUCTS_DIR': 16, # Products Directory - # Other types that can be chosen via the Xcode UI. - # TODO(mark): Map Xcode variable names to these. - # : 1, # Wrapper - # : 6, # Executables: 6 - # : 7, # Resources - # : 15, # Java Resources - # : 10, # Frameworks - # : 11, # Shared Frameworks - # : 12, # Shared Support - # : 13, # PlugIns - } - - def Name(self): - if 'name' in self._properties: - return self._properties['name'] - - return 'CopyFiles' - - def FileGroup(self, path): - return self.PBXProjectAncestor().RootGroupForPath(path) - - def SetDestination(self, path): - """Set the dstSubfolderSpec and dstPath properties from path. - - path may be specified in the same notation used for XCHierarchicalElements, - specifically, "$(DIR)/path". - """ - - path_tree_match = self.path_tree_re.search(path) - if path_tree_match: - # Everything else needs to be relative to an Xcode variable. - path_tree = path_tree_match.group(1) - relative_path = path_tree_match.group(3) - - if path_tree in self.path_tree_to_subfolder: - subfolder = self.path_tree_to_subfolder[path_tree] - if relative_path == None: - relative_path = '' - else: - # The path starts with an unrecognized Xcode variable - # name like $(SRCROOT). Xcode will still handle this - # as an "absolute path" that starts with the variable. - subfolder = 0 - relative_path = path - elif path.startswith('/'): - # Special case. Absolute paths are in dstSubfolderSpec 0. - subfolder = 0 - relative_path = path[1:] - else: - raise ValueError, 'Can\'t use path %s in a %s' % \ - (path, self.__class__.__name__) - - self._properties['dstPath'] = relative_path - self._properties['dstSubfolderSpec'] = subfolder - - -class PBXBuildRule(XCObject): - _schema = XCObject._schema.copy() - _schema.update({ - 'compilerSpec': [0, str, 0, 1], - 'filePatterns': [0, str, 0, 0], - 'fileType': [0, str, 0, 1], - 'isEditable': [0, int, 0, 1, 1], - 'outputFiles': [1, str, 0, 1, []], - 'script': [0, str, 0, 0], - }) - - def Name(self): - # Not very inspired, but it's what Xcode uses. - return self.__class__.__name__ - - def Hashables(self): - # super - hashables = XCObject.Hashables(self) - - # Use the hashables of the weak objects that this object refers to. - hashables.append(self._properties['fileType']) - if 'filePatterns' in self._properties: - hashables.append(self._properties['filePatterns']) - return hashables - - -class PBXContainerItemProxy(XCObject): - # When referencing an item in this project file, containerPortal is the - # PBXProject root object of this project file. When referencing an item in - # another project file, containerPortal is a PBXFileReference identifying - # the other project file. - # - # When serving as a proxy to an XCTarget (in this project file or another), - # proxyType is 1. When serving as a proxy to a PBXFileReference (in another - # project file), proxyType is 2. Type 2 is used for references to the - # producs of the other project file's targets. - # - # Xcode is weird about remoteGlobalIDString. Usually, it's printed without - # a comment, indicating that it's tracked internally simply as a string, but - # sometimes it's printed with a comment (usually when the object is initially - # created), indicating that it's tracked as a project file object at least - # sometimes. This module always tracks it as an object, but contains a hack - # to prevent it from printing the comment in the project file output. See - # _XCKVPrint. - _schema = XCObject._schema.copy() - _schema.update({ - 'containerPortal': [0, XCContainerPortal, 0, 1], - 'proxyType': [0, int, 0, 1], - 'remoteGlobalIDString': [0, XCRemoteObject, 0, 1], - 'remoteInfo': [0, str, 0, 1], - }) - - def __repr__(self): - props = self._properties - name = '%s.gyp:%s' % (props['containerPortal'].Name(), props['remoteInfo']) - return '<%s %r at 0x%x>' % (self.__class__.__name__, name, id(self)) - - def Name(self): - # Admittedly not the best name, but it's what Xcode uses. - return self.__class__.__name__ - - def Hashables(self): - # super - hashables = XCObject.Hashables(self) - - # Use the hashables of the weak objects that this object refers to. - hashables.extend(self._properties['containerPortal'].Hashables()) - hashables.extend(self._properties['remoteGlobalIDString'].Hashables()) - return hashables - - -class PBXTargetDependency(XCObject): - # The "target" property accepts an XCTarget object, and obviously not - # NoneType. But XCTarget is defined below, so it can't be put into the - # schema yet. The definition of PBXTargetDependency can't be moved below - # XCTarget because XCTarget's own schema references PBXTargetDependency. - # Python doesn't deal well with this circular relationship, and doesn't have - # a real way to do forward declarations. To work around, the type of - # the "target" property is reset below, after XCTarget is defined. - # - # At least one of "name" and "target" is required. - _schema = XCObject._schema.copy() - _schema.update({ - 'name': [0, str, 0, 0], - 'target': [0, None.__class__, 0, 0], - 'targetProxy': [0, PBXContainerItemProxy, 1, 1], - }) - - def __repr__(self): - name = self._properties.get('name') or self._properties['target'].Name() - return '<%s %r at 0x%x>' % (self.__class__.__name__, name, id(self)) - - def Name(self): - # Admittedly not the best name, but it's what Xcode uses. - return self.__class__.__name__ - - def Hashables(self): - # super - hashables = XCObject.Hashables(self) - - # Use the hashables of the weak objects that this object refers to. - hashables.extend(self._properties['targetProxy'].Hashables()) - return hashables - - -class PBXReferenceProxy(XCFileLikeElement): - _schema = XCFileLikeElement._schema.copy() - _schema.update({ - 'fileType': [0, str, 0, 1], - 'path': [0, str, 0, 1], - 'remoteRef': [0, PBXContainerItemProxy, 1, 1], - }) - - -class XCTarget(XCRemoteObject): - # An XCTarget is really just an XCObject, the XCRemoteObject thing is just - # to allow PBXProject to be used in the remoteGlobalIDString property of - # PBXContainerItemProxy. - # - # Setting a "name" property at instantiation may also affect "productName", - # which may in turn affect the "PRODUCT_NAME" build setting in children of - # "buildConfigurationList". See __init__ below. - _schema = XCRemoteObject._schema.copy() - _schema.update({ - 'buildConfigurationList': [0, XCConfigurationList, 1, 1, - XCConfigurationList()], - 'buildPhases': [1, XCBuildPhase, 1, 1, []], - 'dependencies': [1, PBXTargetDependency, 1, 1, []], - 'name': [0, str, 0, 1], - 'productName': [0, str, 0, 1], - }) - - def __init__(self, properties=None, id=None, parent=None, - force_outdir=None, force_prefix=None, force_extension=None): - # super - XCRemoteObject.__init__(self, properties, id, parent) - - # Set up additional defaults not expressed in the schema. If a "name" - # property was supplied, set "productName" if it is not present. Also set - # the "PRODUCT_NAME" build setting in each configuration, but only if - # the setting is not present in any build configuration. - if 'name' in self._properties: - if not 'productName' in self._properties: - self.SetProperty('productName', self._properties['name']) - - if 'productName' in self._properties: - if 'buildConfigurationList' in self._properties: - configs = self._properties['buildConfigurationList'] - if configs.HasBuildSetting('PRODUCT_NAME') == 0: - configs.SetBuildSetting('PRODUCT_NAME', - self._properties['productName']) - - def AddDependency(self, other): - pbxproject = self.PBXProjectAncestor() - other_pbxproject = other.PBXProjectAncestor() - if pbxproject == other_pbxproject: - # The easy case. Add a dependency to another target in the same - # project file. - container = PBXContainerItemProxy({'containerPortal': pbxproject, - 'proxyType': 1, - 'remoteGlobalIDString': other, - 'remoteInfo': other.Name()}) - dependency = PBXTargetDependency({'target': other, - 'targetProxy': container}) - self.AppendProperty('dependencies', dependency) - else: - # The hard case. Add a dependency to a target in a different project - # file. Actually, this case isn't really so hard. - other_project_ref = \ - pbxproject.AddOrGetProjectReference(other_pbxproject)[1] - container = PBXContainerItemProxy({ - 'containerPortal': other_project_ref, - 'proxyType': 1, - 'remoteGlobalIDString': other, - 'remoteInfo': other.Name(), - }) - dependency = PBXTargetDependency({'name': other.Name(), - 'targetProxy': container}) - self.AppendProperty('dependencies', dependency) - - # Proxy all of these through to the build configuration list. - - def ConfigurationNamed(self, name): - return self._properties['buildConfigurationList'].ConfigurationNamed(name) - - def DefaultConfiguration(self): - return self._properties['buildConfigurationList'].DefaultConfiguration() - - def HasBuildSetting(self, key): - return self._properties['buildConfigurationList'].HasBuildSetting(key) - - def GetBuildSetting(self, key): - return self._properties['buildConfigurationList'].GetBuildSetting(key) - - def SetBuildSetting(self, key, value): - return self._properties['buildConfigurationList'].SetBuildSetting(key, \ - value) - - def AppendBuildSetting(self, key, value): - return self._properties['buildConfigurationList'].AppendBuildSetting(key, \ - value) - - def DelBuildSetting(self, key): - return self._properties['buildConfigurationList'].DelBuildSetting(key) - - -# Redefine the type of the "target" property. See PBXTargetDependency._schema -# above. -PBXTargetDependency._schema['target'][1] = XCTarget - - -class PBXNativeTarget(XCTarget): - # buildPhases is overridden in the schema to be able to set defaults. - # - # NOTE: Contrary to most objects, it is advisable to set parent when - # constructing PBXNativeTarget. A parent of an XCTarget must be a PBXProject - # object. A parent reference is required for a PBXNativeTarget during - # construction to be able to set up the target defaults for productReference, - # because a PBXBuildFile object must be created for the target and it must - # be added to the PBXProject's mainGroup hierarchy. - _schema = XCTarget._schema.copy() - _schema.update({ - 'buildPhases': [1, XCBuildPhase, 1, 1, - [PBXSourcesBuildPhase(), PBXFrameworksBuildPhase()]], - 'buildRules': [1, PBXBuildRule, 1, 1, []], - 'productReference': [0, PBXFileReference, 0, 1], - 'productType': [0, str, 0, 1], - }) - - # Mapping from Xcode product-types to settings. The settings are: - # filetype : used for explicitFileType in the project file - # prefix : the prefix for the file name - # suffix : the suffix for the filen ame - _product_filetypes = { - 'com.apple.product-type.application': ['wrapper.application', - '', '.app'], - 'com.apple.product-type.bundle': ['wrapper.cfbundle', - '', '.bundle'], - 'com.apple.product-type.framework': ['wrapper.framework', - '', '.framework'], - 'com.apple.product-type.library.dynamic': ['compiled.mach-o.dylib', - 'lib', '.dylib'], - 'com.apple.product-type.library.static': ['archive.ar', - 'lib', '.a'], - 'com.apple.product-type.tool': ['compiled.mach-o.executable', - '', ''], - 'com.googlecode.gyp.xcode.bundle': ['compiled.mach-o.dylib', - '', '.so'], - } - - def __init__(self, properties=None, id=None, parent=None, - force_outdir=None, force_prefix=None, force_extension=None): - # super - XCTarget.__init__(self, properties, id, parent) - - if 'productName' in self._properties and \ - 'productType' in self._properties and \ - not 'productReference' in self._properties and \ - self._properties['productType'] in self._product_filetypes: - products_group = None - pbxproject = self.PBXProjectAncestor() - if pbxproject != None: - products_group = pbxproject.ProductsGroup() - - if products_group != None: - (filetype, prefix, suffix) = \ - self._product_filetypes[self._properties['productType']] - # Xcode does not have a distinct type for loadable modules that are - # pure BSD targets (not in a bundle wrapper). GYP allows such modules - # to be specified by setting a target type to loadable_module without - # having mac_bundle set. These are mapped to the pseudo-product type - # com.googlecode.gyp.xcode.bundle. - # - # By picking up this special type and converting it to a dynamic - # library (com.apple.product-type.library.dynamic) with fix-ups, - # single-file loadable modules can be produced. - # - # MACH_O_TYPE is changed to mh_bundle to produce the proper file type - # (as opposed to mh_dylib). In order for linking to succeed, - # DYLIB_CURRENT_VERSION and DYLIB_COMPATIBILITY_VERSION must be - # cleared. They are meaningless for type mh_bundle. - # - # Finally, the .so extension is forcibly applied over the default - # (.dylib), unless another forced extension is already selected. - # .dylib is plainly wrong, and .bundle is used by loadable_modules in - # bundle wrappers (com.apple.product-type.bundle). .so seems an odd - # choice because it's used as the extension on many other systems that - # don't distinguish between linkable shared libraries and non-linkable - # loadable modules, but there's precedent: Python loadable modules on - # Mac OS X use an .so extension. - if self._properties['productType'] == 'com.googlecode.gyp.xcode.bundle': - self._properties['productType'] = \ - 'com.apple.product-type.library.dynamic' - self.SetBuildSetting('MACH_O_TYPE', 'mh_bundle') - self.SetBuildSetting('DYLIB_CURRENT_VERSION', '') - self.SetBuildSetting('DYLIB_COMPATIBILITY_VERSION', '') - if force_extension == None: - force_extension = suffix[1:] - - if force_extension is not None: - # If it's a wrapper (bundle), set WRAPPER_EXTENSION. - if filetype.startswith('wrapper.'): - self.SetBuildSetting('WRAPPER_EXTENSION', force_extension) - else: - # Extension override. - suffix = '.' + force_extension - self.SetBuildSetting('EXECUTABLE_EXTENSION', force_extension) - - if filetype.startswith('compiled.mach-o.executable'): - product_name = self._properties['productName'] - product_name += suffix - suffix = '' - self.SetProperty('productName', product_name) - self.SetBuildSetting('PRODUCT_NAME', product_name) - - # Xcode handles most prefixes based on the target type, however there - # are exceptions. If a "BSD Dynamic Library" target is added in the - # Xcode UI, Xcode sets EXECUTABLE_PREFIX. This check duplicates that - # behavior. - if force_prefix is not None: - prefix = force_prefix - if filetype.startswith('wrapper.'): - self.SetBuildSetting('WRAPPER_PREFIX', prefix) - else: - self.SetBuildSetting('EXECUTABLE_PREFIX', prefix) - - if force_outdir is not None: - self.SetBuildSetting('TARGET_BUILD_DIR', force_outdir) - - # TODO(tvl): Remove the below hack. - # http://code.google.com/p/gyp/issues/detail?id=122 - - # Some targets include the prefix in the target_name. These targets - # really should just add a product_name setting that doesn't include - # the prefix. For example: - # target_name = 'libevent', product_name = 'event' - # This check cleans up for them. - product_name = self._properties['productName'] - prefix_len = len(prefix) - if prefix_len and (product_name[:prefix_len] == prefix): - product_name = product_name[prefix_len:] - self.SetProperty('productName', product_name) - self.SetBuildSetting('PRODUCT_NAME', product_name) - - ref_props = { - 'explicitFileType': filetype, - 'includeInIndex': 0, - 'path': prefix + product_name + suffix, - 'sourceTree': 'BUILT_PRODUCTS_DIR', - } - file_ref = PBXFileReference(ref_props) - products_group.AppendChild(file_ref) - self.SetProperty('productReference', file_ref) - - def GetBuildPhaseByType(self, type): - if not 'buildPhases' in self._properties: - return None - - the_phase = None - for phase in self._properties['buildPhases']: - if isinstance(phase, type): - # Some phases may be present in multiples in a well-formed project file, - # but phases like PBXSourcesBuildPhase may only be present singly, and - # this function is intended as an aid to GetBuildPhaseByType. Loop - # over the entire list of phases and assert if more than one of the - # desired type is found. - assert the_phase == None - the_phase = phase - - return the_phase - - def HeadersPhase(self): - headers_phase = self.GetBuildPhaseByType(PBXHeadersBuildPhase) - if headers_phase == None: - headers_phase = PBXHeadersBuildPhase() - - # The headers phase should come before the resources, sources, and - # frameworks phases, if any. - insert_at = len(self._properties['buildPhases']) - for index in xrange(0, len(self._properties['buildPhases'])): - phase = self._properties['buildPhases'][index] - if isinstance(phase, PBXResourcesBuildPhase) or \ - isinstance(phase, PBXSourcesBuildPhase) or \ - isinstance(phase, PBXFrameworksBuildPhase): - insert_at = index - break - - self._properties['buildPhases'].insert(insert_at, headers_phase) - headers_phase.parent = self - - return headers_phase - - def ResourcesPhase(self): - resources_phase = self.GetBuildPhaseByType(PBXResourcesBuildPhase) - if resources_phase == None: - resources_phase = PBXResourcesBuildPhase() - - # The resources phase should come before the sources and frameworks - # phases, if any. - insert_at = len(self._properties['buildPhases']) - for index in xrange(0, len(self._properties['buildPhases'])): - phase = self._properties['buildPhases'][index] - if isinstance(phase, PBXSourcesBuildPhase) or \ - isinstance(phase, PBXFrameworksBuildPhase): - insert_at = index - break - - self._properties['buildPhases'].insert(insert_at, resources_phase) - resources_phase.parent = self - - return resources_phase - - def SourcesPhase(self): - sources_phase = self.GetBuildPhaseByType(PBXSourcesBuildPhase) - if sources_phase == None: - sources_phase = PBXSourcesBuildPhase() - self.AppendProperty('buildPhases', sources_phase) - - return sources_phase - - def FrameworksPhase(self): - frameworks_phase = self.GetBuildPhaseByType(PBXFrameworksBuildPhase) - if frameworks_phase == None: - frameworks_phase = PBXFrameworksBuildPhase() - self.AppendProperty('buildPhases', frameworks_phase) - - return frameworks_phase - - def AddDependency(self, other): - # super - XCTarget.AddDependency(self, other) - - static_library_type = 'com.apple.product-type.library.static' - shared_library_type = 'com.apple.product-type.library.dynamic' - framework_type = 'com.apple.product-type.framework' - if isinstance(other, PBXNativeTarget) and \ - 'productType' in self._properties and \ - self._properties['productType'] != static_library_type and \ - 'productType' in other._properties and \ - (other._properties['productType'] == static_library_type or \ - ((other._properties['productType'] == shared_library_type or \ - other._properties['productType'] == framework_type) and \ - ((not other.HasBuildSetting('MACH_O_TYPE')) or - other.GetBuildSetting('MACH_O_TYPE') != 'mh_bundle'))): - - file_ref = other.GetProperty('productReference') - - pbxproject = self.PBXProjectAncestor() - other_pbxproject = other.PBXProjectAncestor() - if pbxproject != other_pbxproject: - other_project_product_group = \ - pbxproject.AddOrGetProjectReference(other_pbxproject)[0] - file_ref = other_project_product_group.GetChildByRemoteObject(file_ref) - - self.FrameworksPhase().AppendProperty('files', - PBXBuildFile({'fileRef': file_ref})) - - -class PBXAggregateTarget(XCTarget): - pass - - -class PBXProject(XCContainerPortal): - # A PBXProject is really just an XCObject, the XCContainerPortal thing is - # just to allow PBXProject to be used in the containerPortal property of - # PBXContainerItemProxy. - """ - - Attributes: - path: "sample.xcodeproj". TODO(mark) Document me! - _other_pbxprojects: A dictionary, keyed by other PBXProject objects. Each - value is a reference to the dict in the - projectReferences list associated with the keyed - PBXProject. - """ - - _schema = XCContainerPortal._schema.copy() - _schema.update({ - 'attributes': [0, dict, 0, 0], - 'buildConfigurationList': [0, XCConfigurationList, 1, 1, - XCConfigurationList()], - 'compatibilityVersion': [0, str, 0, 1, 'Xcode 3.1'], - 'hasScannedForEncodings': [0, int, 0, 1, 1], - 'mainGroup': [0, PBXGroup, 1, 1, PBXGroup()], - 'projectDirPath': [0, str, 0, 1, ''], - 'projectReferences': [1, dict, 0, 0], - 'projectRoot': [0, str, 0, 1, ''], - 'targets': [1, XCTarget, 1, 1, []], - }) - - def __init__(self, properties=None, id=None, parent=None, path=None): - self.path = path - self._other_pbxprojects = {} - # super - return XCContainerPortal.__init__(self, properties, id, parent) - - def Name(self): - name = self.path - if name[-10:] == '.xcodeproj': - name = name[:-10] - return posixpath.basename(name) - - def Path(self): - return self.path - - def Comment(self): - return 'Project object' - - def Children(self): - # super - children = XCContainerPortal.Children(self) - - # Add children that the schema doesn't know about. Maybe there's a more - # elegant way around this, but this is the only case where we need to own - # objects in a dictionary (that is itself in a list), and three lines for - # a one-off isn't that big a deal. - if 'projectReferences' in self._properties: - for reference in self._properties['projectReferences']: - children.append(reference['ProductGroup']) - - return children - - def PBXProjectAncestor(self): - return self - - def _GroupByName(self, name): - if not 'mainGroup' in self._properties: - self.SetProperty('mainGroup', PBXGroup()) - - main_group = self._properties['mainGroup'] - group = main_group.GetChildByName(name) - if group == None: - group = PBXGroup({'name': name}) - main_group.AppendChild(group) - - return group - - # SourceGroup and ProductsGroup are created by default in Xcode's own - # templates. - def SourceGroup(self): - return self._GroupByName('Source') - - def ProductsGroup(self): - return self._GroupByName('Products') - - # IntermediatesGroup is used to collect source-like files that are generated - # by rules or script phases and are placed in intermediate directories such - # as DerivedSources. - def IntermediatesGroup(self): - return self._GroupByName('Intermediates') - - # FrameworksGroup and ProjectsGroup are top-level groups used to collect - # frameworks and projects. - def FrameworksGroup(self): - return self._GroupByName('Frameworks') - - def ProjectsGroup(self): - return self._GroupByName('Projects') - - def RootGroupForPath(self, path): - """Returns a PBXGroup child of this object to which path should be added. - - This method is intended to choose between SourceGroup and - IntermediatesGroup on the basis of whether path is present in a source - directory or an intermediates directory. For the purposes of this - determination, any path located within a derived file directory such as - PROJECT_DERIVED_FILE_DIR is treated as being in an intermediates - directory. - - The returned value is a two-element tuple. The first element is the - PBXGroup, and the second element specifies whether that group should be - organized hierarchically (True) or as a single flat list (False). - """ - - # TODO(mark): make this a class variable and bind to self on call? - # Also, this list is nowhere near exhaustive. - # INTERMEDIATE_DIR and SHARED_INTERMEDIATE_DIR are used by - # gyp.generator.xcode. There should probably be some way for that module - # to push the names in, rather than having to hard-code them here. - source_tree_groups = { - 'DERIVED_FILE_DIR': (self.IntermediatesGroup, True), - 'INTERMEDIATE_DIR': (self.IntermediatesGroup, True), - 'PROJECT_DERIVED_FILE_DIR': (self.IntermediatesGroup, True), - 'SHARED_INTERMEDIATE_DIR': (self.IntermediatesGroup, True), - } - - (source_tree, path) = SourceTreeAndPathFromPath(path) - if source_tree != None and source_tree in source_tree_groups: - (group_func, hierarchical) = source_tree_groups[source_tree] - group = group_func() - return (group, hierarchical) - - # TODO(mark): make additional choices based on file extension. - - return (self.SourceGroup(), True) - - def AddOrGetFileInRootGroup(self, path): - """Returns a PBXFileReference corresponding to path in the correct group - according to RootGroupForPath's heuristics. - - If an existing PBXFileReference for path exists, it will be returned. - Otherwise, one will be created and returned. - """ - - (group, hierarchical) = self.RootGroupForPath(path) - return group.AddOrGetFileByPath(path, hierarchical) - - def RootGroupsTakeOverOnlyChildren(self, recurse=False): - """Calls TakeOverOnlyChild for all groups in the main group.""" - - for group in self._properties['mainGroup']._properties['children']: - if isinstance(group, PBXGroup): - group.TakeOverOnlyChild(recurse) - - def SortGroups(self): - # Sort the children of the mainGroup (like "Source" and "Products") - # according to their defined order. - self._properties['mainGroup']._properties['children'] = \ - sorted(self._properties['mainGroup']._properties['children'], - cmp=lambda x,y: x.CompareRootGroup(y)) - - # Sort everything else by putting group before files, and going - # alphabetically by name within sections of groups and files. SortGroup - # is recursive. - for group in self._properties['mainGroup']._properties['children']: - if not isinstance(group, PBXGroup): - continue - - if group.Name() == 'Products': - # The Products group is a special case. Instead of sorting - # alphabetically, sort things in the order of the targets that - # produce the products. To do this, just build up a new list of - # products based on the targets. - products = [] - for target in self._properties['targets']: - if not isinstance(target, PBXNativeTarget): - continue - product = target._properties['productReference'] - # Make sure that the product is already in the products group. - assert product in group._properties['children'] - products.append(product) - - # Make sure that this process doesn't miss anything that was already - # in the products group. - assert len(products) == len(group._properties['children']) - group._properties['children'] = products - else: - group.SortGroup() - - def AddOrGetProjectReference(self, other_pbxproject): - """Add a reference to another project file (via PBXProject object) to this - one. - - Returns [ProductGroup, ProjectRef]. ProductGroup is a PBXGroup object in - this project file that contains a PBXReferenceProxy object for each - product of each PBXNativeTarget in the other project file. ProjectRef is - a PBXFileReference to the other project file. - - If this project file already references the other project file, the - existing ProductGroup and ProjectRef are returned. The ProductGroup will - still be updated if necessary. - """ - - if not 'projectReferences' in self._properties: - self._properties['projectReferences'] = [] - - product_group = None - project_ref = None - - if not other_pbxproject in self._other_pbxprojects: - # This project file isn't yet linked to the other one. Establish the - # link. - product_group = PBXGroup({'name': 'Products'}) - - # ProductGroup is strong. - product_group.parent = self - - # There's nothing unique about this PBXGroup, and if left alone, it will - # wind up with the same set of hashables as all other PBXGroup objects - # owned by the projectReferences list. Add the hashables of the - # remote PBXProject that it's related to. - product_group._hashables.extend(other_pbxproject.Hashables()) - - # The other project reports its path as relative to the same directory - # that this project's path is relative to. The other project's path - # is not necessarily already relative to this project. Figure out the - # pathname that this project needs to use to refer to the other one. - this_path = posixpath.dirname(self.Path()) - projectDirPath = self.GetProperty('projectDirPath') - if projectDirPath: - if posixpath.isabs(projectDirPath[0]): - this_path = projectDirPath - else: - this_path = posixpath.join(this_path, projectDirPath) - other_path = gyp.common.RelativePath(other_pbxproject.Path(), this_path) - - # ProjectRef is weak (it's owned by the mainGroup hierarchy). - project_ref = PBXFileReference({ - 'lastKnownFileType': 'wrapper.pb-project', - 'path': other_path, - 'sourceTree': 'SOURCE_ROOT', - }) - self.ProjectsGroup().AppendChild(project_ref) - - ref_dict = {'ProductGroup': product_group, 'ProjectRef': project_ref} - self._other_pbxprojects[other_pbxproject] = ref_dict - self.AppendProperty('projectReferences', ref_dict) - - # Xcode seems to sort this list case-insensitively - self._properties['projectReferences'] = \ - sorted(self._properties['projectReferences'], cmp=lambda x,y: - cmp(x['ProjectRef'].Name().lower(), - y['ProjectRef'].Name().lower())) - else: - # The link already exists. Pull out the relevnt data. - project_ref_dict = self._other_pbxprojects[other_pbxproject] - product_group = project_ref_dict['ProductGroup'] - project_ref = project_ref_dict['ProjectRef'] - - self._SetUpProductReferences(other_pbxproject, product_group, project_ref) - - return [product_group, project_ref] - - def _SetUpProductReferences(self, other_pbxproject, product_group, - project_ref): - # TODO(mark): This only adds references to products in other_pbxproject - # when they don't exist in this pbxproject. Perhaps it should also - # remove references from this pbxproject that are no longer present in - # other_pbxproject. Perhaps it should update various properties if they - # change. - for target in other_pbxproject._properties['targets']: - if not isinstance(target, PBXNativeTarget): - continue - - other_fileref = target._properties['productReference'] - if product_group.GetChildByRemoteObject(other_fileref) == None: - # Xcode sets remoteInfo to the name of the target and not the name - # of its product, despite this proxy being a reference to the product. - container_item = PBXContainerItemProxy({ - 'containerPortal': project_ref, - 'proxyType': 2, - 'remoteGlobalIDString': other_fileref, - 'remoteInfo': target.Name() - }) - # TODO(mark): Does sourceTree get copied straight over from the other - # project? Can the other project ever have lastKnownFileType here - # instead of explicitFileType? (Use it if so?) Can path ever be - # unset? (I don't think so.) Can other_fileref have name set, and - # does it impact the PBXReferenceProxy if so? These are the questions - # that perhaps will be answered one day. - reference_proxy = PBXReferenceProxy({ - 'fileType': other_fileref._properties['explicitFileType'], - 'path': other_fileref._properties['path'], - 'sourceTree': other_fileref._properties['sourceTree'], - 'remoteRef': container_item, - }) - - product_group.AppendChild(reference_proxy) - - def SortRemoteProductReferences(self): - # For each remote project file, sort the associated ProductGroup in the - # same order that the targets are sorted in the remote project file. This - # is the sort order used by Xcode. - - def CompareProducts(x, y, remote_products): - # x and y are PBXReferenceProxy objects. Go through their associated - # PBXContainerItem to get the remote PBXFileReference, which will be - # present in the remote_products list. - x_remote = x._properties['remoteRef']._properties['remoteGlobalIDString'] - y_remote = y._properties['remoteRef']._properties['remoteGlobalIDString'] - x_index = remote_products.index(x_remote) - y_index = remote_products.index(y_remote) - - # Use the order of each remote PBXFileReference in remote_products to - # determine the sort order. - return cmp(x_index, y_index) - - for other_pbxproject, ref_dict in self._other_pbxprojects.iteritems(): - # Build up a list of products in the remote project file, ordered the - # same as the targets that produce them. - remote_products = [] - for target in other_pbxproject._properties['targets']: - if not isinstance(target, PBXNativeTarget): - continue - remote_products.append(target._properties['productReference']) - - # Sort the PBXReferenceProxy children according to the list of remote - # products. - product_group = ref_dict['ProductGroup'] - product_group._properties['children'] = sorted( - product_group._properties['children'], - cmp=lambda x, y: CompareProducts(x, y, remote_products)) - - -class XCProjectFile(XCObject): - _schema = XCObject._schema.copy() - _schema.update({ - 'archiveVersion': [0, int, 0, 1, 1], - 'classes': [0, dict, 0, 1, {}], - 'objectVersion': [0, int, 0, 1, 45], - 'rootObject': [0, PBXProject, 1, 1], - }) - - def SetXcodeVersion(self, version): - version_to_object_version = { - '2.4': 45, - '3.0': 45, - '3.1': 45, - '3.2': 46, - } - if not version in version_to_object_version: - supported_str = ', '.join(sorted(version_to_object_version.keys())) - raise Exception( - 'Unsupported Xcode version %s (supported: %s)' % - ( version, supported_str ) ) - compatibility_version = 'Xcode %s' % version - self._properties['rootObject'].SetProperty('compatibilityVersion', - compatibility_version) - self.SetProperty('objectVersion', version_to_object_version[version]); - - def ComputeIDs(self, recursive=True, overwrite=True, hash=None): - # Although XCProjectFile is implemented here as an XCObject, it's not a - # proper object in the Xcode sense, and it certainly doesn't have its own - # ID. Pass through an attempt to update IDs to the real root object. - if recursive: - self._properties['rootObject'].ComputeIDs(recursive, overwrite, hash) - - def Print(self, file=sys.stdout): - self.VerifyHasRequiredProperties() - - # Add the special "objects" property, which will be caught and handled - # separately during printing. This structure allows a fairly standard - # loop do the normal printing. - self._properties['objects'] = {} - self._XCPrint(file, 0, '// !$*UTF8*$!\n') - if self._should_print_single_line: - self._XCPrint(file, 0, '{ ') - else: - self._XCPrint(file, 0, '{\n') - for property, value in sorted(self._properties.iteritems(), - cmp=lambda x, y: cmp(x, y)): - if property == 'objects': - self._PrintObjects(file) - else: - self._XCKVPrint(file, 1, property, value) - self._XCPrint(file, 0, '}\n') - del self._properties['objects'] - - def _PrintObjects(self, file): - if self._should_print_single_line: - self._XCPrint(file, 0, 'objects = {') - else: - self._XCPrint(file, 1, 'objects = {\n') - - objects_by_class = {} - for object in self.Descendants(): - if object == self: - continue - class_name = object.__class__.__name__ - if not class_name in objects_by_class: - objects_by_class[class_name] = [] - objects_by_class[class_name].append(object) - - for class_name in sorted(objects_by_class): - self._XCPrint(file, 0, '\n') - self._XCPrint(file, 0, '/* Begin ' + class_name + ' section */\n') - for object in sorted(objects_by_class[class_name], - cmp=lambda x, y: cmp(x.id, y.id)): - object.Print(file) - self._XCPrint(file, 0, '/* End ' + class_name + ' section */\n') - - if self._should_print_single_line: - self._XCPrint(file, 0, '}; ') - else: - self._XCPrint(file, 1, '};\n') diff --git a/third_party/gyp/pylib/gyp/xml_fix.py b/third_party/gyp/pylib/gyp/xml_fix.py deleted file mode 100644 index 20f782d..0000000 --- a/third_party/gyp/pylib/gyp/xml_fix.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Applies a fix to CR LF TAB handling in xml.dom. - -Fixes this: http://code.google.com/p/chromium/issues/detail?id=76293 -Working around this: http://bugs.python.org/issue5752 -TODO(bradnelson): Consider dropping this when we drop XP support. -""" - - -import xml.dom.minidom - - -def _Replacement_write_data(writer, data, is_attrib=False): - """Writes datachars to writer.""" - data = data.replace("&", "&").replace("<", "<") - data = data.replace("\"", """).replace(">", ">") - if is_attrib: - data = data.replace( - "\r", " ").replace( - "\n", " ").replace( - "\t", " ") - writer.write(data) - - -def _Replacement_writexml(self, writer, indent="", addindent="", newl=""): - # indent = current indentation - # addindent = indentation to add to higher levels - # newl = newline string - writer.write(indent+"<" + self.tagName) - - attrs = self._get_attributes() - a_names = attrs.keys() - a_names.sort() - - for a_name in a_names: - writer.write(" %s=\"" % a_name) - _Replacement_write_data(writer, attrs[a_name].value, is_attrib=True) - writer.write("\"") - if self.childNodes: - writer.write(">%s" % newl) - for node in self.childNodes: - node.writexml(writer, indent + addindent, addindent, newl) - writer.write("%s%s" % (indent, self.tagName, newl)) - else: - writer.write("/>%s" % newl) - - -class XmlFix(object): - """Object to manage temporary patching of xml.dom.minidom.""" - - def __init__(self): - # Preserve current xml.dom.minidom functions. - self.write_data = xml.dom.minidom._write_data - self.writexml = xml.dom.minidom.Element.writexml - # Inject replacement versions of a function and a method. - xml.dom.minidom._write_data = _Replacement_write_data - xml.dom.minidom.Element.writexml = _Replacement_writexml - - def Cleanup(self): - if self.write_data: - xml.dom.minidom._write_data = self.write_data - xml.dom.minidom.Element.writexml = self.writexml - self.write_data = None - - def __del__(self): - self.Cleanup() diff --git a/third_party/gyp/samples/samples b/third_party/gyp/samples/samples deleted file mode 100755 index 804b618..0000000 --- a/third_party/gyp/samples/samples +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import os.path -import shutil -import sys - - -gyps = [ - 'app/app.gyp', - 'base/base.gyp', - 'build/temp_gyp/googleurl.gyp', - 'build/all.gyp', - 'build/common.gypi', - 'build/external_code.gypi', - 'chrome/test/security_tests/security_tests.gyp', - 'chrome/third_party/hunspell/hunspell.gyp', - 'chrome/chrome.gyp', - 'media/media.gyp', - 'net/net.gyp', - 'printing/printing.gyp', - 'sdch/sdch.gyp', - 'skia/skia.gyp', - 'testing/gmock.gyp', - 'testing/gtest.gyp', - 'third_party/bzip2/bzip2.gyp', - 'third_party/icu38/icu38.gyp', - 'third_party/libevent/libevent.gyp', - 'third_party/libjpeg/libjpeg.gyp', - 'third_party/libpng/libpng.gyp', - 'third_party/libxml/libxml.gyp', - 'third_party/libxslt/libxslt.gyp', - 'third_party/lzma_sdk/lzma_sdk.gyp', - 'third_party/modp_b64/modp_b64.gyp', - 'third_party/npapi/npapi.gyp', - 'third_party/sqlite/sqlite.gyp', - 'third_party/zlib/zlib.gyp', - 'v8/tools/gyp/v8.gyp', - 'webkit/activex_shim/activex_shim.gyp', - 'webkit/activex_shim_dll/activex_shim_dll.gyp', - 'webkit/build/action_csspropertynames.py', - 'webkit/build/action_cssvaluekeywords.py', - 'webkit/build/action_jsconfig.py', - 'webkit/build/action_makenames.py', - 'webkit/build/action_maketokenizer.py', - 'webkit/build/action_useragentstylesheets.py', - 'webkit/build/rule_binding.py', - 'webkit/build/rule_bison.py', - 'webkit/build/rule_gperf.py', - 'webkit/tools/test_shell/test_shell.gyp', - 'webkit/webkit.gyp', -] - - -def Main(argv): - if len(argv) != 3 or argv[1] not in ['push', 'pull']: - print 'Usage: %s push/pull PATH_TO_CHROME' % argv[0] - return 1 - - path_to_chrome = argv[2] - - for g in gyps: - chrome_file = os.path.join(path_to_chrome, g) - local_file = os.path.join(os.path.dirname(argv[0]), os.path.split(g)[1]) - if argv[1] == 'push': - print 'Copying %s to %s' % (local_file, chrome_file) - shutil.copyfile(local_file, chrome_file) - elif argv[1] == 'pull': - print 'Copying %s to %s' % (chrome_file, local_file) - shutil.copyfile(chrome_file, local_file) - else: - assert False - - return 0 - - -if __name__ == '__main__': - sys.exit(Main(sys.argv)) diff --git a/third_party/gyp/samples/samples.bat b/third_party/gyp/samples/samples.bat deleted file mode 100644 index 778d9c9..0000000 --- a/third_party/gyp/samples/samples.bat +++ /dev/null @@ -1,5 +0,0 @@ -@rem Copyright (c) 2009 Google Inc. All rights reserved. -@rem Use of this source code is governed by a BSD-style license that can be -@rem found in the LICENSE file. - -@python %~dp0/samples %* diff --git a/third_party/gyp/setup.py b/third_party/gyp/setup.py deleted file mode 100755 index ed2b41a..0000000 --- a/third_party/gyp/setup.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from distutils.core import setup -from distutils.command.install import install -from distutils.command.install_lib import install_lib -from distutils.command.install_scripts import install_scripts - -setup( - name='gyp', - version='0.1', - description='Generate Your Projects', - author='Chromium Authors', - author_email='chromium-dev@googlegroups.com', - url='http://code.google.com/p/gyp', - package_dir = {'': 'pylib'}, - packages=['gyp', 'gyp.generator'], - - scripts = ['gyp'], - cmdclass = {'install': install, - 'install_lib': install_lib, - 'install_scripts': install_scripts}, -) diff --git a/third_party/gyp/tools/README b/third_party/gyp/tools/README deleted file mode 100644 index 712e4ef..0000000 --- a/third_party/gyp/tools/README +++ /dev/null @@ -1,15 +0,0 @@ -pretty_vcproj: - Usage: pretty_vcproj.py "c:\path\to\vcproj.vcproj" [key1=value1] [key2=value2] - - They key/value pair are used to resolve vsprops name. - - For example, if I want to diff the base.vcproj project: - - pretty_vcproj.py z:\dev\src-chrome\src\base\build\base.vcproj "$(SolutionDir)=z:\dev\src-chrome\src\chrome\\" "$(CHROMIUM_BUILD)=" "$(CHROME_BUILD_TYPE)=" > orignal.txt - pretty_vcproj.py z:\dev\src-chrome\src\base\base_gyp.vcproj "$(SolutionDir)=z:\dev\src-chrome\src\chrome\\" "$(CHROMIUM_BUILD)=" "$(CHROME_BUILD_TYPE)=" > gyp.txt - - And you can use your favorite diff tool to see the changes. - - Note: In the case of base.vcproj, the original vcproj is one level up the generated one. - I suggest you do a search and replace for '"..\' and replace it with '"' in original.txt - before you perform the diff. \ No newline at end of file diff --git a/third_party/gyp/tools/graphviz.py b/third_party/gyp/tools/graphviz.py deleted file mode 100755 index 7f71668..0000000 --- a/third_party/gyp/tools/graphviz.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2011 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Using the JSON dumped by the dump-dependency-json generator, -generate input suitable for graphviz to render a dependency graph of -targets.""" - -import collections -import json -import sys - - -def ParseTarget(target): - target, _, suffix = target.partition('#') - filename, _, target = target.partition(':') - return filename, target, suffix - - -def LoadEdges(filename, targets): - """Load the edges map from the dump file, and filter it to only - show targets in |targets| and their depedendents.""" - - file = open('dump.json') - edges = json.load(file) - file.close() - - # Copy out only the edges we're interested in from the full edge list. - target_edges = {} - to_visit = targets[:] - while to_visit: - src = to_visit.pop() - if src in target_edges: - continue - target_edges[src] = edges[src] - to_visit.extend(edges[src]) - - return target_edges - - -def WriteGraph(edges): - """Print a graphviz graph to stdout. - |edges| is a map of target to a list of other targets it depends on.""" - - # Bucket targets by file. - files = collections.defaultdict(list) - for src, dst in edges.items(): - build_file, target_name, toolset = ParseTarget(src) - files[build_file].append(src) - - print 'digraph D {' - print ' fontsize=8' # Used by subgraphs. - print ' node [fontsize=8]' - - # Output nodes by file. We must first write out each node within - # its file grouping before writing out any edges that may refer - # to those nodes. - for filename, targets in files.items(): - if len(targets) == 1: - # If there's only one node for this file, simplify - # the display by making it a box without an internal node. - target = targets[0] - build_file, target_name, toolset = ParseTarget(target) - print ' "%s" [shape=box, label="%s\\n%s"]' % (target, filename, - target_name) - else: - # Group multiple nodes together in a subgraph. - print ' subgraph "cluster_%s" {' % filename - print ' label = "%s"' % filename - for target in targets: - build_file, target_name, toolset = ParseTarget(target) - print ' "%s" [label="%s"]' % (target, target_name) - print ' }' - - # Now that we've placed all the nodes within subgraphs, output all - # the edges between nodes. - for src, dsts in edges.items(): - for dst in dsts: - print ' "%s" -> "%s"' % (src, dst) - - print '}' - - -if __name__ == '__main__': - if len(sys.argv) < 2: - print >>sys.stderr, __doc__ - print >>sys.stderr - print >>sys.stderr, 'usage: %s target1 target2...' % (sys.argv[0]) - sys.exit(1) - - edges = LoadEdges('dump.json', sys.argv[1:]) - - WriteGraph(edges) diff --git a/third_party/gyp/tools/pretty_gyp.py b/third_party/gyp/tools/pretty_gyp.py deleted file mode 100644 index 04c7901..0000000 --- a/third_party/gyp/tools/pretty_gyp.py +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/env python -# Copyright (c) 2009 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# This file pretty-prints the contents of a GYP file. - -import sys -import re - -input = [] -if len(sys.argv) > 1: - input_file = open(sys.argv[1]) - input = input_file.read().splitlines() - input_file.close() -else: - input = sys.stdin.read().splitlines() - -# This is used to remove comments when we're counting braces. -comment_re = re.compile(r'\s*#.*') - -# This is used to remove quoted strings when we're counting braces. -# It takes into account quoted quotes, and makes sure that the quotes -# match. -# NOTE: It does not handle quotes that span more than one line, or -# cases where an escaped quote is preceeded by an escaped backslash. -quote_re_str = r'(?P[\'"])(.*?)(? 0: - after = True - - # This catches the special case of a closing brace having something - # other than just whitespace ahead of it -- we don't want to - # unindent that until after this line is printed so it stays with - # the previous indentation level. - if cnt < 0 and closing_prefix_re.match(stripline): - after = True - return (cnt, after) - -# This does the main work of indenting the input based on the brace counts. -def prettyprint_input(lines): - indent = 0 - basic_offset = 2 - last_line = "" - for line in lines: - if comment_re.match(line): - print line - else: - line = line.strip('\r\n\t ') # Otherwise doesn't strip \r on Unix. - if len(line) > 0: - (brace_diff, after) = count_braces(line) - if brace_diff != 0: - if after: - print " " * (basic_offset * indent) + line - indent += brace_diff - else: - indent += brace_diff - print " " * (basic_offset * indent) + line - else: - print " " * (basic_offset * indent) + line - else: - print "" - last_line = line - -# Split up the double braces. -lines = split_double_braces(input) - -# Indent and print the output. -prettyprint_input(lines) diff --git a/third_party/gyp/tools/pretty_sln.py b/third_party/gyp/tools/pretty_sln.py deleted file mode 100755 index 0741fff..0000000 --- a/third_party/gyp/tools/pretty_sln.py +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/python2.5 - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Prints the information in a sln file in a diffable way. - - It first outputs each projects in alphabetical order with their - dependencies. - - Then it outputs a possible build order. -""" - -__author__ = 'nsylvain (Nicolas Sylvain)' - -import os -import re -import sys -import pretty_vcproj - -def BuildProject(project, built, projects, deps): - # if all dependencies are done, we can build it, otherwise we try to build the - # dependency. - # This is not infinite-recursion proof. - for dep in deps[project]: - if dep not in built: - BuildProject(dep, built, projects, deps) - print project - built.append(project) - -def ParseSolution(solution_file): - # All projects, their clsid and paths. - projects = dict() - - # A list of dependencies associated with a project. - dependencies = dict() - - # Regular expressions that matches the SLN format. - # The first line of a project definition. - begin_project = re.compile(('^Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942' - '}"\) = "(.*)", "(.*)", "(.*)"$')) - # The last line of a project definition. - end_project = re.compile('^EndProject$') - # The first line of a dependency list. - begin_dep = re.compile('ProjectSection\(ProjectDependencies\) = postProject$') - # The last line of a dependency list. - end_dep = re.compile('EndProjectSection$') - # A line describing a dependency. - dep_line = re.compile(' *({.*}) = ({.*})$') - - in_deps = False - solution = open(solution_file) - for line in solution: - results = begin_project.search(line) - if results: - # Hack to remove icu because the diff is too different. - if results.group(1).find('icu') != -1: - continue - # We remove "_gyp" from the names because it helps to diff them. - current_project = results.group(1).replace('_gyp', '') - projects[current_project] = [results.group(2).replace('_gyp', ''), - results.group(3), - results.group(2)] - dependencies[current_project] = [] - continue - - results = end_project.search(line) - if results: - current_project = None - continue - - results = begin_dep.search(line) - if results: - in_deps = True - continue - - results = end_dep.search(line) - if results: - in_deps = False - continue - - results = dep_line.search(line) - if results and in_deps and current_project: - dependencies[current_project].append(results.group(1)) - continue - - # Change all dependencies clsid to name instead. - for project in dependencies: - # For each dependencies in this project - new_dep_array = [] - for dep in dependencies[project]: - # Look for the project name matching this cldis - for project_info in projects: - if projects[project_info][1] == dep: - new_dep_array.append(project_info) - dependencies[project] = sorted(new_dep_array) - - return (projects, dependencies) - -def PrintDependencies(projects, deps): - print "---------------------------------------" - print "Dependencies for all projects" - print "---------------------------------------" - print "-- --" - - for (project, dep_list) in sorted(deps.items()): - print "Project : %s" % project - print "Path : %s" % projects[project][0] - if dep_list: - for dep in dep_list: - print " - %s" % dep - print "" - - print "-- --" - -def PrintBuildOrder(projects, deps): - print "---------------------------------------" - print "Build order " - print "---------------------------------------" - print "-- --" - - built = [] - for (project, dep_list) in sorted(deps.items()): - if project not in built: - BuildProject(project, built, projects, deps) - - print "-- --" - -def PrintVCProj(projects): - - for project in projects: - print "-------------------------------------" - print "-------------------------------------" - print project - print project - print project - print "-------------------------------------" - print "-------------------------------------" - - project_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[1]), - projects[project][2])) - - pretty = pretty_vcproj - argv = [ '', - project_path, - '$(SolutionDir)=%s\\' % os.path.dirname(sys.argv[1]), - ] - argv.extend(sys.argv[3:]) - pretty.main(argv) - -def main(): - # check if we have exactly 1 parameter. - if len(sys.argv) < 2: - print 'Usage: %s "c:\\path\\to\\project.sln"' % sys.argv[0] - return - - (projects, deps) = ParseSolution(sys.argv[1]) - PrintDependencies(projects, deps) - PrintBuildOrder(projects, deps) - - if '--recursive' in sys.argv: - PrintVCProj(projects) - -if __name__ == '__main__': - main() - diff --git a/third_party/gyp/tools/pretty_vcproj.py b/third_party/gyp/tools/pretty_vcproj.py deleted file mode 100755 index 292a39f..0000000 --- a/third_party/gyp/tools/pretty_vcproj.py +++ /dev/null @@ -1,316 +0,0 @@ -#!/usr/bin/python2.5 - -# Copyright (c) 2009 Google Inc. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Make the format of a vcproj really pretty. - - This script normalize and sort an xml. It also fetches all the properties - inside linked vsprops and include them explicitly in the vcproj. - - It outputs the resulting xml to stdout. -""" - -__author__ = 'nsylvain (Nicolas Sylvain)' - -import os -import sys - -from xml.dom.minidom import parse -from xml.dom.minidom import Node - -REPLACEMENTS = dict() -ARGUMENTS = None - -class CmpTuple: - """Compare function between 2 tuple.""" - def __call__(self, x, y): - (key1, value1) = x - (key2, value2) = y - return cmp(key1, key2) - -class CmpNode: - """Compare function between 2 xml nodes.""" - - def get_string(self, node): - node_string = "node" - node_string += node.nodeName - if node.nodeValue: - node_string += node.nodeValue - - if node.attributes: - # We first sort by name, if present. - node_string += node.getAttribute("Name") - - all_nodes = [] - for (name, value) in node.attributes.items(): - all_nodes.append((name, value)) - - all_nodes.sort(CmpTuple()) - for (name, value) in all_nodes: - node_string += name - node_string += value - - return node_string - - def __call__(self, x, y): - return cmp(self.get_string(x), self.get_string(y)) - -def PrettyPrintNode(node, indent=0): - if node.nodeType == Node.TEXT_NODE: - if node.data.strip(): - print '%s%s' % (' '*indent, node.data.strip()) - return - - if node.childNodes: - node.normalize() - # Get the number of attributes - attr_count = 0 - if node.attributes: - attr_count = node.attributes.length - - # Print the main tag - if attr_count == 0: - print '%s<%s>' % (' '*indent, node.nodeName) - else: - print '%s<%s' % (' '*indent, node.nodeName) - - all_attributes = [] - for (name, value) in node.attributes.items(): - all_attributes.append((name, value)) - all_attributes.sort(CmpTuple()) - for (name, value) in all_attributes: - print '%s %s="%s"' % (' '*indent, name, value) - print '%s>' % (' '*indent) - if node.nodeValue: - print '%s %s' % (' '*indent, node.nodeValue) - - for sub_node in node.childNodes: - PrettyPrintNode(sub_node, indent=indent+2) - print '%s' % (' '*indent, node.nodeName) - -def FlattenFilter(node): - """Returns a list of all the node and sub nodes.""" - node_list = [] - - if (node.attributes and - node.getAttribute('Name') == '_excluded_files'): - # We don't add the "_excluded_files" filter. - return [] - - for current in node.childNodes: - if current.nodeName == 'Filter': - node_list.extend(FlattenFilter(current)) - else: - node_list.append(current) - - return node_list - -def FixFilenames(filenames, current_directory): - new_list = [] - for filename in filenames: - if filename: - for key in REPLACEMENTS: - filename = filename.replace(key, REPLACEMENTS[key]) - os.chdir(current_directory) - filename = filename.strip('"\' ') - if filename.startswith('$'): - new_list.append(filename) - else: - new_list.append(os.path.abspath(filename)) - return new_list - -def AbsoluteNode(node): - # Make all the properties we know about in this node absolute. - if node.attributes: - for (name, value) in node.attributes.items(): - if name in ['InheritedPropertySheets', 'RelativePath', - 'AdditionalIncludeDirectories', - 'IntermediateDirectory', 'OutputDirectory', - 'AdditionalLibraryDirectories']: - # We want to fix up these paths - path_list = value.split(';') - new_list = FixFilenames(path_list, os.path.dirname(ARGUMENTS[1])) - node.setAttribute(name, ';'.join(new_list)) - if not value: - node.removeAttribute(name) - -def CleanupVcproj(node): - # For each sub node, we call recursively this function. - for sub_node in node.childNodes: - AbsoluteNode(sub_node) - CleanupVcproj(sub_node) - - # Normalize the node, and remove all extranous whitespaces. - for sub_node in node.childNodes: - if sub_node.nodeType == Node.TEXT_NODE: - sub_node.data = sub_node.data.replace("\r", "") - sub_node.data = sub_node.data.replace("\n", "") - sub_node.data = sub_node.data.rstrip() - - # Fix all the semicolon separated attributes to be sorted, and we also - # remove the dups. - if node.attributes: - for (name, value) in node.attributes.items(): - sorted_list = sorted(value.split(';')) - unique_list = [] - [unique_list.append(i) for i in sorted_list if not unique_list.count(i)] - node.setAttribute(name, ';'.join(unique_list)) - if not value: - node.removeAttribute(name) - - if node.childNodes: - node.normalize() - - # For each node, take a copy, and remove it from the list. - node_array = [] - while node.childNodes and node.childNodes[0]: - # Take a copy of the node and remove it from the list. - current = node.childNodes[0] - node.removeChild(current) - - # If the child is a filter, we want to append all its children - # to this same list. - if current.nodeName == 'Filter': - node_array.extend(FlattenFilter(current)) - else: - node_array.append(current) - - - # Sort the list. - node_array.sort(CmpNode()) - - # Insert the nodes in the correct order. - for new_node in node_array: - # But don't append empty tool node. - if new_node.nodeName == 'Tool': - if new_node.attributes and new_node.attributes.length == 1: - # This one was empty. - continue - if new_node.nodeName == 'UserMacro': - continue - node.appendChild(new_node) - -def GetConfiguationNodes(vcproj): - #TODO(nsylvain): Find a better way to navigate the xml. - nodes = [] - for node in vcproj.childNodes: - if node.nodeName == "Configurations": - for sub_node in node.childNodes: - if sub_node.nodeName == "Configuration": - nodes.append(sub_node) - - return nodes - -def GetChildrenVsprops(filename): - dom = parse(filename) - if dom.documentElement.attributes: - vsprops = dom.documentElement.getAttribute('InheritedPropertySheets') - return FixFilenames(vsprops.split(';'), os.path.dirname(filename)) - return [] - -def SeekToNode(node1, child2): - # A text node does not have properties. - if child2.nodeType == Node.TEXT_NODE: - return None - - # Get the name of the current node. - current_name = child2.getAttribute("Name") - if not current_name: - # There is no name. We don't know how to merge. - return None - - # Look through all the nodes to find a match. - for sub_node in node1.childNodes: - if sub_node.nodeName == child2.nodeName: - name = sub_node.getAttribute("Name") - if name == current_name: - return sub_node - - # No match. We give up. - return None - -def MergeAttributes(node1, node2): - # No attributes to merge? - if not node2.attributes: - return - - for (name, value2) in node2.attributes.items(): - # Don't merge the 'Name' attribute. - if name == 'Name': - continue - value1 = node1.getAttribute(name) - if value1: - # The attribute exist in the main node. If it's equal, we leave it - # untouched, otherwise we concatenate it. - if value1 != value2: - node1.setAttribute(name, ';'.join([value1, value2])) - else: - # The attribute does nto exist in the main node. We append this one. - node1.setAttribute(name, value2) - - # If the attribute was a property sheet attributes, we remove it, since - # they are useless. - if name == 'InheritedPropertySheets': - node1.removeAttribute(name) - -def MergeProperties(node1, node2): - MergeAttributes(node1, node2) - for child2 in node2.childNodes: - child1 = SeekToNode(node1, child2) - if child1: - MergeProperties(child1, child2) - else: - node1.appendChild(child2.cloneNode(True)) - -def main(argv): - global REPLACEMENTS - global ARGUMENTS - ARGUMENTS = argv - """Main function of this vcproj prettifier.""" - - # check if we have exactly 1 parameter. - if len(argv) < 2: - print ('Usage: %s "c:\\path\\to\\vcproj.vcproj" [key1=value1] ' - '[key2=value2]' % argv[0]) - return - - # Parse the keys - for i in range(2, len(argv)): - (key, value) = argv[i].split('=') - REPLACEMENTS[key] = value - - # Open the vcproj and parse the xml. - dom = parse(argv[1]) - - # First thing we need to do is find the Configuration Node and merge them - # with the vsprops they include. - for configuration_node in GetConfiguationNodes(dom.documentElement): - # Get the property sheets associated with this configuration. - vsprops = configuration_node.getAttribute('InheritedPropertySheets') - - # Fix the filenames to be absolute. - vsprops_list = FixFilenames(vsprops.strip().split(';'), - os.path.dirname(argv[1])) - - # Extend the list of vsprops with all vsprops contained in the current - # vsprops. - for current_vsprops in vsprops_list: - vsprops_list.extend(GetChildrenVsprops(current_vsprops)) - - # Now that we have all the vsprops, we need to merge them. - for current_vsprops in vsprops_list: - MergeProperties(configuration_node, - parse(current_vsprops).documentElement) - - # Now that everything is merged, we need to cleanup the xml. - CleanupVcproj(dom.documentElement) - - # Finally, we use the prett xml function to print the vcproj back to the - # user. - #print dom.toprettyxml(newl="\n") - PrettyPrintNode(dom.documentElement) - -if __name__ == '__main__': - main(sys.argv) diff --git a/third_party/japanese_usage_dictionary/usage_dict.txt b/third_party/japanese_usage_dictionary/usage_dict.txt index f68f000..7fb52d9 100644 --- a/third_party/japanese_usage_dictionary/usage_dict.txt +++ b/third_party/japanese_usage_dictionary/usage_dict.txt @@ -1,357 +1,349 @@ -あいがん 哀願 * 情にうったえて頼むこと。 -あいがん 愛玩 * かわいがること。 -あいしょう 愛唱 * 好んで歌うこと。 +あいがん 哀願 * 情にうったえる。 +あいがん 愛玩 * かわいがる。 +あいしょう 愛唱 * 好んで歌う あいしょう 哀傷 * 悲しみいたむこと。 あいしょう 愛称 * 親しみを込めて呼ぶ名称。 -あいしょう 相性 * 互いの性格、性質の合う程度。「相性が良い」 -あう 逢う 五段・ワ行促音便 「会う」に同じ。情緒をこめるときに使われる。「恋人に逢う」 +あいしょう 相性 * 性格、性質が合うこと。 +あう 逢う 五段・ワ行促音便 人にあう。「恋人に逢う」 あう 会う 五段・ワ行促音便 人にあう。「友達と会う」 -あう 合う 五段・ワ行促音便 ぴったりあう。「息が合う」「答が合う」 -あう 遭う 五段・ワ行促音便 思いがけず、よくないことに巻き込まれる。「事故に遭う」 -あおい 青い 形容詞・アウオ段 1. 晴れているときの空や海の色。「空が青い」\n2. 〈「蒼い」とも〉血の気がない。「青い顔をしている」 -あおい 蒼い 形容詞・アウオ段 〈まれ〉血の気がない。「顔が蒼い」→青い2 -あおぐ 仰ぐ 五段・ガ行 1. 上を向く。「天を仰ぐ」\n2. 教えなどを求める。「指示を仰ぐ」\n3. 尊敬する。「師と仰ぐ」\n4. 飲む。「毒を仰ぐ」 -あおぐ 扇ぐ 五段・ガ行 うちわなどを動かし、風を出す。 -あか 垢 * 皮膚上の脂、汗など老廃物が固まったもの。 -あがく 足掻く 五段・カ行イ音便 〈かな書きも〉あばれる。もがく。 -あかし 証 * 証明するもの。証明。「友好の証として自国の動物を寄贈する」 -あかし 灯 * 〈文語〉 ともしび。 -あかり 明かり * ともしび。照明。「街に明かりがともる」 -あがる 挙がる 五段・ラ行 1. (特に手について)上にあげられる。「手が挙がる」\n2. (証拠・犯人が)見つかる。「証拠が挙がる」「犯人が挙がった」\n3. (名前などが)話に出される。「候補として彼女の名前が挙がった」\n4. 〈「上がる」とも〉ひとつひとつ取りざたされる。列挙される。「これら3点が問題点として挙がった」 -あがる 上がる 五段・ラ行 1. 高い位置、高い水準に移る。「階段を上がる」「中級クラスに上がった」「物価が上がる」\n2. 建物に入る。「靴を脱いでお上がりください」\n3. (水浴びなどを)終える。「シャワーから上がった」\n4. (火・煙が)出る。「煙が上がっている」\n5. (声などが)発せされる。「歓声が上がった」\n6. (費用が)思ったより安く、その中におさまる。「旅行は3万円で上がった」\n7. (電池が)放電して使えなくなる。「車のバッテリーが上がった」\n8. (仕事が)終わる。「仕事が上がって飲みに行った」\n9. 〈ボードゲームで〉ゲームの目的を達成する。「彼女が最初に上がった」\n10. 〈尊敬語〉食べる。「冷めないうちにお上がりください」\n11. (謙譲語)訪れる。「近々お礼に上がります」\n12. (成果・効果などが)あらわれる。「効果が上がる」\n13.(雨などが)止まる。「雨が上がる」\n14. 〈「アガる」とも〉緊張する。「面接で上がってしまった」 -あがる 揚がる 五段・ラ行 1. 〈「上がる」とも〉空高くあがる。「凧(たこ)が揚がる」\n2. 〈「上がる」とも〉高くかかげられる。「旗が揚がる」\n3. 油であげたものができあがる。「天ぷらが揚がる」 -あきる 厭きる 一段 →飽きる -あきる 飽きる 一段 〈「厭きる」とも〉同じようなことの繰り返しにうんざりする。 -あく 開く 五段・カ行イ音便 1. (閉まっていたものが)ひらく。「扉が開く」「蓋が開く」⇔閉まる・閉じる。\n2. (店などの)営業が始まる。「新しい店がまだ開かない」\n3. 〈「空く」とも〉(穴が)できる。「壁に穴が開いた」 -あく 空く 五段・カ行イ音便 1. そこにあったものがなくなり、空間や時間ができる。「隙間が空く」「席が空く」「グラスが空く」「手が空く」(=さしあたってすることがなくなる)\n2. 〈「開く」とも〉(穴が)できる。「壁に穴が空いた」 -あく 飽く 五段・カ行イ音便 〈文語〉「飽きる」に同じ。 -あく 明く 五段・カ行イ音便 〈文語〉見えるようになる。「目が明く」 -あげ 上げ * 〈接尾語〉上げること。「問題を棚上げする」 -あげ 揚げ * 1. 〈接尾語〉油で揚げること。また、揚げたもの。「さつま揚げ」「から揚げ」\n2. 〈多く「お揚げ」として〉「油揚げ」の略。薄く切った豆腐を揚げたもの。「うどんに揚げがのっている」 -あける 開ける 一段 1. (閉じていたものを)ひらく。「窓を開ける」\n2. (店などの)営業を始める。また、営業をする。「日曜日にも店を開ける」\n3. (穴を)つくる。「板に穴を開けた」 -あける 空ける 一段 1. からにする。「グラスを空ける」「家を空ける」\n2. あいだに時間や空白をはさむ。「ある程度の期間を空ける」「行間を空ける」\n3. 空間や時間を埋めないでおく。「後から来る人のために場所を空ける」「来客のためにスケジュールを空ける」\n4. 〈「開ける」とも〉(穴を)つくる。「板に穴を空けた」 -あける 明ける 一段 ある時期が終わって、別の時期になる。「夜が明ける」「年が明ける」「テストが明ける」 -あげる 挙げる 一段 1. (特に手について)上にあげる。「手を挙げる」\n2. (証拠・犯人を)見つける。「証拠を挙げる」「犯人を挙げた」\n3. (名前などを)話に出す。「候補として彼女の名前を挙げた」\n4. 〈「上げる」とも〉ひとつひとつ取りざたする。列挙する。「これら3点を問題点として挙げた」 -あげる 上げる 一段 1. 高い位置、高い水準に移す。「荷物を網棚に上げる」「学生を中級クラスに上げる」「料金を上げる」\n2. 建物に入れる。「客を家に上げる」\n3. (火・煙を)出す。「煙を上げて燃えている」\n4. (声などを)発する。「歓声を上げた」\n5. (費用を)安い範囲におさめる。「旅費を3万円で上げる」\n6. (仕事を)終える。「この仕事を上げてから飲みに行く」\n7. (成果・効果を)あらわす。「効果を上げる」 -あげる 揚げる 一段 1. 〈「上げる」とも〉空高くあげる。「凧(たこ)を揚げる」\n2. 〈「上げる」とも〉高くかかげる。「旗を揚げる」\n3. 高温の油に浸して調理する。「天ぷらを揚げる」 -あし 葦 * イネ科の多年草。 -あし 脚 * 足の付け根から足首までを指すときに、「足」と区別して使う。「すらりとした脚」 -あし 足 * 1. 人間・動物などが移動のために使う部分の総称。「昆虫には足が六本ある」\n2. 足首から下の部分。「足が大きい」 -あじ 味 * 1. 舌で感じる、あまい・からい・にがいなどの感覚。\n2. -あじ 鰺 * アジ科の魚。 -あずかる 与る 五段・ラ行 〈かな書きも〉\n1. かかわる。「計画に与る」\n2. (恩恵などを)受ける。もらう。「恩恵に与る」「栄誉に与る」 -あずかる 預る 五段・ラ行 →預かる -あずかる 預かる 五段・ラ行 一時的にまかせられる。「荷物を預かる」 -あだ 仇 * 1. 〈「仇になる」として〉(かえって)害になる。「自分で解決しようとしたのが仇になった」\n2. かたき。「仇を打つ」 -あだ 徒 * 〈かな書きも〉無駄。「親切が徒となる」 -あたたか 温か * 1. (ものなどが)冷たくなくほどよい。「温かな水」\n2. 〈「暖か」とも〉(心・態度などが)やさしく気遣いがある。「温かな心」 -あたたか 暖か * 1. (気温、気象などが)寒くなくほどよい。「暖かな春」\n2. 〈「温か」とも〉(心・態度などが)やさしく気遣いがある。「暖かな心」 -あたたかい 温かい 形容詞・アウオ段 1. (ものなどが)冷たくなくほどよい。「水温が温かい」\n2. 〈「暖かい」とも〉(心・態度などが)やさしく気遣いがある。「心が温かい」 -あたたかい 暖かい 形容詞・アウオ段 1. (気温、気象などが)寒くなくほどよい。「春は暖かい」\n2. 〈「温かい」とも〉(心・態度などが)やさしく気遣いがある。「心が暖かい」 -あたたまる 温まる 五段・ラ行 1. (ものなどが)温かくなる。「水が温まる」\n2. 〈「暖まる」とも〉(心が)じんわりと和やかになる。「心が温まる」 -あたたまる 暖まる 五段・ラ行 1. (気温、気象などが)暖かくなる。「部屋が暖まる」\n2. 〈「温まる」とも〉(心が)じんわりと和やかになる。「心が暖まる」 -あたためる 温める 一段 1. (ものなどを)温かくする。「水を温める」「卵を温める」\n2. 〈「暖める」とも〉(心を)和やかにする。\n3. (考えなどを)外に出さずに自分の中で練る。「数年温めていた計画」\n4. (友情などを)確認し、親しく過ごす。「旧交を温める」 -あたためる 暖める 一段 1. (気温などを)暖かくする。「部屋を暖める」\n2. 〈「温める」とも〉(心を)和やかにする。 -あつい 厚い 形容詞・アウオ段 1. 幅がある。「厚い本」\n2. 〈「篤い」とも〉感情の程度が大きい。「情に厚い」「信頼が厚い」 -あつい 暑い 形容詞・アウオ段 気温が高い。「夏は暑い」⇔寒い -あつい 篤い 形容詞・アウオ段 〈文語〉\n1. 重症である。「篤い病」\n2. 〈「厚い」とも〉感情の程度が大きい。「情に篤い」「信頼が篤い」 -あつい 熱い 形容詞・アウオ段 1. ものなどの温度が高い。「熱いお湯」⇔冷たい 2. 相手を思う気持ちが強い。「熱い仲」 -あっかん 悪漢 * 悪いことをする男。「悪漢に襲われる」 -あっかん 圧巻 * 特にすばらしいこと。「圧巻のラストシーン」 +あう 合う 五段・ワ行促音便 ぴったりあう。「息が合う、答が合う」 +あう 遭う 五段・ワ行促音便 おもいがけずにあう。「事故に遭う」 +あおい 青い 形容詞・アウオ段 あおいろに見える。「空が青い」 +あおい 蒼い 形容詞・アウオ段 血の気のないあお。「顔が蒼い」 +あおぐ 仰ぐ 五段・ガ行 上を向く。「天を仰ぐ、指示を仰ぐ、師と仰ぐ、毒を仰ぐ」 +あおぐ 扇ぐ 五段・ガ行 団扇などを動かし、風を出す。 +あか 垢 * 脂、汗などが +あがく 足掻く 五段・カ行イ音便 あばれる、もがく +あかし 証 * 証明すること +あかし 灯 * ともしび +あかり 灯 * ともしび +あかり 明かり * 明るいもの。「街に明かりがともる」 +あがる 挙がる 五段・ラ行 はっきり示される。「手が挙がる」 +あがる 上がる 五段・ラ行 (一般的)高い位置に移る。「階段を上がる、雨が上がる」 +あがる 騰がる 五段・ラ行 値段があがる。「物価が騰がる」 +あがる 揚がる 五段・ラ行 高くあがる。「凧が揚がる、天ぷらが揚がる」 +あきる 厭きる 一段 あきること(飽きると同じ意味) +あきる 飽きる 一段 あきること(厭きると同じ意味) +あく 開く 五段・カ行イ音便 ひらく。「扉が開く、蓋が開く」<->閉まる、閉じる。 +あく 空く 五段・カ行イ音便 そこにあったものがなくなる。「隙間が空く、手が空く、席が空く、グラスが空く」 +あく 飽く 五段・カ行イ音便 あきる。うんざりする。 +あく 明く 五段・カ行イ音便 見えるようになる。はっきりする。「目が明く、喪が明く」 +あげ 上げ * 上に移す。「問題を棚上げする」 +あげ 揚げ * あぶらであげたもの。「薩摩揚げ、唐揚げ」 +あける 開ける 一段 ひらく。「窓を開ける」 +あける 空ける 一段 からにする。「グラスを空ける、家を空ける」 +あける 明ける 一段 あかるくなる。「夜が明ける」 +あげる 挙げる 一段 はっきり示す。「手を挙げる」 +あげる 上げる 一段 (一般的)高い位置に移す。「棚に上げる」 +あげる 揚げる 一段 高くあげる。「旗を揚げる」 +あし 葦 * イネ科の多年草 +あし 脚 * (人、動物などで)支えとなるもの。 +あし 足 * (一般的)支えとなるもの。 +あじ 味 * 舌で感じる感覚。 +あじ 鰺 * アジ科の魚 +あずかる 与る 五段・ラ行 かかわる。「計画に与る」 +あずかる 預る 五段・ラ行 まかせられる。「荷物を預る」 +あずかる 預かる 五段・ラ行 まかせられる。「荷物を預かる」 +あだ 仇 * (敵)自分に害となるもの。 +あだ 徒 * (類義:無駄)「親切が徒となる」 +あたたか 温か * (感触などに対して)冷たくなくほどよい。「温かな水」 +あたたか 暖か * (気温、気象などに対して)寒くなくほどよい。「暖かな春、暖かな心」 +あたたかい 温かい 形容詞・アウオ段 (感触などに対して)冷たくなくほどよい。「水温が温かい」 +あたたかい 暖かい 形容詞・アウオ段 (気温、気象などに対して)寒くなくほどよい。「春は暖かい、心が暖かい」 +あたたまる 温まる 五段・ラ行 (感触などに対して)温かくなる。「水が温まる」 +あたたまる 暖まる 五段・ラ行 (気温、気象などに対して)暖かくなる。「部屋が暖まる」 +あたためる 温める 一段 (感触などに対して)温かくする。「水を温める」 +あたためる 暖める 一段 (気温、気象などに対して)暖かくする。「部屋を暖める」 +あつい 厚い 形容詞・アウオ段 幅があるさま。(対:薄い)「厚い本、情に厚い」 +あつい 暑い 形容詞・アウオ段 気温などが高い。(対:寒い)「夏は暑い」 +あつい 篤い 形容詞・アウオ段 重症であるさま。「篤い病」 +あつい 熱い 形容詞・アウオ段 ものなどの温度が高い。(対:冷たい)「熱いお湯、熱い仲」 +あっかん 悪漢 * わるいことをする男 +あっかん 圧巻 * 特にすばらしいこと あてる 宛てる 一段 指名する。「友人に宛てて手紙を書く」 あてる 充てる 一段 充当する。「その一万円を食費に充てる」 -あてる 当てる 一段 1. 命中させる。「ボールを的に当てる」\n2. 正しい答を言う。「答を当てる」 -あな 穴 * 1. くぼんだ部分。「落とし穴」「虎の穴」\n2. 〈「孔」とも〉つきぬけた部分。「服の穴」\n3. 行き届いていない部分。「捜査の穴」 -あな 孔 * つきぬけた部分。「針の孔」→穴2 +あてる 当てる 一段 命中させる。「ボールを的に当てる、答を当てる」 +あな 穴 * (一般的)くぼんだ部分。「落とし穴、虎の穴、捜査の穴」 +あな 孔 * つきぬけた穴。「針の孔」 あぶら 脂 * (常温で固体の)動物、植物の脂質。「脂身」 -あぶら 油 * (常温で液体の)動物、植物の脂質。「ごま油」 +あぶら 油 * (常温で液体の)動物、植物の脂質。「胡麻油」 あやまる 誤る 五段・ラ行 まちがえる。「目測を誤る」 あやまる 謝る 五段・ラ行 間違いをわびる。「失礼を謝る」 -あらい 荒い 形容詞・アウオ段 (性質などが)はげしい。「気性が荒い」「波が荒い」 -あらい 粗い 形容詞・アウオ段 1. ざらざらしている。「木目が粗い」\n2. いい加減である。「作りが粗い」 -あらわ 露わ * 外から見えているさま。「肌が露わになる」 -あらわす 顕す 五段・サ行 広く知らせる。「名を顕す」 -あらわす 現す 五段・サ行 かくれていたものをあきらかにする。「姿を現す」 +あらい 荒い 形容詞・アウオ段 (性質などが)はげしい。「気性が荒い、波が荒い」 +あらい 粗い 形容詞・アウオ段 おおざっぱであるさま。「木目が粗い、作りが粗い」 +あらわ 露わ * あきらかになるさま。「肌が露わになる」 +あらわす 顕す 五段・サ行 広く知らせる。「世の中に事実を顕す」 +あらわす 現す 五段・サ行 かくれていたものがあらわれる。「姿を現す」 あらわす 著す 五段・サ行 書物を書いて世に出す。「書物を著す」 -あらわす 表す 五段・サ行 はっきりと示す。「感情を表す」「文章に表す」 -あらわれる 現れる 一段 隠れていたものが明らかになる。「本性が現れる」 -あらわれる 表れる 一段 はっきりと示される。「感情が表情に表れる」 -ある 在る 五段・ラ行 〈主にかな書き〉\n1. 物が存在する。「建物がある」\n2. ある状態に置かれている。「苦しい境遇にある」 -ある 有る 五段・ラ行 〈主にかな書き〉\n所有している。「彼には金がある」 -いう 謂う 五段・ワ行促音便 →言う -いう 云う 五段・ワ行促音便 →言う -いう 言う 五段・ワ行促音便 〈「謂う」「云う」とも〉言葉に出す。「御礼を言う」 -いかす 生かす 五段・サ行 1. 生きているままにする。「生かしておけない」\n2.〈「活かす」とも〉力を発揮させる。「才能を活かす」 -いかす 活かす 五段・サ行 〈「生かす」とも〉力を発揮させる。「才能を活かす」 -いき 遺棄 * すてること。「死体を遺棄する」 -いき 息 * 呼吸。「まだ息をしている」 +あらわす 表す 五段・サ行 はっきりと示す。「感情を表す、文章に表す」 +あらわれる 現れる 一段 かくれていたものがあらわれる。「本章が現れる」 +あらわれる 表れる 一段 表面にでる。「感情が表情に表れる」 +ある 在る 五段・ラ行 物が存在する。いる。「建物が在る、境遇に在る」 +ある 有る 五段・ラ行 物事が存在する。所有する。「金が有る、学生で有る」 +あわす 会わす 五段・サ行 (人と人とを)対面させる。「顔を会わせる」 +あわす 合わす 五段・サ行 ひとつにする。「答を合わせる、息を合わせる」 +いう 謂う 五段・ワ行促音便 (「言う、云う」と区別なし)言葉に出す。「御礼を謂う」 +いう 云う 五段・ワ行促音便 (「謂う、言う」と区別なし)言葉に出す。「御礼を云う」 +いう 言う 五段・ワ行促音便 (「云う、謂う」と区別なし、一般的)言葉に出す。「御礼を言う」 +いかす 活かす 五段・サ行 (「生かす」ともいう)力を発揮させる。「才能を活かす」 +いき 遺棄 * すてる。「死体を遺棄する」 +いき 息 * 呼吸をする。「まだ息をしている」 いぎ 意義 * 意味。「参加することに意義がある」 いぎ 異義 * 異なる意味。「同音異義語」 いぎ 異議 * 異なる意見。「その提案に異議があります」 いぎょう 偉業 * すばらしい仕事。「歴史に残る偉業」 いぎょう 遺業 * 故人がなしとげた仕事。「遺業を引き継ぐ」 -いぎょう 医業 * 医者としての仕事。「医業に携わる」 -いく 行く 五段・カ行促音便 今の場所から移動する。「学校に行く」 +いぎょう 医業 * 医者としての仕事。 +いく 行く 五段・カ行促音便 今の場所から出かける。「学校に行く」 いく 逝く 五段・カ行促音便 (人が)死ぬ。「偉大な学者が逝ってしまった」 いしょく 委嘱 * (仕事などを)たのむ。「研究を委嘱する」 -いしょく 移植 * 他の場所に移して機能させる。「肝臓を移植する」「プログラムを移植する」 -いたく 依託 * 〈まれ〉他人にまかせること。 -いたく 委託 * 委ねまかせること。「委託売買」 -いたむ 傷む 五段・マ行 1. 傷つく。「床が傷む」\n2. 腐る。「野菜が傷む」 -いたむ 痛む 五段・マ行 痛みを感じる。「傷が痛む」 +いしょく 移植 * 他の場所に移す。「肝臓を移植する、プログラムを移植する」 +いたく 依託 * たよりまかすこと。 +いたく 委託 * 委ねまかすこと。「委託売買」 +いたむ 傷む 五段・マ行 きずつく、腐る。「床が傷む、野菜が傷む」 +いたむ 痛む 五段・マ行 いたみを感じる。「傷が痛む」 いたむ 悼む 五段・マ行 (人の死を)悲しく思う。「彼の死を悼む」 -いためる 傷める 一段 傷つける。「床を傷める」 -いためる 痛める 一段 痛くする。「腕を痛める」 -いためる 炒める 一段 少量の油を使って加熱調理する。「豚肉を炒める」 -いっかつ 一喝 * 大きなひと声でしかりつける。「若者を一喝する」 -いっかつ 一括 * ひとつにまとめる。「一括して精算する」 +いためる 傷める 一段 きずつける。「床を傷める」 +いためる 痛める 一段 いたい思いをさせる。「腕を痛める」 +いためる 炒める 一段 油を使って加熱調理する。「豚肉を炒める」 +いっかつ 一喝 * 大きな声でしかりつける。「若者を一喝する」 +いっかつ 一括 * ひとつにくくる。「一括して精算する」 いっしゅう 一周 * ひとまわりする。「グラウンドを一周する」 いっしゅう 一蹴 * はねつける。「申し出を一蹴する」 -いどう 異動 * (地位などが)かわること。「異動して部長になった」 -いどう 移動 * (場所などが)うつること。「場所を移動する。」 -いりゅう 慰留 * (辞任することを)なだめて思いとどまらせること。「部下を慰留する」 +いどう 異動 * (地位などが)かわる。「異動して部長になった」 +いどう 移動 * うつる。「場所を移動する。」 +いりゅう 慰留 * (辞任することを)なだめて思いとどまらせる。「部下を慰留する」 いりゅう 遺留 * 死後にのこす。「遺留品」 いる 煎る 五段・ラ行 強い火で熱して水分をとる。「ごまを煎る」 いる 入る 五段・ラ行 はいる。「薮に分け入る」 いる 要る 五段・ラ行 必要とする。「人手が要る」 -いる 居る 一段 〈主にかな書き〉一つの場所に存在する。「学校にいる」 -いる 射る 一段 矢を放つ。また、矢を放って目的に命中させる。「的を射る」 +いる 居る 一段 一つの場所に存在する。「学校に居る、本を読んでいる」 +いる 射る 一段 矢を放つ。「的を射る」 いる 鋳る 一段 鋳造する。「鉄瓶を鋳る」 いんすう 員数 * 人などの数。 -いんすう 因数 * 整式をいくつかの整式の積として分解したとき、その分解したもの。「因数分解」 +いんすう 因数 * 数や式において、1、その数以外の整数では割れない因子。「因数分解」 うかがう 窺う 五段・ワ行促音便 様子をみる。「顔色を窺う」 -うかがう 伺う 五段・ワ行促音便 〈謙譲語〉\n1. 訪問する。「そちらに伺います」\n2. 尋ねる。聞く。「住所を伺ってもよろしいでしょうか」 -うける 受ける 一段 1. 来るものを手でとめる。受け止める。「ボールを受ける」\n2. もらう。授かる。「恩恵を受ける」「生を受ける」\n3. 〈「承ける」とも〉もとにする。対処する。「事故の結果を受けて態勢を見直す」\n4. 〈文語〉〈「承ける」とも〉(跡を)つぐ。「父の跡を受ける」\n5. 影響をこうむる。(自然現象などに)さらされる。「風雨を受ける」「暴力を受ける」\n6. (検査・審査などの)対象となる。「検査を受ける」\n7. 人気を得る。笑ってもらえる。「このギャグはやたらと受けた」\n8. 〈若者言葉〉〈「ウケる」とも〉おもしろい。笑える。「あの人すごく受ける」 -うける 承ける 一段 〈まれ〉\n1. もとにする。「事故の結果を承けて態勢を見直す」→受ける3\n2. 〈文語〉(跡を)つぐ。「父の跡を承ける」→受ける4 -うける 請ける 一段 1. お金をもらって仕事を任される。「公共工事を請ける」\n2. 〈文語〉お金を払って取り戻す。「質草を請ける」 -うける 享ける 一段 (命などを)授かる。「生を享ける」→受ける2 -うし 丑 * 干支(えと)の一つ。子(ね)の次、寅(とら)の前。 +うかがう 伺う 五段・ワ行促音便 (謙譲語)訪問する、尋ねる。「明日に伺います、ご住所を伺ってもよろしいでしょうか」 +うける 受ける 一段 (一般的)迎え入れる。「ボールを受ける、ダジャレが受ける、恩恵を受ける」 +うける 承ける 一段 あとをつぐ。「稼業を承ける」 +うける 請ける 一段 (仕事を)引き受ける。「ダム工事を請ける」 +うし 丑 * 干支の一つ。 うし 牛 * ウシ目ウシ科の動物の総称。 -うし 齲歯 * むしば。 -うたう 唄う 五段・ワ行促音便 →歌う -うたう 歌う 五段・ワ行促音便 〈「唄う」「謡う」とも〉歌をくちずさむ。「歌謡曲を歌う」 -うたう 謡う 五段・ワ行促音便 →歌う -うたう 謳う 五段・ワ行促音便 (理念や宣伝文句を)前に押し出す。「戦争放棄が憲法で謳われている」「東洋一と謳われる校舎」 -うつ 撃つ 五段・タ行 (弾丸などを)発射する。発射して傷つける。「銃を撃つ」「相手を撃つ」 -うつ 打つ 五段・タ行 (ものを)強くあてる。「ボールを打つ」「釘を打つ」 -うつ 討つ 五段・タ行 (敵などを)たおす。殺す「敵を討つ」 -うつす 移す 五段・サ行 移動させる。「場所を移す」「視線を移す」 -うつす 映す 五段・サ行 1. (光をはねかえすものに)反射させて見る。「自分の姿を鏡に映す」\n2. (スクリーンなどに)映写する。「映画を映す」 -うつす 写す 五段・サ行 1. 元となるものを見ながら同じものを書く。「ノートを写す」\n2. 写真をとる。 -うつる 移る 五段・ラ行 移動する。「場所を移る」「視線が移る」 -うつる 映る 五段・ラ行 1. (光をはねかえすものに)反射されて見える。「水面に映る景色」\n2. (スクリーンなどに)映写する。(テレビなどに画面が)あらわれる。「テレビが映らない」 -うつる 写る 五段・ラ行 (写真として)撮影される。「写真に写る」 -うま 午 * 干支(えと)の一つ。巳(み)の次、未(ひつじ)の前。 -うま 馬 * ウマ目ウマ科の動物の総称。 -うむ 産む 五段・マ行 (子供、卵などを)体外に出す。出産する。「にわとりが卵を産む」\n※具体的な出産をあらわすときに多く使われる。 -うむ 生む 五段・マ行 1. 〈一般的〉出産する。「子供を生む」\n※抽象的な表現で多く使われる。\n2. つくりだす。「傑作を生む」 -うむ 膿む 五段・マ行 化膿する。うみがたまる。「傷口が膿む」 -うらむ 怨む 五段・マ行 →恨む -うらむ 憾む 五段・マ行 〈文語〉残念に思う。「稚拙な攻撃が憾まれる」→恨む2 -うらむ 恨む 五段・マ行 1. 人から嫌なことをされたと思い、反感を持つ。「彼に恨まれている」\n2. 〈文語では「憾む」とも〉残念に思う。「自分の不勉強を恨む」「稚拙な攻撃が恨まれる」 -うる 得る 一段・得ル 〈文語〉える。手に入れる。「大金を得る」 +うし 齲歯 * むしば +うたう 唄う 五段・ワ行促音便 (「歌う、謡う」と区別なし)歌をくちずさむ。「歌謡曲を唄う」 +うたう 歌う 五段・ワ行促音便 (「唄う、謡う」と区別なし、一般的)歌をくちずさむ。「歌謡曲を歌う」 +うたう 謡う 五段・ワ行促音便 (「歌う、唄う」と区別なし)歌をくちずさむ。「歌謡曲を謡う」 +うたう 謳う 五段・ワ行促音便 強調されている。「戦争放棄が憲法で謳われている、東洋一と謳われる校舎」 +うつ 撃つ 五段・タ行 (弾丸などを)発射する。「銃を撃つ、相手を撃つ」 +うつ 打つ 五段・タ行 (ものを)強くあてる。「ボールを打つ、釘を打つ、芝居を打つ」 +うつ 討つ 五段・タ行 (敵などを)たおす。「敵を討つ」 +うつす 移す 五段・サ行 移動させる。「場所を移す、視線を移す」 +うつす 映す 五段・サ行 (スクリーンなどに)ものの形をあらわす。「映画を映す」 +うつす 写す 五段・サ行 まねてあらわす。「写真を写す、ノートを写す」 +うつる 移る 五段・ラ行 移動する。「場所を移る、視線が移る」 +うつる 映る 五段・ラ行 (スクリーンなどに)あらわれる。「テレビが映る」 +うつる 写る 五段・ラ行 あらわれる。「写真に写る」 +うま 午 * 干支の一つ +うま 馬 * ウマ目ウマ科の動物の総称 +うむ 産む 五段・マ行 (子供、卵などを)体外にだす。「にわとりが卵を産む」 +うむ 生む 五段・マ行 子供が誕生する。「子供を生む、傑作を生む」 +うむ 膿む 五段・マ行 うみがたまる。「傷口が膿む」 +うらむ 怨む 五段・マ行 (「恨む」と区別なし)根にもつ。「彼に怨まれている」 +うらむ 憾む 五段・マ行 残念に思う。「稚拙な攻撃が憾まれる」 +うらむ 恨む 五段・マ行 (「怨む」と区別なし)根にもつ。「彼に恨まれている」 +うる 得る 一段・得ル (文語)える。「大金を得る、実現し得る」 うる 売る 五段・ラ行 代金を受けとり品物を渡す。「土地を売る」 -うれい 愁い * →憂い -うれい 憂い * 〈「愁い」とも〉\n1. 心配すること。\n2. 悲しく思うこと。 -うれう 愁う 五段・ワ行ウ音便 →憂う -うれう 憂う 五段・ワ行ウ音便 〈「愁う」とも〉\n1. 心配する。また、悲しく思う。「将来を憂う」「被災地の惨状を憂う」 -うれえる 愁える 一段 →憂える -うれえる 憂える 一段 〈「愁える」とも〉\n1. 心配する。また、悲しく思う。「将来を憂える」「被災地の惨状を憂える」 +うれい 愁い * 悲しう思うこと。 +うれい 憂い * 心配すること。 +うれえる 愁える 一段 悲しく思う。「死を愁える」 +うれえる 憂える 一段 心配する。「将来を憂える」 うんこう 運航 * (船、航空機が)きまった航路をすすむこと。「飛行機は正常に運航している」 うんこう 運行 * きまった路線をすすむこと。「バスの運行」 -えいずる 映ずる サ変・−ズル (光などが)うつる。「木々が湖面に映ずる」 +えいずる 映ずる サ変・−ズル うつる。「木々が湖面に映ずる」 えいずる 詠ずる サ変・−ズル (詩歌を)うたう。「詩を詠ずる」 -えびす 夷 * 1. 未開の土地の人間に対する古い蔑称。\n2. 〈「恵比寿」が一般的〉七福神の一人。 -えびす 恵比寿 * 七福神の一人。 -えびす 恵比須 * 1. 大阪の地名。\n2. 〈「恵比寿」が一般的〉七福神の一人。 -えびす 戎 * 〈「恵比寿」が一般的〉七福神の一人。 -えびす 蛭子 * 〈「恵比寿」が一般的〉七福神の一人。 -える 獲る 一段 (獲物を)とる。「鹿を獲る」 +えびす 夷 * えぞ、七福神の一人 +えびす 恵比寿 * 七福神の一人 +えびす 恵比須 * 地名、七福神の一人 +えびす 戎 * 七福神の一人 +えびす 蛭子 * 七福神の一人 +える 獲る 一段 (獲物を)とる。「鹿を獲る、戦利品を獲る」 える 選る 一段 えらぶ。 -える 得る 一段 手に入れる。「利益を得る」 +える 得る 一段 手に入れる。「利益を得る、やむをえない」 えんげい 園芸 * 庭木などの栽培。 えんげい 演芸 * 落語などの芸。 おいこむ 追い込む 五段・マ行 追いつめる。「犯人を追い込む」 おいこむ 老い込む 五段・マ行 年をとる。「彼もすっかり老い込んだ」 -おう 逐う 五段・ワ行促音便 →追う -おう 追う 五段・ワ行促音便 目標をつかまえようとする。「犯人を追う」 -おう 負う 五段・ワ行促音便 1. 背負う。「荷物を負う」\n2. ひきうける。「責任を負う」 +おう 逐う 五段・ワ行促音便 (「追う」と区別なし)目標をつかまえようとする。「犯人を逐う」 +おう 追う 五段・ワ行促音便 (「逐う」と区別なし)目標をつかまえようとする。「犯人を追う」 +おう 負う 五段・ワ行促音便 ひきうける。「荷物を負う、責任を負う」 おういん 押印 * 判をおすこと。「申請書に押印する」 おういん 押韻 * 韻をふむこと。 おうしゅう 応酬 * やりとりする。「互いに応酬する」 おうしゅう 押収 * (証拠品などを)とりあげる。「証拠品を押収する」 -おかす 侵す 五段・サ行 1. 侵害する。「領土を侵す」\n2. 〈「冒す」とも〉〈受身で〉(病気に)かかる。「病に侵された少年」 -おかす 犯す 五段・サ行 1. 規則にそむく。「過ちを犯す」「罪を犯す」\n2. 性的暴行を加える。 -おかす 冒す 五段・サ行 1. 押し切ってする。「危険を冒す」\n2. 〈「侵す」とも〉〈受身で〉(病気に)かかる。「病に冒された少年」 -おく 置く 五段・カ行イ音便 1. ものから手を離して、ある位置にとどめる。「グラスを置く」\n2. (機関や部署、役職などを)つくる。設置する。また、設置している。「マイアミに司令部を置く」「監督官を置く」\n3. (抽象的なものを)設定する。「重点を置く」\n4. 仮に割り当てる。「この関数をf(x)と置く」\n5. ある状態にする。ある状態に留める。「国家管理の下に置く」\n6. (時間・空間を)あける。「間を置く」「距離を置く」\n7. (信用などを)与える。「信頼を置く人」\n8. 〈特に執筆に関しては「擱く」とも〉ものから手を離して、それを使った行為をやめる。「筆を置く」「箸を置く」\n9. 〈口語体では「置いておく」とすることが多い。文語体では「措く」とも〉とりあえず考えないことにする。棚上げする。「この問題はとりあえず置いておこう」「この問題はひとまず置くとする」 -おく 擱く 五段・カ行イ音便 〈「置く」とも〉〈特に執筆に関して〉ものから手を離して、それを使った行為をやめる。「筆を擱く」「ペンを擱く」 -おく 措く 五段・カ行イ音便 〈文語体〉〈「置く」とも〉とりあえず考えないことにする。棚上げする。「この問題はひとまず措くとする」 -おくる 送る 五段・ラ行 1. 郵送や電子的な手段でものや情報を他の場所に届ける。「手紙を送る」「メールを送る」\n2. 去る人に途中まで同行する。「客を駅まで送る」 -おくる 贈る 五段・ラ行 気持ちを示すためにあたえる。「御歳暮を贈る」 -おくれる 後れる 一段 〈文語〉\n1. あとである。うしろである。「順位が後れるもの」\n2. 〈「遅れる」とも〉ついていけなくなる。取り残される。「時代に後れる」 -おくれる 遅れる 一段 1. (決まった時間より)遅くなる。「待ち合わせに遅れる」\n2. 速度が遅く、しだいに後ろに行く。「この時計は一日に一分遅れる」\n3. 後ろの位置を保って進む。「この時計は遅れている」「三歩ほど遅れてついていく」\n4. 〈「後れる」とも〉ついていけなくなる。取り残される。「時代に遅れる」 -おこす 起こす 五段・サ行 1. 持ち上げて縦にする。「体を起こす」\n2. 人を目覚めさせる。「毎朝子供を起こしている」 +おかす 侵す 五段・サ行 侵害する。「領土を侵す、病に侵される」 +おかす 犯す 五段・サ行 規則にそむく。「過ちを犯す」 +おかす 冒す 五段・サ行 押し切ってする。「危険を冒す、病に冒される」 +おく 置く 五段・カ行イ音便 その位置にとどめる。「グラスを置く、担当者を置く」 +おくる 送る 五段・ラ行 (物・人を)他の場所に移す。「手紙を送る、駅まで送る」 +おくる 贈る 五段・ラ行 あたえる。「御歳暮を贈る」 +おくれる 後れる 一段 とりのこされる。「流行に後れる」 +おくれる 遅れる 一段 まにあわなくなる。「待ち合わせに遅れる」 +おこす 起こす 五段・サ行 たたせる。「からだを起こす、毎朝子供を起こしている」 おこす 興す 五段・サ行 さかんにする。「国を興す」 -おこる 起こる 五段・ラ行 〈「起きる」に同じ〉(現象、気持ちなどが)生まれる。「波が起こる」「地震が起こる」「発作が起こる」「憎しみが起こる」 +おこる 起こる 五段・ラ行 はじまる。「地震が起こる」 おこる 興る 五段・ラ行 さかんになる。「国が興る」 -おこる 怒る 五段・ラ行 腹を立てる。また、その気持を相手にぶつける。いかる。「怒ってどなりつける」「部下を怒る」 -おさえこむ 押え込む 五段・マ行 おさえて動かないようにする。「犯人を押さえ込む」 +おこる 怒る 五段・ラ行 いかる。「怒ってどなりつける、部下を怒る」 +おさえこむ 押え込む 五段・マ行 おさえて動かないようにする。「犯人を押さえ込む おさえこむ 抑え込む 五段・マ行 (柔道の寝技の意で)おさえこむ。 -おさまる 治まる 五段・ラ行 1. 政治がゆきとどく。「国内が治まる」\n2. 痛み・症状などが静まる。「痛みが治まる」\n3. 〈「収まる」とも〉風雨や騒ぎなどが静まる。「騒ぎが治まる」 -おさまる 収まる 五段・ラ行 1. 入れ物の中にはいる。「倉庫の中に収まる」\n2. 〈「治まる」とも〉風雨や騒ぎが静まる。「騒ぎが収まる」 +おさまる 治まる 五段・ラ行 しずまる。「国内が治まる、傷みが治まる」 +おさまる 収まる 五段・ラ行 入れ物の中にはいる。「倉庫の中に収まった、騒ぎが収まる」 おさまる 修まる 五段・ラ行 言動がととのう。「素行が修まる」 -おさまる 納まる 五段・ラ行 1. (金品が)きちんとわたされる。「税金が納まる」\n2. ある位置・地位につく。「社長に納まる」 +おさまる 納まる 五段・ラ行 (金品が)きちんとわたされる。「税金が納まる、社長に納まる」 おさめる 治める 一段 統治する。「国を治める」 -おさめる 収める 一段 1. しまう。収納する。「倉庫に収める」\n2. のせる。収録する。「辞書に収める」\n3. 手に入れる。成し遂げる。「成功を収める」 -おさめる 修める 一段 1. (学問・技能などを)修得する。「学問を修める」\n2. 整える。きちんとする。「身を修める」 -おさめる 納める 一段 (渡すべき金品を)渡す。「税金を納める」 -おじ 叔父 * 父または母の弟。 -おじ 小父 * 〈主にかな書き〉(子供から見た)血のつながっていない大人の男性。一般的には「さん」をつける。「近所のおじさん」 -おじ 伯父 * 父または母の兄。 -おす 圧す 五段・サ行 →押す5 -おす 押す 五段・サ行 1. ものに触れて力を入れる。「背中を押す」「上から押す」\n2. 〈「捺す」とも〉(印鑑などに)力を入れることで印字する。「判を押す」\n3. (説得や宣伝、求愛などで)積極的に働きかける。「あんまり押しすぎると引かれるよ」\n4. (勝負などで)積極的に攻める。「いい手が入ったので押すことにした」\n5. 〈「圧す」とも〉圧倒する。「気迫に押される」 -おす 推す 五段・サ行 推薦する。「彼を議長に推す」 -おす 捺す 五段・サ行 →押す2 -おぞましい 鈍ましい 形容詞・アウオ段 〈文語〉にぶい。 -おぞましい 悍ましい 形容詞・アウオ段 〈主にかな書き〉ぞっとするようないやな感じ。「おぞましい光景」 -おちる 堕ちる 一段 〈「落ちる」とも〉堕落(だらく)する。落ちぶれる。悪い状態になる。悪い環境に身をおとす。「あいつも堕ちたものだ」「地獄に堕ちる」→落ちる4 -おちる 墜ちる 一段 〈「落ちる」とも〉引力などにより、上から下に移動する。墜落する。「飛行機が墜ちる」→落ちる1 -おちる 落ちる 一段 1. 〈「墜ちる」とも〉引力などにより、ものが上から下に移動する。「りんごが落ちる」「飛行機が落ちる」\n2. (状態が)悪くなる。「鮮度が落ちるのが早い」\n3. 〈形容詞的〉(状態が)悪い。「品質が落ちる品」\n4. (試験などに)不合格になる。「予選で落ちる」\n5. 〈「堕ちる」とも〉堕落(だらく)する。落ちぶれる。悪い状態になる。悪い環境に身をおとす。「あいつも落ちたものだ」「地獄に落ちる」\n6. 〈柔道で〉首を絞められて気を失う。「絞め技をかけられて落ちてしまった」\n7. (原稿などが)入稿が遅れて掲載されなくなる。「病気で原稿が落ちた」 -おどる 躍る 五段・ラ行 1. 躍動する。\n2. わくわくする。「胸が躍る」 -おどる 踊る 五段・ラ行 (音に合わせて)体や手足を動かす。「日本舞踊を踊る」 -おば 叔母 * 父または母の妹。 -おば 小母 * 〈主にかな書き〉(子供から見た)血のつながっていない大人の女性。一般的には「さん」をつける。「近所のおばさん」 -おば 伯母 * 父または母の姉。 -おもて 表 * 二つの面があるものに関して、目に見えている側。「コインの表」⇔裏 -おもて 面 * 〈文語〉顔。「面を上げよ」 -おりこむ 織り込む 五段・マ行 1. 織ってくみこむ。「模様を織り込む」\n2. 事態を予想して、それに基づいた行動をとる。「相場は悪材料を織り込んで動いている」 -おりこむ 折り込む 五段・マ行 折りまげて小さくたたむ。「紙を折り込む」 -おりる 下りる 一段 1. 下に移動する。「山から下りる」\n2. (上の立場のものから、許可や承認が)得られる。「工場建設の許可が下りる」 -おりる 降りる 一段 乗物から外に出る。「電車から降りる」 -おる 居る 五段・ラ行 〈古風〉いる。「昔、一休という和尚が居った」 -おる 織る 五段・ラ行 縦糸と横糸を組み合わせて布をつくる。「布を織る」 -おる 折る 五段・ラ行 曲げる、また曲げて二つにする。「紙を折る」「釣りざおを折ってしまった」 -おろす 卸す 五段・サ行 問屋が小売店に商品を売る。「野菜を卸す」 -おろす 下ろす 五段・サ行 1. 下に移す。「棚から荷物を下ろす」\n2. すりおろす。「大根を下ろす」\n3. 銀行などに預けていたお金を引き出す。「貯金を下ろす」 -おろす 降ろす 五段・サ行 1. 乗物から出す。「バスから降ろす」\n2. 役から外す。「役者を降ろす」 +おさめる 収める 一段 しまう。「倉庫に収める、辞書に収める、成功を収める」 +おさめる 修める 一段 つくろう。「身を修める、学問を修める」 +おさめる 納める 一段 (金品を)わたす。「税金を納める」 +おじ 叔父 * 父または母の弟 +おじ 小父 * (血のつながっていない)おじさん +おじ 伯父 * 父または母の兄 +おす 圧す 五段・サ行 (「押す」も使う)圧迫する。「気迫に圧される」 +おす 押す 五段・サ行 (一般的)ものに触れて力を入れる。「背中を押す、念を押す」 +おす 推す 五段・サ行 推進させる。「彼を議長に推す」 +おす 捺す 五段・サ行 (「押す」も使う)捺印する。「判を捺す」 +おぞましい 鈍ましい 形容詞・アウオ段 にぶい。 +おぞましい 悍ましい 形容詞・アウオ段 ぞっとするようないやな感じ。「悍ましい光景」 +おちる 堕ちる 一段 (堕落した意で)ある状態におちこむ。「深い眠りに堕ちる」 +おちる 墜ちる 一段 ついらくする。「飛行機が墜ちる」 +おちる 落ちる 一段 (引力で)ものが上から下に移動する。「りんごが落ちる、試験に落ちる、品質が落ちる」 +おどる 躍る 五段・ラ行 (躍動、跳躍の意)はねあがる。「胸が躍る」 +おどる 踊る 五段・ラ行 (音に合わせて)手足をうごかす。「日本舞踊を踊る」 +おば 叔母 * 父または母の妹 +おば 小母 * (血のつながっていない)おばさん +おば 伯母 * 父または母の姉 +おもて 表 * 表面。 +おもて 面 * かお。物の表面。 +おりこむ 織り込む 五段・マ行 織ってくみこむ。「模様を織り込む」 +おりこむ 折り込む 五段・マ行 折りまげる。「紙を折り込む」 +おりる 下りる 一段 下にいく。「幕が下りる、許可が下りる」 +おりる 降りる 一段 乗物からでる。「車を降りる、梯子を降りる」 +おる 居る 五段・ラ行 いる。「彼はどこにおられますか、勉強しております」 +おる 織る 五段・ラ行 布をつくる。「布を織る。」 +おる 折る 五段・ラ行 まげる。「小枝を折る、骨を折る(苦労する)」 +おろす 卸す 五段・サ行 卸売をする。「野菜を卸す」 +おろす 下ろす 五段・サ行 下へいかせる。「のれんを下ろす、大根を下ろす、貯金を下ろす」 +おろす 降ろす 五段・サ行 乗物から出す。「バスから降ろす、役者を降ろす」 おんし 恩師 * 教えをうけた先生。 おんし 恩賜 * 天皇から賜わること。 -おんわ 温和 * 1. (気候が)あたたかい。「沖縄は温和な気候だ」\n2. 〈「穏和」とも〉(性格が)おだやかである。「彼は温和な性格だ」 -おんわ 穏和 * 〈「温和」とも〉(性格が)穏やかである。「彼は穏和な性格だ」 -かす 化す 五段・サ行 (悪い状態に)変化する。「廃虚と化す」 -かす 嫁す 五段・サ行 1. (古風)嫁にいく。「豊臣家に嫁した」\n2. 転嫁する。「責任を嫁す」 -かす 科す 五段・サ行 刑罰を負わせる。「刑罰を科す」 -かす 課す 五段・サ行 負担させる。「税金を課す」 -かする 化する サ変・−スル (悪い状態に)変化する。「廃虚と化する」 -かする 嫁する サ変・−スル 1. (古風)嫁にいく。「豊臣家に嫁した」\n2. 転嫁する。「責任を嫁する」 -かする 科する サ変・−スル 刑罰を負わせる。「刑罰を科する」 -かする 架する サ変・−スル かけわたす。「橋を架する」 -かする 課する サ変・−スル 負担させる。「税金を課する」 -かい 介する サ変・−スル 1. 間におく。「彼女を介して出会った」\n2. 〈「意に介する」の形で〉気にかける。「意に介さない」 -かい 会する サ変・−スル 集まる。「一堂に会する」 -かい 解する サ変・−スル 理解する。「気持を解する」「文意を解する」 -かいえん 開園 * 動物園・公園などが営業を開始する。「その動物園の開園は10時だ」 +おんわ 温和 * (気候が)あたたかい。「沖縄は温和である」 +おんわ 穏和 * おとなしい。「彼は穏和である」 +かする 化する サ変・−スル 変化する。「廃虚と化する」 +か 化 * 変化する。「廃虚と化する」 +か 嫁 * とつぐ。転嫁する。「責任を嫁する」 +か 科 * 刑罰を負わせる。「刑罰を科する」 +か 架 * かけわたす。「橋を架する」 +か 課 * 負担させる。「税金を課する」 +かい 介 * あいだにおく。「彼女を介して出逢う、意に介さない」 +かい 会 * よりあう。「一堂に会する」 +かい 解 * 理解する。「気持を解する、文意を解する」 +かいえん 開園 * 動物園などが営業を開始する。「その動物園の開園は10時だ」 かいえん 開宴 * うたげを始める。 かいえん 開演 * 演劇などを始める。 かいか 開化 * 文明が開ける。「文明開化」 -かいか 開花 * 1. 花が開く。「さくらが開花した」\n2. 発揮される。「才能が開花した」 -がいかん 外患 * 外国から受ける圧力や攻撃、またその憂慮。 -がいかん 外観 * 外から見た様子。 -かいてい 改定 * (規則などについて)更新すること。「運賃を改定する」 -かいてい 改訂 * (書物などを)内容を改め、再び出版すること。「本を改訂する」 -かいてい 開廷 * 法廷を開くこと。 -かいふく 回復 * 1. もとの良い状態にもどる、またはもどすこと。「天気が回復する」「体力が少し回復した」「名誉を回復する」\n2. (遅れなどを)解消して追いつく。「遅れを回復する」 -かいふく 快復 * 病気が完治すること。「病気の快復を祝う」 +かいか 開花 * はなが開く。「さくらが開花した、才能が開花した」 +がいかん 外患 * そとから受ける心配事。 +がいかん 外観 * そとからみた様子。 +かいてい 改定 * あらためる。「運賃を改定する」 +かいてい 改訂 * (書物などを)あらためる。「本を改訂する」 +かいてい 開廷 * 法廷を開く。 +かいふく 回復 * もとの良い状態にもどること。「天気が回復する、信用を回復する」 +かいふく 快復 * 病気が治ること。「病気が快復する」 かいへい 開平 * 平方根を求めること。 かいへい 開閉 * 開くことと閉じること。「ドアを開閉する」 かいほう 介抱 * 病人などの世話をする。「怪我人を介抱する」 -かいほう 解放 * 解き放つ。自由にする「人質を解放する」 -かいほう 開放 * 1. 開けっぱなしにする。「ドアを開放する」\n2. 自由に使えるようにする。「施設を開放する」 +かいほう 解放 * 自由にする。「人質を解放する」 +かいほう 開放 * 開けっぱなしにする。「ドアを開放する、施設を開放する」 かう 飼う 五段・ワ行促音便 動物をやしなう。「猫を飼う」 -かう 買う 五段・ワ行促音便 1. 代金をはらい、物をもらう。「パソコンを買う」\n2. 他人に何らかの感情を引き起こす。「恨みを買う」\n3. (人物について)高く評価する。「彼の人柄を買う」 +かう 買う 五段・ワ行促音便 代金をはらい、物をもらう。「パソコンを買う、彼の人柄を買う、うらみを買う」 かえす 帰す 五段・サ行 帰らせる。「生徒を自宅に帰す」 -かえす 返す 五段・サ行 1. 元の場所・あるべき場所にかえす。「自然に返す」\n2. 借りていたものをかえす。「借金を返す」\n3. 働きかけに対して反応をする。「答えを返す」 -かえりみる 顧みる 一段 1. ふりかえる。「歴史を顧みる」\n2. 考慮する。「危険を顧みない」 -かえりみる 省みる 一段 過去の自分や自分の言動について思いを巡らせる。「過去の行動を省みる」 -かえる 帰る 五段・ラ行 (人が)元の場所・住居に戻る。「家に帰る」 -かえる 返る 五段・ラ行 1. 元の場所・あるべき場所にもどる。「自然に返る」\n2. 貸していたものがもどってくる。「借金が返る」\n3. 働きかけに対して反応がある。「答えが返る」 -かえる 換える 一段 〈「替える」とも〉(主に液体・気体について)古いものを出し、新しいものを入れる。「風呂の湯を換える」 -かえる 替える 一段 〈「換える」とも〉とりかえる。交換する。「二人の席を替える」 -かえる 代える 一段 代わりをさせる。代替とする。「押印に代えて署名する」 +かえす 返す 五段・サ行 もとに戻す。「借金を返す、自然に返す、手のひらを返す」 +かえりみる 顧みる 一段 ふりかえる。「歴史を顧みる、危険を顧みない」 +かえりみる 省みる 一段 反省する。「過去のことを省みる」 +かえる 帰る 五段・ラ行 もとの場所に戻る。「家に帰る」 +かえる 返る 五段・ラ行 もとに戻る。「借金が返る、自然に返る、あきれ返る」 +かえる 換える 一段 交換する。「商品を入れ換える」 +かえる 替える 一段 とりかえる。「席を替える」 +かえる 代える 一段 代りをさせる。「これをもって挨拶と代える」 かえる 変える 一段 異なった状態にする。「顔色を変える」 -かかる 架かる 五段・ラ行 空中に長いものがかけわたされる。「橋が架かる」 -かかる 掛かる 五段・ラ行 〈1, 2, 3 以外はかな書きが多い〉\n1. ぶらさがる。「壁に絵が掛かっている」\n2. おおいかぶさる。「体に毛布が掛かっていた」\n3. ひっかかってつかまる。「魚が網に掛かった」\n4. 液体をかぶる。「顔に水が掛かった」\n5. 時間や金などが必要となる。「金が掛かる」\n6. 電話などの着信を受ける。「彼から電話が掛かってきた」\n7. (主に音声を出す)機械のスイッチが入る。また、それによって音が出る。「ラジオが掛かっていた」\n8. (鍵などによって)閉められている。「ドアには鍵が掛かっている」\n9. 診察してもらう。「医者に掛かる」\n10. 〈「罹る」とも〉(病気に)なる。「おたふく風邪に掛かった」 -かかる 係る 五段・ラ行 (言語において、単語が)修飾する。「この形容詞はこの名詞に係る」 -かかる 罹る 五段・ラ行 (病気に)なる。「おたふく風邪に罹った」→掛かる10 -かかる 懸かる 五段・ラ行 1. あることがらの成否によって、ものが得られるかどうか、または別のことがらの成否が決まる。「その競技には賞品が懸かっている」「この事件の解決は君の努力に懸かっている」\n2. 空に浮かんでいる。「夜空に月が懸かる」 -かかわる 関わる 五段・ラ行 〈「係わる」とも〉関係する。「その仕事に関わる」「命に関わる」 -かかわる 係わる 五段・ラ行 関係する。→関わる +かかる 架かる 五段・ラ行 わたされる。「橋が架かる」 +かかる 掛かる 五段・ラ行 ぶらさがる。「のれんが掛かる、わなに掛かる、迷惑が掛かる、金が掛かる」 +かかる 係る 五段・ラ行 かかわる。「人命に係る、彼の腕に係っている」 +かかる 懸かる 五段・ラ行 ものがうかぶ。「その競技には賞品が懸かっている、夜空に月が懸かる」 +かかわる 関わる 五段・ラ行 (「係わる」と区別なし)関係する。「命に関わる、その仕事に関わる」 +かかわる 係わる 五段・ラ行 (「関わる」と区別なし)関係する。「命に係わる、その仕事に係わる」 かかわる 拘る 五段・ラ行 こだわる。「つまらないことに拘る」 -かきあげる かき揚げる 一段 →かき上げる -かきあげる かき上げる 一段 (髪などに手をかけて)ひきあげる。「髪をかき上げる」 -かきあげる 書き上げる 一段 1. 書き終える。「本を書き上げる」\n2. いくつかのことを残さずひとつひとつ書く。列挙する。「必要なことを書き上げる」 -かきあげる 掻き上げる 一段 →かき上げる -かきあげる 掻き揚げる 一段 →かき上げる -かく 欠く 五段・カ行イ音便 1. 不足している。「協調性を欠く」\n2. 物のまわりを一部を壊して落とす。「花瓶の縁を欠く」 -かく 書く 五段・カ行イ音便 文字をしるす。「文字を書く」「本を書く」 -かく 掻く 五段・カ行イ音便 1. (爪などで)ものをこする。「頭を掻く」\n2. 手などを水の中で動かす。「水を掻いて泳ぐ」 -かく 描く 五段・カ行イ音便 絵にえがく。「似顔絵を描く」 +かきあげる かき揚げる 一段 上にひきあげる。「髪をかき揚げる」 +かきあげる 書き上げる 一段 ひとつひとつ書く。書き終える。「必要な事を書き上げる、本を書き上げる」 +かきあげる 掻き上げる 一段 上にひきあげる。「髪を掻き上げる」 +かきあげる 掻き揚げる 一段 上にひきあげる。「髪を掻き揚げる」 +かく 欠く 五段・カ行イ音便 こわす。「花瓶を欠く、協調性を欠く」 +かく 書く 五段・カ行イ音便 文字をしるす。「文字を書く、文章を書く、本を書く」 +かく 掻く 五段・カ行イ音便 (爪などで)ものをこする。「頭を掻く、水を掻く」 +かく 描く 五段・カ行イ音便 絵にあらわす。「似顔絵を描く」 かくしゅう 各週 * それぞれの週。 -かくしゅう 隔週 * 一週間おき(二週間ごと)。 -かげ 蔭 * →陰 -かげ 陰 * 〈「蔭」とも〉\n1. 光の当たらない場所。「建物の陰になっている場所で涼む」「建物の陰になっていてここからは見えない」\n2. 表にあらわれないところ。「経済成長の陰で貧困が増加している」\n3. 対象となる人がいないところ。「陰で悪口を言う」\n4. 〈「翳」とも〉人に知らせない内面の暗さ。「陰のある悪役」 -かげ 影 * 1. 光によってできるものの形。「日が暮れるにつれて影が長くなる」\n2. 人の姿、または印象。「影をひそめる」「影が薄い」「影も形もない」 -かげ 翳 * 〈「陰」とも〉人に知らせない内面の暗さ。「翳のある悪役」→陰4 -かける 架ける 一段 空中に長いものをわたす。「橋を架ける」 -かける 掛ける 一段 〈1, 2, 3 以外はかな書きが多い〉\n1. ぶらさげる。「壁に絵を掛ける」\n2. おおいかぶせる。「体に毛布を掛けてあげた」\n3. ひっかけてつかまえる。「わなに掛ける」\n4. 液体を浴びせる。「怒ってコップの水を相手の顔に掛けた」\n5. 時間や金などをつぎこむ。「金を掛けて作る」\n6. 電話などを発信する。「彼に電話を掛けた」\n7. (主に音声を出す)機械のスイッチを入れる。また、それによって音を出す。「音楽を掛けた」\n8. (鍵などによって)閉める。「ドアに鍵を掛ける」\n9. 道具を使って掃除などをする。「床にぞうきんを掛ける」「部屋に掃除機を掛けた」\n10. 乗算を行う。「底辺と高さを掛ける」 -かける 駆ける 一段 〈「駈ける」とも〉はしる。「丘を駆ける」 -かける 駈ける 一段 →駆ける -かける 欠ける 一段 1. ものの一部が(壊れて)なくなり、形が完全でない状態になる。「皿が欠ける」「月が欠ける」\n2. 集団の一部がいなくなり、完全でない状態になる。「メンバーが欠ける」 -かける 懸ける 一段 1. あることがらの成否によって、ものを与えるかどうかを決める。「賞金を懸ける」\n2. 失う覚悟をして取り組む。「命を懸けて戦う」 -かける 賭ける 一段 勝負して、金品を受け渡す約束をする。「麻雀で金を賭ける」 -かける 翔ける 一段 (鳥などが)飛ぶ。飛翔する。「天を翔ける」 +かくしゅう 隔週 * 一週間おき。 +かげ 蔭 * (「陰」と区別なし)光の当たらない場所。 +かげ 陰 * (「蔭」と区別なし)光の当たらない場所。「陰で糸を引く」 +かげ 影 * 光によってできるものの形。「影をひそめる、影も形もない」 +かげ 翳 * かげり。 +かける 架ける 一段 わたす。「橋を架ける」 +かける 掛ける 一段 ぶらさげる。「のれんを掛ける、わなに掛ける、迷惑を掛ける、金を掛ける」 +かける 駆ける 一段 (「駈ける」と区別なし)はしる。「丘を駆ける」 +かける 駈ける 一段 (「駆ける」と区別なし)はしる。「丘を駈ける」 +かける 欠ける 一段 一部がこわれる。「皿が欠ける、メンバーが欠ける」 +かける 懸ける 一段 失う覚悟でおこなう。「命を懸ける、賞金を懸ける」 +かける 賭ける 一段 勝負してものをもらえる約束をする。「麻雀で金を賭ける」 +かける 翔ける 一段 (鳥などが)とぶ。「天を翔ける」 かしぐ 傾ぐ 五段・ガ行 かたむく。「船が傾ぐ」 -かしぐ 炊ぐ 五段・ガ行 〈文語〉(飯を)炊く。 +かしぐ 炊ぐ 五段・ガ行 めしを炊く。 かしょう 過小 * ちいさすぎること。「過小評価」 かしょう 過少 * すくなすぎること。 -かす 化す 五段・サ行 (悪い状態に)変化する。「廃虚と化す」 -かす 科す 五段・サ行 (刑罰を)負わせる。「刑罰を科す」 -かす 貸す 五段・サ行 自分のものを一時的に他人に渡す。「金を貸す」 +かす 化す 五段・サ行 変化する。「廃虚と化す」 +かす 科す 五段・サ行 刑罰を負わせる。「刑罰を科す」 +かす 貸す 五段・サ行 自分のものを一時的に他人に渡す。「金を貸す、力を貸す」 かする 科する サ変・−スル 刑罰を負わせる。「刑罰を科する」 かせつ 仮設 * (建物などを)間に合わせでつくること。「仮設住宅」 かせつ 架設 * (橋などを)かけること。「橋の架設工事」 -かそう 仮想 * 1. かりに想定すること。「仮想敵国」\n2. そうではないものをそう見せること。「仮想ドライブ」 -かそう 仮装 * 衣装によって外見をかえること。「仮装パーティー」 +かそう 仮想 * かりに想定すること。「仮想記憶、仮想敵国」 +かそう 仮装 * かりによそおうこと。「仮装パーティー」 かそう 火葬 * 死体を焼いて葬ること。「祖父を火葬する」 -かたい 堅い 形容詞・アウオ段 1. 〈「固い」とも〉しっかりしている。堅固、堅実である。「堅い守備」\n2. 〈「固い」とも〉確実性が高い。「堅い投資」\n3. 〈「固い」とも〉間違いがない。動かない。「彼の勝利は堅い」\n4. 〈「固い」とも〉(意志などが)ゆるぎない。「堅い意志」\n5. 〈「固い」「硬い」とも〉まじめだ。ふざけたところがない。「堅い話はこのぐらいにしよう」 -かたい 固い 形容詞・アウオ段 1. 力を加えても形がなかなか変わらない。「結び目が固い」「固いマット」\n2. 〈「堅い」とも〉融通がきかない。「発想が固い」 -かたい 硬い 形容詞・アウオ段 1. 力を加えてもまったく形が変わらない。「硬い岩石」\n2. 〈「固い」とも〉筋肉がこわばってなかなか動かない。「体が硬い」\n3. (表情などが)こわばっている。とりつきにくい。「硬い表情」\n4. (水について)カルシウムやマグネシウムのイオン含有量が多い。硬度が高い。硬水である。「硬い水」 -かたい 難い 形容詞・アウオ段 〈「想像に難くない」として〉容易に想像できる。 +かたい 堅い 形容詞・アウオ段 (材木など)力を加えても形が変わらない。堅実。「堅い材質、手堅い方法、堅い話、守備が堅い」 +かたい 固い 形容詞・アウオ段 (一般的)力を加えても(形が)変わらない。「結び目が固い、意志が固い、頭が固い、勝利は固い」 +かたい 硬い 形容詞・アウオ段 (金属、石など)力を加えても形が変わらない。「硬い岩石、硬い表情」 +かたい 難い 形容詞・アウオ段 むずかしい。「想像に難くない」 がっしゅうこく 合衆国 * アメリカ合衆国の略。 かなう 叶う 五段・ワ行促音便 思うようになる。「願いが叶う」 -かなう 敵う 五段・ワ行促音便 〈かな書きも〉匹敵する。「彼には敵わない」 +かなう 敵う 五段・ワ行促音便 匹敵する。「彼には敵わない」 かなう 適う 五段・ワ行促音便 よく合う。「理に適う」 かねつ 加熱 * 熱を加えること。「なべを加熱する」 かねつ 過熱 * 熱くなりすぎること。「競争が過熱する」 がま 蝦蟇 * ヒキガエル。 がま 蒲 * ガマ科の多年草。 -かりあげる 刈り上げる 一段 1. 上に向かって切っていく。「髪を刈り上げる」\n2. 全体的に切って短くする。「雑草を刈り上げる」 +かりあげる 刈り上げる 一段 髪を上に向かって刈る。「髪を刈り上げる、雑草を刈り上げる」 かりあげる 借り上げる 一段 目上のものが目下のものから金品を借りる。「土地を借り上げる」 -かりいれる 刈り入れる 一段 切って収穫する。「稲を刈り入れる」 -かりいれる 借り入れる 一段 (金などを)借りる。「銀行から金を借り入れる」 -かる 刈る 五段・ラ行 生えているものをきりとる。「草を刈る」「髪を刈る」 -かる 苅る 五段・ラ行 →刈る -かる 駆る 五段・ラ行 1. 走らせる。「馬を駆る」\n2. 人をつかう。「雑用に駆られる」\n3. つきうごかす。「衝動に駆られる」 +かりいれる 刈り入れる 一段 収穫する。「稲を刈り入れる」 +かりいれる 借り入れる 一段 金などを借りること。「銀行から金を借り入れる」 +かる 刈る 五段・ラ行 (苅ると区別なし)生えているものをきりとる。「草を刈る、髪を刈る」 +かる 苅る 五段・ラ行 (刈ると区別なし)生えているものをきりとる。「草を苅る」 +かる 駆る 五段・ラ行 走らせる。「馬を駆る、雑用に駆られる、衝動に駆られる」 かる 狩る 五段・ラ行 鳥や獣をとる。「鹿を狩る」 -かれる 枯れる 一段 1. (植物が)生気をなくす。「花が枯れる」「木が枯れた」\n2. 〈「涸れる」とも〉水がなくなる。「井戸が枯れる」\n3. 〈「嗄れる」とも〉声が出なくなる。「歌いすぎて喉が枯れた」\n4. 円熟する。「芸が枯れる」 -かれる 涸れる 一段 →枯れる2 -かれる 嗄れる 一段 →枯れる3 -かわく 渇く 五段・カ行イ音便 1. 〈「喉が渇く」の形で〉生き物の水分が不足し、水分をとりたくなる。「喉が渇く」\n2. 渇望する。「愛に渇く」 -かわく 乾く 五段・カ行イ音便 ものから水分がなくなる。「洗濯物が乾く」 -かわる 換わる 五段・ラ行 〈「替わる」とも〉(主に液体・気体について)古いものが出て、新しいものが入る。「空気が換わる」 -かわる 替わる 五段・ラ行 〈「換わる」とも〉とりかわる。交換される。「二人の席が替わる」 +かれる 枯れる 一段 水分がなくなる。「花が枯れる、芸が枯れる」 +かれる 涸れる 一段 (川、池などで)水がなくなる。「井戸が涸れる」 +かわく 渇く 五段・カ行イ音便 (のどに)水分がなくなる。「のどが渇く」 +かわく 乾く 五段・カ行イ音便 水分がなくなる。「洗濯物が乾く」 +かわる 換わる 五段・ラ行 他のものといれかわる。「席を換わる」 +かわる 替わる 五段・ラ行 新しいものといれかわる。「先生が替わる」 かわる 代わる 五段・ラ行 代理をする。「彼に代わって試合に参加する」 -かわる 変わる 五段・ラ行 1. 異なる状態になる。「信号が変わる」\n2. 〈「変わっている」「変わった」として〉一般的なものから外れている。「性格が変わっている」「変わった人」 +かわる 変わる 五段・ラ行 異なる状態になる。「信号が変わる、性格が変わっている」 かんき 喚起 * 呼びおこすこと。「潜在的な需要を喚起する」 かんき 換気 * 空気を入れ換えること。「部屋を換気する」 かんき 歓喜 * よろこぶこと。「一挙手一投足に歓喜する」 @@ -365,41 +357,39 @@ かんさ 鑑査 * 調べて優劣を決めること。「骨董品を鑑査する」 かんさつ 監察 * 監督し、とりしまること。「行政を監察する」 かんさつ 観察 * ものごとを注意して見ること。「朝顔を観察する」 -かんしょう 干渉 * 1. 他人のことに口や手を出すこと。「内政干渉」\n2. (お互いに)影響を与えること。「電波が干渉する」 +かんしょう 干渉 * 他人のことに口や手を出すこと。「内政干渉、電波が干渉する」 かんしょう 観賞 * 見て楽しむこと。「花を観賞する」 かんしょう 鑑賞 * (芸術などを)たのしむこと。「音楽を鑑賞する」 -かんしん 歓心 * 気に入る気持ち。「彼の歓心を買う」 +かんしん 歓心 * 嬉しく思う気持。 かんしん 関心 * 興味を持つこと。「彼女に関心を持つ」 かんすい 冠水 * (洪水などで)水びたしになること。「道路が冠水する」 かんすい 完遂 * 完全にやりとげること。「任務を完遂する」 かんすい 灌水 * 水を注ぐこと。「畑に灌水する」 -かんずる 感ずる サ変・−ズル 〈文語〉感覚をえる。「喜びを感ずる」 -かんずる 観ずる サ変・−ズル 〈文語〉さとる。観念する。「因縁を観ずる」 -かんち 感知 * 感づくこと。「危険性を感知する」 +かんずる 感ずる サ変・−ズル (文語)感覚をえる。「喜びを感ずる」 +かんずる 観ずる サ変・−ズル (文語)さとる。観念する。「因縁を観ずる」 +かんち 感知 * 感づくこと。「危険性を関知する」 かんち 関知 * かかわって知ること。「事件には関知していない」 -きうん 機運 * なにかをするのにちょうどいい時期。「機運が熟するのを待つ」 -きうん 気運 * 世の中の雰囲気。「政権交代の気運が高まった」 -ぎえんきん 義援金 * 災害などを受けた人々のために送るお金。\n※「義捐金」の書き換え。 -ぎえんきん 義捐金 * 災害などを受けた人々のために送るお金。\n※「義援金」と書き換えられることが多い。 -ききょう 帰京 * 首都に帰ること。「仕事を終えて帰京する」 +きうん 機運 * なにかをするのにちょうどいい時期。「機運が高まってきた」 +きうん 気運 * 世の中のなりゆき。 +ききょう 帰京 * みやこに帰ること。「仕事を終えて帰京する」 ききょう 帰郷 * 故郷に帰ること。「正月に帰郷した」 きく 効く 五段・カ行イ音便 ききめがある。「麻酔が効く」 -きく 訊く 五段・カ行イ音便 人にものをたずねる。「道を訊く」→聞く2 -きく 聴く 五段・カ行イ音便 注意深く聞く。「講演を聴く」「音楽を聴く」→聞く1 -きく 聞く 五段・カ行イ音便 1. 音を耳で感じる。「話を聞く」「講演を聞く」「音楽を聞く」\n2. 〈「訊く」とも〉人にものをたずねる。「道を聞く」\n3. 味やにおいを判断する。「香を聞く」 -きく 利く 五段・カ行イ音便 1. じゅうぶんな働きをする。「気が利く」\n2. 〈「口を利く」の形で〉しゃべる。 +きく 訊く 五段・カ行イ音便 たずねる。「道を訊く」(聞くとも書く) +きく 聴く 五段・カ行イ音便 注意深く聞く。「講演を聴く、音楽を聴く」 +きく 聞く 五段・カ行イ音便 (一般的)音を耳で感じる。「話を聞く、道を聞く、香を聞く」 +きく 利く 五段・カ行イ音便 じゅうぶんな働らきをする。「気が利く、口を利く」 きぐ 器具 * 道具。「電気器具」 きぐ 機具 * 機械と器具。 きざす 兆す 五段・サ行 ものごとが起ころうとする。「復調が兆す」 -きざす 萌す 五段・サ行 〈文語〉(芽が)出始める。「木の芽が萌す」 +きざす 萌す 五段・サ行 芽が出始める。「木の芽が萌す」 ぎし 技師 * 技術者。 ぎし 義肢 * 義手や義足など。 きじく 基軸 * ものごとの基本となるもの。「基軸通貨」 -きじく 機軸 * 1. 機械の中心となる軸。\n2. 大きな構想。「新しい機軸を打ち出す」 +きじく 機軸 * 活動の中心。「新しい基軸をだす」 きしつ 基質 * 基盤となる物質。 きしつ 気質 * 生まれつきの性質。「職人気質」 -ぎしょう 偽称 * 名称を偽ること。 -ぎしょう 偽証 * いつわりの証言をすること。「裁判で偽証する」 +ぎしょう 偽称 * 名称を偽る。 +ぎしょう 偽証 * いつわって証明する。「証拠を偽称する」 きせい 規制 * きまりを決めて制限すること。「交通規制」 きせい 規正 * 悪いことを正しくなおすこと。 きせい 既成 * すでに出来あがっていること。「既成概念」 @@ -407,1323 +397,1308 @@ ぎそう 偽装 * 細工をして欺くこと。「偽装結婚」 ぎそう 擬装 * 外見を変えてごまかすこと。 ぎそう 艤装 * 船に装備を施すこと。 -きぬ 衣 * 〈文語〉きもの。「歯に衣着せぬ」(ずけずけとものを言う) -きぬ 絹 * 蚕の糸からつくった布。 +きぬ 衣 * きもの。「歯に衣着せぬ」 +きぬ 絹 * 絹の糸。 きばん 基板 * 集積回路を配線するシリコンの板。 きばん 基盤 * 物事の土台。「情報基盤」 -きゅう 窮する サ変・-スル 行き詰る。「答えに窮する」 -きゅう 給する サ変・-スル 〈文語〉あたえる。 +きゅう 窮 * 行き詰る。「答えに窮する」 +きゅう 給 * (文語)あたえる。 きゅうはく 急迫 * さしせまること。 きゅうはく 窮迫 * 行き詰まって、どうにもならないこと。 きゅうめい 救命 * 人命を救うこと。「救命胴衣」 きゅうめい 究明 * 真理を追及し、あきらかにすること。「真理を究明する」 きゅうめい 糾明 * 悪いことを問い正して、あきらかにすること。「悪事を糾明する」 -きょうする 供する サ変・-スル 1. 〈文語〉(飲食物を)与える。提供する。「酒食を供する」\n2. 〈「〜に供する」として〉その目的のために提供する。「公共の利用に供する」 -きょうする 狂する サ変・-スル 〈文語〉くるう。 -きょうする 饗する サ変・-スル 〈文語〉ふるまう。 +きょう 供 * (文語)そなえる。 +きょう 狂 * (文語)くるう。 +きょう 饗 * (文語)ふるまう。 きょうえん 競演 * 演技を競うこと。 きょうえん 共演 * 主役が2人出演すること。「二人のスターが共演する」 -きょうじょう 教場 * 〈文語〉授業をする場所。 -きょうじょう 教条 * 教義。「教条主義に陥る」 -きょうせい 共棲 * →共生 -きょうせい 共生 * 1. 共にくらすこと。\n2. 異種の生物が、お互いに利益を与えて生活すること。 +きょうじょう 教場 * 授業をする場所。 +きょうじょう 教条 * 教義を箇条書きにしたもの。 +きょうせい 共棲 * (「共生」と区別なし)同じところでくらすこと。 +きょうせい 共生 * (「共棲」と区別なし)同じところでくらすこと。 きょうせい 強制 * むりやりさせること。「強制収容」 -きょうせい 強請 * 〈文語〉〈「ごうせい」とも読む〉無理に頼むこと。 +きょうせい 強請 * むりに頼むこと。ごうせい。 きょうどう 共同 * 複数の人でなにかをすること。「共同研究」 きょうどう 協同 * 助けあってなにかをすること。「協同組合」 -きょうはく 強迫 * 1. むりに要求すること。\n2. 強く定着し、逃れられないこと。「強迫観念」\n3. 〈民法〉「脅迫」の意で使う。 +きょうはく 強迫 * 相手にむりやりになにかをさせること。「強迫観念」 きょうはく 脅迫 * 相手を脅して、むりやりになにかをさせること。「脅迫罪」 きょうぼう 凶暴 * 凶悪で乱暴なようす。 きょうぼう 狂暴 * くるったように暴れるようす。 きょうわ 共和 * 複数の人が政務などをすること。「共和国」 -きょうわ 協和 * 1. こころを合わせて仲よくすること。\n2. (音が)うまく合っていること。「協和音」 -きる 斬る 五段・ラ行 (人などに対して)刃物などで傷つける、または殺す。「人に斬りつける」 -きる 切る 五段・ラ行 1. くっついているもの、またはひとつのものをはなればなれにする。「ひもを手で切る」「爪を切る」「木を切る」\n2. 鋭いものできずつける。「紙の端で手を切ってしまった」\n3. 機械の動作を止める。「テレビの電源を切る」\n4. 操作して方向をかえる。「ハンドルを切る」 -きる 伐る 五段・ラ行 (木に対して)刃物などで断つ。「木を伐る」→切る1 -きわめる 究める 一段 ものごとを追究する。「学問を究める」 -きわめる 極める 一段 1. 物事をつきつめ、そのすべてを習得する。「剣術を極める」\n2. (困難な場所に)到達する。「山頂を極める」\n3. 程度が極限に達する。「栄華を極める」 -ぐうする 寓する サ変・-スル 〈文語〉ことよせる。 -ぐうする 遇する サ変・-スル 〈文語〉もてなす。「自宅で遇する」 +きょうわ 協和 * こころを合わせて仲よくすること。「協和音」 +きる 斬る 五段・ラ行 (人などに対して)刃物などで傷つける。「人を斬りつける」 +きる 切る 五段・ラ行 くっついているものをはなればなれにする。「爪を切る、電話を切る、洗顔料を使い切る、伝票を切る、ハンドルを切る」 +きる 伐る 五段・ラ行 (木に対して、「切る」とも書く)刃物などで断つ。「木を伐る」 +きわめる 究める 一段 真理を追究する。「学問を究める」 +きわめる 極める 一段 物事をつきつめる。「山頂を極める」 +ぐう 寓 * (文語)ことよせる。 +ぐう 遇 * (文語)もてなす。「自宅で遇する」 くず 葛 * マメ科の多年草。「葛切り」 -くず 屑 * ごみ。「紙屑」 -くだる 下る 五段・ラ行 1. 高いところから低いところに、または中心とされる場所から周辺に移る。「山を下る」「川を下る」\n2. 言い渡される。「判決が下る」\n3. 下痢をする。「腹が下る」 -くだる 降る 五段・ラ行 降服して所属するようになる。「敵の軍門に降る」 -くみあげる 汲み上げる 一段 水をくみ、高い場所に上げる。「井戸水を汲み上げる」 -くみあげる 組み上げる 一段 組み終える。「計画を組み上げる」「足場を組み上げる」 -くむ 汲む 五段・マ行 1. 水などをすくう。「井戸水を汲む」\n2. おしはかる。「意図を汲む」 -くむ 酌む 五段・マ行 1. 酒などをつぐ。「酒を酌む」\n2. 考慮する。斟酌(しんしゃく)する。「酌むべき事情がある」 -くむ 組む 五段・マ行 1. 互い違いに合わせる。また、そうしてものを作る。「腕を組む」「やぐらを組む」\n2. (複数人が、目的のある集団を)集まって構成する。「チームを組む」\n3. 複雑なものをつくりあげる。「プログラムを組む」\n4. 長期間の契約を結ぶ。「ローンを組む」 -ぐんしゅう 群衆 * 〈「群集」とも〉大勢集まった人々。 -ぐんしゅう 群集 * 人、動物などの集まり。「群集心理」 -くんずる 薫ずる サ変・−ズル 〈文語〉かおる、またはにおいを起こす。 -くんずる 訓ずる サ変・−ズル 〈文語〉訓読する。 -けいする 慶する サ変・−スル 〈文語〉いわう。 -けいする 敬する サ変・−スル 〈文語〉うやまう。 -けいじょう 啓上 * 〈文語〉〈「一筆啓上」として〉書いて申し上げること。 +くず 屑 * ゴミ。「紙屑」 +くだる 下る 五段・ラ行 高いとことから低いところに移る。「山を下る、川を下る、判決が下る、腹が下る」 +くだる 降る 五段・ラ行 おりる。「山を降る、敵の軍門に降る」 +くみあげる 汲み上げる 一段 水を汲み、高い場所に上げる。「井戸水を汲み上げる」 +くみあげる 組み上げる 一段 組み終える。「計画を組み上げる、足場を組み上げる」 +くむ 汲む 五段・マ行 水などをすくう。「井戸水を汲む、意図を汲む」 +くむ 酌む 五段・マ行 酒などをつぐ。「酒を酌む」 +くむ 組む 五段・マ行 組になる。「チームを組む、腕を組む、やぐらを組む」 +ぐんしゅう 群衆 * 大勢の人。 +ぐんしゅう 群集 * 人、虫などの集まり。「群集心理」 +くんずる 薫ずる サ変・−ズル かおる。 +くんずる 訓ずる サ変・−ズル 訓読する。 +けい 慶 * いわう。 +けい 敬 * うやまう。 +けいじょう 啓上 * 申し上げること。 けいじょう 計上 * 計算に加えること。「予算に計上する」 -けいすう 係数 * 数式において、変数にかかっている数。 +けいすう 係数 * 数式において変数にかかっている数。 けいすう 計数 * 数を数えること。 -けっさい 決済 * 支払いを行うこと。「月末に決済する」 +けっさい 決済 * 支払を行うこと。「月末に決済する」 けっさい 決裁 * 上の立場の人が決定を下すこと。「決裁をあおぐ」 -げっぽう 月俸 * ひと月の給料。 -げっぽう 月報 * 月ごとの報告。 -けんする 検する サ変・−スル とりしらべる。 -けんする 験する サ変・−スル ためす。 +げっぽう 月俸 * 月毎の給料。 +げっぽう 月報 * 月毎の報告。 +けん 検 * とりしらべる。 +けん 験 * ためす。 けんあん 懸案 * 問題になっているが、解決されていない問題。「懸案事項」 けんあん 検案 * 形状などを調べること。 -げんけい 原型 * 1. 基準とする型、また進化する以前の型。「長安を原型として都を建造する」「ウマの原型となる動物」\n2. それを土台に複製を作るような、基本となる型。 -げんけい 原形 * 変化する前の形。「ゆがんだハンガーを原形に戻す」 -げんし 原始 * 発展のはじめの段階にあること。「原始宇宙」「原始仏教」 -げんし 原子 * 単独の化学元素。「原子物理」「原子爆弾」 +げんけい 原型 * もととなる型。「日本列島の原型」 +げんけい 原形 * もとのかたち。「原形質」 +げんし 原始 * はじめ。「原始人」 +げんし 原子 * 物質の要素。「原子物理、原子爆弾」 げんずる 減ずる サ変・−ズル 減る。 -げんずる 現ずる サ変・−ズル 〈文語〉あらわれる。 +げんずる 現ずる サ変・−ズル あらわれる。 けんめい 懸命 * いのちがけ。「懸命に挑戦する」 けんめい 賢明 * 賢く、道理にあっていること。「賢明な対処」 ごい 語意 * ことばの意味。 ごい 語彙 * 語のあつまり。ボキャブラリ。 -こうする 抗する サ変・−スル 〈文語〉抵抗する。「時代に抗する」 -こうする 航する サ変・−スル 〈文語〉航海する。「東海岸を航する」 -こう 乞う 五段・ワ行ウ音便 〈「請う」に同じ〉ねがう、またはものを求める。「許しを乞う」「援助を乞う」 -こう 請う 五段・ワ行ウ音便 〈「乞う」に同じ〉ねがう、またはものを求める。「許しを請う」「援助を請う」 -こう 恋う 五段・ワ行ウ音便 なつかしく思う。「故郷を恋う」 +こう 抗 * (文語)抵抗する。「時代に抗する」 +こう 航 * (文語)航海する。「東海岸を航する」 +こう 乞う 五段・ワ行ウ音便 (「請う」と区別なし)ものを求める。「許しを乞う」 +こう 請う 五段・ワ行促音便 (「乞う」と区別なし)ものを求める。「許しを請う」 +こう 恋う 五段・ワ行ウ音便 いとしく思う。「故郷を恋う」 こうい 厚意 * 親切な気持。「ご厚意に甘えさせていただきます」 -こうい 好意 * 好きだという気持。「好意を抱く」「好意を寄せる」 +こうい 好意 * いいと思う気持。親切な気持。「好意を抱く」 こうえき 公益 * 公共の利益。「公益事業」 こうえき 公役 * 公共団体から任せられた役割。 -こうかん 交感 * 心や感情が通い合うこと。 -こうかん 交換 * とりかえること。「交換日記」「ユニフォームを交換する」 -こうかん 交歓 * 交流して親睦を深めること。「交歓会」 +こうかん 交感 * 心や感情が通い合うこと。「交感神経」 +こうかん 交換 * とりかえること。「交換日記、ユニフォームを交換する」 +こうかん 交歓 * よろこびを分かちあうこと。「交歓会」 こうこう 後攻 * 野球などで、後から攻めること。 こうこう 孝行 * 親に対して行なうよい行い。「親孝行」 -こうこう 航行 * 船や飛行機で水上や空中を移動すること。「インド洋を航行する」 -こうこく 公告 * 公共機関が公に知らせること。「政策を公告する」 -こうこく 広告 * 商業的な目的で広く知らせること。また、それに使われるもの。「新商品の広告を行う」「広告が掲載されている」 +こうこう 航行 * 船で水上を移動すること。「インド洋を航行する」 +こうこく 公告 * 公に知らせること。「政策を公告する」 +こうこく 広告 * 広く世間に知らせること。「新商品を広告する」 こうしゃく 侯爵 * 華族の階級の第二番目。 こうしゃく 公爵 * 華族の階級の第一番目。 -こうずる 昂ずる サ変・−ズル →高ずる -こうずる 嵩ずる サ変・−ズル →高ずる -こうずる 講ずる サ変・−ズル 1. (手段・対策などを)実行する。「必要な措置を講ずる」\n2. 〈文語〉講義をする。「数学を講ずる」\n3. 〈「和を講ずる」として〉講和する。 -こうずる 高ずる サ変・−ズル 〈「昂ずる」「嵩ずる」とも〉たかまる。「病気が高ずる」「趣味が高じて本まで書くようになった」 -こうせい 更正 * あやまりを正すこと。また、倫理的によい方向に進むこと。「非行少年を更正させる」 -こうせい 更生 * 立ち直ること。「自力更生」「会社更生法」 +こうずる 昂ずる サ変・−ズル (「高ずる」と区別なし)たかまる。「病気が昂ずる」 +こうずる 講ずる サ変・−ズル 講義をする。「数学を講ずる、手段を講ずる」 +こうずる 高ずる サ変・−ズル (「昂ずる」と区別なし)たかまる。「病気が高ずる」 +こうせい 更正 * あやまりを正すこと。 +こうせい 更生 * 生きかえること。「会社更生法」 こうそ 公訴 * 刑事に関する訴訟。 -こうそ 控訴 * 判決を不服として、上級裁判所に再審を求めること。 +こうそ 控訴 * 判決を不服として上級裁判所に再審を求めること。 こうちゃく 降着 * 競馬で進路を妨害した馬の順位を下げること。 -こうちゃく 膠着 * 事態が固定して、変化が起きなくなること。「事件が膠着状態になる」 -こえる 越える 一段 1. 上を通りすぎる。「山を越える」「橋を越える」\n2. きびしい状況をしのぐ。「冬を越える」\n3. 〈「超える」とも〉うわまわる。「限界を越える」「容量が500MBを越える」 -こえる 超える 一段 〈「越える」とも〉うわまわる。超過する。「限界を超える」「容量が500MBを超える」 -こえる 肥える 一段 1. 太る。\n2. (土壌が)ゆたかである。「土地が肥えている」\n3. 鑑識眼がある。「目が肥えている」 -こおる 凍る 五段・ラ行 水などが冷えて固まる。「湖が凍る」 -こおる 氷る 五段・ラ行 →凍る +こうちゃく 膠着 * 変化が起きないこと。「事件が膠着状態になる」 +こえる 越える 一段 上を過ぎる。「山を越える、冬を越える」 +こえる 超える 一段 (「越える」も使う)うわまわる。「限界を超える、容量が500MBを超える」 +こえる 肥える 一段 ふとる。「目が肥えている、土地が肥えている」 +こおる 凍る 五段・ラ行 (一般的)水などが冷えて固まる。「湖が凍る」 +こおる 氷る 五段・ラ行 水などが冷えて固まる。「湖が氷る」 ごかん 語幹 * 動詞・形容詞・形容動詞において変化しない部分。「『こわい』の語幹は『こわ』である」 -ごかん 語感 * 言葉のあたえる感覚。「語感がよくないので別の言い方を考える」 +ごかん 語感 * 言葉のあたえる感覚。 ごこうい ご厚意 * 親切な気持。「ご厚意に甘えさせていただきます」 -ごこうい ご好意 * 好きだという気持。 +ごこうい ご好意 * いいと思う気持。親切な気持。 ごこうい 御厚意 * 親切な気持。「御厚意に甘えさせていただきます」 -ごこうい 御好意 * 好きだという気持。 +ごこうい 御好意 * いいと思う気持。親切な気持。 こじ 固持 * かたく持ちつづけて変えないこと。 こじ 固辞 * かたく辞退すること。「役職を固辞する」 こじ 誇示 * 自慢して示すこと。「力を誇示する」 こじ 古寺 * ふるい寺。 こじ 孤児 * 両親のいない子供。 -こじ 故事 * 昔あったことがら。 +こじ 故事 * 昔あった事柄。 ごしん 誤信 * あやまって信じること。 ごしん 誤診 * あやまって診断すること。 -こす 越す 五段・サ行 1. 通りすぎる。「山を越す」\n2. きびしい状況をしのぐ。「冬を越す」\n3. 住居を移る。引っ越す。「隣町へ越す」\n4. 〈「お越し」の形で〉「来る」の尊敬語。「お客様がお越しです」\n5. 〈「超す」とも〉うわまわる。「3万人を越す」 -こす 漉す 五段・サ行 →濾す -こす 超す 五段・サ行 〈「越す」とも〉うわまわる。「3万人を超す」 -こす 濾す 五段・サ行 〈「漉す」とも〉目の細かいものなどを通して不純物を取り除く。濾過(ろか)する。「水を濾す」 -ごぜん 午前 * 24時間制でいうところの0時から12時まで。一日の前半。 +こす 越す 五段・サ行 通りすぎる。「山を越す、隣町へ越す、冬を越す、お客様がお越しです」 +こす 漉す 五段・サ行 (「濾す」とも書く)濾過する。「水を漉す」 +こす 超す 五段・サ行 (「越す」とも書く)ある値よりも上になる。「3万人を超す」 +こす 濾す 五段・サ行 (「漉す」とも書く)濾過する。「水を濾す」 +ごぜん 午前 * 0時から12時まで。 ごぜん 御前 * 地位の高い人の前。 -こちょう 胡蝶 * 昆虫のチョウのこと。 +こちょう 胡蝶 * (「蝴蝶」と区別なし)蝶のこと。 こちょう 誇張 * おおげさに言うこと。「誇張表現」 -こちょう 蝴蝶 * →胡蝶 -こて 小手 * 〈「籠手」とも〉\n1. 剣道で、指先からひじまでを覆う防具。\n2. よろいの中で、肩から腕までを覆う防具。 -こて 籠手 * 〈「小手」とも〉\n1. よろいの中で、肩から腕までを覆う防具。\n2. 剣道で、指先からひじまでを覆う防具。 -こて 鏝 * 〈普通かな書き〉漆喰などを塗る道具。 -こべつ 個別 * ひとつずつ。ひとりずつ。「個別指導」 -こべつ 戸別 * いえごと。「戸別訪問」 -こむ 込む 五段・マ行 1. 〈「混む」が一般的〉混雑する。「遊園地が込んでいる」\n2. 巧妙である。「手の込んだ細工」\n3. 〈主に複合語で〉中に入る、または入れる。「入り込む」「中に飛び込む」\n4. とことん行う。「鍛え込む」「教え込む」 -こむ 混む 五段・マ行 混雑する。「遊園地が混んでいる」 +こちょう 蝴蝶 * (「胡蝶」と区別なし)蝶のこと。 +こて 小手 * 肘と手首との間。 +こて 籠手 * (「小手」とも書く)手から肩を覆う防具。 +こて 鏝 * 漆喰などを塗る道具。 +こべつ 個別 * ひとつずつ。「個別指導」 +こべつ 戸別 * いえごと。 +こむ 込む 五段・マ行 混雑する。中にはいる。「遊園地が込む、手が込む、入り込む、鍛え込む」 +こむ 混む 五段・マ行 混雑する。「遊園地が混む」 ごよう 御用 * 用事があること。「御用始め」 ごよう 誤用 * 誤って用いること。「薬を誤用している」 -こらす 凝らす 五段・サ行 〈かな書きも〉\n1. (意識などを)一つのところに集中させる。「目を凝らす」「視線を凝らす」\n2. 〈「息を凝らす」として〉呼吸を抑える。\n3. (工夫、技巧などを)時間をかけてほどこす。「工夫を凝らした授業」「趣向を凝らした衣装」 -こらす 懲らす 五段・サ行 〈文語〉こらしめる。「いたずらを懲らす」 +こらす 凝らす 五段・サ行 一つのところに集中させる。「工夫を凝らす、目を凝らす」 +こらす 懲らす 五段・サ行 こらしめる。「いたずらを懲らす」 さいかい 再会 * 再び会うこと。「旧友と再会する」 さいかい 再開 * 再び始める。「会議を再開する」 -さいき 再帰 * 関数などが自分自身を呼び出すこと。「再帰的関数」 -さいき 再起 * たちなおる。「重症から再起する」「再起不能」 +さいき 再帰 * 関数などで自分自身を呼び出すこと。「再帰的関数」 +さいき 再起 * たちなおる。「重症から再起する、再起不能」 さいけつ 採決 * 議案を多数決で決めること。「採決をとる」 -さいけつ 採血 * 血液を採取すること。「検査のために採血した」 -さいけつ 裁決 * さばきを行うこと。「裁決を下す」 +さいけつ 採血 * 血液を採取する。「検査のために採血した」 +さいけつ 裁決 * さばきを行う。「採決を下す」 さいけん 債券 * 公共機関が発行する有価証券。「債券を発行する」 さいけん 債権 * 金品の返還要求を行う権利。「債権者」 -さいご 最期 * 〈「最後」とも〉死にぎわ。「祖父の最期に立ち会う」 -さいご 最後 * 1. いちばんうしろ。\n2. 〈「最期」とも〉死に際。「祖父の最後に立ち会う」 +さいご 最期 * 死にぎわ。 +さいご 最後 * いちばんうしろ。 さいしょう 最小 * いちばん小さいこと。 さいしょう 最少 * いちばん少ないこと。 さいしょく 彩色 * 着色。「彩色を施す」 さいしょく 才色 * (女性の)才能と美貌。「才色兼備」 -さいせい 再生 * 1. 廃物を利用して再び使えるようにすること。リサイクル。「再生紙」\n2. 再び生えてくること。\n3. 機械に記録したものを読み出し、音声や映像を復元すること。「音楽を再生する」 -さいせい 再製 * 1. 既存のものに再び加工してつくること。「再製茶」\n2. 作り直すこと。「戸籍を再製する」 +さいせい 再生 * 生きかえること、リサイクル。「再生紙」 +さいせい 再製 * 製品を作りなおすこと。「再製生糸」 さいせき 採石 * 石を採取すること。「採石場」 -さいせき 砕石 * 石を砕くこと。「砕石して砂利にする」 +さいせき 砕石 * 石を砕くこと。「砕石してジャリにする」 さいろく 採録 * 記録すること。「民話を採録する」 さいろく 載録 * 印刷物に載せること。「論文が載録された」 -さがす 捜す 五段・サ行 見失ったものや人を見つけようとする。「迷子を捜す」「なくした眼鏡を捜す」※この意味でも「探す」が多く使われる。 -さがす 探す 五段・サ行 目当てのものを見つけようとする。「自分に似合う眼鏡を探す」「他人のあらを探す」 +さがす 捜す 五段・サ行 なくなったもの見つけようとする。「迷子を捜す」 +さがす 探す 五段・サ行 欲しいものを見つけようとする。「眼鏡を探す、あらを探す」 さかな 魚 * 魚類。 -さかな 肴 * 〈かな書きも〉酒のつまみ。 +さかな 肴 * 酒のつまみ。 さかん 佐官 * 僧侶の役職の一つ。 さかん 左官 * 壁を塗る職人。 -さく 割く 五段・カ行イ音便 1. 切ってひらく。「魚の腹を割く」\n2. 一部を他にまわす。「時間を割く」 -さく 咲く 五段・カ行イ音便 花のつぼみが開く。「桜が咲く」 -さく 裂く 五段・カ行イ音便 1. (手などで)ふたつに切りはなす。「紙を裂く」\n2. 人々を離ればなれにする。「彼女との仲を裂く」 -さくせい 作成 * (特に書類などの)ものを作ること。「契約書を作成する」 -さくせい 作製 * 〈「作成」とも〉ものを作ること。 -さげる 下げる 一段 1. 低くする。「水量を下げる」「値段を下げる」\n2. つるす。「ペンダントを下げる」\n3. 〈「提げる」とも〉手で取っ手を持つ。「カバンを手に下げる」\n4. 回収する。「椅子を下げる」 -さげる 提げる 一段 手に持ってぶらさげる。「カバンを手に提げる」→下げる3 +さく 割く 五段・カ行イ音便 一部を他にまわす。「時間を割く、魚の腹を割く」 +さく 咲く 五段・カ行イ音便 花のつぼみが開く。「さくらが咲く」 +さく 裂く 五段・カ行イ音便 強引に2つに切りはなす。「紙を裂く、彼女との仲を裂く」 +さくせい 作成 * 書類などを作ること。「契約書を作成する」 +さくせい 作製 * ものを作ること。 +さげる 下げる 一段 下へ移動させる。「水量を下げる、値段を下げる、椅子を下げる」 +さげる 提げる 一段 手に持ってぶらさげる。「カバンを手に提げる」 さじ 些事 * ささいなこと。 -さじ 匙 * 液体などをすくうもの。スプーン。「匙を投げる」(あきらめる) -さす 差す 五段・サ行 1. 状態が生じる。「いやけが差す」\n2. 光などがかかる。「日が差す」\n3. (傘を)手で支えて体の上にかぶせる。「日傘を差す」\n4. 〈「挿す」とも〉(刀などを)帯に通して持ち運ぶ。 -さす 鎖す 五段・サ行 〈文語〉錠をおろす。とざす。「戸を鎖す」 -さす 刺す 五段・サ行 つきとおす。「釘を刺す」「人を刺す」 -さす 指す 五段・サ行 1. 指を向ける。指し示す。「ある方向を指す」\n2. 言及する。「これは彼のことを指している」\n3. (将棋を)する。「将棋を指す」 -さす 挿す 五段・サ行 1. 細長いものにつきとおす。「花瓶に花を挿す」\n2. 〈「差す」とも〉(刀などを)帯に通して持ち運ぶ。 -さばく 裁く 五段・カ行イ音便 善し悪しの判断を下す。「けんかを裁く」 -さばく 捌く 五段・カ行イ音便 〈かな書きも〉\n1. 効率よく対処する。「大量の仕事を捌く」\n2. (動物、特に魚を)解体する。「魚を捌く」\n3. 売って少なくする。「在庫を捌く」 -さます 覚ます 五段・サ行 〈「醒ます」とも〉\n1. (眠りなどから)頭が働く状態になる。「目を覚ます」\n2. 酒などの影響がなくなるようにする。「酔いを覚ます」 +さじ 匙 * 液体などをすくうもの。スプーン。「匙を投げる」 +さす 差す 五段・サ行 状態が生じる。「いやけが差す、日が差す、かさを差す」 +さす 鎖す 五段・サ行 とざす。「戸を鎖す」 +さす 刺す 五段・サ行 つきとおす。「釘を刺す、人を刺す」 +さす 指す 五段・サ行 ゆびを向ける、示す。「ある方向を指す、これは彼のことを指している、将棋を指す」 +さす 挿す 五段・サ行 ものをはさむ。「刀を挿す、花を挿す」 +さばく 裁く 五段・カ行イ音便 善し悪しをはっきりさせる。「けんかを裁く」 +さばく 捌く 五段・カ行イ音便 上手に対処する。「大量の仕事を捌く、魚を捌く、在庫を捌く」 +さます 覚ます 五段・サ行 (眠りなどから)頭が働く状態になる。「目を覚ます」 さます 冷ます 五段・サ行 ものを冷たくする。「お湯を冷ます」 -さます 醒ます 五段・サ行 →覚ます -さめる 覚める 一段 1. (眠りなどから)頭が働く状態になる。「目が覚める」\n2. 酒などの影響がなくなる。「酔いが覚める」 -さめる 醒める 一段 →覚める -さめる 冷める 一段 1. 冷たくなる。「お湯が冷める」\n2. (関係が)冷淡になる。「彼女との関係が冷める」\n3. 〈口語〉情熱や恋が失われる。「横柄な態度を見て一気に冷めた」 +さめる 覚める 一段 (眠りなどから)頭が働く状態になる。「目が覚める」 +さめる 醒める 一段 酔いがなくなる。「酔いが醒める」 +さめる 冷める 一段 冷たくなる。「お湯が冷める、彼女との関係が冷める」 さわら 椹 * ヒノキ科の高木。 さわら 鰆 * サバ科の魚。 -さわる 障る 五段・ラ行 1. 差し支える。悪い影響を及ぼす。「仕事に障る」「体に障る」\n2. 嫌な感情を引き起こす。「気に障る」 -さわる 触る 五段・ラ行 1. 手でふれる。「物に触る」\n2. 関係する。「その仕事には触っていない」 -さんする 参する サ変・−スル 〈文語〉たずさわる。「ボランティアに参する」 -さんする 産する サ変・−スル 1. 〈文語〉産む。「メスだけを産するハチ」\n2. (ものを)生産する。また、生産される。「天然に産する鉱物」 -さんする 算する サ変・−スル 〈文語〉計算する。「期待値を算する」 -さんか 傘下 * 支配下。「傘下の企業」 +さわる 障る 五段・ラ行 障害になる。「気に障る」 +さわる 触る 五段・ラ行 手でふれる。「物に触る、その仕事には触っていない」 +さん 参 * (文語)たずさわる。「ボランティアに参する」 +さん 産 * (文語)産む。「メスだけを産する蜂、天然に産する鉱物」 +さん 算 * (文語)計算する。「期待値を算する」 +さんか 傘下 * 支配下。「惨禍の企業」 さんか 惨禍 * 悲惨な災い。「戦争の惨禍」 -さんか 讃歌 * →賛歌 -さんか 賛歌 * 〈「讃歌」とも〉ものごとを称賛する歌。 +さんか 讃歌 * (「賛歌」と区別なし)ものごとを称賛する歌。 +さんか 賛歌 * (「讃歌」と区別なし)ものごとを称賛する歌。 さんかい 参会 * 会合に参加する。 さんかい 散会 * 会合を終える。 さんざい 散在 * ちらばって存在すること。「支局が散在する」 -さんざい 散財 * 使うことによって財を失なうこと。「博打で散財した」 +さんざい 散財 * 財を失なうこと。「博打で散財した」 さんしゅつ 産出 * 産物を産み出すこと。「石油を産出する」 さんしゅつ 算出 * 計算して数字を出すこと。「来場者を算出する」 -さんずる 参ずる サ変・−ズル 〈文語〉参上する。「明日に参ずる」 -さんずる 散ずる サ変・−ズル 〈文語〉\n1. (金を)使う。「財を散ずる」\n2. (人が)散らばる。(宴などから)帰る。「客が散ずる」\n3. (気が)散る。(気を)散らす。(気を)晴らす。 +さんずる 参ずる サ変・−ズル (文語)参上する。「明日に参ずる」 +さんずる 散ずる サ変・−ズル (文語)なくなる。「財を散ずる」 さんせい 産生 * 生産すること。「自動車を産生する」 さんせい 賛成 * 意見に同意すること。「彼の意見に賛成する」 さんにゅう 参入 * 加わること。「その市場に参入する」 さんにゅう 算入 * 計算に入れること。「診療報酬を収入に算入する」 -しする 資する サ変・−スル 役立てる。「学問の進歩に資する」 -しい 四囲 * 〈文語〉まわり。 -しい 私意 * 〈文語〉自分の考え。 +し 資 * (文語)役立てる。「学問の進歩に資する」 +しい 四囲 * まわり。 +しい 私意 * 自分の考え。 しい 椎 * ブナ科の木。 -しい 恣意 * 1. 個人の気まぐれ。「恣意的に処罰する」\n2. 意図が入らないこと。何でもよいこと。「記号の恣意性」 -しく 敷く 五段・カ行イ音便 ものがのるように広げる。「ござを敷く」「布団を敷く」 -じこう 時候 * 四季それぞれの気候。「時候の挨拶」 -じこう 時効 * 一定期間後に効力がなくなること。「あの事件はもう時効だ」 +しい 恣意 * 自分勝手な考え。 +しく 敷く 五段・カ行イ音便 ものがのるように広げる。「ゴザを敷く、布団を敷く」 +じこう 時候 * 四季それぞれの気候。 +じこう 時効 * 一定期間後に、権利を失なったり得たりすること。「あの事件はもう時効だ」 ししん 私信 * 個人的な手紙。 ししん 私心 * 自分の考え。 -しずまる 静まる 五段・ラ行 1. 静かになる。「場内が静まる」\n2. 〈「鎮まる」とも〉勢いが弱くなる。「傷口の傷みが静まる」「暴動が静まる」 -しずまる 鎮まる 五段・ラ行 〈「静まる」とも〉勢いが弱くなる、または完全におさまる。「傷口の傷みが鎮まる」「暴動が鎮まる」 -しずめる 静める 一段 1. 静かにする。「場内を静める」\n2. 〈「鎮める」とも〉勢いを弱くする、または完全になくす。「傷みを静める」「暴動を静める」 -しずめる 沈める 一段 沈むようにする。「船を沈める」「ソファーに体を沈める」 -しずめる 鎮める 一段 〈「静める」とも〉勢いを弱くする、または完全になくす。「傷みを鎮める」「暴動を鎮める」 -じす 辞す 五段・サ行 1. やめる。「職を辞す」\n2. 〈「〜を辞さない」として〉〜することをためらわない。「法的措置も辞さない」 -じする 侍する サ変・−スル 〈文語〉そばにつかえる。「酒席に侍する」 -じする 持する サ変・−スル 〈文語〉持つ。たもつ。「名声を持する」 +しずまる 静まる 五段・ラ行 (音や動きが)落ち着く。「場内が静まる」 +しずまる 鎮まる 五段・ラ行 (騒ぎや傷みが)おさまる。「傷口の傷みが鎮まる、暴動が鎮まる」 +しずめる 静める 一段 静かにする。「」 +しずめる 沈める 一段 しずむようにする。「船を沈める、ソファーに体を沈める」 +しずめる 鎮める 一段 騒ぎを落ち着かせる。「暴動を鎮める」 +じする 侍する サ変・−スル つかえる。「酒席に侍する」 +じする 持する サ変・−スル たもつ。「名声を持する」 じする 辞する サ変・−スル やめる。「職を辞する」 -じせい 時世 * 現在の世の中。「このご時世では就職も楽ではない」 -じせい 時制 * 言語において、語形変化などで現在・過去・未来などの時間をあらわすこと。 -じせい 時勢 * 時代の勢い。「時勢を読む」 +じせい 時世 * 世の中。 +じせい 時制 * 英語などで、現在、過去、未来などで動詞の形が変わること。 +じせい 時勢 * 移り変わる勢い。 じせん 自薦 * 自分を推薦すること。「生徒会長に自薦する」 じせん 自選 * 自分で選ぶこと。「自分の詩のなかで良いものを自選する」 じちょう 自重 * 行動をつつしむこと。「ギャンブルを自重する」 -じちょう 自嘲 * 自分をあざ笑うこと。「自嘲的な笑い」 +じちょう 自嘲 * 自分をさげずむこと。「自嘲的な笑い」 しつける 仕付ける 一段 したてる。「服を仕付ける」 -しつける 躾ける 一段 〈かな書きも〉(子供などに)マナーを覚えさせる。「子供を躾ける」 -じっけん 実検 * 〈文語〉実物を見て検査すること。「実検状」 -じっけん 実験 * 理論や考えが正しいかどうか、実際にやって確かめること。「理科の実験」 -じつじょう 実情 * 〈「実状」に同じ〉実際の事情、実際のようす。「実情を訴える」「実情を把握する」 -じつじょう 実状 * 〈「実情」に同じ〉実際の事情、実際のようす。「実状を訴える」「実状を把握する」 +しつける 躾ける 一段 子供にマナーを覚えさせる。「子供を躾ける」 +じっけん 実検 * 実状を検査すること。「実検状」 +じっけん 実験 * 理論を実際にやって確かめること。「理科の実験」 +じつじょう 実情 * 実際の事情。「実情を訴える」 +じつじょう 実状 * 実際のようす。「実状を把握する」 じっせん 実戦 * 実際の戦闘。「実戦経験」 じっせん 実践 * 実際にものごとを行なうこと。「改革案を実践する」 -じったい 実体 * 実在する姿。「実体を持たない幽霊」 +じったい 実体 * 本体。「実体がつかめない」 じったい 実態 * 実際の状態。「実態調査」 -じてん 事典 * さまざまなことがらを説明する本。「百科事典」 -じてん 辞典 * ことばの意味を説明する本。辞書。「国語辞典」「英和辞典」 -じてん 字典 * ひとつひとつの漢字について説明する本。「書道字典」 -じにん 自任 * そうであると自分で考える。「専門家を自任する」 +じてん 事典 * さまざまなことを説明した本。「百科事典」 +じてん 辞典 * 辞書。「国語辞典」 +じにん 自任 * 自らの任務とすること。「管理者を自任する」 じにん 自認 * 自ら認めること。「過ちを自認する」 -しのぶ 偲ぶ 五段・バ行 遠く離れたものや亡くなった人のことを思う。「故郷を偲ぶ」「故人を偲ぶ」 -しのぶ 忍ぶ 五段・バ行 1. こらえる。「恥を忍ぶ」\n2. (人目などを)避ける。目立たないように行動する。「人目を忍ぶ」「忍ぶ恋」「世を忍ぶ仮の姿」(=世間に知られないようにするための仮の姿)\n3. 〈「〜に忍びない」として〉感情的な理由で、〜することができない。「捨てるに忍びない」 -しぼむ 萎む 五段・マ行 〈かな書きも〉ふくらんでいたものが小さくなる。「つぼみが萎む」 -しぼりあげる 絞り上げる 一段 1. すっかりしぼる。「雑巾を絞り上げる」\n2. きびしく責める。「遅く帰宅した息子を絞り上げる」\n3. 取り立てる。「金品を絞り上げる」 -しぼりあげる 搾り上げる 一段 →絞り上げる -しぼる 絞る 五段・ラ行 〈1, 2 は「搾る」とも〉\n1. がんばって出す。「知恵を絞る」\n2. 責める。「先生に絞られた」\n3. よく選んで少なくする。「人数を絞る」\n4. 調節して小さくする。「ボリュームを絞る」 -しぼる 搾る 五段・ラ行 〈「絞る」とも〉ねじって水分を出す。「雑巾を搾る」「乳を搾る」 +しのぶ 偲ぶ 五段・バ行 昔のことを思う。「故人を偲ぶ」 +しのぶ 忍ぶ 五段・バ行 こらえる。「恥を忍ぶ、人目を忍ぶ」 +しぼむ 萎む 五段・マ行 ふくらんでいたものが小さくなる。「つぼみが萎む」 +しぼりあげる 絞り上げる 一段 強く絞る。「雑巾を絞り上げる」 +しぼりあげる 搾り上げる 一段 きびしく責める。「金品を搾り上げる」 +しぼる 絞る 五段・ラ行 ねじって水分を出す。「雑巾を絞る、人数を絞る、ボリュームを絞る」 +しぼる 搾る 五段・ラ行 力を加えて液を出す。「果物を搾る、税金を搾り取る」 しまる 絞まる 五段・ラ行 (首などに)ものが巻きつけられて力が加わる。「首が絞まる」 -しまる 締まる 五段・ラ行 1. 固定されて動きにくい状態になる。「ねじが締まる」\n2. 緊張感が出てしっかりする。「顔が締まる」「気持ちが締まる」 +しまる 締まる 五段・ラ行 ひきしまる。「気持が締まる、ねじが締まる、顔が締まる」 しまる 閉まる 五段・ラ行 (ドアや窓が)とじられる。「ドアが閉まる」 -しみる 染みる 一段 〈かな書きも〉\n1. (液体、臭いなどが)ものに入りこむ。「服に汗が染みる」\n2. 〈主にかな書き〉刺激物が入って痛くなる。「たばこの煙が目にしみる」「歯に水がしみる」\n3. 深く感じる。「教訓が身に染みてわかった」 -しみる 凍みる 一段 〈文語〉こおりつく。「寒さで身が凍みる」 -しむ 染む 五段・マ行 〈文語〉(液体、臭いなどが)ものに入りこむ。染みる。 -しむ 凍む 五段・マ行 〈文語〉こおりつく。凍みる。 -しめきる 締め切る 五段・ラ行 受け付けを終える。「受付を締め切る」「論文を締め切る」 +しみる 染みる 一段 (液体、臭いなどが)ものに入りこむ。「汗が染みる、たばこの煙が目に染みる、教訓が身に染みてわかった」 +しみる 凍みる 一段 こおりつく。「寒さで身が凍みる」 +しむ 染む 五段・マ行 (液体、臭いなどが)ものに入りこむ。染みる。 +しむ 凍む 五段・マ行 こおりつく。凍みる。 +しめきる 締め切る 五段・ラ行 受け付けを終える。「受付を締め切る、論文を締め切る」 しめきる 閉め切る 五段・ラ行 閉じたままにする。「ドアを閉め切る」 -しめす 示す 五段・サ行 1. わかるように見せる。「手本を示す」「自分の力を示す」\n2. 考え・反応をあらわす。「興味を示す」 -しめす 湿す 五段・サ行 しめらせる。「のどを湿す」 +しめす 示す 五段・サ行 わかるように見せる。「手本を示す、自分の力を示す、興味を示す」 +しめす 湿す 五段・サ行 しめらす。「のどを湿す」 しめる 絞める 一段 (首などに)ものを巻きつけて力を加える。「首を絞める」 -しめる 占める 一段 1. ある場所・順位・役割にある。「上位を占める」\n2. (ある割合を)持つ。「大勢を占める」「全体の三割を占める」 -しめる 締める 一段 固定して動きにくい状態にする。「ネジを締める」 +しめる 占める 一段 独占する。「上位を占める、大勢を占める」 +しめる 締める 一段 ひきしめる。「ネジを締める、気持を引き締める」 しめる 閉める 一段 (ドアなどを)閉じる。「ドアを閉める」 -しもん 試問 * 問題を出して試すこと。「口頭試問」 -しもん 諮問 * 意見を求めること。「諮問機関」 +しもん 試問 * 試しに問う。「口頭試問」 +しもん 諮問 * (目上のものが)意見を求めること。「部下に諮問する、諮問機関」 しゃく 勺 * 容積の単位。約18ml。 -しゃく 尺 * 長さの単位。約30.3cm。 +しゃく 尺 * 長さの単位。1mの10/33。 しゃく 杓 * ひしゃく。 しゃく 酌 * 酒を杯にそそぐこと。 -しゅうがく 就学 * 学校に入り、勉強すること。「就学前の児童」 +しゅうがく 就学 * 学校に入り、勉強すること。 しゅうがく 修学 * 学問を修めること。 しゅうかん 習慣 * 日常で決まりごとのように行なわれること。 しゅうかん 週刊 * 週ごとに刊行すること。「週刊誌」 -しゅうかん 週間 * 1週のあいだ。「週間天気予報」 +しゅうかん 週間 * 7日間。「週間天気予報」 じゅうき 什器 * 日常で使用する家具。 じゅうき 銃器 * 銃の総称。 しゅうぎょう 就業 * 職に就くこと。 しゅうぎょう 修業 * 学業などを修めること。 しゅうぎょう 終業 * 業務を終えること。 -しゅうし 終始 * 1. 始めと終り。\n2. 始めから終わりまで。「終始笑顔を浮かべていた」\n3. 始めから終わりまで続けること。「試合では防戦に終始した」 +しゅうし 終始 * 始めから終りまで同じこと。「試合では防戦に終始した」 しゅうし 終止 * おわること。 しゅうしゅう 収拾 * おさめること。「事態を収拾する」 -しゅうしゅう 収集 * 〈「蒐集」の書き換え〉\n1. 趣味などのために集めること。「コインを収集する」\n※この意味では、現在も「蒐集」と書かれることがある。\n2. 集めること。「ごみの収集」 -しゅうしゅう 蒐集 * →収集 +しゅうしゅう 収集 * (「蒐集」と区別なし)あつめること。「コインを収集する」 +しゅうしゅう 蒐集 * (「収集」と区別なし)あつめること。「コインを蒐集する」 じゅうしょう 重傷 * 重い傷。「刃物で切られて重傷を負う」 じゅうしょう 重症 * 重い症状。「重症患者」 しゅうせい 修整 * ととのえなおすこと。「画像を修整する」 しゅうせい 修正 * なおして正しくすること。「軌道を修正する」 しゅうせい 集成 * あつめてまとめること。集大成。 じゅうそう 重奏 * 同時に奏でること。「四重奏」 -じゅうそう 重層 * 何層にも重なっていること。 -しゅうそく 収束 * 1. おさまりがつくこと。「事態が収束する」\n2. (数学で)関数の値がある値に近づいていくこと。「f(x)は0に収束する」 -しゅうそく 終息 * ものごとが終わること。「反乱は完全に終息した」 +じゅうそう 重層 * 何層にも重なること。 +しゅうそく 収束 * おさまりがつくこと。「f(x)は0に収束する」 +しゅうそく 終息 * ものごとが終わること。「反乱が終息に向かっている」 しゅうそく 集束 * 光が一点に集まること。 しゅうとく 収得 * 自分のものとすること。「収得罪」 しゅうとく 修得 * 学んで身につけること。 しゅうとく 拾得 * 拾うこと。「拾得物」 しゅうとく 習得 * 習って覚えること。「技術を習得する」 -しゅうよう 収容 * 特定の場所におさめること。「遺体を収容する」「収容所」 -しゅうよう 収用 * 1. とりあげて用いること。\n2. 国などが補償金を払って強制的に取得すること。「土地を収用する」 +しゅうよう 収容 * 特定の場所におさめること。「遺体を収容する、収容所」 +しゅうよう 収用 * とりあげて用いるいこと。「土地を収用する」 しゅうりょう 修了 * 一定の学業をおさめること。「高校の課程を修了する」 しゅうりょう 終了 * おわること。「ゲームを終了する」 -しゅうろく 収録 * 記録しておさめること。「この曲はこのCDに収録されている」「TV番組を収録する」 -しゅうろく 集録 * あつめて記録すること。「民話を集録する」 +しゅうろく 収録 * のせておくこと。「この曲はこのCDに収録されている、TV番組を収録する」 +しゅうろく 集録 * あつめて記録すること。 しゅかん 主幹 * 仕事の中心となる人。 -しゅかん 主観 * 自分からみた考え方。「主観的な考え方」 +しゅかん 主観 * 自分からの考え方。「主観的な考え方」 しゅくせい 粛正 * 厳しくとりしまり、不正をとりのぞくこと。 しゅくせい 粛清 * 厳しくとりしまり、反対するものを排除すること。「政敵を粛清する」 じゅけん 受検 * 検査を受けること。 じゅけん 受験 * 試験を受けること。「地元の大学を受験する」 しゅさい 主催 * 中心となって催すこと。「大会を主催する」 -しゅさい 主宰 * 中心となってまとめること。「同好会を主宰する」 -しゅし 主旨 * 主な内容。「文章の主旨」 -しゅし 趣旨 * 達成しようとする目的、ねらい。また、伝えたい内容。「会議の趣旨」「話の趣旨をつかむ」 -しゅじ 主事 * 中心となっておこなうこと。また、その人。「教育主事」 +しゅさい 主宰 * 中心となっておこなうこと。「同好会を主宰する」 +しゅし 主旨 * 主な意味。「文章の主旨」 +しゅし 趣旨 * おもむき、ねらい。「会議の趣旨」 +しゅじ 主事 * 中心となっておこなうこと。「教育主事」 しゅじ 主辞 * 主語。 じゅしょう 受賞 * 賞を受けること。「金賞を受賞する」 じゅしょう 授賞 * 賞を授けること。「授賞式」 しゅせき 主席 * 会議などを代表する人。「会議の主席をつとめる」 -しゅせき 首席 * トップの順位。また、それを取った人。「首席で卒業する」 -じゅつご 術語 * 専門用語。 +しゅせき 首席 * 一番。「首席で卒業する」 +じゅつご 術語 * 専門的な用語。 じゅつご 述語 * 主語の状態などを述べる単語。「主語と述語」 しゅっせい 出征 * 戦場に行くこと。「友人が出征する」 -しゅっせい 出生 * 〈「しゅっしょう」とも読む〉うまれること。「出生届」 +しゅっせい 出生 * うまれること。「出生届」 じゅんか 純化 * 純粋にすること。 -じゅんか 順化 * 生物が環境に適した性質を持つようになること。 -じゅんか 馴化 * 生物が環境に適した性質を持つようになること。→順化 -じゅんこう 巡航 * 1. 航海してまわること。\n2. 推進力をもって空中を移動すること。「巡航ミサイル」 -じゅんこう 巡行 * 各地をめぐること。 -じゅんずる 准ずる サ変・−ズル →準ずる +じゅんか 順化 * (「馴化」と区別なし)生物が環境に適した性質を持つこと。 +じゅんか 馴化 * (「順化」と区別なし)生物が環境に適した性質を持つこと。 +じゅんこう 巡航 * 航海してまわること。「巡航ミサイル」 +じゅんこう 巡行 * あるきまわること。 +じゅんずる 准ずる サ変・−ズル (「準ずる」と区別なし)ある基準にならう。「法律に准ずる」 じゅんずる 殉ずる サ変・−ズル あることのために死ぬこと。「職に殉ずる」 -じゅんずる 準ずる サ変・−ズル ある基準にならう。「法律に準ずる」 -じゅんりょう 純良 * 〈文語〉純粋で善良である。 -じゅんりょう 順良 * 〈文語〉従順ですなおである。 -じょする 序する サ変・−スル 〈文語〉順序を決める。 -じょする 除する サ変・−スル 〈文語〉除く。 -しょうする 称する サ変・−スル 1. 名付ける。呼ぶ。「この方法を、ここでは方法Aと称することにする」\n2. 名乗る。「妻の氏を称する」\n3. 自分でそうであると言う。「彼の友人と称する者」\n4. 〈「〜と称して」として〉〜であるという名目で。「しつけと称して虐待を行なっていた」 -しょうする 証する サ変・−スル 〈文語〉証明する。「無実を証する」 -しょうする 賞する サ変・−スル 〈文語〉賞賛する。「彼の行動を賞する」 +じゅんずる 準ずる サ変・−ズル (「准ずる」と区別なし)ある基準にならう。「法律に準ずる」 +じゅんりょう 純良 * 純粋で善良である。 +じゅんりょう 順良 * 従順ですなおである。 +じょ 序 * (文語)順序を決める。 +じょ 除 * (文語)除く。 +しょう 称 * (文語)よぶ、たたえる。「彼の友人と称する者」 +しょう 証 * (文語)証明する。「無実を証する」 +しょう 賞 * (文語)賞賛する。「彼の行動を賞する」 しょうえん 小宴 * 小さな宴。 しょうえん 招宴 * 宴に招くこと。 -しょうか 消化 * 1. 食物を胃などで分解すること。「消化酵素」\n2. たまったものをこなすこと。「日程を消化する」 +しょうか 消化 * 食物を胃などで分解すること。「消化酵素、日程を消化する」 しょうか 消火 * 火を消すこと。「消火器」 しょうがく 奨学 * 学問をすすめること。「奨学金」 しょうがく 小学 * 小学校の略。「小学生」 -しょうがく 小額 * 小さい額面。「小額紙幣」 -しょうがく 少額 * 少ない金額。「少額訴訟」 -しょうきゃく 償却 * 1. (借金などを)返し終わること。「借金を償却する」\n2. 時間にしたがって価値の失われるようなものについて、そのことを計算すること。減価償却。\n3. 金銭化の見込めなくなった資産について、それを失ったものとして処理すること。 -しょうきゃく 消却 * なくすこと。「株式を消却する」 -しょうきゃく 焼却 * 燃やして捨てること。「ゴミを焼却する」 -しょうきん 償金 * 賠償金。 -しょうきん 賞金 * 賞としての金銭。「賞金王」 -しょうさん 称賛 * 褒め称えること。 -しょうさん 賞賛 * →称賛 -しょうしゅう 召集 * (国会、軍隊などに)人を集めること。「国会を召集する」「召集令状」 -しょうしゅう 招集 * 招いて人を集めること。「会議を招集する」 +しょうがく 小額 * (「少額」と区別なし)金額が小さいこと。「小額紙幣」 +しょうがく 少額 * (「小額」と区別なし)金額が少ないこと。「少額訴訟」 +しょうきゃく 償却 * (借金などを)返すこと。「借金を償却する」 +しょうきゃく 消却 * 消しさること。「証拠を消却する」 +しょうきゃく 焼却 * 焼きすてること。「ゴミを焼却する」 +しょうきん 償金 * 賠償金のこと。 +しょうきん 賞金 * 賞としての金銭のこと。「賞金王」 +しょうさん 称賛 * (「賞賛」と区別なし) +しょうさん 賞賛 * (「称賛」と区別なし) +しょうしゅう 召集 * (国会、軍隊などに)人を集めること。「国会を召集する、召集令状」 +しょうしゅう 招集 * 人を集めること。「会議を招集する」 しょうしゅう 消臭 * 臭いを消すこと。「消臭剤」 -じょうじょう 上々 * 〈「上乗」とも〉この上もなくよいこと。「気分は上々」「上々の出来」 -じょうじょう 上乗 * 1. 「大乗」に同じ。仏教流派のひとつ。\n2. →上々 +じょうじょう 上々 * このうえもないこと。「気分は上々」 +じょうじょう 上乗 * 最もすぐれていること。「上乗の出来」 しょうすう 小数 * 整数でない実数。「小数点」 しょうすう 少数 * 数が少ないこと。「少数派」 じょうすう 乗数 * かけ算での掛ける数。 -じょうすう 常数 * 「定数」に同じ。 -しょうずる 招ずる サ変・−ズル 〈文語〉もてなす。「客を招ずる」 -しょうずる 生ずる サ変・−ズル 発生する。「誤解が生ずる」 +じょうすう 常数 * 状態変化において、変わらない値のこと。 +しょうずる 招ずる サ変・−ズル (文語)もてなす。「客を招ずる」 +しょうずる 生ずる サ変・−ズル (文語)発生する。「誤解が生ずる」 じょうたい 常態 * 通常の状態。 じょうたい 状態 * ものごとの様子。「状態変化」 しょうらん 照覧 * (神などが)ごらんになること。「ご照覧あれ」 -しょうらん 笑覧 * 笑いながら見ること(人に自分のものを見てもらう時にへりくだって言う)。「ご笑覧ください」 -しょくする 嘱する サ変・−スル 〈文語〉望みを託す。「将来を嘱されている」 -しょくする 食する サ変・−スル 食べる。「海の幸を食する」 -しょくする 属する サ変・−スル 〈文語〉\n1. 属(ぞく)する。\n2. 嘱する。 +しょうらん 笑覧 * わらいながら見ること。 +しょく 嘱 * (文語)(「属する」と区別なし)たのむ。「将来を嘱されている」 +しょく 食 * (文語)たべる。「海の幸を食する」 +しょく 属 * (文語)(「嘱する」と区別なし)たのむ。「将来を属されている」 しょくぜん 食前 * 食べる前のこと。「食前酒」 しょくぜん 食膳 * 食事を載せた膳。「食膳に上る」 しょくりょう 食料 * 食べ物。「生鮮食料品」 -しょくりょう 食糧 * 食べ物。特に、主食。「食糧管理法」 -じょする 叙する サ変・−スル 〈文語〉\n1. 叙述する。\n2. (地位を)授ける。(地位に)つける。「元帥に叙する」 -じょする 恕する サ変・−スル 〈文語〉許す。 -じょせい 助勢 * 力を貸すこと。 -じょせい 助成 * 成功に導くため援助すること。「研究の助成金」 +しょくりょう 食糧 * 食べ物、主食。「食糧管理法」 +じょする 叙する サ変・−スル (文語)叙述する。 +じょする 恕する サ変・−スル (文語)許す。 +じょせい 助勢 * たすけること。 +じょせい 助成 * たすけて成功させること。「研究の助成金」 しょとう 初冬 * 冬の初め。 しょとう 初等 * 最初の等級。「初等教育」 しょとう 初頭 * はじめのころ。「80年代初頭に」 しょとう 諸島 * 島々。「小笠原諸島」 -しょよう 所用 * 用事。「所用のため欠席する」 -しょよう 所要 * 必要となるものや時間など。「所要時間」 -しる 知る 五段・ラ行 1. ものごとの意味、内容がわかる。「事実を知る」「知る人ぞ知る逸品」\n2. 経験して身につける。「酒の味を知る」 -しれい 司令 * (軍隊などで)指揮をとること。また、その人。「司令官」 +しょよう 所用 * 用事があること。「所用のため欠席する」 +しょよう 所要 * 必要であるもの、こと。「所要時間」 +しる 知る 五段・ラ行 ものごとの意味、内容がわかる。「事実を知る、酒の味を知る、知る人ぞ知る逸品」 +しれい 司令 * (軍隊などで)指揮をとる人。「司令官」 しれい 指令 * 命令。「特攻の指令を出す」 しんい 深意 * 深い意味。 しんい 真意 * 本当の意向。「彼の真意がわからない」 しんか 深化 * 深くなる。「対立が深化する」 -しんか 進化 * (生物などが)時間とともに変わっていき、発展する。「魚類が進化して両生類となった」「技術が進化する」 -しんこく 申告 * 申し出ること。「確定申告」 +しんか 進化 * 進歩する。「猿が進化して人類となる、技術が進化する」 +しんこく 申告 * 申し告げること。「確定申告」 しんこく 親告 * みずから告げること。「親告罪」 しんしゅつ 侵出 * 境界を越えて進出すること。「他国に侵出する」 しんしゅつ 浸出 * にじみ出ること。「浸出液」 -しんしゅつ 進出 * 進み出ること。「販路拡大のため海外に進出する」 -しんしゅつ 滲出 * にじみ出ること。→浸出 -しんしょく 侵食 * 徐々に侵すこと。 -しんしょく 侵蝕 * 徐々に侵すこと。→侵食 -しんしょく 浸食 * 水などが徐々に土を削ること。「海岸が浸食されていく」 -しんしょく 浸蝕 * 水などが徐々に土を削ること。「海岸が浸蝕されていく」→浸食 +しんしゅつ 進出 * 進み出ること。「海外に進出する」 +しんしゅつ 滲出 * しみ出ること。「滲出液」 +しんしょく 侵食 * (「侵蝕」と区別なし)徐々に侵すこと。 +しんしょく 侵蝕 * (「侵食」と区別なし)徐々に侵すこと。 +しんしょく 浸食 * (「浸蝕」と区別なし)水などが徐々に土を削ること。「海岸が浸食されていく」 +しんしょく 浸蝕 * (「浸食」と区別なし)水などが徐々に土を削ること。「海岸が浸蝕されていく」 しんずい 心髄 * 中心。 -しんずい 真髄 * 〈「神髄」とも〉本質。「武士道の真髄を究める」 -しんずい 神髄 * 〈「真髄」とも〉本質。「武士道の神髄を究める」 -しんずる 信ずる サ変・−ズル 〈文語〉正しいと考える。「神々を信ずる」 -しんずる 進ずる サ変・−ズル 〈文語〉差し上げる。進上する。 +しんずい 真髄 * (「神髄」と区別なし)そのことの本質。「武士道の真髄を究める」 +しんずい 神髄 * (「真髄」と区別なし)そのことの本質。「武士道の神髄を究める」 +しんずる 信ずる サ変・−ズル (文語)正しいと考える。「神々を信ずる」 +しんずる 進ずる サ変・−ズル (文語)進上する。 しんそう 深層 * 深い層。「海洋深層水」 -しんそう 深窓 * 家の奥深い部屋。転じて、上流階級の家庭環境。「深窓の令嬢」 -しんそう 真相 * 真実のの事情。「事件の真相を知る」 -しんてん 伸展 * 1. 発達して広がること。「商業が伸展する」\n2. 曲がっていたものをまっすぐにすること。「下肢を伸展する」\n3. 引っ張られて長くなること。「皮膚の伸展」 -しんてん 進展 * 時間とともに事態が展開していくこと。「状況が進展する」 -しんどう 振動 * ゆれ動くこと。「振り子の振動」 -しんどう 震動 * ふるえること。「家が震動する」\n※小さなものに対して「ふるえる」の意味で「振動」を使うことも多い。「携帯電話が振動する」 -しんにゅう 侵入 * 領域を侵して入ること。「不法侵入」 -しんにゅう 浸入 * 水などが入ること。「雨水が浸入する」 -しんにゅう 進入 * 進み入ること。「交差点に進入する」 +しんそう 深窓 * 家の奥にある居間。 +しんそう 真相 * 知らなかった真実。「事件の真相を知る」 +しんてん 伸展 * のばし展開すること。 +しんてん 進展 * 進歩して発展すること。「状況が進展する」 +しんどう 振動 * 振り動くこと。「携帯が振動する」 +しんどう 震動 * ゆれること。「家が震動する」 +しんにゅう 侵入 * 侵し入ること。「不法侵入」 +しんにゅう 浸入 * 水などが入ること。 +しんにゅう 進入 * 進み入ること。 しんり 心理 * 心の状態。「被害者心理」 -しんり 真理 * 変わらない真実。「真理を探究する」 -すいか 垂下 * 〈文語〉垂れ下がること。垂れ下げること。 -すいか 誰何 * 呼び止めて誰であるかを問うこと。「守衛に誰何される」 +しんり 真理 * まことのこと。「真理を探究する」 +すいか 垂下 * たれさがること。 +すいか 誰何 * 自分が誰かを問われること。 すいこう 推考 * 推測して考えること。「原因を推考する」 -すいこう 推敲 * 時間をかけて文章を練ること。「文章を推敲する」 +すいこう 推敲 * 文章を練り直すこと。「文章を推敲する」 すいこう 遂行 * なしとげること。「任務を遂行する」 -すいしょう 推奨 * 良いとして相手にすすめること。「動作環境は以下を推奨する」 -すいしょう 推賞 * ほめること。「彼の描いた作品を推賞する」 +すいしょう 推奨 * すすめること。「動作環境は以下を推奨する」 +すいしょう 推賞 * ほめてすすめること。「彼の描いた作品を推賞する」 すいとう 水稲 * 水田で栽培される稲。 -すいとう 水筒 * 水などを入れる携帯用の容器。 -すいほう 水泡 * 水のあわ。転じて、むだになること。「苦労が水泡に帰す」 +すいとう 水筒 * 水を入れる筒。 +すいほう 水泡 * 水のあわ。「苦労が水泡に帰す」 すいほう 水疱 * 水ぶくれ。 -すう 吸う 五段・ワ行促音便 気体や液体、また雑物などを内部に取りこむ。吸引する。「息を吸う」「煙を吸う」「掃除機でゴミを吸う」 -すき 隙 * 1. 付け入る余地。油断。「隙を見せる」\n2. 〈「〜した隙に」として〉うっかり〜している間に。「目を離した隙に重要な場面を見逃した」 -すき 鋤 * スコップに似た、人手で土を耕す農具。 +すう 吸う 五段・ワ行促音便 気体、液体を口または鼻から体内に取りこむ。「息を吸う、煙を吸う、掃除機がゴミを吸い込む」 +すき 隙 * すきま。「隙を見せる」 +すき 鋤 * 土を耕す農具。 すき 犁 * 馬、牛などに引かせて土を掘り起こす農具。 -すく 空く 五段・カ行イ音便 中身が減って空間ができる。「電車が空く」「おなかが空く(=空腹になる)」「手が空く(=することに余裕ができる)」 -すく 好く 五段・カ行イ音便 〈文語〉好きになる。「ギャンブルは好かない」 -すく 漉く 五段・カ行イ音便 〈かな書きも〉紙をつくる。「和紙を漉く」 -すく 透く 五段・カ行イ音便 〈文語〉物と物の間にすきまができる。「壁の間が透いている」 -すくう 掬う 五段・ワ行促音便 〈かな書きも〉くぼんだもので、液体や粉末・それに含まれるものを取る。「手で水を掬う」「金魚を掬う」 -すくう 救う 五段・ワ行促音便 危険、困難などから助ける。「窮地を救う」「世を救う」 -すくう 巣くう 五段・ワ行促音便 〈「巣食う」とも〉よくないものが根を下ろす。「町に巣くう悪者」 -すくう 巣食う 五段・ワ行促音便 〈「巣くう」とも〉よくないものが根を下ろす「町に巣食う悪者」 -すず 錫 * 〈カタカナ書きが普通〉元素の一つ。またはその金属。 +すく 空く 五段・カ行イ音便 ものの中にすきまができる。「おなかが空く、電車が空く、手が空く」 +すく 好く 五段・カ行イ音便 好きになる。「ギャンブルは好かない」 +すく 漉く 五段・カ行イ音便 紙をつくる。「和紙を漉く」 +すく 透く 五段・カ行イ音便 物と物の間にすきまができる。「壁の間が透いている、」 +すくう 掬う 五段・ワ行促音便 液体をさじなどにとる。「手で水を掬う、金魚を掬う」 +すくう 救う 五段・ワ行促音便 危険、困難などから助ける。「窮地を救う、世を救う」 +すくう 巣食う 五段・ワ行促音便 巣を作る。「町に巣食う悪者」 +すず 錫 * 元素の一つ。またはその金属。 すず 鈴 * 小さい玉を金属などでできた球形のものに入れ、振ると音がなるもの。「ネコの首に鈴を付ける」 -すすめる 勧める 一段 〈「奨める」とも〉\n1. 物を示し、使う・食べるように促す。「ワインを勧める」\n2. 行動をとるようにさそう。「退社するように勧める」「受診を勧める」\n3. 〈「薦める」とも〉物について、良いとして採用を促す。「新商品を勧める」 -すすめる 奨める 一段 →勧める -すすめる 進める 一段 前に出す。前に動かす。「コマを進める」「交渉を進める」「社内の効率化を進める」 -すすめる 薦める 一段 (人や物を)良いとして採用を推薦する。「新商品を薦める」「適任者として2人を薦める」\n※物については、多く「勧める」とされる。 +すすめる 勧める 一段 (「奨める」と区別なし)そうするようにさそう。「退社するように勧める」 +すすめる 奨める 一段 (「勧める」と区別なし)そうするようにさそう。「退社するように奨める」 +すすめる 進める 一段 前に出す。「コマを進める、交渉を進める、社内の効率化を進める」 +すすめる 薦める 一段 推薦する。「新商品を薦める」 すます 済ます 五段・サ行 終わらせる。「仕事を済ませる」 -すます 澄ます 五段・サ行 (液体などを)すきとおらせる。「泥水を澄ます」「耳を澄ます(=注意深く聞く)」 +すます 澄ます 五段・サ行 (液体などを)すきとおらせる。「泥水を澄ませる、耳を澄ませる」 すむ 済む 五段・マ行 終わる。「もう仕事は済んだ」 -すむ 住む 五段・マ行 ある場所で生活する。「彼は東京に住んでいる」「森に住むキツネ」 +すむ 住む 五段・マ行 ある場所で生活する。「彼は東京に住んでいる」 すむ 澄む 五段・マ行 (液体が)すきとおる。「この湧き水はとても澄んでいる」 -すむ 棲む 五段・マ行 「住む」に同じ。特に、動物などが巣で生活する。「森に棲むキツネ」「彼は東京に棲んでいる」 -する 刷る 五段・ラ行 印刷する。「本を刷る」 -する 擦る 五段・ラ行 1. こすり合わせる。「足を擦って歩く」\n2. 〈主にかな書き〉お金を安易に使ってなくす。「競馬で金をする」 -する 摺る 五段・ラ行 →刷る +すむ 棲む 五段・マ行 (動物などが)巣で生活する。「キツネは森に棲んでいる」 +する 刷る 五段・ラ行 (「摺る」と区別なし。一般的)印刷する。「本を刷る」 +する 擦る 五段・ラ行 物と物をこすり合わせる。「足を擦って歩く、競馬で金を擦る」 +する 摺る 五段・ラ行 (「刷る」と区別なし)印刷する。「本を摺る」 すわる 座る 五段・ラ行 腰をおろす。「いすに座る」 -すわる 据わる 五段・ラ行 安定する。「赤ん坊の首が据わる」「彼は腹が据わっている」 -せいする 制する サ変・−スル 1. おさえこむ。「騒ぎを制する」\n2. 支配する。「過半数を制する」\n3. 〈文語〉制定する。「法を制する」 -せいする 征する サ変・−スル 〈文語〉征伐する。「敵を征する」 -せいいく 成育 * 育って成長すること。動物が育つこと。「魚が成育する」 -せいいく 生育 * 生まれ育つこと。植物が生え育つこと。「農作物が生育する」 -せいかい 正解 * 正しい解答。また、それを言うこと。「クイズに正解した」 -せいかい 精解 * 〈文語〉詳しく解釈すること。 -せいけい 成形 * 形をつくること。「粘土を成形する」 -せいけい 整形 * (特に手術で)形を整えること。「整形手術」 +すわる 据わる 五段・ラ行 安定する。「赤ん坊の首が据わる、彼は腹が据わっている」 +せい 制 * おさえこむ。「騒ぎを制する、過半数を制する」 +せい 征 * (文語)征伐する。「敵を征する」 +せいいく 成育 * そだつこと。「魚が成育する」 +せいいく 生育 * 生まれ育つこと。「農作物が生育する」 +せいかい 正解 * 正しい解答。「クイズに正解した」 +せいかい 精解 * (文語)詳しく解釈すること。 +せいけい 成形 * 形をつくること。「ねんどを成形する」 +せいけい 整形 * 形を整えること。「整形手術」 せいけん 政権 * 政治上の権力。「政権政党」 せいけん 政見 * 政治上の意見。「政見放送」 -せいさく 制作 * (特に美術品などを)作ること。「絵画を制作する」「映画を制作する」\n※映像作品については「製作」とも。 -せいさく 製作 * 1. (特に工業品などを)作ること。「機械を製作する」\n2. (映像作品などを)作ること。「映画を製作する」\n※「制作」とも。 -せいさん 清算 * 1. 金銭の貸し借りを整理すること。「借金を清算する」\n2. けりをつけ、それに対する後始末を行うこと。「事業を清算する」「過去を清算する」 -せいさん 精算 * 請求金額などを計算すること。また、その金額を払うこと。「運賃を精算する」「経費を精算する」 -せいし 制止 * おさえて止めること。「暴動を制止する」「制止をふりきる」 -せいし 静止 * 止まってそのままでいること。「静止衛星」 +せいさく 制作 * 美術品などを作ること。「絵画を制作する」 +せいさく 製作 * 工業品などを作ること。「機械を製作する」 +せいさん 清算 * 金銭の貸し借りを整理すること。「事業を清算する、過去を清算する」 +せいさん 精算 * 金額などを細かく計算すること。「運賃を精算する」 +せいし 制止 * おさえて止めること。「暴動を制止する、制止をふりきる」 +せいし 静止 * 止まって静かにすること。「静止衛星」 せいしょう 清勝 * 手紙などで相手が健康で暮していることを祝う語。 -せいしょう 清祥 * 手紙などで相手が幸せに暮していることを祝う語。 -せいすう 整数 * 1に1を複数回足したり引いたりしてできる数。3, -5など。 -せいすう 正数 * 0よりも大きな数。2.5, 8など。 -せいねん 成年 * 1. 充分に成熟し、法律行為を単独で行うことができると規定された年齢。日本では満二十歳。また、それに達すること。また、それに達した人。「成年に達する」「今年成年する男女」「成年には選挙権が与えられる」\n2. 充分に成熟したと見なされる年齢。また、それに達すること。また、それに達した人。「成年用の予防接種」 -せいねん 青年 * 1. 青春期の男性。「一人の青年がたたずんでいた」\n2. 〈主に複合語で〉青春期の男女。「青年海外協力隊」 -せいひ 成否 * 成功するか否か。「法案の成否がかかっている」 -せいひ 正否 * 正しいか否か。「解答の正否を確認する」 +せいしょう 清祥 * 手紙などで相手が元気で暮していることを祝う語。 +せいすう 整数 * 1,-253など1に1を複数回足したり引いたりしてできる数。 +せいすう 正数 * 0よりも大きな数。 +せいねん 成年 * 日本の法律では二十歳。 +せいねん 青年 * 青年期の男女。「二十歳の青年」 +せいひ 成否 * 成功するか否か。 +せいひ 正否 * 正しいか否か。 せいめい 清明 * 清く明らかなこと。 -せいめい 声明 * 意見などを明らかにすること。「政府が声明を出す」「犯行の声明文」 -せいやく 制約 * (行動などを)制限すること。「彼の行動を制約する」 +せいめい 声明 * 意見などを明らかにすること。「政府が声明を出す、犯行の声明文」 +せいやく 制約 * 約束で行動などを制限すること。「彼の行動を制約する」 せいやく 成約 * 契約が成立すること。「保険が成約する」 せいやく 誓約 * 誓って約束すること。「誓約書」 -せじ 世事 * 世の中の事。「世事に疎い」 -せじ 世辞 * 相手を喜ばせるために、心にもないことを言うこと。多く「お世辞」として使う。「世辞を言う」 -せっしゅ 接種 * 免疫力をつけるために、ウィルス、ワクチンなどを体内に入れること。「予防接種」 -せっしゅ 摂取 * (体内に)とりいれること。「栄養を摂取する」 -せってん 接点 * 1. 曲線や曲面、直線などが一点で接するとき、その点。「曲線Aと直線Bとの接点」\n2. かかわり。「犯人との接点」 -せってん 節点 * 接合されている点。ノード。 +せじ 世事 * 世の中の事。 +せじ 世辞 * 相手をよろこばせようとする言葉。「世辞を言う」 +せっしゅ 接種 * ウィルス、ワクチンなどを体内にとり入れること。「予防接種」 +せっしゅ 摂取 * とりいれること。「栄養を摂取する」 +せってん 接点 * 共通する点。「曲線Aと直線Bとの接点、犯人との接点」 +せってん 節点 * 定常波で振幅が最小になる点。 せめる 攻める 一段 攻撃する。「敵を攻める」 -せめる 責める 一段 1. 言葉であやまちをとがめる。「彼の無責任さを責める」\n2. 苦しませる。「捕虜を責める」 -せんする 宣する サ変・−スル 〈文語〉宣言する。 -せんする 撰する サ変・−スル 〈文語〉編纂する。 -せんい 線維 * 〈医学・生物学で〉生物を構成するもので糸状のもの。「神経線維」 +せめる 責める 一段 あやまちをとがめる。「彼の無責任さを責める、捕虜を責める」 +せん 宣 * (文語)宣言する。 +せん 撰 * (文語)編纂する。 +せんい 線維 * 生物を構成するもので糸状のもの。「神経線維」 せんい 繊維 * 細く糸状の物質。「食物の繊維質」 -せんか 戦果 * 戦いにおける成果。「大きな戦果を得た」 -せんか 戦火 * 戦争による火災。また、戦争。「戦火がせまる」 +せんか 戦果 * 戦いで得たもの。「大きな戦果を得た」 +せんか 戦火 * 戦争による火災。「戦火がせまる」 せんか 戦禍 * 戦争の被害。「戦禍をこうむる」 ぜんかい 全壊 * 全て壊れること。「校舎が全壊した」 ぜんかい 全快 * すっかり治ること。「病気が全快した」 -ぜんかい 全開 * 1. 全部開いていること。「窓を全開にする」\n2. 〈接尾語〉〈口語〉隠さずさらけ出すこと。丸出し。「本音全開のトーク」 -ぜんしん 前進 * 前に進むこと。「隊列が前進する」「買収交渉が前進した」 +ぜんかい 全開 * 全部開くこと。「窓を全開にする」 +ぜんしん 前進 * 前に進むこと。「隊列が前進する、買収交渉が前進した」 ぜんしん 漸進 * 順を追ってすこしずつ進むこと。「漸進的」 -せんたん 先端 * 1. とがった端。「鉛筆の先端」\n2. もっとも新しく進んだところ。「先端技術」 -せんたん 尖端 * →先端 +せんたん 先端 * ものの一番先。「先端技術」 +せんたん 尖端 * とがった端。「尖端的」 せんたん 戦端 * 戦争のきっかけ。 せんだん 栴檀 * ビャクダンの総称。 せんだん 船団 * 船の集団。「タンカーの船団」 せんてい 選定 * 選び定める。「請負業者を選定する」 せんてい 剪定 * 枝を切り、果物がよく育つようにすること。「木を剪定する」 せんみん 賎民 * いやしい民。 -せんみん 選民 * 選ばれた民族。「選民主義」 -せんもう 繊毛 * 細胞表面の微細な毛。「繊毛運動」 +せんみん 選民 * 民族を選ぶこと。「選民主義」 +せんもう 繊毛 * 細かい毛。「繊毛運動」 せんもう 剪毛 * 羊などの毛を刈りとること。 せんもう 譫妄 * 軽い意識障害。 -せんゆう 占有 * 1. ひとりで持つこと。独占。「生産手段を占有する」\n2. 自分のものとして所持すること。「物件を占有する人」\n3. (割合などを)占めること。「市場占有率」 -せんゆう 専有 * 共有せず、独立して所有すること。「マンションの個人専有部分」 +せんゆう 占有 * 自分のものにすること。「トイレを占有する」 +せんゆう 専有 * 一人で所有すること。「部屋の専有部分」 せんりょ 千慮 * いろいろと考えること。 せんりょ 浅慮 * あさはかな考え。 -そうする 奏する サ変・−スル 〈文語〉奏上する、演奏する。「お囃子を奏する」 -そうする 相する サ変・−スル 〈文語〉うらなう。 -そうする 草する サ変・−スル 〈文語〉草案を作成する。「提言書を草する」 +そう 奏 * (文語)奏上する、演奏する。「お囃子を奏する」 +そう 相 * (文語)うらなう。 +そう 草 * (文語)草案を作成する。「提言書を草する」 そうい 創意 * 新しいものを作る気持ち。「創意工夫」 そうい 創痍 * きず。「満身創痍」 -そうかい 壮快 * 大胆で快いこと。「壮快な気質」 -そうかい 爽快 * さわやかで快いこと。「爽快な喉越し」 -そうかつ 総括 * 1. (情報などを)まとめること。「講演を総括する」\n2. 振り返って評価・反省すること。「近代史を総括する」\n3. 〈「総轄」とも〉(部署などを)管理すること。「事務を総括する」 -そうかつ 総轄 * (部署などを)管理すること。「事務を総轄する」→総括 +そうかい 壮快 * 元気で快いこと。 +そうかい 爽快 * さわやかで快いこと。 +そうかつ 総括 * 全体をしめくくること。「講演を総括する」 +そうかつ 総轄 * 全体をとりまとめること。「総轄責任者」 そうかん 創刊 * 雑誌などを新しく出版すること。「週刊誌を創刊する」 そうかん 相姦 * 倫理に反する性交。「近親相姦」 -そうかん 相関 * 互いに関係しあうこと。「相関関係」 -そうかん 送還 * (特に、外国人を本国に)送りかえすこと。「強制送還」 +そうかん 相関 * 互いに関係し合うこと。「相関関係」 +そうかん 送還 * 送りかえされること。「強制送還」 そうぎょう 創業 * 事業を新しく始めること。「会社の創業者」 -そうぎょう 操業 * 機械などを操り、仕事をすること。また、一般に業務を行うこと。「操業中の工場」「自転車操業」 -ぞうけい 造形 * 形を造ること。また、造った形。「金属を造形する」「造形が美しい」 -ぞうけい 造詣 * ある分野の深い知識や経験。「造詣が深い」 -そうさ 捜査 * (警察などが)事件について調べること。「犯罪捜査」 -そうさ 操作 * (機械などを)操って動かすこと。「コンピュータを操作する」 -そうさ 走査 * テレビなどで、画面を部分的に更新していくこと。「走査線」 +そうぎょう 操業 * 機械などを操り、仕事をすること。「自転車操業」 +ぞうけい 造形 * (芸術品などを)かたち造ること。「金属を造形する」 +ぞうけい 造詣 * 学問、技術などに優れていること。「造詣が深い」 +そうさ 捜査 * 捜して調べること。「犯罪捜査」 +そうさ 操作 * 機械などを操って動かすこと。「コンピュータを操作する」 +そうさ 走査 * テレビなどで画面を部分的に更新していく操作。「走査線」 そうしゃ 掃射 * 機関銃などを敵全体に発射すること。「機銃掃射」 -そうしゃ 操車 * 列車などを路線に配置すること。「操車場」 -そうそう 早々 * 1. 急ぐさま。「早々に引き上げる」\n2. すぐ。「転校早々遅刻した」 -そうそう 草々 * 1. いい加減なようす。「草々に確認を終える」\n2. 手紙の末尾に、簡略であることをわびるために添える語。 -そうと 壮図 * 〈文語〉壮大な企て。 -そうと 壮途 * 〈文語〉勇ましくさかんな門出。 +そうしゃ 操車 * 電車の車両を路線に入れたり出したりすること。「操車場」 +そうそう 早々 * 急ぐさま。「早々に引き上げる」 +そうそう 草々 * 忙しいさま。「草々不一」 +そうと 壮図 * 壮大な企て。 +そうと 壮途 * 勇ましくさかんな門出。 そくとう 即答 * すぐに答えること。「質問に即答する」 そくとう 速答 * すみやかに答えること。 -ぞくとう 続投 * 1. 野球などで、投手が続けて投げること。「上原が続投する」\n2. 続けて任にあたること。「幹事長の続投が決まった」 -ぞくとう 続騰 * 物価、株価などが継続して上がること。「株価が続騰する」 +ぞくとう 続投 * 続けて投げること。「上原が続投する、幹事長の続投が決まった」 +ぞくとう 続騰 * 物価、株価などが続けて上がること。「株価が続騰する」 そしゃく 租借 * 他国の領土を借りること。「租借地」 -そしゃく 咀嚼 * 1. かみくだくこと。「食べ物を咀嚼する」\n2. よく理解すること。「文章の内容をよく咀嚼している」 +そしゃく 咀嚼 * かみくだくこと。「食べ物を咀嚼する、文章の内容をよく咀嚼している」 そじょう 訴状 * 訴える内容が書かれた文書。 そじょう 俎上 * まないたの上。「俎上の魚」 そなえる 供える 一段 神仏にお供物をさしあげる。 そなえる 備える 一段 準備する。 -そめる 初める 一段 〈文語、動詞連用形の後で〉…しはじめる。「咲き初める(=咲き始める)」 -そめる 染める 一段 色をつける。「布を染める」「頬を染める(=頬を赤くする)」 -そらす 逸らす 五段・サ行 〈かな書きも〉はずす。「目を逸らす」「ボールを逸らす」 -そらす 反らす 五段・サ行 後ろへそらせる。「胸を反らす」 -そる 剃る 五段・ラ行 〈かな書きも〉体毛などを、刃物を表面に斜めに当てて根元から切り落とす。「ひげを剃る」 -そる 反る 五段・ラ行 曲がる。「大きく反っている刀」 -たいする 体する サ変・−スル 〈文語〉心にとめて守る。「教えを体する」 -たいする 対する サ変・−スル 1. 〈文語〉面と向かう。「敵に対する」\n2. 〈「~に対する」として、連体形・連用形で〉~を対象とする。~に対応する。「彼に対する評価」「その抗議に対して回答する」 -たいする 帯する サ変・−スル 〈文語〉身につける。「小刀を帯する」 -たいしょう 対症 * 症状に対処すること。「対症療法」 -たいしょう 対称 * 互いに対応して、つりあいがとれていること。「左右対称」 -たいしょう 対象 * 扱おうとするもの。「対象年齢」「質問の対象」 -たいしょう 対照 * 1. 照らし合わせること。「原本と複写を対照して確認する」\n2. 複数の異なるものを並べることによって得られる印象。また、異なること。「主人公とライバルの対照が面白い」「対照的な性格」 -たいせい 体制 * 仕組み。システム。また、社会の中心となる仕組み。「チェック体制」「反体制組織」 -たいせい 体勢 * 体の姿勢。「相手のキックで体勢を崩した」 -たいせい 態勢 * 物事に対する身構えや準備。「受け入れ態勢を整える」 -たいせい 大勢 * 1. おおよその形勢。「選挙結果の大勢が判明する」\n2. 大きな流れ。「社会の大勢に流される」 -たいせき 堆積 * 積み重なること。「土砂が堆積する」 -たいせき 滞積 * 〈まれ〉滞り、積もること。「仕事が滞積する」→堆積 -たえる 堪える 一段 1. 〈「耐える」とも〉その価値がある。「鑑賞に堪える作品」「見るに堪えない(=見ていられないほどひどい)」\n2. 〈「耐える」とも〉要件を満たす。「実用に堪える」 -たえる 絶える 一段 とだえる。続いていた流れなどが止まる。「息が絶える」「血筋が絶える」 -たえる 耐える 一段 〈「堪える」とも〉\n1. 我慢する。「痛みを耐える」\n2. もちこたえる。「水圧に耐える製品」 -たく 炊く 五段・カ行イ音便 (米などを)煮て食べられるようにする。「ご飯を炊く」 -たく 焚く 五段・カ行イ音便 〈かな書きも〉\n1. 火をつけて燃やす。また、それによって熱する。「まきを焚く」「風呂を焚く」\n2. (カメラのフラッシュを)点灯させる。 -たこ 凧 * 骨組みに紙などを張りひもをつけ、空気の力で空に飛ばす玩具。 -たこ 蛸 * 〈カタカナ書きも〉八本足の軟体動物。「蛸の刺身」 +そめる 初める 一段 はじまる。「見初める」 +そめる 染める 一段 色をつける。「布を染める、頬を染める」 +そらす 逸らす 五段・サ行 はずす。「目を逸らす、ボールを逸らす」 +そらす 反らす 五段・サ行 後ろへそる。「胸を反らす」 +そる 剃る 五段・ラ行 体毛などを根元から切る。「髭を剃る」 +そる 反る 五段・ラ行 のけぞる。「大きく反っている刀」 +たい 体 * (文語)心にとめて守る。「教えを体する」 +たい 対 * 面と向かう。「敵に対する、彼に対する態度、その抗議に対する回答」 +たい 帯 * (文語)身につける。「小刀を帯する」 +たいしょう 対症 * 症状に対すること。「対症療法」 +たいしょう 対称 * 互いに対応していること。「左右対称」 +たいしょう 対象 * 活動などが向けられるもの。「対象年齢、質問の対象」 +たいせい 体勢 * 姿勢。「体勢をくずす」 +たいせい 態勢 * 物事に対する身構え。「体勢を整える」 +たいせい 大勢 * おおよその形勢。「大勢が判明する」 +たいせき 堆積 * 積み重なること。「土壌が堆積する」 +たいせき 滞積 * 滞り、積もること。「仕事が滞積する」 +たえる 堪える 一段 我慢する。「苦痛に堪える、見るに堪えない」 +たえる 絶える 一段 とだえる。「息が絶える、血筋が絶える」 +たえる 耐える 一段 もちこたえる。「水圧に耐える、長期の使用に耐えうる。」 +たき 滝 * (「瀧」と区別なし) +たき 瀧 * (「滝」と区別なし) +たく 炊く 五段・カ行イ音便 (米などを)煮る。「御飯を炊く」 +たく 焚く 五段・カ行イ音便 火を燃やす。「たきびを焚く」 +たこ 凧 * 紐がつき、風で空にあがる玩具。 +たこ 蛸 * 八本足の軟体動物。「蛸足配線」 たさい 多彩 * 種類が多く、にぎやかなこと。「多彩な顔ぶれ」 たさい 多才 * さまざまなことに才能が豊かなこと。「多才な人」 -たしょう 他生 * 前世と来世。「他生の縁(=前世までの縁)」〈「多生の縁」とも〉 -たしょう 多生 * 何度も生まれ変わること。「多生の縁(=前世までの縁)」〈「他生の縁」とも〉 -たしょう 多少 * 1. 多いか少ないかの程度。「多少にかかわらずお持ちください」\n2. 多くない様子。少し。「多少のことには目をつぶります」 +たしょう 他生 * 他が原因となり発生すること。 +たしょう 多少 * 多いことと少ないこと。「多少のことには目をつぶります」 たしょう 多祥 * よろこびの多いこと。 たずねる 尋ねる 一段 質問する。「道を尋ねる」 たずねる 訪ねる 一段 おとずれる。「知人の家を訪ねる」 たたえる 称える 一段 称賛する。「勝利を称える」 -たたえる 湛える 一段 〈かな書きも〉\n1. 水などをいっぱいに満たす。「豊かな水を湛える湖」\n2. 表情を顔いっぱいに表す。「満面の笑みを湛える」 -たたかう 戦う 五段・ワ行促音便 〈「闘う」とも〉勝とうとして、または自分の要求を通すために、争う。「決勝戦を戦う」「敵国と戦う」「偏見と戦う」「病魔と戦う」 -たたかう 闘う 五段・ワ行促音便 「戦う」に同じ。精神的な面を強調するときに好んで使われる。「偏見と闘う」「病魔と闘う」 -たたく 叩く 五段・カ行イ音便 1. 手で打つ。「頭を叩く」「肩を叩く」\n2. (くだらないことを)言う。「へらず口を叩く」 -ただす 質す 五段・サ行 質問する。「行動の目的を質す」 -ただす 正す 五段・サ行 正しくする。「過ちを正す」「えりを正す」 +たたえる 湛える 一段 じゅうぶんに満たす。「満面の笑みを湛える、豊かな水を湛える湖」 +たたかう 戦う 五段・ワ行促音便 (戦争やスポーツなどにおいて)あらそう。「決勝戦を戦う、敵国と戦う」 +たたかう 闘う 五段・ワ行促音便 (困難や対立する人と)あらそう。「重病と闘う」 +たたく 叩く 五段・カ行イ音便 なぐる。「頭を叩く、肩を叩く、へらず口を叩く」 +ただす 質す 五段・サ行 質問する。「彼を問い質す」 +ただす 正す 五段・サ行 正しくする。「不正を正す、襟を正す」 たたむ 畳む 五段・マ行 折り重ねる。「洗濯物を畳む」 -たつ 起つ 五段・タ行 決起する。→立つ4 +たつ 起つ 五段・タ行 起き上がる。「髪が起つ」 たつ 経つ 五段・タ行 (時間が)経過する。「時が経つ」 たつ 建つ 五段・タ行 (建物が)つくられる。「ビルが建つ」 たつ 裁つ 五段・タ行 (布などを)裁断する。「布を裁つ」 -たつ 絶つ 五段・タ行 1. 続いていた流れなどを止める。「供給を絶つ」「命を絶つ」\n2. (連絡などが)なくなる。「航空機が消息を絶った」\n3. 〈「断つ」とも〉(関係などを)なくす。「関係を絶つ」 -たつ 断つ 五段・タ行 1. 切り離す。「糸を断つ」\n2. (道などを)通れなくする。「逃げ道を断つ」\n3. 〈「絶つ」とも〉(関係などを)なくす。「関係を断つ」\n4. 続けてしていたことをやめる。「酒を断つ」 +たつ 絶つ 五段・タ行 なくす。「連絡を絶つ、命を絶つ」 +たつ 断つ 五段・タ行 切り離す。「ロープを断つ、酒を断つ」 たつ 発つ 五段・タ行 出発する。「福岡に発つ」 -たつ 立つ 五段・タ行 1. 上に向かってまっすぐな状態にある。また、その状態になる。「立っている人」「木が立っている」\n2. 波や煙・ちりなど、またうわさなどが起こる。「波が立つ」「ほこりが立つ」\n3. 身を起こしてその場から去る。「席を立つ」\n4. 決起する。 -たつ 辰 * 干支(えと)の一つ。卯(う)の後、巳(み)の前。 -たつ 竜 * 蛇をモチーフとした、空を飛ぶ想像上の生物。りゅう。ドラゴン。 -たつ 龍 * 「竜」の旧漢字。「竜」と並行して用いられている。 -たっとい 貴い 形容詞・アウオ段 高貴・貴重・崇高であるさま。特に、高貴であるさま。とうとい。「貴い身分」 -たっとい 尊い 形容詞・アウオ段 高貴・貴重・崇高であるさま。特に、貴重・崇高であるさま。とうとい。「尊い生命」「尊い使命」 -たっとぶ 貴ぶ 五段・バ行 →尊ぶ -たっとぶ 尊ぶ 五段・バ行 〈「貴ぶ」とも〉\n1. あがめる。「神を尊ぶ」\n2. 大切にする。「人権を尊ぶ」 +たつ 立つ 五段・タ行 身を起こす。「木が立つ、席を立つ、噂が立つ、波が立つ、顔が立つ」 +たつ 辰 * 干支の一つ。 +たつ 竜 * (「龍」と区別なし)想像上の生物。 +たつ 龍 * (「竜」と区別なし)想像上の生物。 +たっとい 貴い 形容詞・アウオ段 高貴である様。「貴い身分」 +たっとい 尊い 形容詞・アウオ段 尊敬できる様。「尊い神」 +たっとぶ 貴ぶ 五段・バ行 大切にする。「人権を貴ぶ」 +たっとぶ 尊ぶ 五段・バ行 あがめる。「神を尊ぶ」 たて 館 * やかた。 -たて 楯 * →盾 -たて 盾 * 手に持ち攻撃を防ぐ防具。 +たて 楯 * (「盾」と区別なし)手に持ち攻撃を防ぐ防具。 +たて 盾 * (「楯」と区別なし)手に持ち攻撃を防ぐ防具。 たてかえる 建て替える 一段 (建物を)つくりなおす。「家を建て替える」 -たてかえる 立て替える 一段 他人のかわりにお金を払い、貸しにする。「食事代を立て替える」 +たてかえる 立て替える 一段 他人のかわりにお金を払う。「食事代を立て替える」 たてる 建てる 一段 (建物を)つくる。「ビルを建てる」 -たてる 立てる 一段 1. ものを上に向かってまっすぐな状態にする。「看板を立てる」\n2. 波・煙・ちり、またうわさなどを起こす。「波を立てる」「煙を立てる」 -たね 胤 * (特に父親の)血筋。また、それを受け継ぐ人。→種 -たね 種 * 1. 種子。\n2. 何かを引き起こす原因。「悩みの種」\n3. 題材。ネタ。「うわさの種」\n4. 〈「胤」とも〉(特に父親の)血筋。また、それを受け継ぐ人。 -たまう 給う 五段・ワ行促音便 〈「賜う」に同じ〉\n1. 〈文語〉「与える」の尊敬語。「官職を給う」\n2. 〈動詞につく尊敬の助動詞〉なさる。「告げ給う」\n3. 〈動詞につく助動詞〉…なさい。主に命令形で、(時にふざけて)尊大な語気を醸すために使われる。「君の思うことを書きたまえ」 -たまう 賜う 五段・ワ行促音便 〈「給う」に同じ〉\n1. 〈文語〉「与える」の尊敬語。「官職を賜う」\n2. (動詞につく尊敬の助動詞)なさる。\n※この用法では「給う」、またはかな書きが多い。 -たまご 玉子 * 鶏の卵を料理に使うとき、「卵」の代わりに使われる書き方。「玉子豆腐」(=卵豆腐) -たまご 卵 * 1. さまざまな種類の動物の雌が生む、殻または膜で覆われた球状のもの。適切な環境に置かれると中で子が育ち、殻または膜を破って出てくる。「魚の卵」「卵を産む」\n2. 〈「玉子」とも〉特に、鶏の卵。「卵豆腐」(=玉子豆腐)\n3. 将来、育ってそれになる可能性があるもの。「実業家の卵」 -たまる 貯まる 五段・ラ行 金銭的な貯蓄が増える。「貯金が貯まる」 -たまる 溜まる 五段・ラ行 〈かな書きも〉排出や消費・解消がされずに残って、一つの場所にものなどが増えていく。「水が溜まる」「不満が溜まる」「ストレスが溜まる」 -ためる 矯める 一段 〈文語〉形を直す。矯正する。「弓を矯める」「角を矯めて牛を殺す」(小さいことを直そうとして大きいことをだいなしにする) -ためる 貯める 一段 金銭的な貯蓄を増やす。「お金を貯める」 -ためる 溜める 一段 排出や消費・解消をせずに、(意図的または非意図的に)一つの場所にものなどを増やす。「風呂桶にお湯を溜める」「ストレスを溜める」 +たてる 立てる 一段 身を起こさせる。「看板を立てる、彼の顔を立てる、煙を立てる」 +たね 胤 * 血筋のこと。 +たね 種 * 種子。 +たまう 給う 五段・ワ行促音便 (動作につく尊敬語。助動詞)なさる。「受け給わりました」 +たまう 賜う 五段・ワ行促音便 (「与える」の尊敬語)くださる。「冠を賜う」 +たまご 玉子 * にわとりのたまご。 +たまご 卵 * 動物(哺乳類を除く)の雌が生み、殻の中に子が入っている。 +たまる 貯る 五段・ラ行 財産が増える。「貯金が貯まる」 +たまる 溜る 五段・ラ行 ものが集る。「水が溜まる、不満が溜まる」 +ためる 矯める 一段 矯正する。「弓を矯める、毒を矯める」 +ためる 貯める 一段 (財産を)たくわえる。「お金を貯める」 +ためる 溜める 一段 ものを集める。「風呂桶にお湯を溜める」 たんきゅう 探求 * さがしもとめる。「文化を探求する」 たんきゅう 探究 * ものごとをさぐり、究めること。「学問を探究する」 たんこう 炭坑 * 石炭を採掘するためのあな。 -たんこう 炭鉱 * 石炭を採掘する鉱山。 -たんそ 炭素 * 元素のひとつ。炭の主成分。「炭素繊維」 -たんそ 炭疽 * 伝染病のひとつ。「炭疽菌」 +たんこう 炭鉱 * 石炭を採掘する場所。 +たんそ 炭素 * 元素の一種。「炭素繊維」 +たんそ 炭疽 * 伝染病の一種。「炭疽菌」 ちめい 知名 * 世間的に名前が知られていること。「芸能人の知名度」 ちめい 知命 * 50歳のこと。 ちめい 地名 * 土地の名前。 ちめい 致命 * 命にかかわること。「致命傷」 -ちゅうせん 抽選 * くじを引くこと。また、くじを引くなどして意図を加えずに選ぶこと。「抽籤」の書き換え。「抽選で景品を贈る」 -ちゅうせん 抽せん * 「抽籤」の書き換え。 -ちゅうせん 抽籤 * くじを引くこと。「抽選」「抽せん」と書き換えられることが多い。 ちょうい 弔意 * 人の死を哀しむこと。「弔意を表わす」 ちょうい 弔慰 * 人の死を哀しみ、遺族を慰めること。「弔慰金」 -ちょうし 調子 * 1. 音程やリズム。「調子の外れた歌」「歌と調子を合わせて踊る」\n2. 言葉の勢い。「きつい調子で非難する」\n3. (良い)状態。コンディション。「調子が出る」「調子が悪い」 +ちょうし 調子 * 音程、いきおい。「調子に乗る」 ちょうし 銚子 * 千葉にある市名。 ちょうし 長子 * 一番目の子供。 -ちょうせい 調整 * 数字や量を変えるなどして、うまくいくように持っていくこと。「日程を調整する」 -ちょうせい 調製 * 成分などをきちんと決めてつくること。「調製豆乳」「薬を調製する」 -ちょっかん 直感 * 論理的な思考によらない感覚。「自分の直感を信じる」 -ちょっかん 直観 * 論理的な思考によらずに理解すること。「直観力がある」 -ちょっこう 直交 * 直角に交じわること。「直交する2本の直線」 -ちょっこう 直行 * どこにも寄らずに直接行くこと。「直行便」 -ついきゅう 追及 * (責任などを)相手に問いただすこと。「責任を追及する」 +ちょうせい 調整 * 調子をととのえること。「日程を調整する」 +ちょうせい 調製 * 注文に合わせてつくること。 +ちょっかん 直感 * すぐに感じたこと。 +ちょっかん 直観 * 本質を直接的にとらえること。 +ちょっこう 直交 * 直角に交じわること。 +ちょっこう 直行 * どこにも寄らずに行くこと。「直行便」 +ついきゅう 追及 * (責任などを)強くもとめること。「責任を追及する」 ついきゅう 追求 * 追いもとめること。「利益を追求する」 -ついきゅう 追究 * (学問などを)究めること。「学問を追究する」 -つかう 遣う 五段・ワ行促音便 「使う」に同じ。「気を遣う」、また時に「金を遣う」などの形で好んで用いられる。 -つかう 使う 五段・ワ行促音便 1. 人やもの・行為を、何かの目的のために役立たせる。「ハサミを使う」「手下を使って嫌がらせをする」「仮病を使って学校を休む」(比喩的に)「気を使う」(=注意を払う)\n2. ついやす。消費する。「ずいぶんと時間を使ってしまった」「金を使いすぎた」 -つく 就く 五段・カ行イ音便 〈1 以外は主にかな書き〉\n1. ある立場になる。または、身をおいている。「社長職に就く」\n2. ある状態になる。「眠りにつく」\n3. 〈「着く」とも〉何かをするために、そのための場所に行く。「食卓につく」「床につく」\n4. ある行動を始める。「帰途につく」 -つく 衝く 五段・カ行イ音便 「突く」に同じ。「怒髪天を衝く」などの形で好んで用いられる。 -つく 着く 五段・カ行イ音便 1. 達する。到着する。「博多に着く」\n2. ある場所を占める。「席に着く」 -つく 撞く 五段・カ行イ音便 〈かな書きも〉(鐘などを)棒で叩いて音を鳴らす。「鐘を撞く」 -つく 突く 五段・カ行イ音便 1. とがったものの先端を当てる。「剣で敵を突く」\n2. 〈主にかな書き〉支えとなるものを地面に当てる。「杖をつく」\n3. 鋭く指摘する。「意表を突く」\n4. 鋭く刺激する。「鼻を突く」 -つく 付く 五段・カ行イ音便 1.離れなくなる。定着する。「汚れが付く」「においが付く」「技術が身に付く」\n2. 近くにいるようになる。「サポートが付く」\n3. 注意をとらえる。「気が付く」「目に付く」 -つく 附く 五段・カ行イ音便 →付く -つく 点く 五段・カ行イ音便 〈主にかな書き〉(明かりが)ともる。「電灯がつく」 -つく 搗く 五段・カ行イ音便 〈主にかな書き〉やわらかいものを、棒などで強く押す。また、それを繰り返して作る。「米を蒸してつく」「餅をつく」 +ついきゅう 追究 * (学問などを)追い、究めること。「学問を追究する」 +つかう 遣う 五段・ワ行促音便 こころをはたらかせる。「気を遣う」 +つかう 使う 五段・ワ行促音便 役立たせる。「ハサミを使う、随分と時間を使ってしまった」 +つく 就く 五段・カ行イ音便 身をおく。「社長職に就く、眠りに就く」 +つく 衝く 五段・カ行イ音便 (「突く」も用いる)攻撃する。「意表を衝く、鼻を衝く」 +つく 着く 五段・カ行イ音便 到着する。「博多に着く」 +つく 撞く 五段・カ行イ音便 (鐘などを)棒で叩いて音を鳴らす。「鐘を撞く」 +つく 突く 五段・カ行イ音便 とがったものの先端で叩く。「剣で敵を突く、杖を突く、意表を突く、鼻を突く」 +つく 付く 五段・カ行イ音便 (「附く」と区別なし、一般的)はなれなくなる。「汚れが付く、匂いが付く、気が付く、高く付く」 +つく 附く 五段・カ行イ音便 (「付く」と区別なし)はなれなくなる。「汚れが附く」 つぐ 継ぐ 五段・ガ行 継承する。「親の仕事を継ぐ」 -つぐ 次ぐ 五段・ガ行 ひとつ下の順位にある。「彼に次いで優秀である」 -つぐ 接ぐ 五段・ガ行 くっつけて一体にする。「骨を接ぐ」「枝を接ぐ」 -つぐ 注ぐ 五段・ガ行 〈かな書きも〉(一人分の容器に液体や穀類を)入れる。「ビールをコップに注ぐ」「おわんにご飯を注ぐ」 -つくる 作る 五段・ラ行 生み出す。こしらえる。製作する。「ホームページを作る」「夕飯を作る」「船を作る」 -つくる 造る 五段・ラ行 「作る」に同じ。大きなもの、また酒などを対象とするときに好んで用いられる。「タンカーを造る」 -つくる 創る 五段・ラ行 「作る」に同じ。創造的な側面を強調するときに好んで用いられる。「未来を創る」 +つぐ 次ぐ 五段・ガ行 次にくる。「彼に次いで優秀である」 +つぐ 接ぐ 五段・ガ行 つなぐ。「骨を接ぐ」 +つぐ 注ぐ 五段・ガ行 そそぐ。「ビールをコップに注ぐ」 +つくる 作る 五段・ラ行 こしらえる。「ホームページを作る、夕飯を作る、嘘を作る」 +つくる 造る 五段・ラ行 (工業的なものを)こしらえる。「客船を造る」 つけこむ 漬け込む 五段・マ行 漬物を仕込む。「大根を漬け込む」 -つけこむ 付け込む 五段・マ行 (隙などを)利用する。「弱点に付け込む」 -つける 漬ける 一段 液体にひたす。また、そうして保存食を作る。「洗濯物を水に漬ける」「おしんこを漬ける」 -つける 点ける 一段 〈主にかな書き〉明かりをともす。「電灯をつける」 -つける 付ける 一段 1. はなれないようにする。「バッジを付ける」「印を付ける」\n2. 近くに置く。「サポートを付ける」\n3. 注意を払う。「気を付ける」\n4. 〈かな書きも〉追う。追跡する。「彼の跡を付ける」 -つつしむ 謹む 五段・マ行 〈「謹んで」の形で〉うやうやしく。「謹しんでお喜び申し上げます」 -つつしむ 慎む 五段・マ行 気をつける。慎重におこなう。少なめにする、またはやめる。「言葉を慎しむ」「飲酒を慎む」「コメントを慎む」 +つけこむ 付け込む 五段・マ行 (すきなどを)利用して何かをする。「隙に付け込む」 +つける 漬ける 一段 液体にひたす。「洗濯物を水に漬ける、おしんこを漬ける」 +つける 点ける 一段 点火、点灯する。「明かりを点ける、火を点ける」 +つける 付ける 一段 はなれないようにする。「バッジを付ける、印を付ける、気を付ける、後を付ける」 +つつしむ 謹む 五段・マ行 かしこまる。「謹しんで」 +つつしむ 慎む 五段・マ行 用心する。「身を慎しむ」 つとめる 勤める 一段 勤務する。「大学に勤めている」 -つとめる 努める 一段 努力する。「学力向上に努める」 -つとめる 勉める 一段 →努める +つとめる 努める 一段 (「勉める」と区別なし、一般的)努力する。「学力向上に努める」 +つとめる 勉める 一段 (「努める」と区別なし)努力する。「学力向上に勉める」 つとめる 務める 一段 役目を担う。「大役を務める」 -つむ 詰む 五段・マ行 1. 将棋で、王将を動かせる場所がなくなる。「あっけなく詰んでしまった」\n2. 〈口語〉どうしようもない状況に陥る。「ゲームで強い敵に囲まれて、詰んだと思ってリセットした」 -つむ 積む 五段・マ行 1. ものを上に重ねる。「まきを積む」\n2. 何かを行なって得た経験などを、自分のものとして身につける。「経験を積む」\n3. 運ぶために、乗り物などに載せる。「トラックに砂利を積む」\n4. 部品としてもつ。搭載する。「最速CPUを積んだパソコン」 -つむ 摘む 五段・マ行 (花などを)指先でつまんで、根元から切ってとる。「花を摘む」 -つりだす 吊り出す 五段・サ行 1. →釣り出す\n2. (相撲で)相手を持ちあげて外にだす。「相手の力士を吊り出す」 -つりだす 釣り出す 五段・サ行 相手のほしがるもので誘い出す。「エサで釣り出す」 -つる 攣る 五段・ラ行 〈主にかな書き〉ひきつって動かせなくなる。「海の中で足がつった」 -つる 吊る 五段・ラ行 高いところから垂れ下げる。つるす。「ハンモックを吊る」「首を吊る」(=首にひもを回して自分の体を吊るすことで自殺を図る) -つる 釣る 五段・ラ行 1. 魚を針にひっかけてとる。「魚を釣る」\n2. 相手のほしがるもので誘う。「おまけで客を釣る」 -ていする 呈する サ変・−スル 1. (状態などを)示す。「惨状を呈している」\n2. 〈「苦言を呈する」の形で〉述べる。\n3. 〈文語〉差し出す。 -ていする 挺する サ変・−スル 〈「身を挺する」の形で〉すすんで差し出す。 -ていする 訂する サ変・−スル 〈文語〉訂正する。 -ていじ 呈示 * 持っているものを相手に見せる。「チケットを呈示する」\n※「提示」が一般的。 -ていじ 提示 * 1. 持っているものを相手に見せる。「チケットを提示する」\n※「呈示」とも。\n2. 提案として示す。「条件を提示する」 -てっこう 鉄工 * 〈主に複合語で〉鉄を使って工作をすること。「鉄工所」 +つむ 詰む 五段・マ行 すきまがなくなる。「将棋で詰む」 +つむ 積む 五段・マ行 上に重ねる。「木を積む、金を積む」 +つむ 摘む 五段・マ行 (花などを)手でとる。「花を摘む」 +つりだす 吊り出す 五段・サ行 そそのかす、(相撲で)相手を持ちあげて外にだす。「相手の力士を吊り出す」 +つりだす 釣り出す 五段・サ行 そそのかす。「エサで釣り出す」 +つる 吊る 五段・ラ行 つるす。「首を吊る、足が吊る」 +つる 釣る 五段・ラ行 魚を針にひっかけてとる。「魚を釣る、値段を釣り上げる」 +てい 呈 * (文語)さしだす。「苦言を呈する」 +てい 挺 * (文語)先に行なう。「身を挺する」 +てい 訂 * (文語)訂正する。 +ていじ 呈示 * さしだして見せること。「チケットを呈示する」 +ていじ 提示 * 提出して示すこと。「証明書を提示する」 +てっこう 鉄工 * 鉄でつくるもの。「鉄工所」 てっこう 鉄鉱 * 鉄の原料となる鉱石。「鉄鉱石」 -てっこう 鉄鋼 * 銑鉄(せんてつ)・鋳鉄・鋼鉄などの総称。「鉄鋼業」 -てんい 転位 * 〈主に体内での〉位置が変わること。「骨折部の転位」 -てんい 転移 * 〈がんなどが〉他の場所で発生するようになること。「がんが転移する」 -てんか 転化 * 移り変わること。変化。「意味が転化する」「憧れが憎しみに転化する」 +てっこう 鉄鋼 * 鋼の総称。「鉄鋼業」 +てらう 衒う 五段・ワ行促音便 ひけらかす。「奇を衒う」 +てらす 照らす 五段・サ行 光をあてる。「暗闇を照らす、解答と照らしあわせる」 +てんい 転位 * 位置がかわること。 +てんい 転移 * 場所がうつること。「ガンが転移する」 +てんか 転化 * 移りかわること。「意味が転化する」 てんか 転嫁 * (責任などを)なすりつけること。「責任を転嫁する」 -てんしん 転身 * 職業などを変えること。「転身して農家になった」 -てんしん 転進 * 進路や拠点を変えること。「北に転進する」 -てんずる 転ずる サ変・−ズル 1. (状態などを)変える。(状態などが)変わる。「攻勢に転ずる」「好況に転ずる」\n2. (単語の形や意味が)変化する。「あばら肉が転じてバラ肉と呼ばれるようになった」 -てんずる 点ずる サ変・−ズル 〈文語〉\n1. (火を)つける。(明かりを)ともす。「香に火を点じる」\n2. (茶を)たてる。 -とう 問う 五段・ワ行ウ音便 1. 〈文語的〉人に聞く。質問する。「年齢を問う」\n2. 〈主に受身で〉(人の資質などが)試される。「首相としての資質が問われる」\n3. 〈否定形で〉条件にする。「男女問わず採用する」\n4. 〈主に受身で〉疑問を投げかける。疑う。「実効性を問われる」「罪に問われる」(=犯罪の嫌疑をかけられる) -とうか 投下 * 投げ落とすこと。「爆弾を投下する」 -とうか 透過 * 透き通ること。「明かりが透過する」 +てんしん 転身 * 職業などをかえること。「転身して農家になった」 +てんしん 転進 * 進路をかえること。「北に転進する」 +てんずる 転ずる サ変・−ズル (文語)まわる。「攻勢に転ずる」 +てんずる 点ずる サ変・−ズル (文語)点をうつ。「目薬を点ずる」 +とう 問う 五段・ワ行ウ音便 質問する。「年齢を問う、首相としての資質を問う」 +とうか 投下 * 投げおとすこと。「爆弾を投下する」 +とうか 透過 * すきとおること。「明かりが透過する」 とうかい 倒壊 * 倒れ壊れること。「ビルが倒壊する」 -とうかい 韜晦 * 自分の地位や本心などを隠すこと。 +とうかい 韜晦 * 自己の才能を隠すこと。 とうき 登記 * 土地などの権利を登記簿に記すこと。「登記簿」 とうき 投棄 * 投げすてること。「不法投棄」 -とうき 騰貴 * (物価などが)上がること。「物価が騰貴する」 -とうこう 登校 * 授業を受けるため、または勤務するために学校に行くこと。「大学に登校する」「登校拒否」 -とうこう 投稿 * 原稿を募集しているところに、それを送ること。「雑誌に投稿する」「投稿写真」 -とうこう 投降 * 戦いつづけることをあきらめ、降参すること。「犯人が説得に応じて投降する」 -とうさく 倒錯 * (特に性的な欲求などが)本来の形から外れること。 -とうさく 盗作 * 他人の作品を、自分の作品の全部または一部として勝手に使うこと。また、そうして作った作品。「彼の曲を盗作する」「この小説は明らかな盗作だ」 +とうき 騰貴 * 物価などが高くなること。「物価が騰貴する」 +とうこう 登校 * 学校に行くこと。「大学に登校する、登校拒否」 +とうこう 投稿 * 原稿を送ること。「雑誌に投稿する、投稿写真」 +とうこう 投降 * 降参すること。「犯人が説得に応じて投降する」 +とうさく 倒錯 * 逆になること。 +とうさく 盗作 * 他人の作品を自分の作品とすること。「彼の曲を盗作する」 とうし 凍死 * 凍えて死ぬこと。「雪山で凍死する」 -とうし 投資 * 将来の利益のために、事業などに資金を出したり、努力を傾けたりすること。「株に投資する」「自分自身に投資する」 -とうし 透視 * さえぎるものの向こう側を、何らかの方法で見ること。「X線による透視」「紙に書かれていることを透視する」 -とうし 闘士 * たたかう人。「独立運動の闘士」 -とうし 闘志 * たたかう意志。「闘志が湧く」 -とうとい 貴い 形容詞・アウオ段 高貴・貴重・崇高であるさま。特に、高貴であるさま。「貴い身分」 -とうとい 尊い 形容詞・アウオ段 高貴・貴重・崇高であるさま。特に、貴重・崇高であるさま。「尊い生命」「尊い使命」 -とうとぶ 貴ぶ 五段・バ行 →尊ぶ -とうとぶ 尊ぶ 五段・バ行 〈「貴ぶ」とも〉\n1. あがめる。「神を尊ぶ」\n2. 大切にする。「人権を尊ぶ」 -とうよう 登用 * 人を採用すること。また、要職につけること。「若者を登用する」 -とうよう 当用 * 当面用いること。また、当面の用事。 -とかす 融かす 五段・サ行 〈「溶かす」とも。氷・雪などに対しては「解かす」とも〉固体に熱を加えるなどして、液体にする。「鉄を融かす」 -とかす 解かす 五段・サ行 1. 〈「融かす」「溶かす」とも〉(氷・雪などを)水にする。「氷を解かす」\n2. くしなどで髪の毛を整える。「髪を解かす」 -とかす 溶かす 五段・サ行 1. 粉などを液体に入れ、まぜて一様な液体にする。「小麦粉を水に溶かす」\n2. 液体の性質によって固体を分解する。「金属を塩酸で溶かす」\n3. 〈「融かす」とも。氷・雪などに対しては「解かす」とも〉固体に熱を加えるなどして、液体にする。「鉄を溶かす」 -とく 解く 五段・カ行イ音便 1. ほどく。ほどいて開ける。「結び目を解く」「包装を解く」\n2. くしなどで髪の毛を整える。とかす。\n3. 対話などの手段で解消する。「誤解を解く」\n4. (緊張している状態などを)ゆるめ、なくす。「包囲を解く」\n5. 答えを出す。「謎を解く」 +とうし 投資 * 事業に資金を出すこと。「株に投資する」 +とうし 透視 * すかし見ること。「紙に書かれていることを透視する」 +とうし 闘士 * 闘う人。 +とうし 闘志 * 闘う意志。「闘志が湧く」 +とうとい 貴い 形容詞・アウオ段 高貴である様。「貴い身分」 +とうとい 尊い 形容詞・アウオ段 尊敬できる様。「尊い神」 +とうとぶ 貴ぶ 五段・バ行 大切にする。「人権を貴ぶ」 +とうとぶ 尊ぶ 五段・バ行 あがめる。「神を尊ぶ」 +とうよう 登用 * 人を要職で用いること。「若者を登用する」 +とうよう 当用 * 当面の用事。 +とかす 解かす 五段・サ行 (氷などを)水にする。「氷を解かす」 +とかす 溶かす 五段・サ行 粉などを液体に入れ、まぜて一様な液体にする。「小麦粉を水に溶かす」 +とく 解く 五段・カ行イ音便 ほどく。「結び目を解く、包囲を解く、問題を解く、誤解を解く」 とく 説く 五段・カ行イ音便 説明する。「仏教の教えを説く」 -とく 溶く 五段・カ行イ音便 粉などを液体に入れ、まぜて一様な液体にする。とかす。「小麦粉を水に溶く」 -とくする 得する サ変・−スル もうける。「くじに当たって得をした」 -とくする 督する サ変・−スル 〈文語〉監督する。 +とく 溶く 五段・カ行イ音便 粉などを液体に入れ、まぜて一様な液体にする。「小麦粉を水に溶く」 +とく 得 * もうける。「くじに当たって得をした」 +とく 督 * (文語)監督する。 とくせい 特性 * そのものが持つ特別な性質。「自己相似特性」 とくせい 特製 * 特別につくること。「特製のケーキ」 とくちょう 特徴 * 特別に目立つところ。「特徴のある顔立ち」 -とくちょう 特長 * 特別にすぐれたこと。「本製品の特長」 -とける 融ける 一段 〈「溶ける」とも。氷・雪などに対しては「解ける」とも〉固体に熱が加わるなどして、液体になる。「鉄が融ける」 -とける 解ける 一段 1. 〈「融ける」「溶ける」とも〉(氷・雪などが)水になる。「氷が解ける」\n2. ほどける。「結び目が解ける」\n3. (感情的なしこりなどが)解消される。「誤解が解ける」「怒りが解ける」\n4. (緊張している状態などが)ゆるみ、なくなる。「包囲が解ける」\n5. 答えが出る。「謎が解ける」 -とける 溶ける 一段 1. 粉などが液体にまざって一様な液体になる。「砂糖が水に溶ける」\n2. 液体の性質によって固体が分解される。「塩酸に溶ける金属」\n3. 〈「融ける」とも。氷・雪などに対しては「解ける」とも〉固体に熱が加わるなどして、液体になる。「鉄が溶ける」 -とじる 綴じる 一段 〈かな書きも〉\n1. 紙をひもなどで一つにまとめる。「文集をひもで綴じる」\n2. 〈主にかな書き〉料理の具材に卵をかけ、熱してゆるく固める。「カキフライを卵でとじる」 -とじる 閉じる 一段 1. 閉まる。「ドアが閉じる」\n2. 閉める。「店を閉じる」 -ととのう 整う 五段・ワ行促音便 1. きちんとした状態になる。「髪型が整う」\n2. 欠けがなく、準備のできた状態になる。「準備が整う」「書類が整う」 -ととのう 調う 五段・ワ行促音便 →整う -ととのえる 整える 一段 1. きちんとした状態にする。「髪型を整える」\n2. 欠けのない、準備のできた状態にする。「準備を整える」「書類を整える」\n3. 〈「調える」とも〉(味などを)加減してちょうどいい状態にする。「塩コショウで味を整える」 -ととのえる 調える 一段 〈「整える」とも〉(味などを)加減してちょうどいい状態にする。「塩コショウで味を調える」 -とぶ 跳ぶ 五段・バ行 地面をけって、はねるように空中に上がる。また、そのようにしてものを乗り越える。「カエルのように跳ぶ」「ハードルを跳ぶ」 -とぶ 飛ぶ 五段・バ行 1. 空中を移動する。「飛行機が飛ぶ」\n2. 緊急にある場所にかけつける。「現場に飛ぶ」\n3. 蒸発するようになくなる。消える。「記憶が飛ぶ」「炭酸が飛ぶ」\n4. 抜けがある。「日記の日付が一日飛んでいる」 -とまる 止まる 五段・ラ行 1. 動かなくなる。または、流れがなくなる。「車が止まる」「計算機が止まる」「息が止まる」\n2. 飛んでいた虫や鳥などが、身を支える場所につかまってそこにとどまる。「ハエが壁に止まった」 -とまる 泊まる 五段・ラ行 夜を過ごす。宿泊する。「友達の家に泊まる」 -とまる 留まる 五段・ラ行 〈「止まる」とも〉〈かな書きも〉\n1. 固定される。「画鋲(がびょう)で留まっている」「ボタンがなかなか留まらない」\n2. 〈「目に留まる」として〉注意をよぶ。 -とまる 停まる 五段・ラ行 (車などが)動きを止める。→止まる -とめる 止める 一段 動かなくする。または、流れなくする。「車を止める」「計算機を止める」「息を止める」 -とめる 停める 一段 1. (車などを)動かなくする。「赤信号で車を停める」→止める\n2. 駐車する。「駐車場に車を停める」 -とめる 泊める 一段 夜を過ごさせる。宿泊させる。「友達を自宅に泊める」 -とめる 留める 一段 〈「止める」とも〉〈かな書きも〉\n1. 固定する。「貼り紙を画鋲(がびょう)で留める」\n2. 注意を払う。「気を留める」 -とら 虎 * ネコ科の大型動物。「虎の威を借る狐」 -とら 寅 * 干支(えと)の一つ。丑(うし)の次、卯(う)の前。 +とくちょう 特長 * 特別にすぐれたこと。 +とける 融ける 一段 融解する。「氷が融ける」 +とける 熔ける 一段 (金属などが)溶解する。「鉄塊が熔ける」 +とじる 綴じる 一段 紙を紐などで一つにまとめる。「文集を紐で綴じる」 +とじる 閉じる 一段 しまる。「ドアが閉じる、店を閉じる」 +ととのう 整う 五段・ワ行促音便 整理された状態になる。「部屋が整う」 +ととのう 調う 五段・ワ行促音便 そろう。「準備が調う」 +ととのえる 整える 一段 整理する。「部屋を整える」 +ととのえる 調える 一段 そろえる。「準備を調える」 +とぶ 跳ぶ 五段・バ行 足でとびあがる。「ハードルを跳ぶ」 +とぶ 飛ぶ 五段・バ行 空に舞う。「飛行機が飛ぶ、現場に飛ぶ、記憶が飛ぶ」 +とまる 止まる 五段・ラ行 動かなくなる。「車が止まる、計算機が止まる、息が止まる」 +とまる 泊まる 五段・ラ行 宿泊する。「友達の家に泊まる」 +とまる 留まる 五段・ラ行 固定される。「画鋲で留まっている、目に留まる」 +とめる 止める 一段 (一般的)動かなくする。「車を止める、計算機を止める、息を止める」 +とめる 停める 一段 動かなくする。停止、停車。「車を停める」 +とめる 泊める 一段 宿泊させる。「友達を自宅に泊める」 +とめる 留める 一段 固定する。「貼り紙を画鋲で留める」 +とら 虎 * ネコ科の動物。「虎の威を借る狐」 +とら 寅 * 干支の一つ。「フーテンの寅さん」 とり 鳥 * 鳥類の総称。「飛ぶ鳥あとを濁さず」 -とり 酉 * 干支(えと)の一つ。申(さる)の次、戌(いぬ)の前。「お酉さま」 -とる 採る 五段・ラ行 〈「取る」とも〉\n1. (人を)採用する。「新人を採る」\n2. (方針などを)採択する。選んでそれを実行する。「親米路線を採る」\n3. 採取する。「木の実を採る」 +とり 酉 * 干支の一つ。「お酉さま」 +とる 採る 五段・ラ行 採取、採択する。「血液を採る、新人を採る」 とる 撮る 五段・ラ行 撮影する。「写真を撮る」 -とる 取る 五段・ラ行 〈採る・摂る・捕る・執るも参照〉\n1. 手でつかむ。「ボールを取る」\n2. 自分のものにする。確保する。「免許を取る」「予約を取る」「人のカバンを取る」\n※「盗む」の意味では「盗る」とも書く。\n3. (離れた店に食べ物を)注文して持ってこさせる。「店屋物を取る」\n4. なくす。取り除く。「水気を取る」\n5. (代価などを)求める。「水を飲むのにも金を取られる」\n6. さまざまな単語と組み合わせて、「調整する」などの意味で使う。「バランスを取る」「機嫌を取る」 -とる 摂る 五段・ラ行 〈「取る」とも〉(栄養などを)摂取する。「鉄分を摂る」 -とる 盗る 五段・ラ行 〈「取る」とも〉盗む。「人のカバンを盗る」 -とる 捕る 五段・ラ行 〈「取る」とも〉つかまえる。「ハエを捕る」 -とる 執る 五段・ラ行 〈「取る」とも〉\n1. 手に持つ。「筆を執る」\n2. おこなう。「指揮を執る」 +とる 取る 五段・ラ行 つかむ。「ボールを取る、免許を取る、機嫌を取る、予約を取る、取り急ぎ」 +とる 盗る 五段・ラ行 ぬすむ。「ハンドバックを盗る」 +とる 捕る 五段・ラ行 つかまえる。「ハエを捕る」 ない 無い 形容詞・アウオ段 存在しない。「お金が無い」 -ないしん 内申 * 内申書の略。上級学校を受験する際、その人についての諸情報を当該校に伝えるために出身下級学校が作成する書類。 -ないしん 内診 * 婦人科等で、女性器の内部を診察すること。「内診台」 -なおす 治す 五段・サ行 (病気やけがなどを)治療する。「風邪を治す」 -なおす 直す 五段・サ行 元の状態、または望ましい状態にする。「故障車を直す」「くせを直す」「機嫌を直す」「誤字を直す」 +ないしん 内申 * 内々に申すこと。「内申書」 +ないしん 内診 * 患者の自宅で診察すること。 +なおす 治す 五段・サ行 (病気などを)治療する。「風邪を治す」 +なおす 直す 五段・サ行 元通りにする。「故障車を直す、くせを直す、機嫌を直す」 なおる 治る 五段・ラ行 (病気などから)回復する。「風邪が治る」 -なおる 直る 五段・ラ行 元の状態、または望ましい状態になる。「故障車が直る」「くせが直る」「機嫌が直る」「誤字が直っている」 -なか 中 * ものの内部や中間、空間の内部、時間の間。また、できごとのさなか。「暗闇の中」「大雨の中駆けつける」「中6日の登板」 -なか 仲 * 人などとの関係。「彼との仲」「仲のいい友人」 -ながい 永い 形容詞・アウオ段 時間が非常に長い、または永遠であることを示すために、「長い」の代わりに使われる。「永い冬」→長い -ながい 長い 形容詞・アウオ段 (細いものの)幅が大きい。または、時間が長期にわたる。「長い柱」「長い時間」 +なおる 直る 五段・ラ行 元通りになる。「故障車が直る、くせが直る、機嫌が直る」 +なか 中 * ものの内部。「暗闇の中、中6日の登板」 +なか 仲 * 人などとの関係。「彼との仲、仲のいい友人」 +ながい 永い 形容詞・アウオ段 (時間が)永遠である。「永い時間」 +ながい 長い 形容詞・アウオ段 (距離などが)おおきい。「長い距離」 なかま 中間 * 福岡県にある市名。 -なかま 仲間 * 共になにかをする人の集まり。「飲み仲間」「仲間割れ」 +なかま 仲間 * 共になにかをする人の集り。「飲み仲間、仲間割れ」 なぎ 凪 * 風がない状態。「夕凪」 -なぎ 薙 * 〈文語〉山の崩れている場所。 -なく 泣く 五段・カ行イ音便 1. 涙を流す。「映画を見て泣く」\n2. 苦労する。「一円を笑うものは一円に泣く」 -なく 鳴く 五段・カ行イ音便 1. (動物などが)声をあげる。「にわとりが鳴く」\n2. (麻雀で)ルールに従い、他の参加者から牌(パイ)をもらう。 -なく 啼く 五段・カ行イ音便 〈普通「鳴く」〉(特に野鳥が)声をあげる。「ほととぎすが啼く」 -なく 哭く 五段・カ行イ音便 〈普通「泣く」〉\n1. 人が大声をあげてなげき悲しむ。\n2. →鳴く2 +なぎ 薙 * 山の崩れている場所。 +なく 泣く 五段・カ行イ音便 涙を流す。「映画を見て泣く、一円を笑うものは一円に泣く」 +なく 鳴く 五段・カ行イ音便 (「啼く」と区別なし、一般的)(動物などが)声をあげる。「にわとりが鳴く」 +なく 啼く 五段・カ行イ音便 (「鳴く」と区別なし)(動物などが)声をあげる。「にわとりが啼く」 +なぐ 凪ぐ 五段・ガ行 風がやんだ状態。「夕凪」 +なぐ 薙ぐ 五段・ガ行 山の崩れた場所。 なくす 亡くす 五段・サ行 (人に)死なれる。「親を亡くす」 -なくす 無くす 五段・サ行 1. うっかりして失う。紛失する。「財布を無くす」\n2. 取り去る。ないようにする。「痛みをなくす」 -なくなる 亡くなる 五段・ラ行 〈尊敬語〉死ぬ。「先生が亡くなる」 -なくなる 無くなる 五段・ラ行 1. うっかりして失われる。「財布が無くなる」\n2. 消える。ないようになる。「痛みがなくなる」 -なす 為す 五段・サ行 〈文語〉〈「成す」とも〉する。「善行を為す」 -なす 成す 五段・サ行 〈文語〉\n1. 作り上げる、または成し遂げる。「財を成す」「名を成す」(=有名になる)\n2. 構成する。「根幹を成す」 -なめす 鞣す 五段・サ行 〈主にかな書き〉動物の表皮に加工して、柔らかくしたり耐久性をもたせたりする。「皮をなめす」 -なめる 嘗める 一段 →舐める -なめる 舐める 一段 〈かな書きも〉\n1. 舌で表面をなでる。また、そのようにして食べる。「アメを舐める」\n2. 軽く見る。「彼を舐めてかかる」 -ならす 慣らす 五段・サ行 1. なじませる。「肩を慣らす」\n2. (動物などを)慣れるようにする。かいならす。「シカを慣らす」 -ならす 均す 五段・サ行 〈主にかな書き〉均等にする。「土をならす」 -ならす 鳴らす 五段・サ行 音をさせる。「笛を鳴らす」 -ならぶ 並ぶ 五段・バ行 1. 列をつくる。「ラーメン屋に並ぶ」\n2. 同等になる。「彼に並ぶ記録」 -なる 成る 五段・ラ行 1. うまくいく。成就する。「為せば成る」\n2. 〈主にかな書き〉構成される。「三つの要素からなる」\n3. 〈主にかな書き〉かわる。達する。「冬になる」 -なる 鳴る 五段・ラ行 音が出る。「鐘が鳴る」 -なれる 慣れる 一段 1. 繰り返し、または長期間触れることで普通に、または快適に感じるようになる。なじむ。また、それによって上達する。「日本の生活に慣れる」「目が慣れる」「機器の操作に慣れる」\n2. 〈「馴れる」とも〉動物が、人間を警戒しなくなる。 -なれる 熟れる 一段 〈文語〉熟成する。「味噌が熟れる」 -なれる 馴れる 一段 〈「慣れる」とも〉動物が、人間を警戒しなくなる。 -なれる 狎れる 一段 〈文語〉打ち解けすぎる。 +なくす 無くす 五段・サ行 うしなう。「財布を無くす」 +なくなる 亡くなる 五段・ラ行 しぬ。「先生が亡くなる」 +なくなる 無くなる 五段・ラ行 知らぬまにうしなう。「財布が無くなる」 +なす 為す 五段・サ行 (文語)する。「善行を為す」 +なす 成す 五段・サ行 (文語)つくりあげる。「名を成す」 +なめす 鞣す 五段・サ行 毛皮の毛を除き柔らかくする。「皮を鞣す」 +なめる 嘗める 一段 舌先で触れる。「アメを嘗める、彼を嘗めてかかる」 +ならす 慣らす 五段・サ行 慣れさせる。「肩を慣らす」 +ならす 均す 五段・サ行 均等にする。「土を均す」 +ならす 鳴らす 五段・サ行 音をさせる。「フエを鳴らす」 +ならぶ 並ぶ 五段・バ行 列をつくる。「ラーメン屋に並ぶ、彼に並ぶ記録」 +なる 成る 五段・ラ行 こうせいされる。「三つの要素から成る、しては成らない」 +なる 鳴る 五段・ラ行 音がする。「鐘が鳴る、腕が鳴る」 +なれる 慣れる 一段 めずらしくなくなる。「日本の生活に慣れる」 +なれる 熟れる 一段 熟成する。「味噌が熟れる」 +なれる 馴れる 一段 なじみになる。「目が馴れる」 +なれる 狎れる 一段 うちとけすぎる。「平和に狎れる」 におう 臭う 五段・ワ行促音便 悪いにおいがする。「トイレが臭う」 におう 匂う 五段・ワ行促音便 よいにおいがする。「香水が匂う」 -にくい 憎い 形容詞・アウオ段 1. 強く嫌いに思うようす。「憎い犯人」\n2. 好ましい。「憎い心遣い」 -にくい 難い 形容詞・アウオ段 〈連用形に続けて〉〈主にかな書き〉困難である。「走りにくい靴」 -にくむ 憎む 五段・マ行 強く嫌う。憎悪する。「犯人を憎む」 +にくい 憎い 形容詞・アウオ段 腹が立つさま。「憎い犯人」 +にくい 難い 形容詞・アウオ段 困難であるさま。「走り難い靴」 +にくい 難い 形容詞・アウオ段 困難であるさま。「この靴は走り難い」 +にくむ 憎む 五段・マ行 腹がたつ。「犯人が憎い」 にる 似る 一段 同じように見える。「似ている親子」 にる 煮る 一段 (食材を)水に入れて熱を通す。「大根を煮る」 -ねんとう 年頭 * 年の初め。 +ねんとう 年頭 * としはじめ。 ねんとう 念頭 * 考え。「今言ったことを念頭に置く」 -ねんぽう 年俸 * 年ごとの給料。「年俸制」 +ねんぽう 年俸 * 年毎の給料。「年俸制」 ねんぽう 年報 * 年次の報告。 -のける 除ける 一段 〈主にかな書き〉\n取り除く。「いらないものをのける」 -のける 退ける 一段 〈主にかな書き〉〈複合語で〉\nしりぞける。「人を押しのけて進む」 -のせる 載せる 一段 1. 〈「乗せる」とも〉運ぶためにものを乗り物の上や中に置く。「車を船に載せる」\n2. 部品としてもたせる。搭載する。「最新CPUを載せたパソコン」\n3. 出版物などに掲載・記載する。「雑誌に記事を載せる」 -のせる 乗せる 一段 1. 人を乗り物に入れて移動させる。「ちょっとそこまで乗せてください」\n2. 移動する媒体や経路に入れる。「流れに乗せる」「軌道に乗せる」\n3. 〈「載せる」とも〉何かのすぐ上に置く。「魚を皿に乗せる」\n4. ほめて調子づかせる。「調子に乗せる」「人を乗せるのがうまい」 -のぞく 除く 五段・カ行イ音便 取りのける。取り除く。「嫌いなものを除く」 -のぞく 覗く 五段・カ行イ音便 〈かな書きも〉\n1. 見えにくいもの、隠されているものを見る。「節穴から中を覗く」「部屋を覗く」\n2. 見えにくいもの、隠されているものがふと見える。「結い上げた髪からうなじが覗く」\n3. ふと立ち寄る。「講義を覗く」「中古屋を覗く」 -のぞむ 望む 五段・マ行 1. 希望する。「転勤を望む」\n2. 遠くに見る。「遠くの山々を望む」 -のぞむ 臨む 五段・マ行 1. (ある状況に)当たる。目の前にする。「手術に臨む」「試合に臨む」「毅然たる態度で臨む」\n2. (場所を)目の前にする。「海に臨む家」 -のっとる 乗っ取る 五段・ラ行 〈否定的な意味合いで〉支配下に置く。「飛行機を乗っ取る」「コンピュータを乗っ取る」「会社を乗っ取る」 -のっとる 則る 五段・ラ行 決められたことに従う。「規則に則って行う」 -のばす 延ばす 五段・サ行 1. 時間を遅らせる。延期する。「締め切りを延ばす」「出発を延ばす」\n2. 〈「伸ばす」とも〉既存のものに付け加えて長くする。「路線を延ばす」 -のばす 伸ばす 五段・サ行 1. 長くする。「爪を伸ばす」「路線を伸ばす」\n2. まっすぐにする。「背筋を伸ばす」「しわを伸ばす」\n3. 勢いなどを増やす。「勢力を伸ばす」 -のびる 延びる 一段 1. 時間が遅れる。延期される。「締め切りが延びる」「出発が延びた」\n2. 〈「伸びる」とも〉既存のものに付け加えられて長くなる。「路線が延びる」 -のびる 伸びる 一段 1. 長くなる。「爪が伸びる」「路線が伸びる」\n2. まっすぐになる。「背筋が伸びる」「しわが伸びる」\n3. 勢いなどが増える。「勢力が伸びる」 -のべる 延べる 一段 〈文語〉→延ばす。「出発を延べる」 +のける 除ける 一段 取り除く。「いらないものを除ける」 +のける 退ける 一段 しりぞかす。「通行人を退ける、」 +のせる 載せる 一段 上に置く、記載する。「本を机の上に載せる、雑誌に記事を載せる」 +のせる 乗せる 一段 乗り物の中に入れる。「子供をバスに乗せる、口車に乗せる、調子に乗せる」 +のぞく 除く 五段・カ行イ音便 取り除く。「嫌いなものを除く」 +のぞく 覗く 五段・カ行イ音便 すきまから見る。「部屋を覗く、講義を覗く、中古屋を覗く」 +のぞむ 望む 五段・マ行 ながめる。「遠くの山々を望む、転勤を望む」 +のぞむ 臨む 五段・マ行 目の前にする。「海に臨む家、試験に臨む」 +のっとる 乗っ取る 五段・ラ行 占拠する。「飛行機を乗っ取る、コンピュータを乗っ取る」 +のっとる 則る 五段・ラ行 ならう。「規則に則って」 +のばす 延ばす 五段・サ行 延期、延長する。「締め切りを延ばす、出発を延ばす、路線を延ばす」 +のばす 伸ばす 五段・サ行 長くする。「爪を伸ばす、背筋を伸ばす、勢力を伸ばす」 +のびる 延びる 一段 延期、延長される。「締め切りが延びた、出発が延びる、路線が延びる」 +のびる 伸びる 一段 長くなる。「爪が伸びる、背筋が伸びる、勢力が伸びる」 +のべる 延べる 一段 (文語)延期する。「出発を延べる」 のべる 述べる 一段 言う。「進捗状況について述べる」 -のべる 伸べる 一段 〈文語〉\n1. →伸ばす。\n2. 〈「手を伸べる」として〉手をさし出す。「救いの手を伸べる」 -のぼる 昇る 五段・ラ行 〈「上る」とも〉まっすぐ上にあがる。上昇する。「日が昇る」「頭に血が昇る」 -のぼる 上る 五段・ラ行 1. 低いところから高いところに、または周辺とされる場所から中心に行く。「坂を上る」「川を上る」「日が上る」「頭に血が上る」\n※まっすぐ上がる場合は「昇る」とも書く。\n2. 数量が大きくなる。「予算が3億円に上る」\n3. 話などにとりあげられる。「話題に上る」 -のぼる 登る 五段・ラ行 人や動物が、主に手足を使って高い場所に行く。「富士山に登る」「木に登る」 -のむ 飲む 五段・マ行 1. 液体を喉から体内に入れる。また、特に酒についてそれを行う。「水を飲む」「酒を飲む」「彼と飲みに行く」\n2. 固形物を喉から体内に入れる。「錠剤を飲む」\n3. (たばこなどを)吸う。「たばこを飲む」「アヘンを飲む」\n4. (相手の条件を)受け入れる。「要求を飲む」\n5. 圧倒する。「雰囲気に飲まれて契約した」\n6. (涙や息を)こらえる。止める。「涙を飲んで撤退する」「その光景に息を飲んだ」\n※1の酒について、また2〜6については「呑む」とも。 -のむ 呑む 五段・マ行 →飲む -のる 載る 五段・ラ行 1. 〈「乗る」とも〉何かのすぐ上に置かれる。「魚が皿に載っている」\n2. 〈「乗る」とも〉ものが、運ぶためのものに入る。「荷物がトランクに載らない」\n3. 部品としてもつ。搭載される。「最新CPUが載ったパソコン」\n4. 出版物などに掲載・記載される。「雑誌に記事が載る」 -のる 乗る 五段・ラ行 1. 人が乗り物に入って移動する。「電車に乗って行く」\n2. 〈「載る」とも〉何かのすぐ上に置かれる。「魚が皿に乗っている」\n3. 〈「載る」とも〉ものが、運ぶためのものに入る。「荷物がトランクに乗らない」\n4. 移動する媒体や経路に入る。「流れに乗る」「軌道に乗る」\n5. ほめられて調子づく。「すぐ調子に乗る」 -はいする 廃する サ変・−スル 〈文語〉用いない。「添加物の使用を廃する」 -はいする 拝する サ変・−スル 〈文語〉おがむ。「地蔵を拝する」 -はいする 排する サ変・−スル 〈文語〉排除する。「不純物を排する」 -はいする 配する サ変・−スル 〈文語〉配分する。「警備を配する」 +のべる 伸べる 一段 長くのばす。「救いの手を伸べる」 +のぼる 昇る 五段・ラ行 (天体や煙、エレベータなどが)高い場所に行く。「日が昇る、頭に血が昇る」 +のぼる 上る 五段・ラ行 (一般的に)高い場所に行く。「坂を上る、川を上る、話題に上る」 +のぼる 登る 五段・ラ行 (山、木などで)高い場所に行く。「富士山に登る、木に登る」 +のむ 飲む 五段・マ行 噛まずに喉に入れる。「水を飲む、酒を飲む、たばこを飲む」 +のむ 呑む 五段・マ行 うけいれる。「犯人の要求を呑む、声を呑む」 +のる 載る 五段・ラ行 上に置かれる、記載される。「本が机の上に載っている、雑誌に載る」 +のる 乗る 五段・ラ行 乗り物の中に入る。「バスに乗る、相談に乗る、口に乗る、波に乗る」 +はい 廃 * (文語)用いない。「添加物の使用を廃する」 +はい 拝 * (文語)おがむ。「地蔵を拝する」 +はい 排 * (文語)排除する。「不純物を排する、戸を排する」 +はい 配 * (文語)配分する。「水を配する、警備を配する」 ばいしゅん 買春 * 男が金銭で女を買うこと。 ばいしゅん 売春 * 女が金銭を目当てに体を売ること。 はいすい 排水 * 水を排泄する。「排水溝」 はいすい 配水 * 水を配給する。「配水管」 -はいふ 配付 * ひとりひとりに配ること。「出席者に資料を配付する」\n※この意味でも「配布」がよく使われる。 -はいふ 配布 * 1. 広く配ること。「ビラを配布する」\n2. 〈「配付」とも〉ひとりひとりに配ること。「出席者に資料を配布する」 -はえる 映える 一段 1. 光を受けて輝く。「夕日に映える川」\n2. ひきたつ。「青い空に映える白い建物」 +はいふ 配付 * 配りつけること。「資料を配付する」 +はいふ 配布 * 広く配ること。「ビラを配布する」 +はいる 入る 五段・ラ行 閉空間に移動する。「部屋に入る」 +はえる 映える 一段 ひきたつ。「夕日に映える、一輪のバラが映える」 はえる 栄える 一段 立派に見える。「栄えない人」 -はえる 生える 一段 (植物、毛などが)出てくる。育つ。伸びる。「草が生える」「毛が生える」 -はかる 計る 五段・ラ行 計測する。「血圧を計る」「時間を計る」※長さなどについては「測る」、重さについては「量る」とすることが多い。 -はかる 諮る 五段・ラ行 相談する。「理事会に諮る」 -はかる 図る 五段・ラ行 しようとする。もくろむ。「対処を図る」「脱走を図る」 -はかる 測る 五段・ラ行 (長さなどを)調べる。計測する。「駅までの距離を測る」\n※「計る」とも。 -はかる 謀る 五段・ラ行 1. (よくないことを)企てる。「脱走を謀る」→図る\n2. だます。陥れる。「彼に謀られた」 -はかる 量る 五段・ラ行 (重さなどを)調べる。計測する。「体重を量る」\n※「計る」、「測る」とも。 -はく 穿く 五段・カ行イ音便 〈主にかな書き〉(ズボンなどを)身につける。「ズボンをはく」 -はく 掃く 五段・カ行イ音便 (ほこりなどを)払う。「床を掃く」 -はく 吐く 五段・カ行イ音便 1. 口から外に出す。特に、吐瀉物(としゃぶつ)を口から外に出す。「つばを吐く」「息を吐く」「飲みすぎて吐いてしまった」\n2. 口のような場所から外に出す。「ばい煙を吐く煙突」\n3. 〈否定的な意味合いで〉言う。「捨てぜりふを吐く」\n4. 追及されて本当のことを言う。白状する。「犯人がついに吐いた」 +はえる 生える 一段 (植物などが)根差す。「草が生える、毛が生える」 +はかる 計る 五段・ラ行 計算する。「損失を計る、時間を計る」 +はかる 諮る 五段・ラ行 相談する。「理事会に諮る、ころあいを諮る」 +はかる 図る 五段・ラ行 計画を立てる。「対処を図る」 +はかる 測る 五段・ラ行 (長さなどを)調べる。「駅までの距離を測る」 +はかる 謀る 五段・ラ行 くわだてる。「脱走を謀る、彼に謀られた」 +はかる 量る 五段・ラ行 (重さなどを)調べる。「体重を量る、体積を量る」 +はく 穿く 五段・カ行イ音便 (ズボンなどを)身につける。「ズボンを穿く」 +はく 掃く 五段・カ行イ音便 (ホコリなどを)払う。「床を掃く」 +はく 吐く 五段・カ行イ音便 口の中のものを外に出す。「唾を吐く、真実を吐く、煙を吐く」 はく 履く 五段・カ行イ音便 (靴などを)足につける。「靴を履く」 はぐ 矧ぐ 五段・ガ行 矢をつくる。「矢を矧ぐ」 -はぐ 剥ぐ 五段・ガ行 むく。はがす。「毛皮を剥ぐ」「身ぐるみ剥ぐ」(=身につけているものを強奪する) -ばくふ 幕府 * 将軍のいる場所。また、将軍の政権。「江戸幕府」 -ばくふ 瀑布 * 滝。 -はげる 禿げる 一段 1. 毛髪がなくなる。「頭が禿げる」\n2. 山から木がなくなり、地面が露出する。「禿げた山」 +はぐ 剥ぐ 五段・ガ行 はがす。「毛皮を剥ぐ、身ぐるみを剥ぐ」 +ばくふ 幕府 * 将軍のいる場所。「江戸幕府」 +ばくふ 瀑布 * たき。 +はげる 禿げる 一段 毛髪がなくなる。「頭が禿げる」 はげる 剥げる 一段 表面がはがれる。「ペンキが剥げる」 -はじめ 始め * 1. 〈主に複合語で〉〈「初め」とも〉はじめること。また、はじめてすぐの時期。「仕事始め」「付き合い始めの時期」\n2. 〈「~を始め」の形で〉〈かな書きも〉主なもの。筆頭。「総理を始め、全閣僚が参加した」 -はじめ 初め * 早い時期。「年の初め」 +はざま はざ間 * 苗字の一つ。 +はざま 狭間 * (「迫間」とも書く)あいだ。「人垣の狭間」 +はじめ 一 * 名前のひとつ。 +はじめ 初め * (時間的な)はじまり。「年の初め」 +はじめる 始める 一段 ものごとのはじまり。「会の始めに、彼を始めとして」 +はずす 外す 五段・サ行 のぞく。「レギュラーから外す、ボタンを外す、席を外す」 +はずむ 弾む 五段・マ行 はねる。「ボールが弾む、息が弾む、会話が弾む、お年玉を弾む」 +はぜ 黄櫨 * ウルシ科の木。 はぜ 黄櫨 * ウルシ科の木。 はぜ 鯊 * ハゼ科の魚。 -ばち 鉢 * (「はち」の連濁)ふかざら。「すり鉢」 -ばち 罰 * 神仏が与える罰(ばつ)。「罰があたる」 +ばち 鉢 * (はち)ふかざら。「すり鉢」 +ばち 罰 * 神仏があたえるばつ。「罰があたる」 はな 花 * 植物の生殖にかかわる器官。「花びら」 はな 華 * 華やかなもの。「彼の演技には華がある」 -はなす 放す 五段・サ行 1. つかんでいたのをやめる。「包丁を放す」\n※「手をはなす」は「離す」とすることが多い。\n2. (動物を)自由にする。野生にもどす。「クマに発信機をつけて放す」 -はなす 離す 五段・サ行 1. くっついていたもの、または近かったものどうしを分けて遠くする。「受話器を耳から離す」「画面から顔を離す」\n2. 〈「目を離す」の形で〉視線をそらす。「目を離したすきに逃げられた」 -はなす 話す 五段・サ行 言葉を使う。言葉で伝える。「日本語を話す」「真実を話す」 -はなれる 放れる 一段 →離れる -はなれる 離れる 一段 1. くっついていたもの、または近かったものどうしが分かれて遠くなる。「ガムが床から離れない」\n2. 距離を置く。「危ないから離れなさい」\n3. 去る。「日本を離れる」\n4. 距離がある。「10メートル離れている」 -はね 羽 * 〈「羽根」とも〉鳥や昆虫、飛行機などが飛ぶために使うもの。つばさ。※昆虫のものは「翅」とも。 -はね 羽根 * 〈「羽」とも〉\n1. 鳥のつばさを構成する、一本一本の羽毛。「羽根ペン」\n2. 小さな玉に鳥の羽毛をつけた遊具。また、それに似せた遊具。「羽根つき」「バドミントンの羽根」 -はやい 早い 形容詞・アウオ段 1. 時間があまりたっていない。時間が前である。「まだ晩ご飯には早い」「朝の早い時間」\n2. 短い時間しかかからない。「待つより電話したほうが早い」 -はやい 速い 形容詞・アウオ段 すみやかである。速度がある。「進歩が速い」「速い車」 +はなす 放す 五段・サ行 自由にする。「犬を放す、包丁を放す」 +はなす 離す 五段・サ行 くっついていたものを分ける。「手を離す、3センチ離す」 +はなす 話す 五段・サ行 言葉で伝える。「日本語を話す、真実を話す」 +はなれる 放れる 一段 自由になる。「犬が放れる」 +はなれる 離れる 一段 くっついていたものが分かれる。「手が離れる、10メートル離れている」 +はね 羽根 * 鳥のつばさ、羽毛。「羽を伸ばす」 +はね 羽根 * 羽を加工したもの。 +はやい 早い 形容詞・アウオ段 じかんが短い。「終わるのが早い、早い時間に」 +はやい 速い 形容詞・アウオ段 すみやかである様。「仕事が速い、速い車」 はやまる 早まる 五段・ラ行 時間が早くなる。「出発時刻が早まる」 はやまる 速まる 五段・ラ行 速度が速くなる。「速度が速まる」 はやめる 早める 一段 時間を早くする。「出発時刻を早める」 はやめる 速める 一段 速度を速くする。「足を速める」 -はやる 逸る 五段・ラ行 〈主にかな書き〉あせる。「はやる気持を抑えられない」 -はやる 流行る 五段・ラ行 流行する。「彼の髪型は流行っている」「風邪が流行る」 -はる 張る 五段・ラ行 1. かけわたす。「綱を張る」\n2. 広がる。「根が張る」\n3. ふくらむ。「腹が張る」\n4. 表面にできる。「水面に氷が張る」\n5. (容器に液体を)満たす。「風呂に湯を張る」\n6. 同じ場所にいて観察を続ける、または待ち伏せる。張り込む。「家の前で3時間も張っていた」\n7. (価格などが)高い。「値が張る」\n8. 強くする。「欲を張る」\n9. (体の一部を)高めに持ち上げる。「胸を張る」(胸を反らせる、誇らしげにする) -はる 貼る 五段・ラ行 表面にべたっとくっつける。また、そのように見えるようにする。「切手を貼る」「ウェブページに画像を貼る」 -はんざつ 繁雑 * ごちゃごちゃしていること。「繁雑な図」 -はんざつ 煩雑 * こみいっていてめんどうなことこと。「煩雑な事務手続き」 +はやる 逸る 五段・ラ行 あせる。「逸る気持を抑えられない」 +はやる 流行る 五段・ラ行 流行する。「彼の髪型は流行っている、風邪が流行る」 +はらす 晴らす 五段・サ行 心のくもりをとりのぞく。「疑いを晴らす」 +はらむ 孕む 五段・マ行 妊娠する。「子を孕む」 +はる 張る 五段・ラ行 広がる。「根が張る、腹が張る、水面に氷が張る、値が張る、欲を張る」 +はる 貼る 五段・ラ行 (糊などで)くっつける。「切手を貼る」 +はんざつ 繁雑 * 多くてこみいってること。「繁雑な倉庫内」 +はんざつ 煩雑 * わずらわしくてこみいってること。「煩雑な作業」 はんれい 判例 * 裁判での判決の先例。「最高裁での判例」 はんれい 反例 * 反証となる例。「命題の反例」 -はんれい 凡例 * 1. 主に辞典などの書物において、編集方針や注記法などを掲げたもの。\n2. 図表などで、使用される表記法などを示すためにつけられた解説文。 -ひきあげる 引き上げる 一段 1. 引っぱって高い位置に移す。「ファスナーを引き上げる」\n2. つるすなどして、まっすぐ上にあげる。「海に落ちた車を引き上げる」\n3. (値段や数字などを)上げる。「値段を引き上げる」\n4. もとの場所に戻る。「戦場から引き上げる」\n5. (与えたもの・預けたものなどを)回収する。「資金を引き上げる」\n6. (派遣していた人員などを)帰ってこさせる。撤退させる。「軍隊を引き上げる」\n※2, 4, 5, 6では「引き揚げる」とも。4, 6 では、出征先からの帰還の場合によく「引き揚げる」が使われる。 -ひきあげる 引き揚げる 一段 〈「引き上げる」とも〉\n1. つるすなどして、まっすぐ上にあげる。「海に落ちた車を引き揚げる」\n2. もとの場所に戻る。「戦場から引き揚げる」\n3. (与えたもの・預けたものなどを)回収する。「資金を引き揚げる」\n4. (派遣していた人員などを)帰ってこさせる。撤退させる。「軍隊を引き揚げる」 -ひきのばす 引き延ばす 五段・サ行 〈「引き伸ばす」とも〉\n1. 〈否定的な意味合いで〉遅らせる。「返事を引き延ばす」\n2. 平たいものをのばす。「生地を引き延ばして薄くする」 -ひきのばす 引き伸ばす 五段・サ行 1. 引っぱって長くする。「バネを引き伸ばす」\n2. (写真を)拡大して現像する。「写真を引き伸ばす」 -ひく 引く 五段・カ行イ音便 1. 端などを持って自分のほうに動かす。「ひもを引く」「弓を引く」\n2. 端などを持って、自分も動きながらそれにつれて動かす。「人力車を引く」「子供の手を引いて歩く」\n3. (一部分を)後ろに動かす。「あごを引く」「顔を引いてよけた」\n4. 減らす。減算する。「5から3を引く」\n5. 〈「惹く」とも〉人の関心などを起こす。「気を引く」「興味を引く」\n6. (線などを)えがく。「地面に白線を引く」\n7. (線状に伝わるものを)通じさせる。「村に電気が引かれる」\n8. (油などを)平らにのばす。「フライパンに油を引く」\n9. もとの場所に戻す。「軍を引く」\n10. 〈「退く」とも〉しりぞく。「身を引く」(=引退する)「手を引く」(=かかわりをやめる)\n11. (辞書などで)求める項目をさがす。「単語を辞書で引く」\n12. 〈若者言葉〉異常とみなし、かかわりたくないと思う。「彼の話を聞いて内心引いてた」 -ひく 曳く 五段・カ行イ音便 〈一般的には「引く」〉端などを持って、自分も動きながらそれにつれて動かす。「人力車を曳く」「船を曳く」\n※船について使う場合が多い。 -ひく 牽く 五段・カ行イ音便 〈一般的には「引く」〉端などを持って、自分も動きながらそれにつれて動かす。「牛に犁(すき)を牽かせる」\n※家畜などについて使う場合が多い。 -ひく 惹く 五段・カ行イ音便 〈「引く」とも〉人の関心などを起こす。「気を惹く」「興味を惹く」 -ひく 退く 五段・カ行イ音便 〈一般的には「引く」〉しりぞく。「身を退く」「手を退く」→引く10 -ひく 弾く 五段・カ行イ音便 (楽器などを)鳴らす。演奏する。「ピアノを弾く」 -ひく 碾く 五段・カ行イ音便 〈主にかな書き〉臼(うす)で食べ物をすりつぶす。「麦をひく」 -ひく 轢く 五段・カ行イ音便 〈かな書きも〉(車などで)生物を下じきにする。または、はねとばして死傷させる。「車で人を轢く」 -ひじょう 非常 * 1. ただごとではないこと。「非常事態」\n2. 程度が普通ではないこと。「非常な悲しみ」 -ひじょう 非情 * 情けがないこと。「非情な男」 +はんれい 凡例 * 書物の方針を掲げたもの。「熟語の凡例」 +ひきあげる 引き上げる 一段 引いて高い位置に移す。「車を引き上げる、値段を引き上げる」 +ひきあげる 引き揚げる 一段 もとの場所にもどる。「戦場から引き揚げる」 +ひきのばす 引き延ばす 五段・サ行 おくらせる。「返事を引き延ばす」 +ひきのばす 引き伸ばす 五段・サ行 引いて大きくする。「写真を引き伸ばす」 +ひく 引く 五段・カ行イ音便 自分の方へ近づける。「紐を引く、村に電気が引かれる、気を引く、手を引く」 +ひく 曳く 五段・カ行イ音便 (「引く」とも書く)ひっぱる。「船を曳く」 +ひく 牽く 五段・カ行イ音便 (「引く」とも書く)ひっぱる。「車を牽く」 +ひく 惹く 五段・カ行イ音便 関心をあたえる。「心を惹く、人目を惹く」 +ひく 退く 五段・カ行イ音便 しりぞく。「身を退く、血の気が退く」 +ひく 弾く 五段・カ行イ音便 (楽器などを)ならす。「ピアノを弾く」 +ひく 碾く 五段・カ行イ音便 臼で食べ物をすりつぶす。「麦を碾く」 +ひく 轢く 五段・カ行イ音便 (車などで)生物を下じきにする。「車で人を轢く」 +ひじょう 非常 * ただごとではないこと。「非常事態」 +ひじょう 非情 * なさけがないこと。「非情な男」 ひそむ 潜む 五段・マ行 かくれる。「物陰に潜む」 -ひそむ 顰む 五段・マ行 〈文語〉(眉を)しかめる。「眉を顰む」 -ひそめる 潜める 一段 1. 〈「身を潜める」として〉隠れる。\n2. 〈「声を潜める」として〉小声になる。 -ひそめる 顰める 一段 〈かな書きも〉(眉を)しかめる。「眉を顰める」 -ひつじ 未 * 干支(えと)の一つ。午(うま)の次、申(さる)の前。 -ひつじ 羊 * 主に毛を刈って糸や織物にするために家畜とされる動物。 -ひとで 人手 * 1. 働く人の数。「人手が足らない」\n2. 他人の所有。「人手に渡る」\n3. 人の手作業。「人手で注釈をつける」 +ひそむ 顰む 五段・マ行 まゆをしかめる。「眉を顰む」 +ひそめる 潜める 一段 かくれさせる。「人を潜める、声を潜める」 +ひそめる 顰める 一段 まゆをしかめる。「眉を顰める」 +ひつじ 未 * 干支の一つ。 +ひつじ 羊 * ウシ科の動物。 +ひとで 人手 * 他人の手。「人手に渡る、人手が足らない」 ひとで 人出 * 人が集まること。「花火大会に多くの人出がありました」 -ひなん 避難 * 災害などから逃れること。「火災から避難する」 -ひなん 非難 * 〈「批難」に同じ〉非があると思う相手を言葉で責めること。「彼の失敗を非難する」 -ひなん 批難 * 〈「非難」に同じ〉非があると思う相手を言葉で責めること。「彼の失敗を批難する」 -ひょうする 表する サ変・−スル あらわす。「敬意を表する」 -ひょうする 評する サ変・−スル 批評する。「この映画を評する」 -ひょうき 標記 * 1. 標題として記すこと。また、その内容。「標記の文には矛盾がある」\n2. しるしとしてつけること。また、その内容。「ロゴを標記する」 -ひょうき 表記 * 1. 文字などであらわすこと。「英語で表記する」\n2. おもてにしるすこと。「『数学』と表記されたノート」 +ひなん 避難 * 災害などから逃れる。「火災から避難する」 +ひなん 非難 * せめる。「彼の失敗を非難する」 +ひょう 表 * あらわす。「敬意を表する」 +ひょう 評 * 批評する。「この映画を評する」 +ひょうき 標記 * 標題として記したこと。「交通標記」 +ひょうき 表記 * 文字などであらわすこと。「英語で表記する」 ひょうけつ 票決 * 投票で決めること。「単純多数で票決する」 -ひょうけつ 表決 * 議案に対して賛否を示すこと。「起立によって表決する」 -ひょうけつ 評決 * 議論して決めること。また、その結論。「陪審員が有罪の評決を告げた」 -ひょうしょう 表彰 * 人々の前で功績を誉め、伝えること。「表彰状」 -ひょうしょう 表象 * 象徴すること。象徴。 -ひょうはく 漂泊 * さまようこと。「各地を漂泊する」 +ひょうけつ 表決 * 議案に対して賛否を示すこと。「草案を表決する」 +ひょうしょう 表彰 * 功績を誉め、伝えること。「表彰状」 +ひょうしょう 表象 * 象徴。 +ひょうはく 漂泊 * さまようこと。「海を漂泊する」 ひょうはく 漂白 * 水などにさらして白くすること。「油汚れを漂白する」 -ひょうはく 表白 * 〈文語〉思いを述べること。「自らの苦悩を表白する」 -ひんする 瀕する サ変・−スル (危機などが)せまる。「危機に瀕する」 -ひんする 貧する サ変・−スル 貧乏な状態になる。また、貧乏な状態にある。「富める者貧する者」 -びん 瓶 * 〈「壜」に同じ。一般的〉〈かな書きも〉\nガラスなどの器。「空き瓶」 -びん 便 * 交通手段・運送手段について、一度の移動。「午後一番の便で送る」 -びん 壜 * →瓶 -ふす 付す 五段・サ行 〈「附する」とも〉\n1. 〈文語〉つけたす。「預託金に付す利子」\n2. (審査、評議などに)通す。「審査に付す」\n3. 扱いをする。「一笑に付す」(=笑ってかたづける)「不問に付す」(=問わない) -ふす 賦す 五段・サ行 〈文語〉くばる。 -ふす 附す 五段・サ行 →付する -ふする 付する サ変・−スル 〈文語〉〈「附する」とも〉〈普通「付す」〉\n1. つけたす。「預託金に付する利子」\n2. (審査、評議などに)通す。「審査に付する」\n3. 扱いをする。「一笑に付する」(=笑ってかたづける)「不問に付する」(=問わない) -ふする 賦する サ変・−スル 〈文語〉くばる。 -ふする 附する サ変・−スル →付する -ふうこう 風光 * 自然の景色。「風光に恵まれた地」「風光明媚」 +ひん 瀕 * (危機などが)せまる。「危機に瀕する」 +ひん 貧 * 貧乏な状態になる。「富める者貧する者」 +びん 瓶 * (「壜」と区別なし、一般的)ガラスなどの器。「空き瓶」 +びん 便 * たより。「宅配便」 +びん 壜 * (「瓶」と区別なし)ガラスなどの器。「空き壜」 +ふ 付 * (文語)(「附する」と区別なし)つけたす。「預託金に付する利子、不問に付す」 +ふ 賦 * (文語)くばる。 +ふ 附 * (文語)(「付する」と区別なし)つけたす。「預託金に附する利子、不問に附す」 +ふうこう 風光 * 自然の景色。「風光明媚な観光地」 ふうこう 風向 * かざむき。「風向計」 -ふえる 殖える 一段 〈「増える」が一般的〉\n(繁殖や利殖によって)数が多くなる。「貯金が殖える」「菌が殖える」 -ふえる 増える 一段 数が多くなる。「人数が増える」「貯金が増える」「菌が増える」\n※繁殖や利殖による場合は「殖える」とも。 +ふえる 殖える 一段 (財産などが)多くなる。「貯金が殖える」 +ふえる 増える 一段 数が多くなる。「人数が増える」 ふか 付加 * 付け加えること。「おまけを付加する」 -ふか 負荷 * (機械などでの)仕事の量。「高負荷」「負荷平均」 -ふか 孵化 * 卵からかえること。「ひよこが孵化する」 +ふか 負荷 * (計算機などでの)仕事の量。「高負荷、負荷平均」 +ふか 孵化 * 卵からかえること。「ヒヨコが孵化する」 ふかす 更かす 五段・サ行 夜おそくまで起きている。「夜を更かす」 -ふかす 吹かす 五段・サ行 1. (タバコを)吸う。\n2. 〈「…風を吹かす」として〉(それに見合わない者が)そのような態度を見せつける。「先輩風を吹かす」 -ふかす 蒸かす 五段・サ行 〈主にかな書き〉蒸気で加熱する。むす。「芋をふかす」 -ふきゅう 不休 * 〈主に「不眠不休」として〉休むことのないこと。「不眠不休で働く」 -ふきゅう 不朽 * 長く価値を保つこと。「不朽の名作」 -ふく 拭く 五段・カ行イ音便 布などで表面をこすってきれいにする。ぬぐう。「机を拭く」 -ふく 吹く 五段・カ行イ音便 1. 口から息を強く出してものに当てる。「ろうそくを吹いて消す」\n2. 口から息を出して音を立てる。「笛を吹く」\n3. 〈「噴く」とも〉(液体や気体が)中から勢いよく出る。または、勢いよく出す。「血が吹く」「銃が火を吹く」\n4. 中からあらわれる。または、中からあらわす。「芽が吹く」「肌が粉を吹く」\n5. 〈主に「ほらを吹く」として〉うそをつく。\n6. 〈若者言葉〉笑い出す。吹き出す。「画像を見て思わず吹いた」 -ふく 葺く 五段・カ行イ音便 (屋根を)瓦やわらなどで覆う。「屋根を葺く」 -ふく 噴く 五段・カ行イ音便 〈「吹く」とも〉(液体や気体が)中から勢いよく出る。または、勢いよく出す。「血が噴く」「銃が火を噴く」 -ふくす 伏す 五段・サ行 〈文語〉かがむ。 -ふくす 復す 五段・サ行 〈文語〉もとにもどす。 -ふくす 服す 五段・サ行 したがう。「刑に服す」「喪に服す」 -ふくする 伏する サ変・−スル 〈文語〉かがむ。 -ふくする 復する サ変・−スル 〈文語〉もとにもどす。 -ふくする 服する サ変・−スル したがう。「刑に服する」「喪に服する」 +ふかす 蒸かす 五段・サ行 むす。「芋を蒸す」 +ふきゅう 不休 * 休むことのないこと。「不眠不休で働く」 +ふきゅう 不朽 * 朽ちることのないこと。「不朽の名作」 +ふく 拭く 五段・カ行イ音便 ぬぐう。「机を拭く」 +ふく 吹く 五段・カ行イ音便 空気が動く。「風が吹く、笛を吹く、粉を吹く」 +ふく 葺く 五段・カ行イ音便 瓦や藁などで屋根を覆う。「屋根を葺く」 +ふく 噴く 五段・カ行イ音便 (液体、気体などが)勢いよく外にでる。「火を噴く」 +ふく 伏 * (文語)かくれる。 +ふく 復 * (文語)もとにもどす。 +ふく 服 * (文語)したがう。「刑に服する、喪に服する」 ふくしゅう 復習 * もう一度勉強すること。「英語の授業を復習する」 -ふくしゅう 復讐 * しかえし。かたきうち。「親の復讐をする」 -ふくす 復す 五段・サ行 〈文語〉もとにもどす。「元の状態に復する」 -ふくす 服す 五段・サ行 〈文語〉したがう。「刑に服す」「喪に服す」 -ふくすい 腹水 * 腹にたまった水。 -ふくすい 覆水 * 〈「覆水盆に返らず」として〉こぼれた水は元に戻らない。取り返しがつかない。 -ふくせん 伏線 * あとになって関連してくること。「伏線をはる」「このことはのちに起こる事件の伏線となっている」 -ふくせん 複線 * 複数の線。鉄道においては、上下の線路を併設すること。「高速道路の複線化」「複線軌道」 +ふくしゅう 復讐 * しかえし。「親の復讐をする」 +ふくす 復す 五段・サ行 もとにもどす。「元の状態に復する」 +ふくす 服す 五段・サ行 したがう。「刑に服す、喪に服す」 +ふくすい 腹水 * 腹に溜まる水。 +ふくすい 覆水 * こぼれた水。「覆水盆に返らず」 +ふくせん 伏線 * あとのことをほのめかすこと。「伏線をはる」 +ふくせん 複線 * 複数の線。「複線軌道」 ふける 更ける 一段 夜になって時間がたつ。「夜が更ける」 -ふける 老ける 一段 年をとる。また、そう見えるようになる。「彼の顔は老けている」「苦労ですっかり老けてしまった」 -ふける 耽る 一段 〈かな書きも〉他のことを忘れるほど、そのことだけをする。耽溺(たんでき)する。「物思いに耽る」「豪遊に耽る」 -ふこう 不孝 * 孝行でないこと。「親不孝」 +ふける 老ける 一段 年をとる。「彼の顔は老けている」 +ふこう 不孝 * 孝行でないこと。「親不幸」 ふこう 不幸 * 幸せでないこと。「不幸な事件」 ふしん 普請 * 建物の工事。「安普請」 -ふしん 腐心 * 目的のためにいろいろ考えること。また、目的のために努力すること。「構造改革に腐心する」 -ふしん 不審 * あやしいこと。「不審者」 -ふしん 不振 * (成績などが)ふるわないこと。ぱっとしないこと。「打撃不振」 -ふじん 夫人 * 他人の妻に対する尊称。「真珠夫人」 -ふじん 婦人 * 成人女性。「婦人会」 -ふす 臥す 五段・サ行 〈「伏す」とも〉横になる。「床に臥す」 -ふす 伏す 五段・サ行 腹ばいになる。また、土下座する。「地に伏す」「伏してお願いする」 +ふしん 腐心 * なにかをして心をいためること。「構造改革に腐心する」 +ふしん 不審 * あやしいこと。「不審者を見かけたら110番」 +ふしん 不振 * ふるわないこと。「打撃不振」 +ふじん 夫人 * 他人の妻。「真珠夫人」 +ふじん 婦人 * 女性。「婦人会」 +ふす 臥す 五段・サ行 (「伏す」と区別なし)うつぶせになる。「床に臥せる、彼には事実を臥せておく」 +ふす 伏す 五段・サ行 (「臥す」と区別なし)うつぶせになる。「床に伏せる、彼には事実を伏せておく」 ふせい 不整 * 整っていないこと。「不整脈」 -ふせい 不正 * 正しくないこと。正しくない行為。「不正な利用」「政治の不正を糾弾する」 -ふせい 不斉 * 対称でないこと。「不斉炭素原子」 -ふせつ 付設 * 〈「附設」とも〉付属して設置すること。「テニスコートを付設する」 -ふせつ 附設 * →付設 -ふせつ 敷設 * 〈「布設」に同じ。一般的〉広い範囲に設置すること。「鉄道を敷設する」 -ふせつ 布設 * 〈「敷設」に同じ〉広い範囲に設置すること。「鉄道を布設する」 -ふたく 付託 * 〈「附託」とも〉処置を委ねること。「核問題を安保理に付託する」 -ふたく 附託 * →付託 -ふたく 負託 * 人に責任を持たせてまかせること。「国民の負託を受ける」 -ふっきゅう 復仇 * 1. かたきをうつこと。\n2. やりかえすこと。 +ふせい 不正 * ただしくないこと。 +ふせい 不斉 * 整っていないこと。「不斉合成」 +ふせつ 付設 * 付属して設置すること。「テニスコートを付設する」 +ふせつ 敷設 * (設備などを)設置すること。「水道を敷設する」 +ふたく 付託 * 依頼すること。「核問題を安保理に付託する」 +ふたく 負託 * 人にまかせること。「機能を負託する」 +ふっきゅう 復仇 * かたきをうつこと。 ふっきゅう 復旧 * 元通りにすること。「停電から復旧した」 ふてい 不貞 * 浮気をすること。「不貞をはたらく」 -ふてい 不定 * 定まっていないこと。「不定形」「住所不定無職の男」 -ふてき 不敵 * 相手を軽く見るさま。「不敵な笑い」「大胆不敵」 -ふてき 不適 * 適さないこと。「飲料水として不適である」 +ふてい 不定 * 定まっていないこと。「不定形、住所不定無職の男」 +ふてき 不敵 * 敵をあいてにしないさま。「不敵な笑い」 +ふてき 不適 * 適さないこと。 ふとう 不当 * 正当でないこと。「不当な扱いを受ける」 ふとう 不等 * 等しくないこと。「不等号」 -ふどう 不動 * 1. 動かないこと。「直立不動」\n2. 堅固でゆるがないこと。「不動の地位」 -ふどう 不同 * (順序について)基準がないこと。「掲載順序は不同です」「順不同」 -ふむ 践む 五段・マ行 〈まれ〉「踏む」に同じ。 -ふむ 踏む 五段・マ行 1. 足で下じきにする。「エンピツを踏む」「祖国の地を踏む」\n2. やり方に従う。踏襲する。「手順を踏む」\n3. 〈「韻を踏む」として〉押韻する。 -ふやす 殖やす 五段・サ行 〈「増やす」が一般的〉(繁殖や利殖によって)数を多くする。「貯金を殖やす」「菌を殖やす」 -ふやす 増やす 五段・サ行 数を多くする。「人数を増やす」「貯金を増やす」「菌を増やす」※繁殖や利殖による場合は「殖やす」とも。 -ふよう 扶養 * 養うこと。「扶養家族」「三人の家族を扶養している」 -ふよう 浮揚 * 1. 〈文語〉浮きあがること。また、浮き上がらせること。「水面に浮揚する」\n2. (景気や人気について)状況を改善する、または改善させること。「景気浮揚策」 -ふよう 不用 * 使わないこと。「不用品」\n※「不用品」は「不要品」とも。 -ふよう 不要 * 必要でないこと。「手続きは不要です」「不要品」\n※「不要品」は「不用品」とも。 -ふりだす 降り出す 五段・サ行 (雨など)が降り始める。「雨が降り出した」 -ふりだす 振り出す 五段・サ行 1. 振り始める。「手を振り出した」\n2. (手形・小切手などを)発行する。「小切手を振り出す」 -ふる 降る 五段・ラ行 (雨などが)空から落ちる。「雨が降る」「2階から水が降ってきた」 -ふる 振る 五段・ラ行 1. ゆり動かす。「バットを振る」\n2. (粉などを)まく。かける。「コショウを振る」\n3. (仕事などを)割り当てる。「仕事を振る」\n4. (話題などを)向ける。「そんな話題を振られても反応に困る」\n5. (交際相手と)交際を断つ。(交際の申し込みを)断る。「彼に振られて泣いていた」「告白したけれど振られた」\n※「フる」「フラれる」とも。 -ふるい 旧い 形容詞・アウオ段 →古い -ふるい 古い 形容詞・アウオ段 1. 〈まれに「旧い」とも〉できてから、あるいは起こってから時間がたっている。また、より新しいものに置き換えられている。「古い資料」「古い考え方」\n2. できてから、あるいは起こってから長い時間がたっている。古代のものである。「古い時代の記録」「古い言い伝え」 -ふるう 振るう 五段・ワ行促音便 〈「揮う」とも。かな書きも〉\n1. 大きく振り動かす。「指揮棒を振るう」\n2. いかんなく発揮する。「腕を振るう」「熱弁を振るう」\n3. (暴力を)おこなう。「暴力を振るう」\n4. 〈主に否定形で〉勢いがある。「成績が振るわない」 -ふるう 揮う 五段・ワ行促音便 →振るう -ふるう 震う 五段・ワ行促音便 〈文語〉震動する。震える。 -ふるう 奮う 五段・ワ行促音便 (勇気・気力などを)わきたたせる。ふりしぼる。「勇気を奮う」 -ふるう 篩う 五段・ワ行促音便 〈主にかな書き〉ふるいにかける。「小麦粉をふるう」 -ぶんか 分化 * 異なるものに変わり、分かれていくこと。「細胞が分化する」 +ふどう 不動 * 動かないこと。「不動の地位、目黒不動尊」 +ふどう 不同 * 同じでないこと。「順不同」 +ふむ 践む 五段・マ行 (「踏む」と区別なし)足で下じきにする。「エンピツを践む、祖国の土を践む、手順を践む、韻を践む」 +ふむ 踏む 五段・マ行 (「践む」と区別なし)足で下じきにする。「エンピツを踏む、祖国の土を踏む、手順を踏む、韻を踏む」 +ふやす 殖やす 五段・サ行 (財産などを)多くする。「貯金を殖やす」 +ふやす 増やす 五段・サ行 多くする。「定員を増やす」 +ふよう 扶養 * 養うこと。「扶養家族、三人の家族を扶養している」 +ふよう 浮揚 * うきあがること。「景気が浮揚する」 +ふよう 不用 * 用のないこと。「不用なもの」 +ふよう 不要 * 必要でないこと。「手続きは不要です」 +ふりだす 降り出す 五段・サ行 雨などが降り始める。「雨が降り出した」 +ふりだす 振り出す 五段・サ行 振り始める。「手を振り出す」 +ふる 降る 五段・ラ行 (雨などが)おちる。「雨が降る、災難が降りかかる」 +ふる 振る 五段・ラ行 ゆり動かす。「バットを振る、コショウを振る、仕事を振る」 +ふるい 旧い 形容詞・アウオ段 (「古い」と区別なし) +ふるい 古い 形容詞・アウオ段 (「旧い」と区別なし) +ふるう 振るう 五段・ワ行促音便 いきおいづく、振る。「成績が振るわない、熱弁を振るう」 +ふるう 震う 五段・ワ行促音便 震動する。 +ふるう 奮う 五段・ワ行促音便 心をわきたたせる。「勇気を奮う」 +ふるう 篩う 五段・ワ行促音便 ふるいで分ける。「参加者を篩う」 +ぶんか 分化 * 異質なものに分かれること。「細胞が分化する」 ぶんか 分科 * 分けられた科目。「分科会」 -ぶんか 文化 * 人間の風俗、思考など独自に育んだものの総称。「古代ローマの文化」「重要文化財」「文化系サークル」 -ぶんか 文科 * 人文科学・社会科学などの科目。「文科系の大学院」 +ぶんか 文化 * 人間の風俗、思考など独自に育んだものの総称。「文化革命、重要文化財」 +ぶんか 文科 * 人文系の科目。 ふんぜん 憤然 * 憤るさま。「彼の発言に憤然とする」 ふんぜん 奮然 * 奮いたつさま。「奮然といきごむ」 -へいこう 平行 * 1. 同一面上の直線がどこまでも交わらないこと。「2本の平行な線」\n2. (移動について)形や傾きをかえないこと。「平行移動」\n3. 〈「並行」「併行」とも〉同時におこなうこと。「学業と平行して執筆する」 -へいこう 平衡 * (物や心の)つりあいがとれている状態。バランス。「平衡感覚」 -へいこう 並行 * 1. ならんで進むこと。「高速道路と並行する国道」\n2. 〈「平行」「併行」とも〉同時におこなうこと。「学業と並行して執筆する」 -へいこう 併行 * 〈「並行」「平行」とも〉同時に行うこと。「学業と併行して執筆する」 -へいこう 閉口 * 困ること。「彼のわがままに閉口する」 +へいこう 平行 * 同一面上の直線がどこまでも交わらないこと。「平行移動」 +へいこう 平衡 * つりあいがとれている状態。「平衡感覚」 +へいこう 並行 * 並んで行なうこと。「高速道路と並行する国道」 +へいこう 閉口 * ものを言わないこと、あきれること。「彼のわがままに閉口する」 へいこう 閉校 * 学校が閉鎖されること。 -へんけい 変型 * 特殊な型。「変型チラシ」 -へんけい 変形 * 形が変わる、または形を変えること。「消しゴムが変形する」「変形ロボット」 -へんざい 偏在 * 偏って存在すること。「一部地域に偏在する資源」 +へき 僻 * かたよること。「僻地」 +へき 壁 * かべ。「絶壁、鉄璧」 +へき 癖 * くせ。「性癖、潔癖」 +へき 碧 * あおみどり色。「紺碧」 +へんけい 変型 * 特殊な型のこと。「変型チラシ」 +へんけい 変形 * 形が変わること。「消しゴムが変形する、変形ロボット」 +へんざい 偏在 * 偏って存在すること。「偏在する資源」 へんざい 遍在 * 広く存在すること。「世界に遍在する情報」 -へんしゅう 偏執 * 〈「へんしつ」とも読む〉偏ったことに執着すること。「偏執狂」 -へんしゅう 編修 * (歴史書などを)まとめること。「日本書紀の編修過程」 -へんしゅう 編集 * 1. 元となる資料を整理し、書籍や画像、動画などにまとめること。「雑誌を編集する」「結婚式の動画を編集する」\n2. (パソコンなどでデータを)改変する。「ファイルを編集した後に上書き保存をする」 -へんしゅう 編輯 * →編集 -べんずる 便ずる サ変・−ズル 〈文語〉用をたす。 -べんずる 弁ずる サ変・−ズル 〈文語〉のべる。 +へんしゅう 偏執 * 偏ったことに執着すること。「偏執狂」 +へんしゅう 編修 * 辞書などの書籍をまとめること。「辞書を編修する」 +へんしゅう 編集 * 雑誌などをつくること。「編集者、編集長」 +べんずる 便ずる サ変・−ズル (文語)用をたす。 +べんずる 弁ずる サ変・−ズル (文語)のべる。 へんせい 変性 * 性質が変わること。「細胞が変性する」 へんせい 変声 * 声変わりすること。「変声期」 -へんせい 編制 * (決まった規模の)団体を組織すること。「師団を編制する」「学級の編制」 -へんせい 編成 * まとめあげること。「チームを編成する」「予算を編成する」 +へんせい 編制 * 軍隊などを組織すること。 +へんせい 編成 * 組織すること。「チームを編成する」 へんれい 返戻 * 返しもどすこと。「返戻金」 -へんれい 返礼 * 1. 礼・贈り物を受け取り、同等のものを返すこと。また、その行為や品。「返礼を贈る」\n2. いやな仕打ちを受けて、それに対してしかえしをすること。 -ほうおう 法王 * 教皇のこと。「ローマ法王」\n※現在は「教皇」が正式。 +へんれい 返礼 * 礼をかえすこと。「内祝いとして返礼する」 +ほ 保 * (文語)ひきうける。 +ほ 補 * (文語)役職をまかせる。 +ほうおう 法王 * 教皇のこと。「ローマ法王」 ほうおう 法皇 * 仏門に入った上皇。 -ぼうさつ 忙殺 * 忙しくて他のことができないこと。用事に追われること。「仕事に忙殺される」 -ぼうさつ 謀殺 * 計画的に殺人すること。 -ほうしょう 報奨 * (行為などに対して)報いることによってすすめること。「若年者雇用に対する報奨金」 -ほうしょう 報償 * 報いるため、または償うために支払うこと。「退職に対する報償金」「被害に対する報償金」 -ほうしょう 褒賞 * 善行などをほめたたえること。また、それに対して与える賞。「軍功を褒賞する」「功労に対する褒賞金」 -ほうずる 報ずる サ変・−ズル 1. 〈文語〉むくいる。\n2. 報道する。「首相の訪朝が報じられた」 -ほうずる 奉ずる サ変・−ズル 〈文語〉うけたまわる。 -ほうずる 崩ずる サ変・−ズル 〈文語〉亡くなる。崩御する。 -ほかん 保管 * 保存・管理すること。「金品を保管する」 +ぼうさつ 忙殺 * とても忙がしいこと。「仕事に忙殺される」 +ぼうさつ 謀殺 * 計画的な殺人。 +ほうしょう 報償 * 損害をつぐなうこと。「事故に対する報償金」 +ほうしょう 褒賞 * ほめたたえること。「功労に対する褒賞金」 +ほうずる 報ずる サ変・−ズル (文語)むくいる、報道する。「首相の訪朝が報じられた」 +ほうずる 奉ずる サ変・−ズル (文語)うけたまわる。 +ほうずる 崩ずる サ変・−ズル (文語)くずれる、崩御する。 +ほかん 保管 * 大事に保存すること。「金品を保管する」 ほかん 補完 * 足りないところを補うこと。「言葉を補完する」 ほけん 保健 * 健康を保つこと。「保健室」 -ほけん 保険 * 1. 加入者から掛け金を集め、取り決めたこと(偶然の事故など)があったときに補償金を支払う制度。「保険に加入する」\n2. あてにしていることがうまくいかなかったときのために用意しておくこと。また、それに使うもの。「行きつけの店が休みのときの保険として他の店を見ておく」 +ほけん 保険 * 事故などのときに積立金から補償を行う制度。「保険金詐欺」 ほしょう 保証 * 確かだということに責任を持つこと。「借金の保証人」 -ほしょう 保障 * ある状態や水準を守ること。「安全保障」「失業者の生活保障」 +ほしょう 保障 * 障害からまもること。「安全保障」 ほしょう 補償 * 損害などを補うこと。「事故の補償金」 -ほしょうきん 保証金 * 債務などの担保として支払う金。「家を借りるのに保証金を払う」 -ほしょうきん 補償金 * 損害を補うための金。「事故の被害に対する補償金をもらった」 -ほせい 補整 * 補って整えること。「句読点を補整する」\n※まれ。主に「補正」が使われる。 -ほせい 補正 * 調整して、正しい、または望ましい状態にすること。「補正予算」「手ぶれを補正する」 -ほそく 捕捉 * つかまえること。また、レーダーなどで検知すること。「目標を捕捉する」 -ほそく 補足 * 足りないところを補うこと。「彼の説明を補足します」 +ほしょうきん 保証金 * 債務の担保として支払う金。 +ほしょうきん 補償金 * 損害をおぎなうための金。 +ほせい 補整 * 補い整えること。「露出を補整する」 +ほせい 補正 * 補い正すこと。「補正予算」 +ほそく 捕捉 * とらえること。「目標を捕捉する」 +ほそく 補足 * 補い足すこと。「彼の説明を補足します」 ぼたん 牡丹 * ボタン科の木。 -ぼたん 釦 * 〈主にカタカナ〉\n1. 服をとめるもの。「ボタンをかけちがえる」\n2. 押すことによって機械を制御する小さな突起物。また、それを模したコンピュータ画面上の表現。「火災を通報するためのボタン」「ボタンをマウスでクリックする」 +ぼたん 釦 * 服をとめるもの。「釦をかけちがえる」 ほどう 舗道 * 舗装された道路。 -ほどう 歩道 * 歩く人のための道。 -ほひつ 補弼 * 君主の政治を補佐すること。 +ほどう 歩道 * 歩くための道路。 +ほひつ 補弼 * 政治を補うこと。 ほひつ 補筆 * 補って書くこと。 -ほる 掘る 五段・ラ行 1. 地面の土を取り除く、または平たいものの一部を削るなどしてくぼみをつくる。「土を掘る」「壁に穴を掘る」\n2. 地面の土を取り除いて、埋まっているものを取り出す。「サツマイモを掘る」 -ほる 彫る 五段・ラ行 1. きざみこむ。「板に文字を彫る」\n2. 材料を削ってつくりあげる。「熊の彫刻を彫る」 -ほんい 本位 * 〈接尾語〉~を基準とする。「自分本位の勝手な考え」「金本位制度」 -ほんい 本意 * 本当の意志。本来意図するところ。「それは私の本意ではない」 -ほんい 翻意 * 決めたことを変えること。「説得して翻意を促した」 +ほる 掘る 五段・ラ行 穴をあける。「土を掘る」 +ほる 彫る 五段・ラ行 彫刻をほどこす。「熊の彫刻を彫る」 +ほんい 本位 * 基本となるもの。「自分本位の勝手な考え」 +ほんい 本意 * 本当の意志。「本意ではないが」 ほんだい 本代 * 本の代金。 ほんだい 本題 * 中心となる題目。「本題に入ります」 ほんりゅう 奔流 * 激しい流れ。「時代の奔流に流される」 -ほんりゅう 本流 * 1. (分岐する河川の)もっとも大きな流れ。「本流に支流が合流する」\n2. (情勢の)もっとも大きな、または伝統のある流れ。「社内の本流」「保守本流」 -まかす 委す 五段・サ行 →任す -まかす 任す 五段・サ行 〈「委す」とも〉\nゆだねる。任せる。「仕事を任す」「想像に任す」 +ほんりゅう 本流 * もとの流れ。 +まかす 委す 五段・サ行 (「任す」と区別なし)ゆだねる。「仕事を委す、想像に委す」 +まかす 任す 五段・サ行 (「委す」と区別なし、一般的)ゆだねる。「仕事を任す、想像に任す」 まかす 負かす 五段・サ行 負けさせる。「試合で相手を負かす」 -まかせる 委せる 一段 →任せる -まかせる 任せる 一段 〈「委せる」とも〉\n1. ゆだねる。相手の自由にさせる。「仕事を任せる」「後は想像に任せます」\n2. 〈「意に任せる」として、主に否定形で〉〈文語〉思うようになる。「なかなか意に任せない」 -まく 巻く 五段・カ行イ音便 〈「捲く」とも〉\n1. 薄いものや細いものを、その端や別のもののまわりに沿って回し、からみつかせる。また、それをきつくする。また、そのようになる。「糸を巻く」「傷に包帯を巻く」「ぜんまいを巻く」「葉が巻く」\n2. (渦などが)できる。「渦を巻く」\n3. 慣用句の一部として使われる。「煙(けむ)に巻く」(=理解しにくいことを話して相手を混乱させる)「舌を巻く」(=感心する)「管を巻く」(=くどくどと同じようなことを何度もしゃべる) -まく 捲く 五段・カ行イ音便 →巻く -まく 撒く 五段・カ行イ音便 〈かな書きも〉\n1. (粉や液体を)散らばらせる。かける。散布する。「水を撒く」\n2. (紙などを、散布や手渡し・郵送などで)広範囲に行き渡らせる。「ビラを撒く」\n3. 〈「巻く」とも〉(追跡するものの)視野から逃れる。「車の速度を上げて追跡を撒く」 -まく 蒔く 五段・カ行イ音便 〈かな書きも〉(成長させる目的で、種を地面に)散らばらせる。または、地中に埋める。「種を蒔く」 -まく 幕 * 1. 上から垂らす布。特に、劇場などで舞台の前に垂らす布。「垂幕」「幕を下ろす」\n2. 1によって区切られる一場面。「第二幕」\n3. 1が下りて、出し物が終了すること。また一般に、終了すること。「勝利の場面で幕となった」「この事件は犯人逮捕で幕となった」\n4. 〈「出る幕」として〉かかわる場面。「親の出る幕じゃない」 -まく 膜 * 薄い皮。「半透膜」「牛乳が膜を張る」 -まざる 交ざる 五段・ラ行 〈「混ざる」が一般的〉違う種類のものが入り込んでまぎれる。「商品に偽物が交ざる」 -まざる 混ざる 五段・ラ行 1. 〈「交ざる」とも〉違う種類のものが入り込んでまぎれる。「商品に偽物が混ざる」\n2. 液体や気体に、別のものが入って一体となる。「淡水に海水が混ざる」 -まじる 交じる 五段・ラ行 〈「混じる」が一般的〉\n1. 違う種類のものが入り込んでまぎれる。「商品に偽物が交じる」\n2. 違う性質の集団に入る。「若者に交じって勉強する」 -まじる 混じる 五段・ラ行 1. 〈「交じる」とも〉違う種類のものが入り込んでまぎれる。「商品に偽物が混ざる」\n2. 液体や気体に、違う種類のものが入って一体となる。「淡水に海水が混じる」\n3. 〈「交じる」とも〉違う性質の集団に入る。「若者に混じって勉強する」 +まかせる 委せる 一段 (「任せる」と区別なし)ゆだねる。「仕事を委せる、後は想像に委せます」 +まかせる 任せる 一段 (「委せる」と区別なし、一般的)ゆだねる。「仕事を任せる、後は想像に任せます」 +まく 巻く 五段・カ行イ音便 (「捲く」と区別なし、一般的)くるくるとたたむ。「包帯を巻く、ぜんまいを巻く、舌を巻く」 +まく 捲く 五段・カ行イ音便 (「巻く」と区別なし)くるくるとたたむ。「包帯を捲く、ぜんまいを捲く、舌を捲く」 +まく 撒く 五段・カ行イ音便 散らばらせる。「水を撒く、ビラを撒く、追跡を撒く」 +まく 蒔く 五段・カ行イ音便 種を植える。「種を蒔く」 +まく 幕 * 空間を分けるための布。「垂幕、開幕」 +まく 膜 * うすい皮。「半透膜、粘膜、角膜」 +まざる 交ざる 五段・ラ行 異種のものが一緒になる。「偽物が交ざる」 +まざる 混ざる 五段・ラ行 複数のものがひとつになる。「砂に塩が混ざる」 +まじる 交じる 五段・ラ行 異種のものが一緒になる。「偽物が交じる」 +まじる 混じる 五段・ラ行 複数のものがひとつになる。「砂に塩が混じる」 ます 升 * 米などをはかるうつわ。 -ます 鱒 * 〈かな書きも〉サケ科の魚。 -まぜる 交ぜる 一段 〈「混ぜる」が一般的〉違う種類のものを入れてまぎれさせる、または一体とする。「商品に偽物を交ぜる」 -まじる 混ぜる 五段・ラ行 1. 〈「交ぜる」とも〉違う種類のものを入れてまぎれさせる。「商品に偽物を混ぜる」\n2. 液体や気体に、違う種類のものを入れて一体とする。「淡水に海水を混ぜる」 -まち 街 * 〈「町」とも〉にぎやかな通り。「街に出る」 -まち 町 * 1. 〈「街」とも〉家や商店などが集まっている場所。「町なかに住む」\n2. 地方公共団体のひとつ。町(ちょう)。「町役場」 -まつる 祭る 五段・ラ行 →祀る -まつる 奉る 五段・ラ行 〈文語〉さしあげる。「神号を奉られた」 -まつる 祀る 五段・ラ行 〈「祭る」とも〉\n1. (死者や神仏を)あがめ、安置する。「死者を祀る場」\n2. (死者や神仏を)あがめ、儀式を行う。「死者を祀る祝日」 -まつる 纏る 五段・ラ行 〈主にかな書き〉まつり縫いをする。「スカートの裾をまつる」 -まゆ 眉 * 目の少し上に生えている毛。「眉毛」「眉をひそめる」(=不快な気持ちをあらわにする) -まゆ 繭 * 蚕などが、変態にあたってさなぎを保護するために糸を吐いて作るもの。「繭を生産している農家」 -まわり 回り * 〈「廻り」とも〉\n1. (さまざまな意味で)回ること。回りぐあい。「換気扇の回りが悪い」「地方回り」「酒の回りが早い」\n2. 〈接尾語〉〈「周り」とも〉…にかかわる部分。「水回りのトラブル」 \n3. 〈助数詞〉回る回数をあらわす。「ひと回りする」\n4. 大きさなどの差について、主観的な一段階ぶんをあらわす。年齢については、干支(えと)のひと回りである12年をあらわす。「普通のものよりふた回りほど小さい」「年齢がひと回り近く離れている」 -まわり 廻り * →回り -まわり 周り * 〈「回り」とも〉取り囲むあたり。周囲。周辺。「駅の周りには何もない」「周りの人がじゃまだ」 -みえ 見栄 * 他人に自分をよく見せようとすること。虚栄心。「彼女は見栄を張りすぎだ」「見栄のためにブランド品を買う」 -みえ 見得 * 1. 〈「見得を切る」として〉役者が一瞬止まりポーズをとること。「役者が見得を切った」\n2. 〈特に「大見得を切る」として〉おおげさに話す。また、大口をたたく。「一人の犠牲者も出さないと大見得を切った」 -みことのり 詔 * 天皇のことば。古くは、大事の際の天皇のことばを指した。 -みことのり 勅 * 古く、小事の際の天皇のことばを指した。 -みだす 見出す 五段・サ行 見はじめる。「しかられているのにテレビを見出した」 -みだす 乱す 五段・サ行 乱れさせる。「風紀を乱す」「集中力を乱す」 +ます 鱒 * サケ科の魚。 +まち 街 * 繁華街などをさす。「繁華街」 +まち 町 * 家などが集まっている場所。「町内会」 +まつる 祭る 五段・ラ行 祈願する。「月を祭る」 +まつる 奉る 五段・ラ行 さしあげる。「讃え奉る」 +まま 間々 * 母親の英語表現。 +まま 儘 * その状態が保たれること。「その儘でいてくれ、なすが儘」 +まゆ 眉 * 目の上に生えている毛。「眉毛、眉をひそめる」 +まゆ 繭 * 蚕などが自分を保護するために作るもの。「繭を生産している農家」 +まわり 回り * (「廻り」と区別なし、一般的)まわること。「金回りがよい、ひと回りする」 +まわり 廻り * (「回り」と区別なし)まわること。「金廻りがよい、ひと廻りする」 +まわり 周り * 取り囲むもの、場所。「駅の周りには何もない、周りの人が邪魔だ」 +みえ 見栄 * 他人からよく見られようとすること。「彼女は見栄を張りすぎだ」 +みえ 見得 * 役者が一瞬止まりポーズをとること。「彼が見得を切った」 +みことのり 詔 * 大事の際の天皇のことば。 +みことのり 勅 * 小事の際の天皇のことば。 +みず 水 * 水素分子が2つと酸素分子が1つ化合したもの。「水を得た魚、水に流す」 +みず 瑞 * みずみずしいこと。 +みだす 見出す 五段・サ行 見はじめる、見つけ出す。「写真を見出した、彼の才能を見出す」 +みだす 乱す 五段・サ行 乱れさせる。「風紀を乱す、集中力を乱す」 みつりょう 密漁 * 違法に漁を行なう。「禁漁区域で魚を密漁する」 みつりょう 密猟 * 違法に猟を行なう。「鹿を密猟する」 -みとる 看取る 五段・ラ行 臨終に付き添う。「親の臨終を看取る」\n※「見取る」とも。 -みとる 見取る 五段・ラ行 見て理解する。見て取る。「彼の本心を見取る」 -みにくい 見にくい 形容詞・アウオ段 見ることが難しい。また、見て理解しにくい。「色が多くて地下鉄の路線図が見にくい」 -みにくい 醜い 形容詞・アウオ段 見た目がよくない。または、嫌悪をもよおすほど悪い。醜悪である。「醜いアヒルの子」「醜い心根」 -みはる 見張る 五段・ラ行 1. あたりを見渡して番をする。「倉庫を見張る」\n2. 〈「瞠る」とも〉(目を)大きく開いて見つめる。「目を見張る」「目を見張るような(=すばらしい)美しさ」 -みはる 瞠る 五段・ラ行 →見張る2 -みる 看る 一段 →見る5 -みる 観る 一段 (出し物などを)観賞する。「映画を観る」「ビデオを観る」→見る2 -みる 見る 一段 〈「視る」とも〉\n1. 目でとらえる。「リンゴを見る」\n2. 〈「観る」とも〉(出し物などを)観賞する。「映画を見る」「ビデオを見る」\n3. 目で確認して、批評や訂正をする。「学生の論文を見てやった」\n4. 確かめる。観察して判断する。「様子を見る」「ブレーキの調子を見る」\n5. 〈「看る」とも〉世話をする。「寝たきりの親の面倒を見る」\n6. 推測する。みなす。「殺人と見て捜査する」\n7. 〈「~な目を見る」として〉(いやなことを)経験する。「大変な目を見た」 -みる 視る 一段 →見る +みとる 看取る 五段・ラ行 看病する。「寝たきりの親を看取る」 +みとる 見取る 五段・ラ行 見てわかる。「彼の本心を見取る」 +みにくい 見にくい 形容詞・アウオ段 見るのが難しい。「見にくい形をしている」 +みにくい 醜い 形容詞・アウオ段 外見がみっともない。「醜いアヒルの子」 +みはる 見張る 五段・ラ行 あたりを見渡して番をする。「倉庫を見張る」 +みはる 瞠る 五段・ラ行 目を大きく開いて見つめる。「目を瞠る」 +みょうばん 明晩 * 次の日の晩。 +みる 看る 一段 看病する。「寝た切りの親の面倒を看る」 +みる 観る 一段 観覧する。「芝居を観る」 +みる 見る 一段 目で感じる。「リンゴを見る、彼を見る、様子を見る、甘く見すぎていた」 +みる 視る 一段 視察する。「被災地を視る」 みる 診る 一段 診察する。「患者を診る」 -みんせい 民政 * 1. 民衆にかかわる政治。「民政局」\n2. 文民による政治。「軍政から民政に移行する」 +みんせい 民政 * 民生のための政治。「民政党」 みんせい 民生 * 民衆の生活。「民生委員」 みんぞく 民俗 * 民衆の伝統的な文化。「民俗芸能」 -みんぞく 民族 * 同じ言語や文化・歴史などを共有し、一体感を持つ人々の集まり。「民族主義」「民族大移動」 -むえん 無縁 * 1. 縁がないこと。「汚職とは無縁である」\n2. 縁者がいないこと。「無縁墓地」 -むえん 無鉛 * 鉛を含まないこと。「無鉛ガソリン」 +みんぞく 民族 * 同じ文化を持つ集り。「民族主義、民族大移動」 +むえん 無縁 * 縁がないこと。「汚職とは無縁である、無縁墓地」 +むえん 無鉛 * 鉛を含まないこと。 むえん 無塩 * 塩を含まないこと。「無塩のトマトジュース」 -むく 向く 五段・カ行イ音便 1. (ある方向に対して)顔など、主な部分が正面になるように動く。「彼の方を向く」\n2. 適する。ちょうどいい。「この仕事は彼の性格に向いている」\n3. (意識などが、ある対象に)動く。「気が向かない」(=やる気にならない) -むく 剥く 五段・カ行イ音便 〈かな書きも〉\n1. (皮などを)取り去って中身だけにする。「リンゴを剥く」「ミカンの皮をを剥く」\n2. (目や歯を)露出させる。「目を剥いて怒った」「牙を剥く」 -むしょう 無償 * 報酬、または代金のないこと。「無償で働く」「無償で貸し出す」 -むしょう 無性 * 〈「無性に」として〉(欲求などに関して)やたらに。「無性に食べたくなる」 -むじょう 無上 * この上なくよい・大きいこと。「無上の喜び」 -むじょう 無常 * 全てのものははかなく滅びるということ。また、はかなさ。「人生の無常を感じる」 -むじょう 無情 * 情けをかけないこと。容赦のないこと。「無情にも最後の望みが絶たれた」 -むめい 無名 * 1. 名前が広く知られていないこと。「無名の新人」\n2. 名前のついていないこと。「無名の山に名前をつけた」\n3. 名前が記入されていないこと。無記名。「無名の手紙」 +むく 向く 五段・カ行イ音便 正面になるように動く。「彼の方を向く、気が向く、彼の性格に向いている」 +むく 剥く 五段・カ行イ音便 皮などを取り除く。「リンゴの皮を剥く」 +むくろ 骸 * 死体。 +むくろ 躯 * 体。 +むしょう 無償 * 報いのないこと。「無償で働く」 +むしょう 無性 * 心がなくなること。「無性に食べたくなる」 +むじょう 無常 * 全てのものははかなく滅びるという真理。「諸行無常の響きあり」 +むじょう 無情 * 情けのないこと。「無情にも最後の望みが絶たれた」 +むめい 無名 * 名前が知られていないこと。「無名の新人」 むめい 無銘 * 作者の名前が入ってないこと。 -むれる 群れる 一段 1. (動物が)1か所に集まる。「羊が群れる」\n2. (人間が)集団を作る。徒党を組む。「仲良し同士で群れる」 -むれる 蒸れる 一段 1. 湿気がこもる。「靴が蒸れる」\n2. 蒸していたものができあがる。「シュウマイが蒸れる」 -め 眼 * →目 -め 目 * 〈「眼」とも〉\n1. 光を感じる感覚器。「目を見つめる」\n2. 視線。「冷静な目で判断する」\n3. 〈「見た目」として〉外見。「見た目がよくない」\n4. 〈形容詞に続いて〉経験。「ひどい目にあった」\n5. (台風などの)中心。「台風の目」\n6. 穴があいているところ。「目が細かいざる」\n7. (さいころの)数字をあらわすためにつけた点。また、転がして上になったその数。「同じ目が2回連続で出た」\n8. 〈接尾語〉助数詞に付き、はじめからの数ということを示す。「3回目の挑戦」 -めいかい 明解 * 1. わかりやすいこと。「明解な文章」\n2. はっきりと解説すること。 -めいかい 明快 * すっきりとわかりやすいこと。「明快な返事をした」「単純明快」 +むれる 群れる 一段 一つに集まる。「羊が群れている。」 +むれる 蒸れる 一段 湿気がこもる。「靴が蒸れる、シュウマイが蒸れる」 +め 眼 * 眼球。「」 +め 目 * 光を感じる感覚器。「目を見つめる、目が冴える、目が点になる」 +めいかい 明解 * はっきりとわかること。 +めいかい 明快 * 明らかで快いこと。「単純明快」 めいき 明記 * はっきりと記すこと。「条件を明記する」 -めいき 銘記 * 心に刻んで忘れないこと。「教えを銘記する」 +めいき 銘記 * 忘れないこと。「教えを銘記する」 めいずる 命ずる サ変・−ズル 命令する。「転勤を命ずる」 -めいずる 銘ずる サ変・−ズル 1. 〈文語〉きざみつける。「石に名を銘ずる」\n2. 〈「肝に銘ずる」として〉心にしっかりと刻みつける。 -もうける 設ける 一段 1. (場などを)用意する。「懇親会を設ける」「給水所を設ける」\n2. (建物・規則・組織などを)新たに作る。設置・設定する。「制限を設ける」「部署を設ける」 -もうける 儲ける 一段 1. 金銭的な利益を得る。「株で儲ける」\n2. 〈口語〉意外なことで得をする。「うちのチーム不戦勝だってさ。儲けたな」\n3. 〈主にかな書き〉子供をもつ。「一子をもうけた」 -もえる 燃える 一段 1. 炎が立つ。燃焼する。「家が燃える」\n2. 情熱がわきおこる。「心が燃える」「だんだん燃えてきた」 -もえる 萌える 一段 1. 芽が出る。「草木が萌える」\n2. 〈若者言葉〉可愛らしいと感じ、愛情や保護欲をかきたてられる。また、そのような感情を起こす。「彼女の上目遣いに萌えた」「萌える絵」 +めいずる 銘ずる サ変・−ズル きざみつける。「肝に銘ずる」 +もうける 設ける 一段 用意する。「懇親会を設ける、給水所を設ける」 +もうける 儲ける 一段 利益を得る。「株で儲ける」 +もえる 燃える 一段 炎が立つ。「家が燃える、心が燃える」 +もえる 萌える 一段 芽が出る。 もくする 黙する サ変・−スル 黙る。「黙して語らず」 -もくする 目する サ変・−スル 1. そうではないかと推測する。「犯人と目される」\n2. 将来そうなるのではないかと推測する。「次期社長と目される」\n3. 有望視する。嘱望する。「将来を目される小説家」 -もっこう 木瓜 * 紋の名。 -もっこう 木工 * 1. 木材を使って工作すること。\n2. 〈文語〉大工。 -もの 者 * 〈修飾句に続いて〉人。へりくだるとき、責めるときや、文語体の文などで用いられる。「部下の者が失礼をいたしました」「活動を妨害する者がいる」「免許を有する者」 -もの 物 * 1. 物体。手に取れるような対象。「部屋に物が多い」「持参する物」\n2. 商品の品質。「物はいいが値段が高い」\n3. 具体的に対象を示さないとき、一部の動詞の目的語として使う。「物を食べる」「物を考える」「物を書く」\n4. 〈主にかな書き〉無生物に対し、形式名詞として使う。「果物を切ったものを皿に載せる」「この靴は彼のものだ」 -もも 股 * →腿 -もも 腿 * 〈「股」とも〉足の、膝から付け根までの部分。特に、その柔らかい部分。ふともも。「腿をたたいた」 -もも 桃 * 夏に、食用となる果実をつけるバラ科の木。また、その果実。「熟した桃」 -もる 洩る 五段・ラ行 →漏る -もる 盛る 五段・ラ行 1. 山状に積み上げる。「土を盛る」「丼にご飯を盛る」「果物をざるに盛る」\n2. (食べ物などに、毒を)知られないように入れて飲ませる。「毒を盛る」「一服盛られた」\n3. (文章や条項などに)含める。「計画を報告書に盛る」\n4. 〈若者言葉〉髪を山状に整える。「頭を盛る」\n5. 〈若者言葉〉おおげさに言う。誇張する。「話盛ってるんじゃないの」 -もる 漏る 五段・ラ行 〈「洩る」とも〉(水などが)もれる。「天井から水が漏る」 -やく 焼く 五段・カ行イ音便 1. 火をつけて燃やす。または、火にかけて加熱する。また、そのようにしてつくる。「紙を焼く」「芋を焼く」「ケーキを焼く」\n2. (肌を)日光などに当てて濃い色にする。「肌を焼く」\n3. (光メディアに、データを)記録する。「ISOイメージを焼く」\n4. 〈「手を焼く」として〉扱いに苦労する。〈「世話を焼く」として〉世話をする。〈「焼き餅を焼く」として〉嫉妬する。→妬く -やく 妬く 五段・カ行イ音便 嫉妬する。「あの人とよく一緒にいるからって妬いてるみたい」 -やくしゃ 役者 * 1. 役柄を演じる人。「ひいきの役者」\n2. 演技のうまい人。「お前は役者だな」 -やくしゃ 訳者 * 翻訳をした人。翻訳者。「この本の訳者」 -やくす 約す 五段・サ行 約束する。「再会を約す」 +もくする 目する サ変・−スル 見る。「将来を目される」 +もつ 持つ 五段・タ行 手にとる。「箸を持つ、肩を持つ、強い気持を持つ」 +もっこう 木瓜 * バイカアマチャという植物。 +もっこう 木工 * 大工。 +もの 者 * 人をさす。 +もの 物 * 生き物以外をさす。 +もむ 揉む 五段・マ行 力を加えて柔くする。「土を揉む、肩を揉む、人ごみに揉まれる」 +もも 股 * (「腿」と区別なし)足で膝よりも上の部分。 +もも 腿 * (「股」と区別なし)足で膝よりも上の部分。 +もも 桃 * バラ科の植物。 +もる 洩る 五段・ラ行 (「漏る」と区別なし)水などがこぼれる。「天井から水が洩る」 +もる 盛る 五段・ラ行 積上げる。「土を盛る、毒を盛る」 +もる 漏る 五段・ラ行 (「洩る」と区別なし、一般的)水などがこぼれる。「天井から水が漏る」 +やかた 屋形 * 屋根の形をしているもの。「屋形船」 +やかた 館 * やしき。 +やく 焼く 五段・カ行イ音便 火で燃やす。「紙を焼く、芋を焼く、手を焼く」 +やく 妬く 五段・カ行イ音便 嫉妬する。「彼の行動に妬く」 +やくしゃ 役者 * 役柄を演じる人。「大根役者」 +やくしゃ 訳者 * 翻訳をする人。「この本の訳者」 +やくす 約す 五段・サ行 要約する。「説明を約す」 やくす 訳す 五段・サ行 翻訳する。「英文を日本語文に訳す」 -やこう 夜光 * 暗いところで光ること。「夜光虫」「夜光時計」 -やこう 夜行 * 1. 夜に行くこと。「夜行バス」\n2. 夜に行動すること。「夜行動物」 -やさしい 易しい 形容詞・イ段 〈かな書きも〉わかりやすい、またはやりやすい。簡単、容易である。「この問題は易しい」「易しい手品」 -やさしい 優しい 形容詞・イ段 〈かな書きも〉\n1. やわらかく、とげとげしくない。「優しい音楽」\n2. 思いやりや気づかいがある。「優しい子供」 +やこう 夜光 * よるのあかり。「夜光虫、夜光時計」 +やこう 夜行 * 夜に行くこと。「夜行バス」 +やさしい 易しい 形容詞・イ段 簡単である。「この問題は易しい、易しい言葉で話す」 +やさしい 優しい 形容詞・イ段 気づかいがある。「彼が優しい言葉をかけてくれた」 やすい 安い 形容詞・アウオ段 値段が低い。「安い服」 -やすい 易い 形容詞・アウオ段 〈動詞の連用形に続いて〉\n1. 簡単である。「解き易い問題」\n2. すぐにそうなる。「壊れ易い品物」 -やむ 止む 五段・マ行 (続いていた雨・音などが)とまる。「雨が止む」「電話の音が止む」 -やむ 病む 五段・マ行 1. 病気になる。「心身が病む」「気を病む」(=心配する)\n2. 〈若者言葉〉〈「病んでる」として〉精神・行動が正常でない。「そこまで束縛するなんて、その彼絶対病んでるって」 -やめる 止める 一段 〈主にかな書き〉していたことをしなくなる、またはする予定だったことをしないことにする。「話すのをやめる」「参加するのをやめる」 -やめる 辞める 一段 (職などから)離れる。辞す。「会社を辞める」 +やすい 易い 形容詞・アウオ段 簡単である。「解き易い問題」 +やむ 止む 五段・マ行 とまる。「雨が止む」 +やむ 病む 五段・マ行 病気になる。「心を病む」 +やめる 止める 一段 終わらせる。「話すのを止める、参加するのを止める」 +やめる 辞める 一段 (仕事などから)はなれる。「会社を辞める」 やる 遣る 五段・ラ行 行かせる。「おつかいに遣る」 -やわらか 柔らか * 1. 〈「軟らか」とも〉力を加えると形をすぐ変えるようす。かたくないようす。「柔らかなクッション」\n2. おだやかであるようす。「柔らかな表情」 -やわらか 軟らか * →柔らか1 -やわらかい 柔らかい 形容詞・アウオ段 1. 〈汎用的〉力を加えると形をすぐ変える。かたくない。「柔らかいクッション」「体が柔らかい」「柔らかい肉」「野菜を柔らかく煮る」\n2. おだやかである。「柔らかい表情」 -やわらかい 軟らかい 形容詞・アウオ段 1. 柔らかい1 に同じ。特に、ぐにゃぐにゃしたものに対して使う。「軟らかい肉」「野菜を軟らかく煮る」\n2. (水について)カルシウムやマグネシウムのイオン含有量が少ない。硬度が低い。軟水である。「軟らかい水」 -ゆうせい 優勢 * 勢いが優ること。形勢がよいこと。「こっちのチームが優勢だ」 -ゆうせい 優性 * (遺伝子が)対立する遺伝子と組み合わされたときに、相手のものではなくみずからの形質をあらわすこと。「優性遺伝」 -ゆうせい 優生 * すぐれているとされる遺伝的形質をもつこと。また、そのようなものを残そうとすること。「優生学」 +やわらか 柔らか * ふっくらしている。「柔らかなクッション」 +やわらか 軟らか * 硬くない。「軟らかな表情」 +やわらかい 柔らかい 形容詞・アウオ段 ふっくらしている。「柔らかいクッション」 +やわらかい 軟らかい 形容詞・アウオ段 硬くない。「軟らかい表情」 +ゆうせい 優勢 * 勢いが優ること。「こっちのチームが優勢だ」 +ゆうせい 優性 * 他の遺伝子とくっついたときに発現する性質。「優勢遺伝」 +ゆうせい 優生 * 優秀な生体のこと。「優生学」 ゆうせい 有性 * 雌雄があること。「有性生殖」 ゆうせい 遊星 * 惑星のこと。 ゆうせい 郵政 * 郵便事業のこと。「郵政民営化」 -ゆうせい 雄性 * (動植物の)おす。 -ゆうわ 宥和 * 敵などに対し、要求を少なくしたり譲歩したりして関係を保とうとすること。「宥和政策」 -ゆうわ 融和 * (人が)仲よくまじりあうこと。「民族が融和する」 -ゆく 往く 五段・カ行イ音便 →行く -ゆく 行く 五段・カ行促音便ユク 〈「往く」とも〉今の場所から移動する。「海に行く」 +ゆうせい 雄性 * おす。 +ゆうわ 宥和 * ゆるして仲良くすること。「宥和政策」 +ゆうわ 融和 * とけあって、仲良くすること。「民族が融和する」 +ゆく 往く 五段・カ行イ音便 (「行く」と区別なし)向かう、移動する。「往く年」 +ゆく 行く 五段・カ行促音便ユク (「往く」と区別なし、一般的)向かう、移動する。「海に行く」 ゆく 逝く 五段・カ行促音便 死ぬ。「父親が逝く」 -よい 好い 形容詞・アウオ段 →良い -よい 善い 形容詞・アウオ段 〈まれ〉道徳的に正しい。「善い行ない」→良い2 -よい 良い 形容詞・アウオ段 1. 〈「好い」とも〉好ましい。すぐれている。望ましい状態である。「良い商品」「良い天気」「頭が良い」「気持ちが良い」\n2. 〈まれに「善い」とも〉道徳的に正しい。「良い行い」 +よい 好い 形容詞・アウオ段 (「良い」と区別なし)好ましい。「好い商品、好い天気」 +よい 善い 形容詞・アウオ段 正しい。「善い行ない」 +よい 良い 形容詞・アウオ段 (「好い」と区別なし、一般的)好ましい。「良い商品、良い天気、頭が良い、気持ちが良い」 よういん 要員 * 必要な人員。「作業要員」 よういん 要因 * おもだった原因。「負けた要因」 -ようかい 容喙 * 口出しすること。「容喙を許さない」 -ようかい 溶解 * 1. 液体にまざり、均一になること。「食塩を水に溶解させる」\n2. 〈金属の場合は「熔解」とも〉固体が熱により液体になること。「氷河が溶解する」「溶解炉」 -ようかい 熔解 * 〈「溶解」とも〉(金属について)固体が熱により液体になること。「熔解炉」 -ようけん 用件 * 用事。「用件を伺います」「用件のみにて失礼します」 -ようけん 要件 * 1. 必要な条件。「この商品は要件を満たしている」\n2. 〈まれ〉主要な内容。「要件のみにて失礼します」 -ようせつ 溶接 * 〈「熔接」とも〉(金属などを)溶かしてくっつけること。「柱を溶接する」 -ようせつ 熔接 * →溶接 +ようかい 容喙 * 口出しすること。 +ようかい 溶解 * とけること。「氷河が溶解する、溶解炉」 +ようかい 熔解 * 固体が熱により液体になること。「熔解炉」 +ようけん 用件 * 用事。「用件を伺います」 +ようけん 要件 * 必要な条件。「この商品は用件を満たしている」 +ようせつ 溶接 * (「熔接」と区別なし)金属などを溶かしてくっつけること。「柱を溶接する」 +ようせつ 熔接 * (「溶接」と区別なし)金属などを溶かしてくっつけること。「柱を熔接する」 ようせつ 夭折 * 若いうちに死ぬこと。 よじょう 余剰 * あまり。「余剰人員」 -よじょう 余情 * 残るような味わい。「余情がない」 -よす 止す 五段・サ行 〈主にかな書き〉やめる。「いたずらをよす」 -よぶ 呼ぶ 五段・バ行 1. 声をかける。「彼の名前を呼ぶ」\n2. 声をかけて、あるいは連絡して来させる。「妹を呼ぶ」「鑑識を呼ぶ」「友達を懇親会に呼ぶ」\n3. 人や物を指すのに、ある名前を使う。名付ける。「彼をあだ名で呼ぶ」「部長と呼ぶ」\n4. (人気などを)集める。「大変な人気を呼んだ」 +よじょう 余情 * のこるような味わい。 +よす 止す 五段・サ行 やめる。「悪戯を止す」 +よぶ 呼ぶ 五段・バ行 名前を叫ぶ。「彼の名前を呼ぶ、懇親会に呼ぶ、彼を仇名で呼ぶ」 よむ 詠む 五段・マ行 詩歌をつくる。「一句詠む」 -よむ 読む 五段・マ行 1. 文字として書かれたものを見て、それを声に出して聞かせる。「子供に絵本を読んでやる」\n2. 文字を見て意味を理解する。「本を読む」\n3. 状況を見てとり、心情や内情や、将来などを予測する。「市場を読む」「表情を読む」「一手先を読む」 -よる 依る 五段・ラ行 〈主にかな書き〉\n1. (別のものに)頼る。依存する。「努力によるところが大きい」\n2. (別のものの程度や性質に)従う。応じる。「人によって感じ方が違う」\n3. 手段とする。「血液検査により診断する」\n4. 受身文で、動作主を明示するために使う。…に。「独裁者によって占領された」 -よる 因る 五段・ラ行 〈主にかな長き〉(事象について)原因となる。「ウィルスによる障害」 -よる 寄る 五段・ラ行 1. 近づく。「そばに寄る」\n2. 集まる。「日本人同士が寄ると日本語を使ってしまう」\n3. 場所が一方向にずれる。「北に少し寄ったところに引っ越す」「画像が少し寄ってしまった」\n4. 一方にかたよる。「弁当を縦に運んだら寄ってしまった」\n5. ついでに行く。立ち寄る。「店に寄る」\n6. (しわが)できる。「服にしわが寄る」 -よる 拠る 五段・ラ行 〈主にかな書き〉根拠とする。もとづく。「国連決議による攻撃」「彼女の説明によると」 -よる 選る 五段・ラ行 〈文語〉選ぶ。 -よる 撚る 五段・ラ行 〈「縒る」とも〉〈かな書きも〉(糸などについて)ねじりあわせる。また、そうして作る。「糸を撚る」「ひもを撚る」 -よる 縒る 五段・ラ行 →撚る -よろこぶ 悦ぶ 五段・バ行 →喜ぶ -よろこぶ 歓ぶ 五段・バ行 →喜ぶ -よろこぶ 喜ぶ 五段・バ行 〈「悦ぶ」「歓ぶ」とも〉\n1. うれしく思う。「泣いて喜ぶ」\n2. 〈行為に対して、主に否定形で〉よいと思う。肯定的に見る。「子供が遠出することを喜ばない」\n3. 〈挨拶文で〉〈「慶ぶ」とも〉めでたく思う。(よいことを)願う。「時下ますますご清祥のこととお喜び申し上げます」 -よろこぶ 慶ぶ 五段・バ行 〈挨拶文で〉〈「喜ぶ」とも〉めでたく思う。(よいことを)願う。「時下ますますご清祥のこととお慶び申し上げます」 -らんちょう 乱丁 * 書物について、ページの順が乱れていること。「乱丁本」 -らんちょう 乱調 * 調子が乱れていること。「今日の投手は乱調気味だ」 -りっぽう 立方 * 1. 三乗。「立方根」(=三乗根)\n2. 長さの単位の前に付けて、その1単位の縦・横・高さのものが持つ体積の単位をつくる。「1立方メートル」\n3. 長さを示す語の後に付けて、その長さの縦・横・高さの空間をあらわす。「30センチ立方の空間」 +よむ 読む 五段・マ行 文字を見て意味を理解する。「本を読む、市場を読む、表情を読む」 +よる 依る 五段・ラ行 たよる。「エキスパートに依る」 +よる 因る 五段・ラ行 原因となる。「ウィルスによる障害」 +よる 寄る 五段・ラ行 ちかづく。「近くに寄る、店に寄る、皺が寄る、寄らば大樹の蔭」 +よる 拠る 五段・ラ行 根拠とする。「国連決議に拠る攻撃」 +よる 選る 五段・ラ行 えらぶ。「不良品を選り分ける」 +よる 撚る 五段・ラ行 (「撚る」と区別なし)ねじりあわせる。「糸を撚る」 +よる 縒る 五段・ラ行 (「縒る」と区別なし)ねじりあわせる。「糸を縒る」 +よろこぶ 悦ぶ 五段・バ行 (「喜ぶ」と区別なし)うれしく思う。「泣いて悦ぶ」 +よろこぶ 喜ぶ 五段・バ行 (「悦ぶ」と区別なし、一般的)うれしく思う。「泣いて喜ぶ」 +よろこぶ 慶ぶ 五段・バ行 祝福する。「宿縁を慶ぶ」 +らんちょう 乱丁 * 書物でうまく綴じられていないこと。「乱丁本」 +らんちょう 乱調 * 調子が乱れていること。「今日の投手は乱調気味」 +りっぽう 立方 * 三乗すること。「立方根、立方体」 りっぽう 立法 * 法律をつくること。「立法院」 -りょうする 諒する サ変・−スル 〈文語〉おもいやる。 -りょうする 領する サ変・−スル 〈文語〉領有する。 -りんかい 臨海 * 海に臨むこと。「臨海都市」 -りんかい 臨界 * 1. そこで性質が大きく変わるような境界。「臨界点」(気体または液体として存在できる限界の温度と圧力)「臨界状態」(原子核分裂が一定速度で続くような状態)\n2. 〈比喩的に〉それ以上我慢できないような、感情の限界。「彼の怒りは臨界に達していた」 +りょう 諒 * (文語)おもいやる。 +りょう 領 * (文語)領有する。 +りんかい 臨海 * 海に望む場所。「臨海都市」 +りんかい 臨界 * 境界。「臨界点」 りんどう 竜胆 * リンドウ科の植物。 -りんどう 林道 * 林のなかに作られた道。 +りんどう 林道 * 林のなかにある道。 れいじょう 令状 * 命令が書かれた書状。「逮捕令状」 れいじょう 礼状 * お礼をする書状。 -れき 暦 * 〈接尾語〉こよみ。カレンダー。「太陽暦」 -れき 歴 * 〈接尾語〉\n1. 過去の記録。「刑事処分歴のある者」\n2. 続けた年数。「記者歴30年のベテラン」 -れんけい 連係 * かかわり。つながり。「連係を保つ」 -れんけい 連繋 * →連係 -れんけい 連携 * 互いに連絡して協力すること。「連携して犯人を逮捕する」 -れんぱ 連覇 * 続けて征覇すること。続けて優勝すること。「日本シリーズで連覇する」 -れんぱ 連破 * 続けて打ち負かすこと。「二人の大関を連破した」 +れき 暦 * こよみ。「太陽暦」 +れき 歴 * 通りすぎること。「歴史」 +れんけい 連係 * つながりをもつこと。「連係プレー」 +れんけい 連携 * 協力すること。「連携して犯人を逮捕する」 +れんぱ 連覇 * 続けて征覇する。「日本シリーズで連覇する」 +れんぱ 連破 * 続けて破ること。 れんぽう 連峰 * つらなっている山。「穂高連峰」 -れんぽう 連邦 * ある程度の独立性をもった州や国が集まり、ひとつの国家を構成すること。また、そのような国家。「連邦国家」「連邦制」 +れんぽう 連邦 * 連邦国家のこと。「連邦国家」 れんめい 連名 * 名前をつらねること。「連名でサインする」 れんめい 連盟 * 同一の目的のために集まること。「高校野球連盟」 -ろうする 労する サ変・−スル 〈文語〉苦労する。「労せずして手に入れる」 -ろうする 弄する サ変・−スル 〈否定的〉(計略などを)使う。あやつる。「術策を弄する」「詭弁(きべん)を弄する」 -ろうふ 老夫 * 〈文語〉老いた男。 +ろう 労 * (文語)苦労する。 +ろう 弄 * (文語)愚弄する。 +ろうふ 老夫 * 老いた男。 ろうふ 老父 * 老いた父親。 -ろじ 路地 * 〈「露地」とも〉家などの間の狭い道。 -ろじ 露地 * 1. 露出した地面。「露地栽培」\n2. →路地 -ろんきゅう 論及 * 論じて言及すること。「その事件について論及している」 -ろんきゅう 論究 * つきつめて論じること。「法律の起源について本格的に論究する」 -わかれる 分かれる 一段 (ものや意見などが)別々になる。または、別々である。「道が分かれる」「意見が分かれる」「上下巻に分かれた本」 -わかれる 別れる 一段 1. (人が)わかれわかれになる。互いから離れる。「駅で友達と別れた」\n2. 恋人・夫婦の関係をたつ。「妻と別れる」 -わく 沸く 五段・カ行イ音便 1. お湯になる。または、沸騰する。「風呂が沸く」「ラーメンをゆでる湯が沸いた」\n2. 熱狂する。「会場をおおいに沸かせた」 -わく 湧く 五段・カ行イ音便 〈「涌く」とも〉\n1. (水などが)自然と地面から出てくる。「温泉が湧く土地」\n2. (汗や涙が)自然と出てくる。「立っているだけで汗が湧く」\n3. 〈かな書きが多い〉(感情や発想などが)自然と出てくる。「勇気が湧く」「興味が湧く」「イメージが湧かない」\n4. (虫などが)発生する。〈否定的に〉(人が)集まってくる。「米に虫が湧く」「怪しいやつらがどこからか湧いてきた」 -わく 涌く 五段・カ行イ音便 →湧く -わざ 技 * 1. 技術。「職人の技が活かされている」\n2. 武術などで相手にしかける動作。「必殺技」 -わざ 業 * 〈文語〉行為。〈「~のなせる業」として〉結果。「自信のなせる業」 -わずらう 患う 五段・ワ行促音便 病気になる。かかる。「風邪を患う」 -わずらう 煩う 五段・ワ行促音便 〈複合語で〉上手くいかずに悩む。苦しむ。「思い煩う」 -わたる 渡る 五段・ラ行 1. 間にあるものを越えて移動する。「橋を渡る」「海外に渡る」\n2. つたって移動する。「枝を渡る」\n3. (世の中で)暮らしていく。「世間を渡る」\n4. 〈主にかな書き〉〈「亘る」とも〉ある範囲に及ぶ。「広範囲にわたって調査する」「五十項目にわたる改善案」「三日間にわたる調査」 -わたる 亘る 五段・ラ行 →渡る4 +ろじ 路地 * 家などの間の狭いみち。 +ろじ 露地 * 露出した地面。「露地栽培」 +ろんきゅう 論及 * 論じて及ぶこと。 +ろんきゅう 論究 * 論じて究めること。 +わかれる 分かれる 一段 分裂する。「意見が分かれる」 +わかれる 別れる 一段 別々になる。「彼氏と別れる」 +わく 沸く 五段・カ行イ音便 お湯になる。「風呂が沸く」 +わく 湧く 五段・カ行イ音便 (「涌く」と区別なし) +わく 涌く 五段・カ行イ音便 (「湧く」と区別なし) +わざ 技 * 技術、武術などで相手にしかける動作。「職人の技が活かされている、必殺技」 +わざ 業 * 行ない、職業。「人間業ではない」 +わずらう 患う 五段・ワ行促音便 病気になる。「風邪を患う」 +わずらう 煩う 五段・ワ行促音便 上手くいかずに悩む、苦しむ。「思い煩う」 +わたる 渡る 五段・ラ行 移動する。「海外に渡る、職を渡る、橋を渡る」 +わたる 亘る 五段・ラ行 長さがおよぶ。「2ヶ月に亘る捜索」 diff --git a/upstream-debian/changelog b/upstream-debian/changelog new file mode 100755 index 0000000..afc379d --- /dev/null +++ b/upstream-debian/changelog @@ -0,0 +1,153 @@ +mozc (1.3.911.102) lucid; urgency=low + + * Ver. 1.3.911.102 on 2011-11-28 + * Support new features for IBus. + - Support UNDO feature. + - Support Reconversion feature for IBus >=1.4. + - Add some menus into language bar. + - Set ibus-mozc rank as 80. + * Fixed some bugs. + - Fixed English-number toggle key issue for emacs.(Issue 101) + - Fixed crash problem on scim.(Issue 104) + * Change dependency name for Ubuntu 11.10.(Issue 106) + + -- Seigo Nonaka Mon, 28 Nov 2011 15:02:44 +0900 + +mozc (1.2.855.102) lucid; urgency=low + + * Ver. 1.2.855.102 on 2011-09-27 + + -- Tsuyoshi Horo Tue, 27 Sep 2011 15:55:43 +0900 + +mozc (1.2.831.102) lucid; urgency=low + + * Updated dictionary. + * Fixed some bugs. + + -- Tatsuhisa Yamaguchi Thu, 01 Sep 2011 15:37:09 +0900 + +mozc (1.2.809.102) lucid; urgency=low + + * Ver. 1.2.809.102 on 2011-08-12 + + -- Tsuyoshi Horo Fri, 12 Aug 2011 12:28:58 +0900 + +mozc (1.1.773.102) lucid; urgency=low + + * Ver. 1.1.773.102 on 2011-07-07 + + -- Hiroshi Sumita Thu, 07 Jul 2011 15:45:12 +0900 + +mozc (1.1.758.102) lucid; urgency=low + + * Ver. 1.1.758.102 on 2011-06-23 + + -- Hitoshi Yoshida Thu, 23 Jun 2011 20:22:10 +0900 + +mozc (1.1.739.102) lucid; urgency=low + + * Ver. 1.1.739.102 on 2011-06-09 + + -- Seigo Nonaka Thu, 09 Jun 2011 15:36:56 +0900 + +mozc (1.1.717.102) lucid; urgency=low + + * Ver. 1.1.717.102 on 2011-05-12 + + -- Hiroyuki Komatsu Thu, 12 May 2011 14:33:14 +0900 + +mozc (1.1.690.102) lucid; urgency=low + + * Ver. 1.1.690.102 on 2011-04-14 + + -- Hiroyuki Komatsu Thu, 14 Apr 2011 17:43:40 +0900 + +mozc (1.1.626.102) lucid; urgency=low + + * Ver. 1.1.626.102 on 2011-02-16 + + -- Yasuhiro Matsuda Wed, 16 Feb 2011 18:44:11 +0900 + +mozc (1.0.558.102) lucid; urgency=low + + * Ver. 1.0.558.102 on 2010-12-09 + + -- Hiroyuki Komatsu Thu, 09 Dec 2010 11:23:35 +0900 + +mozc (0.13.523.102) lucid; urgency=low + + * Ver. 0.13.523.102 on 2010-11-02 + + -- Yasuhiro Matsuda Tue, 02 Nov 2010 19:45:33 +0900 + +mozc (0.13.499.102) lucid; urgency=low + + * Ver. 0.13.499.102 on 2010-10-07 + + -- Hiroyuki Komatsu Thu, 07 Oct 2010 14:43:24 +0900 + +mozc (0.13.492.102) lucid; urgency=low + + * Ver. 0.13.492.102 on 2010-09-27 + + -- Yasuhiro Matsuda Mon, 27 Sep 2010 18:26:11 +0900 + +mozc (0.13.481.102) lucid; urgency=low + + * Ver. 0.13.481.102 on 2010-09-22 + + -- Yasuhiro Matsuda Wed, 22 Sep 2010 18:39:14 +0900 + +mozc (0.13.464.102) lucid; urgency=low + + * Ver. 0.13.464.102 on 2010-09-02 + + -- Hiroyuki Komatsu Fri, 03 Sep 2010 13:14:44 +0900 + +mozc (0.12.434.102) lucid; urgency=low + + * Ver. 0.12.434.102 on 2010-08-11 + + -- Yasuhiro Matsuda Wed, 11 Aug 2010 19:59:17 +0900 + +mozc (0.12.422.102) lucid; urgency=low + + * Ver. 0.12.422.102 on 2010-07-23 + + -- Yasuhiro Matsuda Fri, 23 Jul 2010 14:33:29 +0900 + +mozc (0.12.410.102) lucid; urgency=low + + * Ver. 0.12.410.102 on 2010-07-12 + + -- Hiroyuki Komatsu Mon, 12 Jul 2010 14:11:04 +0900 + +mozc (0.12.402.102) lucid; urgency=low + + * Ver. 0.12.402.102 on 2010-06-30 + + -- Yasuhiro Matsuda Wed, 30 Jun 2010 13:22:54 +0900 + +mozc (0.11.383.102) lucid; urgency=low + + * Ver. 0.11.383.102 on 2010-06-16 + + -- Yasuhiro Matsuda Wed, 16 Jun 2010 15:39:33 +0900 + +mozc (0.11.365.102) lucid; urgency=low + + * Ver. 0.11.365.102 on 2010-05-25 + + -- Yasuhiro Matsuda Tue, 25 May 2010 16:54:03 +0900 + +mozc (0.11.354.100) lucid; urgency=low + + * Ver. 0.11.354.100 on 2010-05-17 + + -- Yusuke Sato Mon, 17 May 2010 19:22:54 +0900 + +mozc (0.10.288.102) jaunty; urgency=low + + * Ver. 0.10.288.102 on 2010-03-09 + + -- Hiroyuki Komatsu Tue, 09 Mar 2010 16:01:11 +0900 diff --git a/upstream-debian/compat b/upstream-debian/compat new file mode 100755 index 0000000..b8626c4 --- /dev/null +++ b/upstream-debian/compat @@ -0,0 +1 @@ +4 diff --git a/upstream-debian/control b/upstream-debian/control new file mode 100755 index 0000000..5cdbd46 --- /dev/null +++ b/upstream-debian/control @@ -0,0 +1,36 @@ +Source: mozc +Section: utils +Priority: extra +Maintainer: Yusuke Sato +Build-Depends: debhelper (>= 4.0.0), libibus-dev | libibus-1.0-dev, libcurl4-openssl-dev, pkg-config, libprotobuf-dev, protobuf-compiler, libgtest-dev, libqt4-dev, scim, libscim-dev, gyp, libzinnia-dev +Standards-Version: 3.6.2 + +Package: ibus-mozc +Architecture: any +Depends: ${shlibs:Depends}, ibus, mozc-server (= ${Source-Version}) +Description: IBus engine module for Mozc. + +Package: scim-mozc +Architecture: any +Depends: ${shlibs:Depends}, scim, mozc-server (= ${Source-Version}) +Description: SCIM IMEngine module for Mozc. + +Package: emacs-mozc +Architecture: all +Depends: emacs | emacs22 | emacs23 | emacs-snapshot, emacs-mozc-bin (= ${Source-Version}) +Description: Mozc for Emacs. + +Package: emacs-mozc-bin +Architecture: any +Depends: ${shlibs:Depends}, mozc-server (= ${Source-Version}) +Description: Helper module for emacs-mozc + +Package: mozc-server +Architecture: any +Depends: ${shlibs:Depends} +Description: Server part of the Mozc input method, used by Mozc clients such as ibus-mozc. + +Package: mozc-utils-gui +Architecture: any +Depends: ${shlibs:Depends}, mozc-server (= ${Source-Version}), tegaki-zinnia-japanese, libzinnia0 +Description: Mozc GUI uitilities, such as the configuration dialog, user dictionary tool and about dialog. diff --git a/upstream-debian/copyright b/upstream-debian/copyright new file mode 100755 index 0000000..2ebf7c0 --- /dev/null +++ b/upstream-debian/copyright @@ -0,0 +1,28 @@ +Copyright 2010, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/upstream-debian/rules b/upstream-debian/rules new file mode 100755 index 0000000..978e079 --- /dev/null +++ b/upstream-debian/rules @@ -0,0 +1,149 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. +# +# Modified to make a template file for a multi-binary package with separated +# build-arch and build-indep targets by Bill Allombert 2001 + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +BUILD_DIR=./out_linux +TARGETS=unix/ibus/ibus.gyp:ibus_mozc unix/scim/scim.gyp:scim_mozc unix/scim/scim.gyp:scim_mozc_setup unix/emacs/emacs.gyp:mozc_emacs_helper server/server.gyp:mozc_server gui/gui.gyp:mozc_tool + +configure: configure-stamp +configure-stamp: + dh_testdir + touch configure-stamp + + +#Architecture +build: build-arch build-indep + +build-arch: build-arch-stamp +build-arch-stamp: configure-stamp + python build_mozc.py gyp --gypdir=/usr/bin + python build_mozc.py build_tools -c Release + python build_mozc.py build $(TARGETS) -c Release + touch build-arch-stamp + +build-indep: build-indep-stamp +build-indep-stamp: configure-stamp + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP# + python build_mozc.py clean + dh_clean + +install: install-arch install-indep + +install-indep: + dh_testdir + dh_testroot + dh_prep + dh_installdirs + + mkdir -p $(CURDIR)/debian/emacs-mozc/usr/share/emacs/site-lisp/emacs-mozc/ + cp -p unix/emacs/mozc.el $(CURDIR)/debian/emacs-mozc/usr/share/emacs/site-lisp/emacs-mozc/ + +install-arch: + dh_testdir + dh_testroot + dh_clean -k -s + dh_installdirs -s + + mkdir -p $(CURDIR)/debian/ibus-mozc/usr/lib/ibus-mozc/ + cp -p $(BUILD_DIR)/Release/ibus_mozc $(CURDIR)/debian/ibus-mozc/usr/lib/ibus-mozc/ibus-engine-mozc + mkdir -p $(CURDIR)/debian/ibus-mozc/usr/share/ibus/component/ + sed 's|/usr/libexec/ibus-engine-mozc|/usr/lib/ibus-mozc/ibus-engine-mozc|' < $(BUILD_DIR)/Release/obj/gen/unix/ibus/mozc.xml > $(CURDIR)/debian/ibus-mozc/usr/share/ibus/component/mozc.xml + mkdir -p $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/ + cp -p data/images/unix/ime_product_icon_opensource-32.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/product_icon.png + cp -p data/images/unix/ui-tool.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/tool.png + cp -p data/images/unix/ui-properties.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/properties.png + cp -p data/images/unix/ui-dictionary.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/dictionary.png + cp -p data/images/unix/ui-direct.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/direct.png + cp -p data/images/unix/ui-hiragana.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/hiragana.png + cp -p data/images/unix/ui-katakana_half.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/katakana_half.png + cp -p data/images/unix/ui-katakana_full.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/katakana_full.png + cp -p data/images/unix/ui-alpha_half.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/alpha_half.png + cp -p data/images/unix/ui-alpha_full.png $(CURDIR)/debian/ibus-mozc/usr/share/ibus-mozc/alpha_full.png + + mkdir -p $(CURDIR)/debian/scim-mozc`pkg-config --variable=moduledir scim`/IMEngine/ + cp -p $(BUILD_DIR)/Release/lib.target/libscim_mozc.so $(CURDIR)/debian/scim-mozc`pkg-config --variable=moduledir scim`/IMEngine/mozc.so + mkdir -p $(CURDIR)/debian/scim-mozc`pkg-config --variable=moduledir scim`/SetupUI/ + cp -p $(BUILD_DIR)/Release/lib.target/libscim_mozc_setup.so $(CURDIR)/debian/scim-mozc`pkg-config --variable=moduledir scim`/SetupUI/mozc-setup.so + mkdir -p $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/ + cp -p data/images/unix/ime_product_icon_opensource-32.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc.png + cp -p data/images/unix/ui-tool.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-tool.png + cp -p data/images/unix/ui-properties.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-properties.png + cp -p data/images/unix/ui-dictionary.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-dictionary.png + cp -p data/images/unix/ui-direct.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-direct.png + cp -p data/images/unix/ui-hiragana.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-hiragana.png + cp -p data/images/unix/ui-katakana_half.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-katakana_half.png + cp -p data/images/unix/ui-katakana_full.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-katakana_full.png + cp -p data/images/unix/ui-alpha_half.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-alpha_half.png + cp -p data/images/unix/ui-alpha_full.png $(CURDIR)/debian/scim-mozc`pkg-config --variable=icondir scim`/scim-mozc-alpha_full.png + + mkdir -p $(CURDIR)/debian/emacs-mozc-bin/usr/bin/ + cp -p $(BUILD_DIR)/Release/mozc_emacs_helper $(CURDIR)/debian/emacs-mozc-bin/usr/bin/ + + mkdir -p $(CURDIR)/debian/mozc-server/usr/lib/mozc + cp -p $(BUILD_DIR)/Release/mozc_server $(CURDIR)/debian/mozc-server/usr/lib/mozc/ + + mkdir -p $(CURDIR)/debian/mozc-utils-gui/usr/lib/mozc + cp -p $(BUILD_DIR)/Release/mozc_tool $(CURDIR)/debian/mozc-utils-gui/usr/lib/mozc + + dh_install -s + +# Must not depend on anything. This is to be called by +# binary-arch/binary-indep +# in another 'make' thread. +binary-common: + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate + dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_python + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-indep: build-indep install-indep + $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common + +# Build architecture dependant packages using the common target. +binary-arch: build-arch install-arch + $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common + +binary: binary-arch binary-indep +.PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure