Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: pylib/gyp/generator/ninja.py

Issue 27418008: ninja: Write gypcmd files into the output directory instead of the tree. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pylib/gyp/__init__.py ('k') | pylib/gyp/input.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013 Google Inc. All rights reserved. 1 # Copyright (c) 2013 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import copy 5 import copy
6 import hashlib 6 import hashlib
7 import json 7 import json
8 import multiprocessing 8 import multiprocessing
9 import os.path 9 import os.path
10 import re 10 import re
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 'RULE_INPUT_DIRNAME': '${dirname}', 51 'RULE_INPUT_DIRNAME': '${dirname}',
52 'RULE_INPUT_PATH': '${source}', 52 'RULE_INPUT_PATH': '${source}',
53 'RULE_INPUT_EXT': '${ext}', 53 'RULE_INPUT_EXT': '${ext}',
54 'RULE_INPUT_NAME': '${name}', 54 'RULE_INPUT_NAME': '${name}',
55 } 55 }
56 56
57 # Placates pylint. 57 # Placates pylint.
58 generator_additional_non_configuration_keys = [] 58 generator_additional_non_configuration_keys = []
59 generator_additional_path_sections = [] 59 generator_additional_path_sections = []
60 generator_extra_sources_for_rules = [] 60 generator_extra_sources_for_rules = []
61 generator_filelist_path = None
61 62
62 # TODO: figure out how to not build extra host objects in the non-cross-compile 63 # TODO: figure out how to not build extra host objects in the non-cross-compile
63 # case when this is enabled, and enable unconditionally. 64 # case when this is enabled, and enable unconditionally.
64 generator_supports_multiple_toolsets = ( 65 generator_supports_multiple_toolsets = (
65 os.environ.get('GYP_CROSSCOMPILE') or 66 os.environ.get('GYP_CROSSCOMPILE') or
66 os.environ.get('AR_host') or 67 os.environ.get('AR_host') or
67 os.environ.get('CC_host') or 68 os.environ.get('CC_host') or
68 os.environ.get('CXX_host') or 69 os.environ.get('CXX_host') or
69 os.environ.get('AR_target') or 70 os.environ.get('AR_target') or
70 os.environ.get('CC_target') or 71 os.environ.get('CC_target') or
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 operating_system = flavor 1452 operating_system = flavor
1452 if flavor == 'android': 1453 if flavor == 'android':
1453 operating_system = 'linux' # Keep this legacy behavior for now. 1454 operating_system = 'linux' # Keep this legacy behavior for now.
1454 default_variables.setdefault('OS', operating_system) 1455 default_variables.setdefault('OS', operating_system)
1455 default_variables.setdefault('SHARED_LIB_SUFFIX', '.so') 1456 default_variables.setdefault('SHARED_LIB_SUFFIX', '.so')
1456 default_variables.setdefault('SHARED_LIB_DIR', 1457 default_variables.setdefault('SHARED_LIB_DIR',
1457 os.path.join('$!PRODUCT_DIR', 'lib')) 1458 os.path.join('$!PRODUCT_DIR', 'lib'))
1458 default_variables.setdefault('LIB_DIR', 1459 default_variables.setdefault('LIB_DIR',
1459 os.path.join('$!PRODUCT_DIR', 'obj')) 1460 os.path.join('$!PRODUCT_DIR', 'obj'))
1460 1461
1462 def ComputeOutputDir(params):
1463 """Returns the path from the toplevel_dir to the build output directory."""
1464 # generator_dir: relative path from pwd to where make puts build files.
1465 # Makes migrating from make to ninja easier, ninja doesn't put anything here.
1466 generator_dir = os.path.relpath(params['options'].generator_output or '.')
1467
1468 # output_dir: relative path from generator_dir to the build directory.
1469 output_dir = params.get('generator_flags', {}).get('output_dir', 'out')
1470
1471 # Relative path from source root to our output files. e.g. "out"
1472 return os.path.normpath(os.path.join(generator_dir, output_dir))
1473
1474
1475 def CalculateGeneratorInputInfo(params):
1476 """Called by __init__ to initialize generator values based on params."""
1477 # E.g. "out/gypfiles"
1478 qualified_out_dir = os.path.normpath(os.path.join(
1479 params['options'].toplevel_dir, ComputeOutputDir(params), 'gypfiles'))
1480
1481 def gypfile_path(build_file_dir, name):
1482 # build_file_dir is absolute, make it relative to toplevel
1483 if os.path.isabs(build_file_dir):
1484 build_file_dir = gyp.common.RelativePath(build_file_dir, toplevel)
1485 name = os.path.join(qualified_out_dir, build_file_dir, name)
1486 if not os.path.isdir(os.path.dirname(name)):
1487 os.makedirs(os.path.dirname(name))
1488 return name
1489
1490 global generator_filelist_path
1491 generator_filelist_path = gypfile_path
1492
1461 1493
1462 def OpenOutput(path, mode='w'): 1494 def OpenOutput(path, mode='w'):
1463 """Open |path| for writing, creating directories if necessary.""" 1495 """Open |path| for writing, creating directories if necessary."""
1464 try: 1496 try:
1465 os.makedirs(os.path.dirname(path)) 1497 os.makedirs(os.path.dirname(path))
1466 except OSError: 1498 except OSError:
1467 pass 1499 pass
1468 return open(path, mode) 1500 return open(path, mode)
1469 1501
1470 1502
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 rspfile_content='$in_newline $libs $ldflags', 1633 rspfile_content='$in_newline $libs $ldflags',
1602 pool='link_pool') 1634 pool='link_pool')
1603 1635
1604 1636
1605 def GenerateOutputForConfig(target_list, target_dicts, data, params, 1637 def GenerateOutputForConfig(target_list, target_dicts, data, params,
1606 config_name): 1638 config_name):
1607 options = params['options'] 1639 options = params['options']
1608 flavor = gyp.common.GetFlavor(params) 1640 flavor = gyp.common.GetFlavor(params)
1609 generator_flags = params.get('generator_flags', {}) 1641 generator_flags = params.get('generator_flags', {})
1610 1642
1611 # generator_dir: relative path from pwd to where make puts build files.
1612 # Makes migrating from make to ninja easier, ninja doesn't put anything here.
1613 generator_dir = os.path.relpath(params['options'].generator_output or '.')
1614
1615 # output_dir: relative path from generator_dir to the build directory.
1616 output_dir = generator_flags.get('output_dir', 'out')
1617
1618 # build_dir: relative path from source root to our output files. 1643 # build_dir: relative path from source root to our output files.
1619 # e.g. "out/Debug" 1644 # e.g. "out/Debug"
1620 build_dir = os.path.normpath(os.path.join(generator_dir, 1645 build_dir = os.path.normpath(
1621 output_dir, 1646 os.path.join(ComputeOutputDir(params), config_name))
1622 config_name))
1623 1647
1624 toplevel_build = os.path.join(options.toplevel_dir, build_dir) 1648 toplevel_build = os.path.join(options.toplevel_dir, build_dir)
1625 1649
1626 master_ninja = ninja_syntax.Writer( 1650 master_ninja = ninja_syntax.Writer(
1627 OpenOutput(os.path.join(toplevel_build, 'build.ninja')), 1651 OpenOutput(os.path.join(toplevel_build, 'build.ninja')),
1628 width=120) 1652 width=120)
1629 1653
1630 # Put build-time support tools in out/{config_name}. 1654 # Put build-time support tools in out/{config_name}.
1631 gyp.common.CopyTool(flavor, toplevel_build) 1655 gyp.common.CopyTool(flavor, toplevel_build)
1632 1656
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
2108 arglists.append( 2132 arglists.append(
2109 (target_list, target_dicts, data, params, config_name)) 2133 (target_list, target_dicts, data, params, config_name))
2110 pool.map(CallGenerateOutputForConfig, arglists) 2134 pool.map(CallGenerateOutputForConfig, arglists)
2111 except KeyboardInterrupt, e: 2135 except KeyboardInterrupt, e:
2112 pool.terminate() 2136 pool.terminate()
2113 raise e 2137 raise e
2114 else: 2138 else:
2115 for config_name in config_names: 2139 for config_name in config_names:
2116 GenerateOutputForConfig(target_list, target_dicts, data, params, 2140 GenerateOutputForConfig(target_list, target_dicts, data, params,
2117 config_name) 2141 config_name)
OLDNEW
« no previous file with comments | « pylib/gyp/__init__.py ('k') | pylib/gyp/input.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698