Skip to content

Commit

Permalink
Upgrade gyp to b3cef02.
Browse files Browse the repository at this point in the history
* adds netbsd support: https://codereview.chromium.org/1421073004

* fixes cp(1) use on openbsd: https://codereview.chromium.org/1483473002

Fixes: #571
Fixes: #803
PR-URL: #831
Reviewed-By: Jeremiah Senkpiel <[email protected]>
  • Loading branch information
bnoordhuis committed Dec 3, 2015
1 parent 90078ec commit ab89b47
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 103 deletions.
1 change: 1 addition & 0 deletions gyp/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Steven Knight <[email protected]>
Ryan Norton <[email protected]>
David J. Sankel <[email protected]>
Eric N. Vander Weele <[email protected]>
Tom Freudenberg <[email protected]>
2 changes: 2 additions & 0 deletions gyp/pylib/gyp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ def GetFlavor(params):
return 'freebsd'
if sys.platform.startswith('openbsd'):
return 'openbsd'
if sys.platform.startswith('netbsd'):
return 'netbsd'
if sys.platform.startswith('aix'):
return 'aix'

Expand Down
293 changes: 213 additions & 80 deletions gyp/pylib/gyp/generator/analyzer.py

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions gyp/pylib/gyp/generator/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
'CONFIGURATION_NAME': '${configuration}',
}

FULL_PATH_VARS = ('${CMAKE_SOURCE_DIR}', '${builddir}', '${obj}')
FULL_PATH_VARS = ('${CMAKE_CURRENT_LIST_DIR}', '${builddir}', '${obj}')

