diff --git a/tools/gyp/pylib/gyp/common.py b/tools/gyp/pylib/gyp/common.py index b5a6e82049..b44b0956f7 100644 --- a/tools/gyp/pylib/gyp/common.py +++ b/tools/gyp/pylib/gyp/common.py @@ -76,6 +76,9 @@ def ResolveTarget(build_file, target, toolset): # 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)) + # Further (to handle cases like ../cwd), make it relative to cwd) + if not os.path.isabs(build_file): + build_file = RelativePath(build_file, '.') else: build_file = parsed_build_file diff --git a/tools/gyp/pylib/gyp/generator/make.py b/tools/gyp/pylib/gyp/generator/make.py index 3971360618..31c016e4c8 100644 --- a/tools/gyp/pylib/gyp/generator/make.py +++ b/tools/gyp/pylib/gyp/generator/make.py @@ -2015,6 +2015,27 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD order_only = True, multiple_output_trick = False) + if self.flavor == 'mac': + # Write an envvar for postbuilds. + # CHROMIUM_STRIP_SAVE_FILE is a chromium-specific hack. + # TODO(thakis): It would be nice to have some general mechanism instead. + # This variable may be referenced by TARGET_POSTBUILDS_$(BUILDTYPE), + # so we must output its definition first, since we declare variables + # using ":=". + # TODO(thakis): Write this only for targets that actually have + # postbuilds. + strip_save_file = self.xcode_settings.GetPerTargetSetting( + 'CHROMIUM_STRIP_SAVE_FILE') + if strip_save_file: + strip_save_file = self.Absolutify(strip_save_file) + else: + # Explicitly clear this out, else a postbuild might pick up an export + # from an earlier target. + strip_save_file = '' + self.WriteXcodeEnv( + self.output, spec, + additional_settings={'CHROMIUM_STRIP_SAVE_FILE': strip_save_file}) + has_target_postbuilds = False if self.type != 'none': for configname in sorted(configs.keys()): @@ -2078,23 +2099,6 @@ $(obj).$(TOOLSET)/$(TARGET)/%%.o: $(obj)/%%%s FORCE_DO_CMD postbuilds.append(gyp.common.EncodePOSIXShellList(shell_list)) if postbuilds: - # Write envvars for postbuilds. - extra_settings = {} - - # CHROMIUM_STRIP_SAVE_FILE is a chromium-specific hack. - # TODO(thakis): It would be nice to have some general mechanism instead. - strip_save_file = self.xcode_settings.GetPerTargetSetting( - 'CHROMIUM_STRIP_SAVE_FILE') - if strip_save_file: - strip_save_file = self.Absolutify(strip_save_file) - else: - # Explicitly clear this out, else a postbuild might pick up an export - # from an earlier target. - strip_save_file = '' - extra_settings['CHROMIUM_STRIP_SAVE_FILE'] = strip_save_file - - self.WriteXcodeEnv(self.output, spec, additional_settings=extra_settings) - for i in xrange(len(postbuilds)): if not postbuilds[i].startswith('$'): postbuilds[i] = EscapeShellArgument(postbuilds[i]) diff --git a/tools/gyp/test/mac/gyptest-strip.py b/tools/gyp/test/mac/gyptest-strip.py index 2e4c3b0355..d031d4b3d8 100755 --- a/tools/gyp/test/mac/gyptest-strip.py +++ b/tools/gyp/test/mac/gyptest-strip.py @@ -49,5 +49,6 @@ if sys.platform == 'darwin': CheckNsyms(test.built_file_path( 'strip_all_bundle.framework/Versions/A/strip_all_bundle', chdir='strip'), 0) + CheckNsyms(OutPath('strip_save'), 3) test.pass_test() diff --git a/tools/gyp/test/mac/strip/strip.saves b/tools/gyp/test/mac/strip/strip.saves new file mode 100644 index 0000000000..b60ca62857 --- /dev/null +++ b/tools/gyp/test/mac/strip/strip.saves @@ -0,0 +1,5 @@ +# 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. + +# This file would list symbols that should not be stripped. diff --git a/tools/gyp/test/mac/strip/test.gyp b/tools/gyp/test/mac/strip/test.gyp index 4eb5447d7d..08c8c526ab 100644 --- a/tools/gyp/test/mac/strip/test.gyp +++ b/tools/gyp/test/mac/strip/test.gyp @@ -100,5 +100,16 @@ 'STRIP_STYLE': 'all', }, }, + { + 'target_name': 'strip_save', + 'type': 'shared_library', + 'sources': [ 'file.c', ], + 'xcode_settings': { + 'DEPLOYMENT_POSTPROCESSING': 'YES', + 'STRIP_INSTALLED_PRODUCT': 'YES', + 'STRIPFLAGS': '-s $(CHROMIUM_STRIP_SAVE_FILE)', + 'CHROMIUM_STRIP_SAVE_FILE': 'strip.saves', + }, + }, ], } diff --git a/tools/gyp/test/relative/foo/a/a.cc b/tools/gyp/test/relative/foo/a/a.cc new file mode 100644 index 0000000000..7d1c953448 --- /dev/null +++ b/tools/gyp/test/relative/foo/a/a.cc @@ -0,0 +1,9 @@ +/* + * 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. + */ + +int main() { + return 0; +} diff --git a/tools/gyp/test/relative/foo/a/a.gyp b/tools/gyp/test/relative/foo/a/a.gyp new file mode 100644 index 0000000000..66316ac681 --- /dev/null +++ b/tools/gyp/test/relative/foo/a/a.gyp @@ -0,0 +1,13 @@ +{ + 'targets': [ + { + 'target_name': 'a', + 'type': 'executable', + 'sources': ['a.cc'], + 'dependencies': [ + '../../foo/b/b.gyp:b', + 'c/c.gyp:c', + ], + }, + ], +} diff --git a/tools/gyp/test/relative/foo/a/c/c.cc b/tools/gyp/test/relative/foo/a/c/c.cc new file mode 100644 index 0000000000..9d22471684 --- /dev/null +++ b/tools/gyp/test/relative/foo/a/c/c.cc @@ -0,0 +1,9 @@ +/* + * 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. + */ + +int func() { + return 0; +} diff --git a/tools/gyp/test/relative/foo/a/c/c.gyp b/tools/gyp/test/relative/foo/a/c/c.gyp new file mode 100644 index 0000000000..c1f087db99 --- /dev/null +++ b/tools/gyp/test/relative/foo/a/c/c.gyp @@ -0,0 +1,12 @@ +{ + 'targets': [ + { + 'target_name': 'c', + 'type': 'static_library', + 'sources': ['c.cc'], + 'dependencies': [ + '../../b/b.gyp:b', + ], + }, + ], +} diff --git a/tools/gyp/test/relative/foo/b/b.cc b/tools/gyp/test/relative/foo/b/b.cc new file mode 100644 index 0000000000..011d59cebb --- /dev/null +++ b/tools/gyp/test/relative/foo/b/b.cc @@ -0,0 +1,9 @@ +/* + * 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. + */ + +int func2() { + return 0; +} diff --git a/tools/gyp/test/relative/foo/b/b.gyp b/tools/gyp/test/relative/foo/b/b.gyp new file mode 100644 index 0000000000..0ebe4533d3 --- /dev/null +++ b/tools/gyp/test/relative/foo/b/b.gyp @@ -0,0 +1,9 @@ +{ + 'targets': [ + { + 'target_name': 'b', + 'type': 'static_library', + 'sources': ['b.cc'], + }, + ], +} diff --git a/tools/gyp/test/relative/gyptest-default.py b/tools/gyp/test/relative/gyptest-default.py new file mode 100755 index 0000000000..2d657aa675 --- /dev/null +++ b/tools/gyp/test/relative/gyptest-default.py @@ -0,0 +1,25 @@ +#!/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. + +""" +Verifies simplest-possible build of a "Hello, world!" program +using the default build target. +""" + +import TestGyp + +test = TestGyp.TestGyp(workdir='workarea_default', formats=['msvs']) + +# Run from down in foo. +test.run_gyp('a.gyp', chdir='foo/a') +sln = test.workpath('foo/a/a.sln') +sln_data = open(sln, 'rb').read() +vcproj = sln_data.count('b.vcproj') +vcxproj = sln_data.count('b.vcxproj') +if (vcproj, vcxproj) not in [(1, 0), (0, 1)]: + test.fail_test() + +test.pass_test() diff --git a/tools/gyp/test/variables/commands/commands-repeated.gyp.stdout b/tools/gyp/test/variables/commands/commands-repeated.gyp.stdout index 2a9f64f2f9..fa140991e1 100644 --- a/tools/gyp/test/variables/commands/commands-repeated.gyp.stdout +++ b/tools/gyp/test/variables/commands/commands-repeated.gyp.stdout @@ -1,405 +1,405 @@ -GENERAL:__init__.py:356:main running with these options: -GENERAL:__init__.py:363:main check: None -GENERAL:__init__.py:363:main circular_check: True -GENERAL:__init__.py:363:main debug: ['variables', 'general'] -GENERAL:__init__.py:363:main defines: None -GENERAL:__init__.py:361:main depth: '.' -GENERAL:__init__.py:363:main formats: ['gypd'] -GENERAL:__init__.py:363:main generator_flags: [] -GENERAL:__init__.py:363:main generator_output: None -GENERAL:__init__.py:363:main includes: None -GENERAL:__init__.py:363:main msvs_version: None -GENERAL:__init__.py:361:main suffix: '' -GENERAL:__init__.py:363:main toplevel_dir: None -GENERAL:__init__.py:363:main use_environment: True -GENERAL:__init__.py:417:main cmdline_default_variables: {} -GENERAL:__init__.py:443:main generator_flags: {} -VARIABLES:input.py:785:ExpandVariables Expanding '0' to 0 -VARIABLES:input.py:785:ExpandVariables Expanding '11 ' to '11 ' -VARIABLES:input.py:785:ExpandVariables Expanding '+14' to '+14' -VARIABLES:input.py:785:ExpandVariables Expanding '-15' to -15 -VARIABLES:input.py:785:ExpandVariables Expanding ' 10' to ' 10' -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'letters_list', 'is_array': '', 'replace': '<(letters_list)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'letters_list' to 'letters_list' -VARIABLES:input.py:767:ExpandVariables Found output 'ABCDEFG', recursing. -VARIABLES:input.py:785:ExpandVariables Expanding 'ABCDEFG' to 'ABCDEFG' -VARIABLES:input.py:785:ExpandVariables Expanding '<(letters_list)EFG' to 'ABCDEFG' -VARIABLES:input.py:785:ExpandVariables Expanding '012' to '012' -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'other_letters', 'is_array': '', 'replace': '<(other_letters)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'other_letters' to 'other_letters' -VARIABLES:input.py:767:ExpandVariables Found output '<(letters_list)EFGHIJK', recursing. -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'letters_list', 'is_array': '', 'replace': '<(letters_list)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'letters_list' to 'letters_list' -VARIABLES:input.py:767:ExpandVariables Found output 'ABCDEFGHIJK', recursing. -VARIABLES:input.py:785:ExpandVariables Expanding 'ABCDEFGHIJK' to 'ABCDEFGHIJK' -VARIABLES:input.py:785:ExpandVariables Expanding '<(letters_list)EFGHIJK' to 'ABCDEFGHIJK' -VARIABLES:input.py:785:ExpandVariables Expanding '<(other_letters)HIJK' to 'ABCDEFGHIJK' -VARIABLES:input.py:785:ExpandVariables Expanding 'XYZ' to 'XYZ' -VARIABLES:input.py:785:ExpandVariables Expanding 'ABCD' to 'ABCD' -VARIABLES:input.py:785:ExpandVariables Expanding '13.0' to '13.0' -VARIABLES:input.py:785:ExpandVariables Expanding 'import math; print math.pi' to 'import math; print math.pi' -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'included_variable', 'is_array': '', 'replace': '<(included_variable)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'included_variable' to 'included_variable' -VARIABLES:input.py:767:ExpandVariables Found output 'XYZ', recursing. -VARIABLES:input.py:785:ExpandVariables Expanding 'XYZ' to 'XYZ' -VARIABLES:input.py:785:ExpandVariables Expanding '<(included_variable)' to 'XYZ' -VARIABLES:input.py:785:ExpandVariables Expanding '6' to 6 -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'included_variable', 'is_array': '', 'replace': '<(included_variable)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'included_variable' to 'included_variable' -VARIABLES:input.py:767:ExpandVariables Found output 'XYZ', recursing. -VARIABLES:input.py:785:ExpandVariables Expanding 'XYZ' to 'XYZ' -VARIABLES:input.py:785:ExpandVariables Expanding '<(included_variable)' to 'XYZ' -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'third_letters', 'is_array': '', 'replace': '<(third_letters)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'third_letters' to 'third_letters' -VARIABLES:input.py:767:ExpandVariables Found output '<(other_letters)HIJK', recursing. -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'other_letters', 'is_array': '', 'replace': '<(other_letters)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'other_letters' to 'other_letters' -VARIABLES:input.py:767:ExpandVariables Found output '<(letters_list)EFGHIJK', recursing. -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'letters_list', 'is_array': '', 'replace': '<(letters_list)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'letters_list' to 'letters_list' -VARIABLES:input.py:767:ExpandVariables Found output 'ABCDEFGHIJK', recursing. -VARIABLES:input.py:785:ExpandVariables Expanding 'ABCDEFGHIJK' to 'ABCDEFGHIJK' -VARIABLES:input.py:785:ExpandVariables Expanding '<(letters_list)EFGHIJK' to 'ABCDEFGHIJK' -VARIABLES:input.py:785:ExpandVariables Expanding '<(other_letters)HIJK' to 'ABCDEFGHIJK' -VARIABLES:input.py:785:ExpandVariables Expanding '<(third_letters)' to 'ABCDEFGHIJK' -VARIABLES:input.py:785:ExpandVariables Expanding '8' to 8 -VARIABLES:input.py:785:ExpandVariables Expanding '.' to '.' -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'letters_list', 'is_array': '', 'replace': '<(letters_list)', 'type': '<', 'command_string': None} -VARIABLES:input.py:785:ExpandVariables Expanding 'letters_list' to 'letters_list' -VARIABLES:input.py:546:ExpandVariables Matches: {'content': 'python -c "print \'