Merge tools/gyp from https://chromium.googlesource.com/external/gyp.git at 9cb43f00f9b417f241db051f058c52e7a132c435

This commit was generated by merge_from_chromium.py.

Change-Id: Ia1b359d0976ce49a5b391d2f74fb7d3a804b5a6b
diff --git a/pylib/gyp/MSVSSettings.py b/pylib/gyp/MSVSSettings.py
index 63a83dc..205b3b5 100644
--- a/pylib/gyp/MSVSSettings.py
+++ b/pylib/gyp/MSVSSettings.py
@@ -616,7 +616,9 @@
 _Same(_compile, 'EnableEnhancedInstructionSet',
       _Enumeration(['NotSet',
                     'StreamingSIMDExtensions',  # /arch:SSE
-                    'StreamingSIMDExtensions2']))  # /arch:SSE2
+                    'StreamingSIMDExtensions2',  # /arch:SSE2
+                    'AdvancedVectorExtensions',  # /arch:AVX (vs2012+)
+                    'NoExtensions',]))  # /arch:IA32 (vs2012+)
 _Same(_compile, 'ErrorReporting',
       _Enumeration(['None',  # /errorReport:none
                     'Prompt',  # /errorReport:prompt
diff --git a/pylib/gyp/generator/xcode.py b/pylib/gyp/generator/xcode.py
index 331e78b..8751810 100644
--- a/pylib/gyp/generator/xcode.py
+++ b/pylib/gyp/generator/xcode.py
@@ -705,9 +705,11 @@
     support_xct = None
     if type != 'none' and (spec_actions or spec_rules):
       support_xccl = CreateXCConfigurationList(configuration_names);
+      support_target_suffix = generator_flags.get(
+          'support_target_suffix', ' Support')
       support_target_properties = {
         'buildConfigurationList': support_xccl,
-        'name':                   target_name + ' Support',
+        'name':                   target_name + support_target_suffix,
       }
       if target_product_name:
         support_target_properties['productName'] = \
diff --git a/pylib/gyp/input.py b/pylib/gyp/input.py
index 3e5cf8d..f694e57 100644
--- a/pylib/gyp/input.py
+++ b/pylib/gyp/input.py
@@ -200,7 +200,7 @@
          "': " + repr(node)
 
 
-def LoadOneBuildFile(build_file_path, data, aux_data, variables, includes,
+def LoadOneBuildFile(build_file_path, data, aux_data, includes,
                      is_target, check):
   if build_file_path in data:
     return data[build_file_path]
@@ -236,10 +236,10 @@
     try:
       if is_target:
         LoadBuildFileIncludesIntoDict(build_file_data, build_file_path, data,
-                                      aux_data, variables, includes, check)
+                                      aux_data, includes, check)
       else:
         LoadBuildFileIncludesIntoDict(build_file_data, build_file_path, data,
-                                      aux_data, variables, None, check)
+                                      aux_data, None, check)
     except Exception, e:
       gyp.common.ExceptionAppend(e,
                                  'while reading includes of ' + build_file_path)
@@ -249,7 +249,7 @@
 
 
 def LoadBuildFileIncludesIntoDict(subdict, subdict_path, data, aux_data,
-                                  variables, includes, check):
+                                  includes, check):
   includes_list = []
   if includes != None:
     includes_list.extend(includes)
@@ -273,30 +273,27 @@
     gyp.DebugOutput(gyp.DEBUG_INCLUDES, "Loading Included File: '%s'", include)
 
     MergeDicts(subdict,
-               LoadOneBuildFile(include, data, aux_data, variables, None,
-                                False, check),
+               LoadOneBuildFile(include, data, aux_data, 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,
+      LoadBuildFileIncludesIntoDict(v, subdict_path, data, aux_data,
                                     None, check)
     elif v.__class__ == list:
-      LoadBuildFileIncludesIntoList(v, subdict_path, data, aux_data, variables,
+      LoadBuildFileIncludesIntoList(v, subdict_path, data, aux_data,
                                     check)
 
 
 # This recurses into lists so that it can look for dicts.
-def LoadBuildFileIncludesIntoList(sublist, sublist_path, data, aux_data,
-                                  variables, check):
+def LoadBuildFileIncludesIntoList(sublist, sublist_path, data, aux_data, check):
   for item in sublist:
     if item.__class__ == dict:
       LoadBuildFileIncludesIntoDict(item, sublist_path, data, aux_data,
-                                    variables, None, check)
+                                    None, check)
     elif item.__class__ == list:
-      LoadBuildFileIncludesIntoList(item, sublist_path, data, aux_data,
-                                    variables, check)
+      LoadBuildFileIncludesIntoList(item, sublist_path, data, aux_data, check)
 
 # Processes toolsets in all the targets. This recurses into condition entries
 # since they can contain toolsets as well.
@@ -358,7 +355,7 @@
   gyp.DebugOutput(gyp.DEBUG_INCLUDES,
                   "Loading Target Build File '%s'", build_file_path)
 
-  build_file_data = LoadOneBuildFile(build_file_path, data, aux_data, variables,
+  build_file_data = LoadOneBuildFile(build_file_path, data, aux_data,
                                      includes, True, check)
 
   # Store DEPTH for later use in generators.
diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py
index 709ba30..6de77d7 100644
--- a/pylib/gyp/msvs_emulation.py
+++ b/pylib/gyp/msvs_emulation.py
@@ -379,6 +379,8 @@
         map={'false': '-', 'true': ''}, prefix='/Zc:wchar_t')
     cl('EnablePREfast', map={'true': '/analyze'})
     cl('AdditionalOptions', prefix='')
+    cl('EnableEnhancedInstructionSet',
+       map={'1': 'SSE', '2': 'SSE2', '3': 'AVX', '4': 'IA32'}, prefix='/arch:')
     cflags.extend(['/FI' + f for f in self._Setting(
         ('VCCLCompilerTool', 'ForcedIncludeFiles'), config, default=[])])
     if self.vs_version.short_name in ('2013', '2013e'):
diff --git a/pylib/gyp/xcode_emulation.py b/pylib/gyp/xcode_emulation.py
index 3fe8ed6..d86413a 100644
--- a/pylib/gyp/xcode_emulation.py
+++ b/pylib/gyp/xcode_emulation.py
@@ -1321,6 +1321,11 @@
   install_name_base = xcode_settings.GetInstallNameBase()
   if install_name_base:
     env['DYLIB_INSTALL_NAME_BASE'] = install_name_base
+  if XcodeVersion() >= '0500' and not env.get('SDKROOT'):
+    sdk_root = xcode_settings._SdkRoot(configuration)
+    if not sdk_root:
+      sdk_root = xcode_settings._XcodeSdkPath('')
+    env['SDKROOT'] = sdk_root
 
   if not additional_settings:
     additional_settings = {}
diff --git a/test/link-dependency/gyptest-link-dependency.py b/test/link-dependency/gyptest-link-dependency.py
index 357f3ea..3a8300d 100755
--- a/test/link-dependency/gyptest-link-dependency.py
+++ b/test/link-dependency/gyptest-link-dependency.py
@@ -12,7 +12,9 @@
 
 import TestGyp
 
-test = TestGyp.TestGyp()
+# See https://codereview.chromium.org/177043010/#msg15 for why this doesn't
+# work with cmake.
+test = TestGyp.TestGyp(formats=['!cmake'])
 
 test.run_gyp('test.gyp')
 test.build('test.gyp', 'main')
diff --git a/test/link-dependency/mymalloc.c b/test/link-dependency/mymalloc.c
index a6345ed..23d034f 100644
--- a/test/link-dependency/mymalloc.c
+++ b/test/link-dependency/mymalloc.c
@@ -1,4 +1,11 @@
 #include <stdlib.h>
+
+// The windows ninja generator is expecting an import library to get generated,
+// but it doesn't if there are no exports.
+#ifdef _MSC_VER
+__declspec(dllexport) void foo() {}
+#endif
+
 void *malloc(size_t size) {
   return (void*)0xdeadbeef;
 }
diff --git a/test/mac/gyptest-xcode-support-actions.py b/test/mac/gyptest-xcode-support-actions.py
new file mode 100755
index 0000000..ecc1402
--- /dev/null
+++ b/test/mac/gyptest-xcode-support-actions.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 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.
+
+"""
+Verifies that support actions are properly created.
+"""
+
+import TestGyp
+
+import os
+import subprocess
+import sys
+
+if sys.platform == 'darwin':
+  test = TestGyp.TestGyp(formats=['xcode'])
+
+  CHDIR = 'xcode-support-actions'
+
+  test.run_gyp('test.gyp', '-Gsupport_target_suffix=_customsuffix', chdir=CHDIR)
+  test.build('test.gyp', target='target_customsuffix', chdir=CHDIR)
+
+  test.pass_test()
diff --git a/test/mac/type_envvars/test_bundle_executable.sh b/test/mac/type_envvars/test_bundle_executable.sh
index c66ce28..5cd740c 100755
--- a/test/mac/type_envvars/test_bundle_executable.sh
+++ b/test/mac/type_envvars/test_bundle_executable.sh
@@ -17,5 +17,4 @@
 [[ ! $DYLIB_INSTALL_NAME_BASE && ${DYLIB_INSTALL_NAME_BASE-_} ]]
 [[ ! $LD_DYLIB_INSTALL_NAME && ${LD_DYLIB_INSTALL_NAME-_} ]]
 
-# Should be set, but empty.
-[[ ! $SDKROOT && ! ${SDKROOT-_} ]]
+"$(dirname "$0")/test_check_sdkroot.sh"
diff --git a/test/mac/type_envvars/test_bundle_loadable_module.sh b/test/mac/type_envvars/test_bundle_loadable_module.sh
index 79c11c0..ea985f5 100755
--- a/test/mac/type_envvars/test_bundle_loadable_module.sh
+++ b/test/mac/type_envvars/test_bundle_loadable_module.sh
@@ -18,5 +18,4 @@
 [[ ! $DYLIB_INSTALL_NAME_BASE && ${DYLIB_INSTALL_NAME_BASE-_} ]]
 [[ ! $LD_DYLIB_INSTALL_NAME && ${LD_DYLIB_INSTALL_NAME-_} ]]
 
-# Should be set, but empty.
-[[ ! $SDKROOT && ! ${SDKROOT-_} ]]
+"$(dirname "$0")/test_check_sdkroot.sh"
diff --git a/test/mac/type_envvars/test_bundle_shared_library.sh b/test/mac/type_envvars/test_bundle_shared_library.sh
index 9980327..bf49d45 100755
--- a/test/mac/type_envvars/test_bundle_shared_library.sh
+++ b/test/mac/type_envvars/test_bundle_shared_library.sh
@@ -19,5 +19,4 @@
 test $LD_DYLIB_INSTALL_NAME = \
     "/Library/Frameworks/bundle_shared_library.framework/Versions/A/bundle_shared_library"
 
-# Should be set, but empty.
-[[ ! $SDKROOT && ! ${SDKROOT-_} ]]
+"$(dirname "$0")/test_check_sdkroot.sh"
diff --git a/test/mac/type_envvars/test_check_sdkroot.sh b/test/mac/type_envvars/test_check_sdkroot.sh
new file mode 100755
index 0000000..1297dbe
--- /dev/null
+++ b/test/mac/type_envvars/test_check_sdkroot.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+# Copyright (c) 2014 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.
+
+set -e
+
+# `xcodebuild -version` output looks like
+#    Xcode 4.6.3
+#    Build version 4H1503
+# or like
+#    Xcode 4.2
+#    Build version 4C199
+# or like
+#    Xcode 3.2.6
+#    Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0
+#    BuildVersion: 10M2518
+# Convert that to '0463', '0420' and '0326' respectively.
+function xcodeversion() {
+  xcodebuild -version | awk '/Xcode ([0-9]+\.[0-9]+(\.[0-9]+)?)/ {
+    version = $2
+    gsub(/\./, "", version)
+    if (length(version) < 3) {
+      version = version "0"
+    }
+    if (length(version) < 4) {
+      version = "0" version
+    }
+  }
+  END { print version }'
+}
+
+# Returns true if |string1| is smaller than |string2|.
+# This function assumes that both strings represent Xcode version numbers
+# as returned by |xcodeversion|.
+function smaller() {
+  local min="$(echo -ne "${1}\n${2}\n" | sort -n | head -n1)"
+  test "${min}" != "${2}"
+}
+
+if [[ "$(xcodeversion)" < "0500" ]]; then
+  # Xcode version is older than 5.0, check that SDKROOT is set but empty.
+  [[ -z "${SDKROOT}" && -z "${SDKROOT-_}" ]]
+else
+  # Xcode version is newer than 5.0, check that SDKROOT is set.
+  [[ "${SDKROOT}" == "$(xcodebuild -version -sdk '' Path)" ]]
+fi
diff --git a/test/mac/type_envvars/test_nonbundle_executable.sh b/test/mac/type_envvars/test_nonbundle_executable.sh
index 5758595..25afcbe 100755
--- a/test/mac/type_envvars/test_nonbundle_executable.sh
+++ b/test/mac/type_envvars/test_nonbundle_executable.sh
@@ -4,6 +4,7 @@
 # found in the LICENSE file.
 
 set -e
+
 # For some reason, Xcode doesn't set MACH_O_TYPE for non-bundle executables.
 # Check for "not set", not just "empty":
 [[ ! $MACH_O_TYPE && ${MACH_O_TYPE-_} ]]
@@ -18,5 +19,4 @@
 [[ ! $DYLIB_INSTALL_NAME_BASE && ${DYLIB_INSTALL_NAME_BASE-_} ]]
 [[ ! $LD_DYLIB_INSTALL_NAME && ${LD_DYLIB_INSTALL_NAME-_} ]]
 
-# Should be set, but empty.
-[[ ! $SDKROOT && ! ${SDKROOT-_} ]]
+"$(dirname "$0")/test_check_sdkroot.sh"
diff --git a/test/mac/type_envvars/test_nonbundle_loadable_module.sh b/test/mac/type_envvars/test_nonbundle_loadable_module.sh
index 6a66817..9b58426 100755
--- a/test/mac/type_envvars/test_nonbundle_loadable_module.sh
+++ b/test/mac/type_envvars/test_nonbundle_loadable_module.sh
@@ -17,5 +17,4 @@
 test $DYLIB_INSTALL_NAME_BASE = "/usr/local/lib"
 test $LD_DYLIB_INSTALL_NAME = "/usr/local/lib/nonbundle_loadable_module.so"
 
-# Should be set, but empty.
-[[ ! $SDKROOT && ! ${SDKROOT-_} ]]
+"$(dirname "$0")/test_check_sdkroot.sh"
diff --git a/test/mac/type_envvars/test_nonbundle_none.sh b/test/mac/type_envvars/test_nonbundle_none.sh
index a901b98..871af1b 100755
--- a/test/mac/type_envvars/test_nonbundle_none.sh
+++ b/test/mac/type_envvars/test_nonbundle_none.sh
@@ -18,5 +18,4 @@
 [[ ! $DYLIB_INSTALL_NAME_BASE && ${DYLIB_INSTALL_NAME_BASE-_} ]]
 [[ ! $LD_DYLIB_INSTALL_NAME && ${LD_DYLIB_INSTALL_NAME-_} ]]
 
-# Should be set, but empty.
-[[ ! $SDKROOT && ! ${SDKROOT-_} ]]
+"$(dirname "$0")/test_check_sdkroot.sh"
diff --git a/test/mac/type_envvars/test_nonbundle_shared_library.sh b/test/mac/type_envvars/test_nonbundle_shared_library.sh
index d721047..cbb118b 100755
--- a/test/mac/type_envvars/test_nonbundle_shared_library.sh
+++ b/test/mac/type_envvars/test_nonbundle_shared_library.sh
@@ -17,5 +17,4 @@
 test $DYLIB_INSTALL_NAME_BASE = "/usr/local/lib"
 test $LD_DYLIB_INSTALL_NAME = "/usr/local/lib/libnonbundle_shared_library.dylib"
 
-# Should be set, but empty.
-[[ ! $SDKROOT && ! ${SDKROOT-_} ]]
+"$(dirname "$0")/test_check_sdkroot.sh"
diff --git a/test/mac/type_envvars/test_nonbundle_static_library.sh b/test/mac/type_envvars/test_nonbundle_static_library.sh
index 39e4c8c..86c04a9 100755
--- a/test/mac/type_envvars/test_nonbundle_static_library.sh
+++ b/test/mac/type_envvars/test_nonbundle_static_library.sh
@@ -17,5 +17,4 @@
 [[ ! $DYLIB_INSTALL_NAME_BASE && ${DYLIB_INSTALL_NAME_BASE-_} ]]
 [[ ! $LD_DYLIB_INSTALL_NAME && ${LD_DYLIB_INSTALL_NAME-_} ]]
 
-# Should be set, but empty.
-[[ ! $SDKROOT && ! ${SDKROOT-_} ]]
+"$(dirname "$0")/test_check_sdkroot.sh"
diff --git a/test/mac/xcode-support-actions/source.c b/test/mac/xcode-support-actions/source.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/mac/xcode-support-actions/source.c
diff --git a/test/mac/xcode-support-actions/test.gyp b/test/mac/xcode-support-actions/test.gyp
new file mode 100644
index 0000000..ad81b8c
--- /dev/null
+++ b/test/mac/xcode-support-actions/test.gyp
@@ -0,0 +1,26 @@
+# Copyright (c) 2014 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.
+{
+  'targets': [
+    {
+      'target_name': 'target',
+      'product_name': 'Product',
+      'type': 'shared_library',
+      'mac_bundle': 1,
+      'sources': [
+        '<(PRODUCT_DIR)/copy.c',
+      ],
+      'actions': [
+        {
+          'action_name': 'Helper',
+          'description': 'Helps',
+          'inputs': [ 'source.c' ],
+          'outputs': [ '<(PRODUCT_DIR)/copy.c' ],
+          'action': [ 'cp', '${SOURCE_ROOT}/source.c',
+                      '<(PRODUCT_DIR)/copy.c' ],
+        },
+      ],
+    },
+  ],
+}
diff --git a/test/win/compiler-flags/enable-enhanced-instruction-set.cc b/test/win/compiler-flags/enable-enhanced-instruction-set.cc
new file mode 100644
index 0000000..2491f16
--- /dev/null
+++ b/test/win/compiler-flags/enable-enhanced-instruction-set.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2014 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.
+
+#include <stdio.h>
+
+static const char* GetArchOption() {
+#if _M_IX86_FP == 0
+  return "IA32";
+#elif _M_IX86_FP == 1
+  return "SSE";
+#elif _M_IX86_FP == 2
+#  if !defined(__AVX__)
+  return "SSE2";
+#  else
+  return "AVX";
+#  endif
+#else
+  return "UNSUPPORTED OPTION";
+#endif
+}
+
+int main() {
+  printf("/arch:%s\n", GetArchOption());
+  return 0;
+}
diff --git a/test/win/compiler-flags/enable-enhanced-instruction-set.gyp b/test/win/compiler-flags/enable-enhanced-instruction-set.gyp
new file mode 100644
index 0000000..44d8ad3
--- /dev/null
+++ b/test/win/compiler-flags/enable-enhanced-instruction-set.gyp
@@ -0,0 +1,54 @@
+# Copyright (c) 2014 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.
+
+{
+  'targets': [
+    {
+      'target_name': 'sse_extensions',
+      'type': 'executable',
+      'msvs_settings': {
+        'VCCLCompilerTool': {
+          'EnableEnhancedInstructionSet': '1',  # StreamingSIMDExtensions
+        }
+      },
+      'sources': ['enable-enhanced-instruction-set.cc'],
+    },
+    {
+      'target_name': 'sse2_extensions',
+      'type': 'executable',
+      'msvs_settings': {
+        'VCCLCompilerTool': {
+          'EnableEnhancedInstructionSet': '2',  # StreamingSIMDExtensions2
+        }
+      },
+      'sources': ['enable-enhanced-instruction-set.cc'],
+    },
+  ],
+  'conditions': [
+    ['MSVS_VERSION[0:4]>"2010"', {
+      'targets': [
+        {
+          'target_name': 'avx_extensions',
+          'type': 'executable',
+          'msvs_settings': {
+            'VCCLCompilerTool': {
+              'EnableEnhancedInstructionSet': '3',  # AdvancedVectorExtensions
+            }
+          },
+          'sources': ['enable-enhanced-instruction-set.cc'],
+        },
+        {
+          'target_name': 'no_extensions',
+          'type': 'executable',
+          'msvs_settings': {
+            'VCCLCompilerTool': {
+              'EnableEnhancedInstructionSet': '4',  # NoExtensions
+            }
+          },
+          'sources': ['enable-enhanced-instruction-set.cc'],
+        },
+      ],
+    }],
+  ],
+}
diff --git a/test/win/gyptest-cl-enable-enhanced-instruction-set.py b/test/win/gyptest-cl-enable-enhanced-instruction-set.py
new file mode 100644
index 0000000..5ee4cdd
--- /dev/null
+++ b/test/win/gyptest-cl-enable-enhanced-instruction-set.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 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.
+
+"""
+Test VCCLCompilerTool EnableEnhancedInstructionSet setting.
+"""
+
+import TestGyp
+
+import os
+import sys
+
+if sys.platform == 'win32':
+  test = TestGyp.TestGyp()
+
+  CHDIR = 'compiler-flags'
+  test.run_gyp('enable-enhanced-instruction-set.gyp', chdir=CHDIR)
+
+  test.build('enable-enhanced-instruction-set.gyp', test.ALL, chdir=CHDIR)
+
+  test.run_built_executable('sse_extensions', chdir=CHDIR,
+                            stdout='/arch:SSE\n')
+  test.run_built_executable('sse2_extensions', chdir=CHDIR,
+                            stdout='/arch:SSE2\n')
+
+  # /arch:AVX introduced in VS2010, but MSBuild support lagged until 2012.
+  if os.path.exists(test.built_file_path('avx_extensions')):
+    test.run_built_executable('no_extensions', chdir=CHDIR,
+                              stdout='/arch:AVX\n')
+
+  # /arch:IA32 introduced in VS2012.
+  if os.path.exists(test.built_file_path('no_extensions')):
+    test.run_built_executable('no_extensions', chdir=CHDIR,
+                              stdout='/arch:IA32\n')
+
+  test.pass_test()