generator_supports_multiple_toolsets = True
generator_wants_static_library_dependencies_adjusted = True
Expand Down Expand Up @@ -103,7 +103,7 @@ def NormjoinPathForceCMakeSource(base_path, rel_path):
if any([rel_path.startswith(var) for var in FULL_PATH_VARS]):
return rel_path
# TODO: do we need to check base_path for absolute variables as well?
return os.path.join('${CMAKE_SOURCE_DIR}',
return os.path.join('${CMAKE_CURRENT_LIST_DIR}',
os.path.normpath(os.path.join(base_path, rel_path)))


Expand Down Expand Up @@ -293,7 +293,7 @@ def WriteActions(target_name, actions, extra_sources, extra_deps,
WriteVariable(output, inputs_name)
output.write('\n')

output.write(' WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/')
output.write(' WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/')
output.write(path_to_gyp)
output.write('\n')

Expand Down Expand Up @@ -398,9 +398,9 @@ def WriteRules(target_name, rules, extra_sources, extra_deps,
output.write(NormjoinPath(path_to_gyp, rule_source))
output.write('\n')

# CMAKE_SOURCE_DIR is where the CMakeLists.txt lives.
# CMAKE_CURRENT_LIST_DIR is where the CMakeLists.txt lives.
# The cwd is the current build directory.
output.write(' WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/')
output.write(' WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/')
output.write(path_to_gyp)
output.write('\n')

Expand Down Expand Up @@ -522,7 +522,7 @@ def __init__(self, ext, command):
WriteVariable(output, copy.inputs_name, ' ')
output.write('\n')

output.write('WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/')
output.write('WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/')
output.write(path_to_gyp)
output.write('\n')

Expand Down Expand Up @@ -1126,7 +1126,7 @@ def GenerateOutputForConfig(target_list, target_dicts, data,
if cc:
SetVariable(output, 'CMAKE_ASM_COMPILER', cc)

SetVariable(output, 'builddir', '${CMAKE_BINARY_DIR}')
SetVariable(output, 'builddir', '${CMAKE_CURRENT_BINARY_DIR}')
SetVariable(output, 'obj', '${builddir}/obj')
output.write('\n')

Expand Down
7 changes: 6 additions & 1 deletion gyp/pylib/gyp/generator/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ def WriteTarget(self, spec, configs, deps, link_deps, bundle_deps,
for link_dep in link_deps:
assert ' ' not in link_dep, (
"Spaces in alink input filenames not supported (%s)" % link_dep)
if (self.flavor not in ('mac', 'openbsd', 'win') and not
if (self.flavor not in ('mac', 'openbsd', 'netbsd', 'win') and not
self.is_standalone_static_library):
self.WriteDoCmd([self.output_binary], link_deps, 'alink_thin',
part_of_all, postbuilds=postbuilds)
Expand Down Expand Up @@ -2046,6 +2046,11 @@ def CalculateMakefilePath(build_file, base_name):
header_params.update({
'flock': 'lockf',
})
elif flavor == 'openbsd':
copy_archive_arguments = '-pPRf'
header_params.update({
'copy_archive_args': copy_archive_arguments,
})
elif flavor == 'aix':
copy_archive_arguments = '-pPRf'
header_params.update({
Expand Down
16 changes: 12 additions & 4 deletions gyp/pylib/gyp/generator/ninja.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ def __init__(self, type):
self.bundle = None
# On Windows, incremental linking requires linking against all the .objs
# that compose a .lib (rather than the .lib itself). That list is stored
# here.
# here. In this case, we also need to save the compile_deps for the target,
# so that the the target that directly depends on the .objs can also depend
# on those.
self.component_objs = None
self.compile_deps = None
# Windows only. The import .lib is the output of a build step, but
# because dependents only link against the lib (not both the lib and the
# dll) we keep track of the import library here.
Expand Down Expand Up @@ -474,16 +477,17 @@ def WriteSpec(self, spec, config_name, generator_flags):
elif self.flavor == 'mac' and len(self.archs) > 1:
link_deps = collections.defaultdict(list)


compile_deps = self.target.actions_stamp or actions_depends
if self.flavor == 'win' and self.target.type == 'static_library':
self.target.component_objs = link_deps
self.target.compile_deps = compile_deps

# Write out a link step, if needed.
output = None
is_empty_bundle = not link_deps and not mac_bundle_depends
if link_deps or self.target.actions_stamp or actions_depends:
output = self.WriteTarget(spec, config_name, config, link_deps,
self.target.actions_stamp or actions_depends)
compile_deps)
if self.is_mac_bundle:
mac_bundle_depends.append(output)

Expand Down Expand Up @@ -1093,6 +1097,7 @@ def WriteLinkForArch(self, ninja_file, spec, config_name, config,

implicit_deps = set()
solibs = set()
order_deps = set()

if 'dependencies' in spec:
# Two kinds of dependencies:
Expand All @@ -1111,6 +1116,8 @@ def WriteLinkForArch(self, ninja_file, spec, config_name, config,
target.component_objs and
self.msvs_settings.IsUseLibraryDependencyInputs(config_name)):
new_deps = target.component_objs
if target.compile_deps:
order_deps.add(target.compile_deps)
elif self.flavor == 'win' and target.import_lib:
new_deps = [target.import_lib]
elif target.UsesToc(self.flavor):
Expand Down Expand Up @@ -1249,6 +1256,7 @@ def WriteLinkForArch(self, ninja_file, spec, config_name, config,

ninja_file.build(output, command + command_suffix, link_deps,
implicit=list(implicit_deps),
order_only=list(order_deps),
variables=extra_bindings)
return linked_binary

Expand All @@ -1263,7 +1271,7 @@ def WriteTarget(self, spec, config_name, config, link_deps, compile_deps):
self.target.type = 'none'
elif spec['type'] == 'static_library':
self.target.binary = self.ComputeOutput(spec)
if (self.flavor not in ('mac', 'openbsd', 'win') and not
if (self.flavor not in ('mac', 'openbsd', 'netbsd', 'win') and not
self.is_standalone_static_library):
self.ninja.build(self.target.binary, 'alink_thin', link_deps,
order_only=compile_deps)
Expand Down
48 changes: 45 additions & 3 deletions gyp/pylib/gyp/generator/xcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
'mac_framework_private_headers',
]

generator_filelist_paths = None

# 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([
Expand Down Expand Up @@ -578,6 +580,26 @@ def PerformBuild(data, configurations, params):
subprocess.check_call(arguments)


def CalculateGeneratorInputInfo(params):
toplevel = params['options'].toplevel_dir
if params.get('flavor') == 'ninja':
generator_dir = os.path.relpath(params['options'].generator_output or '.')
output_dir = params.get('generator_flags', {}).get('output_dir', 'out')
output_dir = os.path.normpath(os.path.join(generator_dir, output_dir))
qualified_out_dir = os.path.normpath(os.path.join(
toplevel, output_dir, 'gypfiles-xcode-ninja'))
else:
output_dir = os.path.normpath(os.path.join(toplevel, 'xcodebuild'))
qualified_out_dir = os.path.normpath(os.path.join(
toplevel, output_dir, 'gypfiles'))

global generator_filelist_paths
generator_filelist_paths = {
'toplevel': toplevel,
'qualified_out_dir': qualified_out_dir,
}


def GenerateOutput(target_list, target_dicts, data, params):
# Optionally configure each spec to use ninja as the external builder.
ninja_wrapper = params.get('flavor') == 'ninja'
Expand All @@ -590,6 +612,15 @@ def GenerateOutput(target_list, target_dicts, data, params):
parallel_builds = generator_flags.get('xcode_parallel_builds', True)
serialize_all_tests = \
generator_flags.get('xcode_serialize_all_test_runs', True)
upgrade_check_project_version = \
generator_flags.get('xcode_upgrade_check_project_version', None)

# Format upgrade_check_project_version with leading zeros as needed.
if upgrade_check_project_version:
upgrade_check_project_version = str(upgrade_check_project_version)
while len(upgrade_check_project_version) < 4:
upgrade_check_project_version = '0' + upgrade_check_project_version

skip_excluded_files = \
not generator_flags.get('xcode_list_excluded_files', True)
xcode_projects = {}
Expand All @@ -604,9 +635,17 @@ def GenerateOutput(target_list, target_dicts, data, params):
xcode_projects[build_file] = xcp
pbxp = xcp.project

# Set project-level attributes from multiple options
project_attributes = {};
if parallel_builds:
pbxp.SetProperty('attributes',
{'BuildIndependentTargetsInParallel': 'YES'})
project_attributes['BuildIndependentTargetsInParallel'] = 'YES'
if upgrade_check_project_version:
project_attributes['LastUpgradeCheck'] = upgrade_check_project_version
project_attributes['LastTestingUpgradeCheck'] = \
upgrade_check_project_version
project_attributes['LastSwiftUpdateCheck'] = \
upgrade_check_project_version
pbxp.SetProperty('attributes', project_attributes)

# Add gyp/gypi files to project
if not generator_flags.get('standalone'):
Expand Down Expand Up @@ -648,14 +687,17 @@ def GenerateOutput(target_list, target_dicts, data, params):
'loadable_module': 'com.googlecode.gyp.xcode.bundle',
'shared_library': 'com.apple.product-type.library.dynamic',
'static_library': 'com.apple.product-type.library.static',
'mac_kernel_extension': 'com.apple.product-type.kernel-extension',
'executable+bundle': 'com.apple.product-type.application',
'loadable_module+bundle': 'com.apple.product-type.bundle',
'loadable_module+xctest': 'com.apple.product-type.bundle.unit-test',
'shared_library+bundle': 'com.apple.product-type.framework',
'executable+extension+bundle': 'com.apple.product-type.app-extension',
'executable+watch+extension+bundle':
'com.apple.product-type.watchkit-extension',
'executable+watch+bundle': 'com.apple.product-type.application.watchapp',
'executable+watch+bundle':
'com.apple.product-type.application.watchapp',
'mac_kernel_extension+bundle': 'com.apple.product-type.kernel-extension',
}

target_properties = {
Expand Down
20 changes: 13 additions & 7 deletions gyp/pylib/gyp/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@


# A list of types that are treated as linkable.
linkable_types = ['executable', 'shared_library', 'loadable_module']
linkable_types = [
'executable',
'shared_library',
'loadable_module',
'mac_kernel_extension',
]

# A list of sections that contain links to other targets.
dependency_sections = ['dependencies', 'export_dependent_settings']
Expand Down Expand Up @@ -1724,11 +1729,12 @@ def _LinkDependenciesInternal(self, targets, include_shared_libraries,
dependencies.add(self.ref)
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'):
# Executables, mac kernel extensions 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',
'mac_kernel_extension'):
return dependencies

# Shared libraries are already fully linked. They should only be included
Expand Down Expand Up @@ -2479,7 +2485,7 @@ def ValidateTargetType(target, target_dict):
"""
VALID_TARGET_TYPES = ('executable', 'loadable_module',
'static_library', 'shared_library',
'none')
'mac_kernel_extension', 'none')
target_type = target_dict.get('type', None)
if target_type not in VALID_TARGET_TYPES:
raise GypError("Target %s has an invalid target type '%s'. "
Expand Down
1 change: 1 addition & 0 deletions gyp/pylib/gyp/xcode_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,7 @@ def _GetXcodeEnv(xcode_settings, built_products_dir, srcroot, configuration,

# These are filled in on a as-needed basis.
env = {
'BUILT_FRAMEWORKS_DIR' : built_products_dir,
'BUILT_PRODUCTS_DIR' : built_products_dir,
'CONFIGURATION' : configuration,
'PRODUCT_NAME' : xcode_settings.GetProductName(),
Expand Down
5 changes: 4 additions & 1 deletion gyp/pylib/gyp/xcodeproj_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,7 @@ def __init__(self, properties=None, id=None, parent=None):
'icns': 'image.icns',
'java': 'sourcecode.java',
'js': 'sourcecode.javascript',
'kext': 'wrapper.kext',
'm': 'sourcecode.c.objc',
'mm': 'sourcecode.cpp.objcpp',
'nib': 'wrapper.nib',
Expand Down Expand Up @@ -1951,14 +1952,14 @@ class PBXCopyFilesBuildPhase(XCBuildPhase):
# 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_FRAMEWORKS_DIR': 10, # Frameworks Directory
'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
Expand Down Expand Up @@ -2262,6 +2263,8 @@ class PBXNativeTarget(XCTarget):
'', '.xctest'],
'com.googlecode.gyp.xcode.bundle': ['compiled.mach-o.dylib',
'', '.so'],
'com.apple.product-type.kernel-extension': ['wrapper.kext',
'', '.kext'],
}

def __init__(self, properties=None, id=None, parent=None,
Expand Down

0 comments on commit ab89b47

Please sign in to comment.