diff options
author | Ben Murdoch <benm@google.com> | 2013-07-23 11:17:57 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2013-07-23 11:17:57 +0100 |
commit | e1ac3eb4b1260619b0f71637fbe460f78e7275fa (patch) | |
tree | 35b0ccba185929e9310f16263a4e91ef06d92bc7 | |
parent | 91a008ffad1779ae775d5f88f23bbc47d3cc34a1 (diff) | |
parent | 2706be1fca65f80b625663e595015399600126e2 (diff) | |
download | gyp-e1ac3eb4b1260619b0f71637fbe460f78e7275fa.tar.gz |
Merge from Chromium at DEPS revision r213057
This commit was generated by merge_to_master.py.
Change-Id: I3935ce20042ee59bb9736ae4513b42cb5331c97a
-rw-r--r-- | pylib/gyp/MSVSVersion.py | 8 | ||||
-rw-r--r-- | pylib/gyp/msvs_emulation.py | 22 | ||||
-rw-r--r-- | pylib/gyp/xcode_emulation.py | 8 | ||||
-rwxr-xr-x | test/mac/gyptest-objc-arc.py | 26 | ||||
-rw-r--r-- | test/mac/gyptest-objc-gc.py | 2 | ||||
-rw-r--r-- | test/mac/objc-arc/c-file.c | 6 | ||||
-rw-r--r-- | test/mac/objc-arc/cc-file.cc | 5 | ||||
-rw-r--r-- | test/mac/objc-arc/m-file-no-arc.m | 5 | ||||
-rw-r--r-- | test/mac/objc-arc/m-file.m | 5 | ||||
-rw-r--r-- | test/mac/objc-arc/mm-file-no-arc.mm | 5 | ||||
-rw-r--r-- | test/mac/objc-arc/mm-file.mm | 5 | ||||
-rw-r--r-- | test/mac/objc-arc/test.gyp | 45 | ||||
-rw-r--r-- | test/win/compiler-flags/optimizations.gyp | 40 | ||||
-rw-r--r-- | test/win/gyptest-cl-optimizations.py | 16 | ||||
-rw-r--r-- | test/win/gyptest-link-mapfile.py | 44 | ||||
-rw-r--r-- | test/win/gyptest-macro-targetname.py | 29 | ||||
-rw-r--r-- | test/win/linker-flags/mapfile.cc | 12 | ||||
-rw-r--r-- | test/win/linker-flags/mapfile.gyp | 45 | ||||
-rw-r--r-- | test/win/vs-macros/targetname.gyp | 52 |
19 files changed, 372 insertions, 8 deletions
diff --git a/pylib/gyp/MSVSVersion.py b/pylib/gyp/MSVSVersion.py index 6dfed3bd..4e4dbf33 100644 --- a/pylib/gyp/MSVSVersion.py +++ b/pylib/gyp/MSVSVersion.py @@ -200,21 +200,21 @@ def _CreateVersion(name, path, sdk_based=False): '2013': VisualStudioVersion('2013', 'Visual Studio 2013', solution_version='13.00', - project_version='4.0', + project_version='12.0', flat_sln=False, uses_vcxproj=True, path=path, sdk_based=sdk_based, - default_toolset='v110'), + default_toolset='v120'), '2013e': VisualStudioVersion('2013e', 'Visual Studio 2013', solution_version='13.00', - project_version='4.0', + project_version='12.0', flat_sln=True, uses_vcxproj=True, path=path, sdk_based=sdk_based, - default_toolset='v110'), + default_toolset='v120'), '2012': VisualStudioVersion('2012', 'Visual Studio 2012', solution_version='12.00', diff --git a/pylib/gyp/msvs_emulation.py b/pylib/gyp/msvs_emulation.py index 342ee36e..ae65e859 100644 --- a/pylib/gyp/msvs_emulation.py +++ b/pylib/gyp/msvs_emulation.py @@ -167,12 +167,17 @@ class MsvsSettings(object): """Get a dict of variables mapping internal VS macro names to their gyp equivalents.""" target_platform = 'Win32' if self.GetArch(config) == 'x86' else 'x64' + target_name = self.spec.get('product_prefix', '') + \ + self.spec.get('product_name', self.spec['target_name']) + target_dir = base_to_build + '\\' if base_to_build else '' replacements = { - '$(OutDir)\\': base_to_build + '\\' if base_to_build else '', + '$(OutDir)\\': target_dir, + '$(TargetDir)\\': target_dir, '$(IntDir)': '$!INTERMEDIATE_DIR', '$(InputPath)': '${source}', '$(InputName)': '${root}', '$(ProjectName)': self.spec['target_name'], + '$(TargetName)': target_name, '$(PlatformName)': target_platform, '$(ProjectDir)\\': '', } @@ -289,6 +294,15 @@ class MsvsSettings(object): pdbname = expand_special(self.ConvertVSMacros(pdbname)) return pdbname + def GetMapFileName(self, config, expand_special): + """Gets the explicitly overriden map file name for a target or returns None + if it's not set.""" + config = self._TargetConfig(config) + map_file = self._Setting(('VCLinkerTool', 'MapFileName'), config) + if map_file: + map_file = expand_special(self.ConvertVSMacros(map_file, config=config)) + return map_file + def GetOutputName(self, config, expand_special): """Gets the explicitly overridden output name for a target or returns None if it's not overridden.""" @@ -322,6 +336,8 @@ class MsvsSettings(object): cl('Optimization', map={'0': 'd', '1': '1', '2': '2', '3': 'x'}, prefix='/O') cl('InlineFunctionExpansion', prefix='/Ob') + cl('StringPooling', map={'true': '/GF'}) + cl('EnableFiberSafeOptimizations', map={'true': '/GT'}) cl('OmitFramePointers', map={'false': '-', 'true': ''}, prefix='/Oy') cl('EnableIntrinsicFunctions', map={'false': '-', 'true': ''}, prefix='/Oi') cl('FavorSizeOrSpeed', map={'1': 't', '2': 's'}, prefix='/O') @@ -440,6 +456,10 @@ class MsvsSettings(object): pdb = self.GetPDBName(config, expand_special) if pdb: ldflags.append('/PDB:' + pdb) + map_file = self.GetMapFileName(config, expand_special) + ld('GenerateMapFile', map={'true': '/MAP:' + map_file if map_file + else '/MAP'}) + ld('MapExports', map={'true': '/MAPINFO:EXPORTS'}) ld('AdditionalOptions', prefix='') ld('SubSystem', map={'1': 'CONSOLE', '2': 'WINDOWS'}, prefix='/SUBSYSTEM:') ld('TerminalServerAware', map={'1': ':NO', '2': ''}, prefix='/TSAWARE') diff --git a/pylib/gyp/xcode_emulation.py b/pylib/gyp/xcode_emulation.py index 346bcf9b..3ef1cc7a 100644 --- a/pylib/gyp/xcode_emulation.py +++ b/pylib/gyp/xcode_emulation.py @@ -419,13 +419,16 @@ class XcodeSettings(object): elif gc_policy == 'required': flags.append('-fobjc-gc-only') + def _AddObjectiveCARCFlags(self, flags): + if self._Test('CLANG_ENABLE_OBJC_ARC', 'YES', default='NO'): + flags.append('-fobjc-arc') + def GetCflagsObjC(self, configname): """Returns flags that need to be added to .m compilations.""" self.configname = configname cflags_objc = [] - self._AddObjectiveCGarbageCollectionFlags(cflags_objc) - + self._AddObjectiveCARCFlags(cflags_objc) self.configname = None return cflags_objc @@ -434,6 +437,7 @@ class XcodeSettings(object): self.configname = configname cflags_objcc = [] self._AddObjectiveCGarbageCollectionFlags(cflags_objcc) + self._AddObjectiveCARCFlags(cflags_objcc) if self._Test('GCC_OBJC_CALL_CXX_CDTORS', 'YES', default='NO'): cflags_objcc.append('-fobjc-call-cxx-cdtors') self.configname = None diff --git a/test/mac/gyptest-objc-arc.py b/test/mac/gyptest-objc-arc.py new file mode 100755 index 00000000..b3192a19 --- /dev/null +++ b/test/mac/gyptest-objc-arc.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# Copyright (c) 2013 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 ARC objc settings are handled correctly. +""" + +import TestGyp + +import sys + +if sys.platform == 'darwin': + # set |match| to ignore build stderr output. + test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'], + match = lambda a, b: True) + + CHDIR = 'objc-arc' + test.run_gyp('test.gyp', chdir=CHDIR) + + test.build('test.gyp', 'arc_enabled', chdir=CHDIR) + test.build('test.gyp', 'arc_disabled', chdir=CHDIR) + + test.pass_test() diff --git a/test/mac/gyptest-objc-gc.py b/test/mac/gyptest-objc-gc.py index dc0ee991..70ec7578 100644 --- a/test/mac/gyptest-objc-gc.py +++ b/test/mac/gyptest-objc-gc.py @@ -5,7 +5,7 @@ # found in the LICENSE file. """ -Verifies that objc settings are handled correctly. +Verifies that GC objc settings are handled correctly. """ import TestGyp diff --git a/test/mac/objc-arc/c-file.c b/test/mac/objc-arc/c-file.c new file mode 100644 index 00000000..65361320 --- /dev/null +++ b/test/mac/objc-arc/c-file.c @@ -0,0 +1,6 @@ +#if __has_feature(objc_arc) +#error "C files shouldn't be ARC'd!" +#endif + +void c_fun() {} + diff --git a/test/mac/objc-arc/cc-file.cc b/test/mac/objc-arc/cc-file.cc new file mode 100644 index 00000000..95e14ea3 --- /dev/null +++ b/test/mac/objc-arc/cc-file.cc @@ -0,0 +1,5 @@ +#if __has_feature(objc_arc) +#error "C++ files shouldn't be ARC'd!" +#endif + +void cc_fun() {} diff --git a/test/mac/objc-arc/m-file-no-arc.m b/test/mac/objc-arc/m-file-no-arc.m new file mode 100644 index 00000000..8ffaabfa --- /dev/null +++ b/test/mac/objc-arc/m-file-no-arc.m @@ -0,0 +1,5 @@ +#if __has_feature(objc_arc) +#error "ObjC files without CLANG_ENABLE_OBJC_ARC should not be ARC'd!" +#endif + +void m_fun() {} diff --git a/test/mac/objc-arc/m-file.m b/test/mac/objc-arc/m-file.m new file mode 100644 index 00000000..9689b1f8 --- /dev/null +++ b/test/mac/objc-arc/m-file.m @@ -0,0 +1,5 @@ +#if !__has_feature(objc_arc) +#error "ObjC files with CLANG_ENABLE_OBJC_ARC should be ARC'd!" +#endif + +void m_fun() {} diff --git a/test/mac/objc-arc/mm-file-no-arc.mm b/test/mac/objc-arc/mm-file-no-arc.mm new file mode 100644 index 00000000..0dac5394 --- /dev/null +++ b/test/mac/objc-arc/mm-file-no-arc.mm @@ -0,0 +1,5 @@ +#if __has_feature(objc_arc) +#error "ObjC++ files without CLANG_ENABLE_OBJC_ARC should not be ARC'd!" +#endif + +void mm_fun() {} diff --git a/test/mac/objc-arc/mm-file.mm b/test/mac/objc-arc/mm-file.mm new file mode 100644 index 00000000..9467e965 --- /dev/null +++ b/test/mac/objc-arc/mm-file.mm @@ -0,0 +1,5 @@ +#if !__has_feature(objc_arc) +#error "ObjC++ files with CLANG_ENABLE_OBJC_ARC should be ARC'd!" +#endif + +void mm_fun() {} diff --git a/test/mac/objc-arc/test.gyp b/test/mac/objc-arc/test.gyp new file mode 100644 index 00000000..59cf0e29 --- /dev/null +++ b/test/mac/objc-arc/test.gyp @@ -0,0 +1,45 @@ +# Copyright (c) 2013 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_global_settings': [ + ['CC', '/usr/bin/clang'], + ['CXX', '/usr/bin/clang++'], + ], + + 'targets': [ + { + 'target_name': 'arc_enabled', + 'type': 'static_library', + 'sources': [ + 'c-file.c', + 'cc-file.cc', + 'm-file.m', + 'mm-file.mm', + ], + 'xcode_settings': { + 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', + 'MACOSX_DEPLOYMENT_TARGET': '10.6', + 'ARCHS': [ 'x86_64' ], # For the non-fragile objc ABI. + 'CLANG_ENABLE_OBJC_ARC': 'YES', + }, + }, + + { + 'target_name': 'arc_disabled', + 'type': 'static_library', + 'sources': [ + 'c-file.c', + 'cc-file.cc', + 'm-file-no-arc.m', + 'mm-file-no-arc.mm', + ], + 'xcode_settings': { + 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0', + 'MACOSX_DEPLOYMENT_TARGET': '10.6', + 'ARCHS': [ 'x86_64' ], # For the non-fragile objc ABI. + }, + }, + ], +} + diff --git a/test/win/compiler-flags/optimizations.gyp b/test/win/compiler-flags/optimizations.gyp index d82e3130..e63096f0 100644 --- a/test/win/compiler-flags/optimizations.gyp +++ b/test/win/compiler-flags/optimizations.gyp @@ -163,5 +163,45 @@ }, 'sources': ['hello.cc'], }, + { + 'target_name': 'test_opt_sp', + 'type': 'executable', + 'msvs_settings': { + 'VCCLCompilerTool': { + 'StringPooling': 'true' + } + }, + 'sources': ['hello.cc'], + }, + { + 'target_name': 'test_opt_sp_off', + 'type': 'executable', + 'msvs_settings': { + 'VCCLCompilerTool': { + 'StringPooling': 'false' + } + }, + 'sources': ['hello.cc'], + }, + { + 'target_name': 'test_opt_fso', + 'type': 'executable', + 'msvs_settings': { + 'VCCLCompilerTool': { + 'EnableFiberSafeOptimizations': 'true' + } + }, + 'sources': ['hello.cc'], + }, + { + 'target_name': 'test_opt_fso_off', + 'type': 'executable', + 'msvs_settings': { + 'VCCLCompilerTool': { + 'EnableFiberSafeOptimizations': 'false' + } + }, + 'sources': ['hello.cc'], + }, ] } diff --git a/test/win/gyptest-cl-optimizations.py b/test/win/gyptest-cl-optimizations.py index 025e0a4b..9ca997c4 100644 --- a/test/win/gyptest-cl-optimizations.py +++ b/test/win/gyptest-cl-optimizations.py @@ -85,4 +85,20 @@ if sys.platform == 'win32': chdir=CHDIR) test.must_contain(ninja_file, '/GL') + ninja_file = test.built_file_path('obj/test_opt_sp.ninja', + chdir=CHDIR) + test.must_contain(ninja_file, '/GF') + + ninja_file = test.built_file_path('obj/test_opt_sp_off.ninja', + chdir=CHDIR) + test.must_not_contain(ninja_file, '/GF') + + ninja_file = test.built_file_path('obj/test_opt_fso.ninja', + chdir=CHDIR) + test.must_contain(ninja_file, '/GT') + + ninja_file = test.built_file_path('obj/test_opt_fso_off.ninja', + chdir=CHDIR) + test.must_not_contain(ninja_file, '/GT') + test.pass_test() diff --git a/test/win/gyptest-link-mapfile.py b/test/win/gyptest-link-mapfile.py new file mode 100644 index 00000000..00c1dea9 --- /dev/null +++ b/test/win/gyptest-link-mapfile.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +# Copyright (c) 2013 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 sure mapfile settings are extracted properly. +""" + +import TestGyp + +import sys + +if sys.platform == 'win32': + test = TestGyp.TestGyp(formats=['msvs', 'ninja']) + + CHDIR = 'linker-flags' + test.run_gyp('mapfile.gyp', chdir=CHDIR) + test.build('mapfile.gyp', test.ALL, chdir=CHDIR) + + map_file = test.built_file_path('test_mapfile_unset.map', chdir=CHDIR) + test.must_not_exist(map_file) + + map_file = test.built_file_path('test_mapfile_generate.map', chdir=CHDIR) + test.must_exist(map_file) + test.must_contain(map_file, '?AnExportedFunction@@YAXXZ') + test.must_not_contain(map_file, 'void __cdecl AnExportedFunction(void)') + + map_file = test.built_file_path('test_mapfile_generate_exports.map', + chdir=CHDIR) + test.must_exist(map_file) + test.must_contain(map_file, 'void __cdecl AnExportedFunction(void)') + + map_file = test.built_file_path('test_mapfile_generate_filename.map', + chdir=CHDIR) + test.must_not_exist(map_file) + + map_file = test.built_file_path('custom_file_name.map', chdir=CHDIR) + test.must_exist(map_file) + test.must_contain(map_file, '?AnExportedFunction@@YAXXZ') + test.must_not_contain(map_file, 'void __cdecl AnExportedFunction(void)') + + test.pass_test() diff --git a/test/win/gyptest-macro-targetname.py b/test/win/gyptest-macro-targetname.py new file mode 100644 index 00000000..b1118019 --- /dev/null +++ b/test/win/gyptest-macro-targetname.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# Copyright (c) 2013 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 sure macro expansion of $(TargetName) and $(TargetDir) are handled. +""" + +import TestGyp + +import sys + +if sys.platform == 'win32': + test = TestGyp.TestGyp(formats=['msvs', 'ninja']) + + CHDIR = 'vs-macros' + test.run_gyp('targetname.gyp', chdir=CHDIR) + test.build('targetname.gyp', test.ALL, chdir=CHDIR) + test.built_file_must_exist('test_targetname_plus_something1.exe', + chdir=CHDIR) + test.built_file_must_exist( + 'prod_prefixtest_targetname_with_prefix_plus_something2.exe', + chdir=CHDIR) + test.built_file_must_exist('prod_name_plus_something3.exe', chdir=CHDIR) + test.built_file_must_exist('prod_prefixprod_name_plus_something4.exe', + chdir=CHDIR) + test.pass_test() diff --git a/test/win/linker-flags/mapfile.cc b/test/win/linker-flags/mapfile.cc new file mode 100644 index 00000000..cebccb26 --- /dev/null +++ b/test/win/linker-flags/mapfile.cc @@ -0,0 +1,12 @@ +// Copyright (c) 2013 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. + +__declspec(dllexport) +void AnExportedFunction() { + // We need an exported function to verify that /MAPINFO:EXPORTS works. +} + +int main() { + return 0; +} diff --git a/test/win/linker-flags/mapfile.gyp b/test/win/linker-flags/mapfile.gyp new file mode 100644 index 00000000..14206fe2 --- /dev/null +++ b/test/win/linker-flags/mapfile.gyp @@ -0,0 +1,45 @@ +# Copyright (c) 2013 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': 'test_mapfile_unset', + 'type': 'executable', + 'sources': ['mapfile.cc'], + }, + { + 'target_name': 'test_mapfile_generate', + 'type': 'executable', + 'msvs_settings': { + 'VCLinkerTool': { + 'GenerateMapFile': 'true', + }, + }, + 'sources': ['mapfile.cc'], + }, + { + 'target_name': 'test_mapfile_generate_exports', + 'type': 'executable', + 'msvs_settings': { + 'VCLinkerTool': { + 'GenerateMapFile': 'true', + 'MapExports': 'true', + }, + }, + 'sources': ['mapfile.cc'], + }, + { + 'target_name': 'test_mapfile_generate_filename', + 'type': 'executable', + 'msvs_settings': { + 'VCLinkerTool': { + 'GenerateMapFile': 'true', + 'MapFileName': '<(PRODUCT_DIR)/custom_file_name.map', + }, + }, + 'sources': ['mapfile.cc'], + }, + ] +} diff --git a/test/win/vs-macros/targetname.gyp b/test/win/vs-macros/targetname.gyp new file mode 100644 index 00000000..a53d3c0a --- /dev/null +++ b/test/win/vs-macros/targetname.gyp @@ -0,0 +1,52 @@ +# Copyright (c) 2013 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': 'test_targetname', + 'type': 'executable', + 'sources': ['hello.cc'], + 'msvs_settings': { + 'VCLinkerTool': { + 'OutputFile': '$(TargetDir)\\$(TargetName)_plus_something1.exe', + }, + }, + }, + { + 'target_name': 'test_targetname_with_prefix', + 'product_prefix': 'prod_prefix', + 'type': 'executable', + 'sources': ['hello.cc'], + 'msvs_settings': { + 'VCLinkerTool': { + 'OutputFile': '$(TargetDir)\\$(TargetName)_plus_something2.exe', + }, + }, + }, + { + 'target_name': 'test_targetname_with_prodname', + 'product_name': 'prod_name', + 'type': 'executable', + 'sources': ['hello.cc'], + 'msvs_settings': { + 'VCLinkerTool': { + 'OutputFile': '$(TargetDir)\\$(TargetName)_plus_something3.exe', + }, + }, + }, + { + 'target_name': 'test_targetname_with_prodname_with_prefix', + 'product_name': 'prod_name', + 'product_prefix': 'prod_prefix', + 'type': 'executable', + 'sources': ['hello.cc'], + 'msvs_settings': { + 'VCLinkerTool': { + 'OutputFile': '$(TargetDir)\\$(TargetName)_plus_something4.exe', + }, + }, + }, + ] +} |