diff options
Diffstat (limited to 'Source/ThirdParty/gyp/test')
362 files changed, 12625 insertions, 0 deletions
diff --git a/Source/ThirdParty/gyp/test/actions-bare/gyptest-bare.py b/Source/ThirdParty/gyp/test/actions-bare/gyptest-bare.py new file mode 100644 index 000000000..b0c10938d --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-bare/gyptest-bare.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 actions which are not depended on by other targets get executed. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('bare.gyp', chdir='src') +test.relocate('src', 'relocate/src') +test.build('bare.gyp', chdir='relocate/src') + +file_content = 'Hello from bare.py\n' + +test.built_file_must_match('out.txt', file_content, chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/actions-bare/src/bare.gyp b/Source/ThirdParty/gyp/test/actions-bare/src/bare.gyp new file mode 100644 index 000000000..3d28f099d --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-bare/src/bare.gyp @@ -0,0 +1,25 @@ +# Copyright (c) 2009 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': 'bare', + 'type': 'none', + 'actions': [ + { + 'action_name': 'action1', + 'inputs': [ + 'bare.py', + ], + 'outputs': [ + '<(PRODUCT_DIR)/out.txt', + ], + 'action': ['python', 'bare.py', '<(PRODUCT_DIR)/out.txt'], + 'msvs_cygwin_shell': 0, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/actions-bare/src/bare.py b/Source/ThirdParty/gyp/test/actions-bare/src/bare.py new file mode 100644 index 000000000..970450ea3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-bare/src/bare.py @@ -0,0 +1,11 @@ +#!/usr/bin/python + +# Copyright (c) 2009 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. + +import sys + +f = open(sys.argv[1], 'wb') +f.write('Hello from bare.py\n') +f.close() diff --git a/Source/ThirdParty/gyp/test/actions-multiple/gyptest-all.py b/Source/ThirdParty/gyp/test/actions-multiple/gyptest-all.py new file mode 100644 index 000000000..7b94fef40 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-multiple/gyptest-all.py @@ -0,0 +1,42 @@ +#!/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 two actions can be attached to the same input files. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('actions.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +# Test that two actions can be attached to the same inputs. +test.build('actions.gyp', test.ALL, chdir='relocate/src') +test.must_contain('relocate/src/output1.txt', 'hello there') +test.must_contain('relocate/src/output2.txt', 'hello there') +test.must_contain('relocate/src/output3.txt', 'hello there') +test.must_contain('relocate/src/output4.txt', 'hello there') + +# Test that process_outputs_as_sources works in conjuction with merged +# actions. +test.run_built_executable( + 'multiple_action_source_filter', + chdir='relocate/src', + stdout=( + '{\n' + 'bar\n' + 'car\n' + 'dar\n' + 'ear\n' + '}\n' + ), +) + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/actions-multiple/src/actions.gyp b/Source/ThirdParty/gyp/test/actions-multiple/src/actions.gyp new file mode 100644 index 000000000..b38df45fd --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-multiple/src/actions.gyp @@ -0,0 +1,165 @@ +# 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. + +{ + 'variables': { + # Have a long string so that actions will exceed xp 512 character + # command limit on xp. + 'long_string': + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + 'abcdefghijklmnopqrstuvwxyz0123456789' + }, + 'targets': [ + { + 'target_name': 'multiple_action_target', + 'type': 'none', + 'actions': [ + { + 'action_name': 'action1', + 'inputs': [ + 'copy.py', + 'input.txt', + ], + 'outputs': [ + 'output1.txt', + ], + 'action': [ + 'python', '<@(_inputs)', '<(_outputs)', '<(long_string)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + { + 'action_name': 'action2', + 'inputs': [ + 'copy.py', + 'input.txt', + ], + 'outputs': [ + 'output2.txt', + ], + 'action': [ + 'python', '<@(_inputs)', '<(_outputs)', '<(long_string)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + { + 'action_name': 'action3', + 'inputs': [ + 'copy.py', + 'input.txt', + ], + 'outputs': [ + 'output3.txt', + ], + 'action': [ + 'python', '<@(_inputs)', '<(_outputs)', '<(long_string)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + { + 'action_name': 'action4', + 'inputs': [ + 'copy.py', + 'input.txt', + ], + 'outputs': [ + 'output4.txt', + ], + 'action': [ + 'python', '<@(_inputs)', '<(_outputs)', '<(long_string)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + ], + }, + { + 'target_name': 'multiple_action_source_filter', + 'type': 'executable', + 'sources': [ + 'main.c', + # TODO(bradnelson): add foo.c here once this issue is fixed: + # http://code.google.com/p/gyp/issues/detail?id=175 + ], + 'actions': [ + { + 'action_name': 'action1', + 'inputs': [ + 'foo.c', + 'filter.py', + ], + 'outputs': [ + 'output1.c', + ], + 'process_outputs_as_sources': 1, + 'action': [ + 'python', 'filter.py', 'foo', 'bar', 'foo.c', '<(_outputs)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + { + 'action_name': 'action2', + 'inputs': [ + 'foo.c', + 'filter.py', + ], + 'outputs': [ + 'output2.c', + ], + 'process_outputs_as_sources': 1, + 'action': [ + 'python', 'filter.py', 'foo', 'car', 'foo.c', '<(_outputs)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + { + 'action_name': 'action3', + 'inputs': [ + 'foo.c', + 'filter.py', + ], + 'outputs': [ + 'output3.c', + ], + 'process_outputs_as_sources': 1, + 'action': [ + 'python', 'filter.py', 'foo', 'dar', 'foo.c', '<(_outputs)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + { + 'action_name': 'action4', + 'inputs': [ + 'foo.c', + 'filter.py', + ], + 'outputs': [ + 'output4.c', + ], + 'process_outputs_as_sources': 1, + 'action': [ + 'python', 'filter.py', 'foo', 'ear', 'foo.c', '<(_outputs)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/actions-multiple/src/copy.py b/Source/ThirdParty/gyp/test/actions-multiple/src/copy.py new file mode 100644 index 000000000..7ba29110d --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-multiple/src/copy.py @@ -0,0 +1,9 @@ +#!/usr/bin/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. + +import shutil +import sys + +shutil.copyfile(sys.argv[1], sys.argv[2]) diff --git a/Source/ThirdParty/gyp/test/actions-multiple/src/filter.py b/Source/ThirdParty/gyp/test/actions-multiple/src/filter.py new file mode 100644 index 000000000..d0a0a950b --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-multiple/src/filter.py @@ -0,0 +1,12 @@ +#!/usr/bin/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. + + +import sys + +data = open(sys.argv[3], 'r').read() +fh = open(sys.argv[4], 'w') +fh.write(data.replace(sys.argv[1], sys.argv[2])) +fh.close() diff --git a/Source/ThirdParty/gyp/test/actions-multiple/src/foo.c b/Source/ThirdParty/gyp/test/actions-multiple/src/foo.c new file mode 100644 index 000000000..23c4ef7f2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-multiple/src/foo.c @@ -0,0 +1,11 @@ +/* + * 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. + */ + +#include <stdio.h> + +void foo(void) { + printf("foo\n"); +} diff --git a/Source/ThirdParty/gyp/test/actions-multiple/src/input.txt b/Source/ThirdParty/gyp/test/actions-multiple/src/input.txt new file mode 100644 index 000000000..c7c7da3c6 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-multiple/src/input.txt @@ -0,0 +1 @@ +hello there diff --git a/Source/ThirdParty/gyp/test/actions-multiple/src/main.c b/Source/ThirdParty/gyp/test/actions-multiple/src/main.c new file mode 100644 index 000000000..0a420b903 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-multiple/src/main.c @@ -0,0 +1,22 @@ +/* + * 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. + */ + +#include <stdio.h> + +void bar(void); +void car(void); +void dar(void); +void ear(void); + +int main() { + printf("{\n"); + bar(); + car(); + dar(); + ear(); + printf("}\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/actions-subdir/gyptest-action.py b/Source/ThirdParty/gyp/test/actions-subdir/gyptest-action.py new file mode 100644 index 000000000..09cfef189 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-subdir/gyptest-action.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 actions that output to PRODUCT_DIR. +""" + +import TestGyp + +# TODO fix this for xcode: http://code.google.com/p/gyp/issues/detail?id=88 +test = TestGyp.TestGyp(formats=['!xcode']) + +test.run_gyp('none.gyp', chdir='src') + +test.build('none.gyp', test.ALL, chdir='src') + +file_content = 'Hello from make-file.py\n' +subdir_file_content = 'Hello from make-subdir-file.py\n' + +test.built_file_must_match('file.out', file_content, chdir='src') +test.built_file_must_match('subdir_file.out', subdir_file_content, chdir='src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/actions-subdir/src/make-file.py b/Source/ThirdParty/gyp/test/actions-subdir/src/make-file.py new file mode 100644 index 000000000..74e55811d --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-subdir/src/make-file.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = 'Hello from make-file.py\n' + +open(sys.argv[1], 'wb').write(contents) diff --git a/Source/ThirdParty/gyp/test/actions-subdir/src/none.gyp b/Source/ThirdParty/gyp/test/actions-subdir/src/none.gyp new file mode 100644 index 000000000..23f8d25a5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-subdir/src/none.gyp @@ -0,0 +1,31 @@ +# Copyright (c) 2009 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': 'file', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'actions': [ + { + 'action_name': 'make-file', + 'inputs': [ + 'make-file.py', + ], + 'outputs': [ + '<(PRODUCT_DIR)/file.out', + ], + 'action': [ + 'python', '<(_inputs)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + } + ], + 'dependencies': [ + 'subdir/subdir.gyp:subdir_file', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/actions-subdir/src/subdir/make-subdir-file.py b/Source/ThirdParty/gyp/test/actions-subdir/src/subdir/make-subdir-file.py new file mode 100644 index 000000000..80ce19ae0 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-subdir/src/subdir/make-subdir-file.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = 'Hello from make-subdir-file.py\n' + +open(sys.argv[1], 'wb').write(contents) diff --git a/Source/ThirdParty/gyp/test/actions-subdir/src/subdir/subdir.gyp b/Source/ThirdParty/gyp/test/actions-subdir/src/subdir/subdir.gyp new file mode 100644 index 000000000..0315d4eb8 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions-subdir/src/subdir/subdir.gyp @@ -0,0 +1,28 @@ +# Copyright (c) 2009 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': 'subdir_file', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'actions': [ + { + 'action_name': 'make-subdir-file', + 'inputs': [ + 'make-subdir-file.py', + ], + 'outputs': [ + '<(PRODUCT_DIR)/subdir_file.out', + ], + 'action': [ + 'python', '<(_inputs)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + } + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/actions/gyptest-all.py b/Source/ThirdParty/gyp/test/actions/gyptest-all.py new file mode 100644 index 000000000..8db38d52c --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/gyptest-all.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 simple actions when using an explicit build target of 'all'. +""" + +import glob +import os +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('actions.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +# Test that an "always run" action increases a counter on multiple invocations, +# and that a dependent action updates in step. +test.build('actions.gyp', test.ALL, chdir='relocate/src') +test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '1') +test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '1') +test.build('actions.gyp', test.ALL, chdir='relocate/src') +test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') +test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') + +# The "always run" action only counts to 2, but the dependent target will count +# forever if it's allowed to run. This verifies that the dependent target only +# runs when the "always run" action generates new output, not just because the +# "always run" ran. +test.build('actions.gyp', test.ALL, chdir='relocate/src') +test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') +test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') + +expect = """\ +Hello from program.c +Hello from make-prog1.py +Hello from make-prog2.py +""" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir1' +else: + chdir = 'relocate/src' +test.run_built_executable('program', chdir=chdir, stdout=expect) + + +test.must_match('relocate/src/subdir2/file.out', "Hello from make-file.py\n") + + +expect = "Hello from generate_main.py\n" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir3' +else: + chdir = 'relocate/src' +test.run_built_executable('null_input', chdir=chdir, stdout=expect) + + +# Clean out files which may have been created if test.ALL was run. +def clean_dep_files(): + for file in (glob.glob('relocate/src/dep_*.txt') + + glob.glob('relocate/src/deps_all_done_*.txt')): + if os.path.exists(file): + os.remove(file) + +# Confirm our clean. +clean_dep_files() +test.must_not_exist('relocate/src/dep_1.txt') +test.must_not_exist('relocate/src/deps_all_done_first_123.txt') + +# Make sure all deps finish before an action is run on a 'None' target. +# If using the Make builder, add -j to make things more difficult. +arguments = [] +if test.format == 'make': + arguments = ['-j'] +test.build('actions.gyp', 'action_with_dependencies_123', chdir='relocate/src', + arguments=arguments) +test.must_exist('relocate/src/deps_all_done_first_123.txt') + +# Try again with a target that has deps in reverse. Output files from +# previous tests deleted. Confirm this execution did NOT run the ALL +# target which would mess up our dep tests. +clean_dep_files() +test.build('actions.gyp', 'action_with_dependencies_321', chdir='relocate/src', + arguments=arguments) +test.must_exist('relocate/src/deps_all_done_first_321.txt') +test.must_not_exist('relocate/src/deps_all_done_first_123.txt') + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/actions/gyptest-default.py b/Source/ThirdParty/gyp/test/actions/gyptest-default.py new file mode 100644 index 000000000..c877867b1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/gyptest-default.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 simple actions when using the default build target. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('actions.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +# Test that an "always run" action increases a counter on multiple invocations, +# and that a dependent action updates in step. +test.build('actions.gyp', chdir='relocate/src') +test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '1') +test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '1') +test.build('actions.gyp', chdir='relocate/src') +test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') +test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') + +# The "always run" action only counts to 2, but the dependent target will count +# forever if it's allowed to run. This verifies that the dependent target only +# runs when the "always run" action generates new output, not just because the +# "always run" ran. +test.build('actions.gyp', test.ALL, chdir='relocate/src') +test.must_match('relocate/src/subdir1/actions-out/action-counter.txt', '2') +test.must_match('relocate/src/subdir1/actions-out/action-counter_2.txt', '2') + +expect = """\ +Hello from program.c +Hello from make-prog1.py +Hello from make-prog2.py +""" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir1' +else: + chdir = 'relocate/src' +test.run_built_executable('program', chdir=chdir, stdout=expect) + + +test.must_match('relocate/src/subdir2/file.out', "Hello from make-file.py\n") + + +expect = "Hello from generate_main.py\n" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir3' +else: + chdir = 'relocate/src' +test.run_built_executable('null_input', chdir=chdir, stdout=expect) + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/actions/gyptest-errors.py b/Source/ThirdParty/gyp/test/actions/gyptest-errors.py new file mode 100644 index 000000000..ca41487bb --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/gyptest-errors.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python
+ +# Copyright (c) 2009 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 behavior for different action configuration errors:
+exit status of 1, and the expected error message must be in stderr.
+"""
+
+import TestGyp
+
+test = TestGyp.TestGyp()
+
+
+test.run_gyp('action_missing_name.gyp', chdir='src', status=1, stderr=None)
+expect = [
+ "Anonymous action in target broken_actions2. An action must have an 'action_name' field.",
+]
+test.must_contain_all_lines(test.stderr(), expect)
+
+
+test.pass_test()
diff --git a/Source/ThirdParty/gyp/test/actions/src/action_missing_name.gyp b/Source/ThirdParty/gyp/test/actions/src/action_missing_name.gyp new file mode 100644 index 000000000..00424c35a --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/action_missing_name.gyp @@ -0,0 +1,24 @@ +# Copyright (c) 2009 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': 'broken_actions2', + 'type': 'none', + 'actions': [ + { + 'inputs': [ + 'no_name.input', + ], + 'action': [ + 'python', + '-c', + 'print \'missing name\'', + ], + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/actions/src/actions.gyp b/Source/ThirdParty/gyp/test/actions/src/actions.gyp new file mode 100644 index 000000000..5d2db1955 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/actions.gyp @@ -0,0 +1,114 @@ +# Copyright (c) 2009 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': 'pull_in_all_actions', + 'type': 'none', + 'dependencies': [ + 'subdir1/executable.gyp:*', + 'subdir2/none.gyp:*', + 'subdir3/null_input.gyp:*', + ], + }, + { + 'target_name': 'depend_on_always_run_action', + 'type': 'none', + 'dependencies': [ 'subdir1/executable.gyp:counter' ], + 'actions': [ + { + 'action_name': 'use_always_run_output', + 'inputs': [ + 'subdir1/actions-out/action-counter.txt', + 'subdir1/counter.py', + ], + 'outputs': [ + 'subdir1/actions-out/action-counter_2.txt', + ], + 'action': [ + 'python', 'subdir1/counter.py', '<(_outputs)', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + ], + }, + + # Three deps which don't finish immediately. + # Each one has a small delay then creates a file. + # Delays are 1.0, 1.1, and 2.0 seconds. + { + 'target_name': 'dep_1', + 'type': 'none', + 'actions': [{ + 'inputs': [ 'actions.gyp' ], + 'outputs': [ 'dep_1.txt' ], + 'action_name': 'dep_1', + 'action': [ 'python', '-c', + 'import time; time.sleep(1); open(\'dep_1.txt\', \'w\')' ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }], + }, + { + 'target_name': 'dep_2', + 'type': 'none', + 'actions': [{ + 'inputs': [ 'actions.gyp' ], + 'outputs': [ 'dep_2.txt' ], + 'action_name': 'dep_2', + 'action': [ 'python', '-c', + 'import time; time.sleep(1.1); open(\'dep_2.txt\', \'w\')' ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }], + }, + { + 'target_name': 'dep_3', + 'type': 'none', + 'actions': [{ + 'inputs': [ 'actions.gyp' ], + 'outputs': [ 'dep_3.txt' ], + 'action_name': 'dep_3', + 'action': [ 'python', '-c', + 'import time; time.sleep(2.0); open(\'dep_3.txt\', \'w\')' ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }], + }, + + # An action which assumes the deps have completed. + # Does NOT list the output files of it's deps as inputs. + # On success create the file deps_all_done_first.txt. + { + 'target_name': 'action_with_dependencies_123', + 'type': 'none', + 'dependencies': [ 'dep_1', 'dep_2', 'dep_3' ], + 'actions': [{ + 'inputs': [ 'actions.gyp' ], + 'outputs': [ 'deps_all_done_first_123.txt' ], + 'action_name': 'action_with_dependencies_123', + 'action': [ 'python', 'confirm-dep-files.py', '<(_outputs)' ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }], + }, + # Same as above but with deps in reverse. + { + 'target_name': 'action_with_dependencies_321', + 'type': 'none', + 'dependencies': [ 'dep_3', 'dep_2', 'dep_1' ], + 'actions': [{ + 'inputs': [ 'actions.gyp' ], + 'outputs': [ 'deps_all_done_first_321.txt' ], + 'action_name': 'action_with_dependencies_321', + 'action': [ 'python', 'confirm-dep-files.py', '<(_outputs)' ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }], + }, + + ], +} diff --git a/Source/ThirdParty/gyp/test/actions/src/confirm-dep-files.py b/Source/ThirdParty/gyp/test/actions/src/confirm-dep-files.py new file mode 100644 index 000000000..34efe28f1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/confirm-dep-files.py @@ -0,0 +1,16 @@ +#!/usr/bin/python + +# Confirm presence of files generated by our targets we depend on. +# If they exist, create a new file. +# +# Note target's input files are explicitly NOT defined in the gyp file +# so they can't easily be passed to this script as args. + +import os +import sys + +outfile = sys.argv[1] # Example value we expect: deps_all_done_first_123.txt +if (os.path.exists("dep_1.txt") and + os.path.exists("dep_2.txt") and + os.path.exists("dep_3.txt")): + open(outfile, "w") diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir1/counter.py b/Source/ThirdParty/gyp/test/actions/src/subdir1/counter.py new file mode 100644 index 000000000..3612d7d2b --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir1/counter.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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. + +import sys +import time + +output = sys.argv[1] +persistoutput = "%s.persist" % sys.argv[1] + +count = 0 +try: + count = open(persistoutput, 'r').read() +except: + pass +count = int(count) + 1 + +if len(sys.argv) > 2: + max_count = int(sys.argv[2]) + if count > max_count: + count = max_count + +oldcount = 0 +try: + oldcount = open(output, 'r').read() +except: + pass + +# Save the count in a file that is undeclared, and thus hidden, to gyp. We need +# to do this because, prior to running commands, scons deletes any declared +# outputs, so we would lose our count if we just wrote to the given output file. +# (The other option is to use Precious() in the scons generator, but that seems +# too heavy-handed just to support this somewhat unrealistic test case, and +# might lead to unintended side-effects). +open(persistoutput, 'w').write('%d' % (count)) + +# Only write the given output file if the count has changed. +if int(oldcount) != count: + open(output, 'w').write('%d' % (count)) + # Sleep so the next run changes the file time sufficiently to make the build + # detect the file as changed. + time.sleep(1) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir1/executable.gyp b/Source/ThirdParty/gyp/test/actions/src/subdir1/executable.gyp new file mode 100644 index 000000000..6a1ce4f91 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir1/executable.gyp @@ -0,0 +1,74 @@ +# Copyright (c) 2009 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': 'program', + 'type': 'executable', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'program.c', + ], + 'actions': [ + { + 'action_name': 'make-prog1', + 'inputs': [ + 'make-prog1.py', + ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/prog1.c', + ], + 'action': [ + 'python', '<(_inputs)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + { + 'action_name': 'make-prog2', + 'inputs': [ + 'make-prog2.py', + ], + 'outputs': [ + 'actions-out/prog2.c', + ], + 'action': [ + 'python', '<(_inputs)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + ], + }, + { + 'target_name': 'counter', + 'type': 'none', + 'actions': [ + { + # This action should always run, regardless of whether or not it's + # inputs or the command-line change. We do this by creating a dummy + # first output, which is always missing, thus causing the build to + # always try to recreate it. Actual output files should be listed + # after the dummy one, and dependent targets should list the real + # output(s) in their inputs + # (see '../actions.gyp:depend_on_always_run_action'). + 'action_name': 'action_counter', + 'inputs': [ + 'counter.py', + ], + 'outputs': [ + 'actions-out/action-counter.txt.always', + 'actions-out/action-counter.txt', + ], + 'action': [ + 'python', '<(_inputs)', 'actions-out/action-counter.txt', '2', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir1/make-prog1.py b/Source/ThirdParty/gyp/test/actions/src/subdir1/make-prog1.py new file mode 100644 index 000000000..7ea1d8a2d --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir1/make-prog1.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = r""" +#include <stdio.h> + +void prog1(void) +{ + printf("Hello from make-prog1.py\n"); +} +""" + +open(sys.argv[1], 'w').write(contents) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir1/make-prog2.py b/Source/ThirdParty/gyp/test/actions/src/subdir1/make-prog2.py new file mode 100644 index 000000000..0bfe4973c --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir1/make-prog2.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = r""" +#include <stdio.h> + +void prog2(void) +{ + printf("Hello from make-prog2.py\n"); +} +""" + +open(sys.argv[1], 'w').write(contents) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir1/program.c b/Source/ThirdParty/gyp/test/actions/src/subdir1/program.c new file mode 100644 index 000000000..d5f661d90 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir1/program.c @@ -0,0 +1,12 @@ +#include <stdio.h>
+
+extern void prog1(void);
+extern void prog2(void);
+
+int main(int argc, char *argv[])
+{
+ printf("Hello from program.c\n");
+ prog1();
+ prog2();
+ return 0;
+}
diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir2/make-file.py b/Source/ThirdParty/gyp/test/actions/src/subdir2/make-file.py new file mode 100644 index 000000000..fff065314 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir2/make-file.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = "Hello from make-file.py\n" + +open(sys.argv[1], 'wb').write(contents) diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir2/none.gyp b/Source/ThirdParty/gyp/test/actions/src/subdir2/none.gyp new file mode 100644 index 000000000..2caa97d55 --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir2/none.gyp @@ -0,0 +1,33 @@ +# Copyright (c) 2009 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': 'file', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'actions': [ + { + 'action_name': 'make-file', + 'inputs': [ + 'make-file.py', + ], + 'outputs': [ + 'file.out', + # TODO: enhance testing infrastructure to test this + # without having to hard-code the intermediate dir paths. + #'<(INTERMEDIATE_DIR)/file.out', + ], + 'action': [ + 'python', '<(_inputs)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + } + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir3/generate_main.py b/Source/ThirdParty/gyp/test/actions/src/subdir3/generate_main.py new file mode 100644 index 000000000..b90b3aa6d --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir3/generate_main.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = """ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from generate_main.py\\n"); + return 0; +} +""" + +open(sys.argv[1], 'w').write(contents) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/actions/src/subdir3/null_input.gyp b/Source/ThirdParty/gyp/test/actions/src/subdir3/null_input.gyp new file mode 100644 index 000000000..9b0bea5fd --- /dev/null +++ b/Source/ThirdParty/gyp/test/actions/src/subdir3/null_input.gyp @@ -0,0 +1,29 @@ +# Copyright (c) 2009 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': 'null_input', + 'type': 'executable', + 'msvs_cygwin_shell': 0, + 'actions': [ + { + 'action_name': 'generate_main', + 'process_outputs_as_sources': 1, + 'inputs': [], + 'outputs': [ + '<(INTERMEDIATE_DIR)/main.c', + ], + 'action': [ + # TODO: we can't just use <(_outputs) here?! + 'python', 'generate_main.py', '<(INTERMEDIATE_DIR)/main.c', + ], + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/additional-targets/gyptest-additional.py b/Source/ThirdParty/gyp/test/additional-targets/gyptest-additional.py new file mode 100644 index 000000000..02e7d7a41 --- /dev/null +++ b/Source/ThirdParty/gyp/test/additional-targets/gyptest-additional.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 simple actions when using an explicit build target of 'all'. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('all.gyp', chdir='src') +test.relocate('src', 'relocate/src') + +# Build all. +test.build('all.gyp', chdir='relocate/src') + +if test.format=='xcode': + chdir = 'relocate/src/dir1' +else: + chdir = 'relocate/src' + +# Output is as expected. +file_content = 'Hello from emit.py\n' +test.built_file_must_match('out2.txt', file_content, chdir=chdir) + +test.built_file_must_not_exist('out.txt', chdir='relocate/src') +test.built_file_must_not_exist('foolib1', + type=test.SHARED_LIB, + chdir=chdir) + +# TODO(mmoss) Make consistent with scons, with 'dir1' before 'out/Default'? +if test.format == 'make': + chdir='relocate/src' +else: + chdir='relocate/src/dir1' + +# Build the action explicitly. +test.build('actions.gyp', 'action1_target', chdir=chdir) + +# Check that things got run. +file_content = 'Hello from emit.py\n' +test.built_file_must_exist('out.txt', chdir=chdir) + +# Build the shared library explicitly. +test.build('actions.gyp', 'foolib1', chdir=chdir) + +test.built_file_must_exist('foolib1', + type=test.SHARED_LIB, + chdir=chdir) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/additional-targets/src/all.gyp b/Source/ThirdParty/gyp/test/additional-targets/src/all.gyp new file mode 100644 index 000000000..21c83080a --- /dev/null +++ b/Source/ThirdParty/gyp/test/additional-targets/src/all.gyp @@ -0,0 +1,13 @@ +# Copyright (c) 2009 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': 'all_targets', + 'type': 'none', + 'dependencies': ['dir1/actions.gyp:*'], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/additional-targets/src/dir1/actions.gyp b/Source/ThirdParty/gyp/test/additional-targets/src/dir1/actions.gyp new file mode 100644 index 000000000..5089c8091 --- /dev/null +++ b/Source/ThirdParty/gyp/test/additional-targets/src/dir1/actions.gyp @@ -0,0 +1,56 @@ +# Copyright (c) 2009 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': 'action1_target', + 'type': 'none', + 'suppress_wildcard': 1, + 'actions': [ + { + 'action_name': 'action1', + 'inputs': [ + 'emit.py', + ], + 'outputs': [ + '<(PRODUCT_DIR)/out.txt', + ], + 'action': ['python', 'emit.py', '<(PRODUCT_DIR)/out.txt'], + 'msvs_cygwin_shell': 0, + }, + ], + }, + { + 'target_name': 'action2_target', + 'type': 'none', + 'actions': [ + { + 'action_name': 'action2', + 'inputs': [ + 'emit.py', + ], + 'outputs': [ + '<(PRODUCT_DIR)/out2.txt', + ], + 'action': ['python', 'emit.py', '<(PRODUCT_DIR)/out2.txt'], + 'msvs_cygwin_shell': 0, + }, + ], + }, + { + 'target_name': 'foolib1', + 'type': 'shared_library', + 'suppress_wildcard': 1, + 'sources': ['lib1.c'], + }, + ], + 'conditions': [ + ['OS=="linux"', { + 'target_defaults': { + 'cflags': ['-fPIC'], + }, + }], + ], +} diff --git a/Source/ThirdParty/gyp/test/additional-targets/src/dir1/emit.py b/Source/ThirdParty/gyp/test/additional-targets/src/dir1/emit.py new file mode 100644 index 000000000..5638c43b5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/additional-targets/src/dir1/emit.py @@ -0,0 +1,11 @@ +#!/usr/bin/python + +# Copyright (c) 2009 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. + +import sys + +f = open(sys.argv[1], 'wb') +f.write('Hello from emit.py\n') +f.close() diff --git a/Source/ThirdParty/gyp/test/additional-targets/src/dir1/lib1.c b/Source/ThirdParty/gyp/test/additional-targets/src/dir1/lib1.c new file mode 100644 index 000000000..df4cb10f7 --- /dev/null +++ b/Source/ThirdParty/gyp/test/additional-targets/src/dir1/lib1.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int func1(void) { + return 42; +} diff --git a/Source/ThirdParty/gyp/test/assembly/gyptest-assembly.py b/Source/ThirdParty/gyp/test/assembly/gyptest-assembly.py new file mode 100644 index 000000000..40d0a062f --- /dev/null +++ b/Source/ThirdParty/gyp/test/assembly/gyptest-assembly.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 .hpp files are ignored when included in the source list on all +platforms. +""" + +import sys +import TestGyp + +# TODO(bradnelson): get this working for windows. +test = TestGyp.TestGyp(formats=['make', 'scons', 'xcode']) + +test.run_gyp('assembly.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('assembly.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from program.c +Got 42. +""" +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/assembly/src/as.bat b/Source/ThirdParty/gyp/test/assembly/src/as.bat new file mode 100644 index 000000000..0a47382cb --- /dev/null +++ b/Source/ThirdParty/gyp/test/assembly/src/as.bat @@ -0,0 +1,4 @@ +@echo off +:: Mock windows assembler. +cl /c %1 /Fo"%2" + diff --git a/Source/ThirdParty/gyp/test/assembly/src/assembly.gyp b/Source/ThirdParty/gyp/test/assembly/src/assembly.gyp new file mode 100644 index 000000000..872dd5ec0 --- /dev/null +++ b/Source/ThirdParty/gyp/test/assembly/src/assembly.gyp @@ -0,0 +1,59 @@ +# Copyright (c) 2009 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. + +{ + 'target_defaults': { + 'conditions': [ + ['OS=="win"', { + 'defines': ['PLATFORM_WIN'], + }], + ['OS=="mac"', { + 'defines': ['PLATFORM_MAC'], + }], + ['OS=="linux"', { + 'defines': ['PLATFORM_LINUX'], + }], + ], + }, + 'targets': [ + { + 'target_name': 'program', + 'type': 'executable', + 'dependencies': ['lib1'], + 'sources': [ + 'program.c', + ], + }, + { + 'target_name': 'lib1', + 'type': 'static_library', + 'sources': [ + 'lib1.S', + ], + }, + ], + 'conditions': [ + ['OS=="win"', { + 'target_defaults': { + 'rules': [ + { + 'rule_name': 'assembler', + 'msvs_cygwin_shell': 0, + 'extension': 'S', + 'inputs': [ + 'as.bat', + ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj', + ], + 'action': + ['as.bat', 'lib1.c', '<(_outputs)'], + 'message': 'Building assembly file <(RULE_INPUT_PATH)', + 'process_outputs_as_sources': 1, + }, + ], + }, + },], + ], +} diff --git a/Source/ThirdParty/gyp/test/assembly/src/lib1.S b/Source/ThirdParty/gyp/test/assembly/src/lib1.S new file mode 100644 index 000000000..e7102bf24 --- /dev/null +++ b/Source/ThirdParty/gyp/test/assembly/src/lib1.S @@ -0,0 +1,10 @@ +#if PLATFORM_WINDOWS || PLATFORM_MAC +# define IDENTIFIER(n) _##n +#else /* Linux */ +# define IDENTIFIER(n) n +#endif + +.globl IDENTIFIER(lib1_function) +IDENTIFIER(lib1_function): + movl $42, %eax + ret diff --git a/Source/ThirdParty/gyp/test/assembly/src/lib1.c b/Source/ThirdParty/gyp/test/assembly/src/lib1.c new file mode 100644 index 000000000..be21ecd5f --- /dev/null +++ b/Source/ThirdParty/gyp/test/assembly/src/lib1.c @@ -0,0 +1,3 @@ +int lib1_function(void) { + return 42; +} diff --git a/Source/ThirdParty/gyp/test/assembly/src/program.c b/Source/ThirdParty/gyp/test/assembly/src/program.c new file mode 100644 index 000000000..ecce3b0bb --- /dev/null +++ b/Source/ThirdParty/gyp/test/assembly/src/program.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +extern int lib1_function(void); + +int main(int argc, char *argv[]) +{ + fprintf(stdout, "Hello from program.c\n"); + fflush(stdout); + fprintf(stdout, "Got %d.\n", lib1_function()); + fflush(stdout); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/builddir/gyptest-all.py b/Source/ThirdParty/gyp/test/builddir/gyptest-all.py new file mode 100644 index 000000000..324d7fc73 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/gyptest-all.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Verify the settings that cause a set of programs to be created in +a specific build directory, and that no intermediate built files +get created outside of that build directory hierarchy even when +referred to with deeply-nested ../../.. paths. +""" + +import TestGyp + +# TODO(mmoss): Make only supports (theoretically) a single, global build +# directory (through GYP_GENERATOR_FLAGS 'output_dir'), rather than +# gyp-file-specific settings (e.g. the stuff in builddir.gypi) that the other +# generators support, so this doesn't work yet for make. +# TODO(mmoss) Make also has the issue that the top-level Makefile is written to +# the "--depth" location, which is one level above 'src', but then this test +# moves 'src' somewhere else, leaving the Makefile behind, so make can't find +# its sources. I'm not sure if make is wrong for writing outside the current +# directory, or if the test is wrong for assuming everything generated is under +# the current directory. +test = TestGyp.TestGyp(formats=['!make']) + +test.run_gyp('prog1.gyp', '--depth=..', chdir='src') + +test.relocate('src', 'relocate/src') + +test.subdir('relocate/builddir') + +# Make sure that all the built ../../etc. files only get put under builddir, +# by making all of relocate read-only and then making only builddir writable. +test.writable('relocate', False) +test.writable('relocate/builddir', True) + +# Suppress the test infrastructure's setting SYMROOT on the command line. +test.build('prog1.gyp', test.ALL, SYMROOT=None, chdir='relocate/src') + +expect1 = """\ +Hello from prog1.c +Hello from func1.c +""" + +expect2 = """\ +Hello from subdir2/prog2.c +Hello from func2.c +""" + +expect3 = """\ +Hello from subdir2/subdir3/prog3.c +Hello from func3.c +""" + +expect4 = """\ +Hello from subdir2/subdir3/subdir4/prog4.c +Hello from func4.c +""" + +expect5 = """\ +Hello from subdir2/subdir3/subdir4/subdir5/prog5.c +Hello from func5.c +""" + +def run_builddir(prog, expect): + dir = 'relocate/builddir/Default/' + test.run(program=test.workpath(dir + prog), stdout=expect) + +run_builddir('prog1', expect1) +run_builddir('prog2', expect2) +run_builddir('prog3', expect3) +run_builddir('prog4', expect4) +run_builddir('prog5', expect5) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/builddir/gyptest-default.py b/Source/ThirdParty/gyp/test/builddir/gyptest-default.py new file mode 100644 index 000000000..6171d1597 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/gyptest-default.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Verify the settings that cause a set of programs to be created in +a specific build directory, and that no intermediate built files +get created outside of that build directory hierarchy even when +referred to with deeply-nested ../../.. paths. +""" + +import TestGyp + +# TODO(mmoss): Make only supports (theoretically) a single, global build +# directory (through GYP_GENERATOR_FLAGS 'output_dir'), rather than +# gyp-file-specific settings (e.g. the stuff in builddir.gypi) that the other +# generators support, so this doesn't work yet for make. +# TODO(mmoss) Make also has the issue that the top-level Makefile is written to +# the "--depth" location, which is one level above 'src', but then this test +# moves 'src' somewhere else, leaving the Makefile behind, so make can't find +# its sources. I'm not sure if make is wrong for writing outside the current +# directory, or if the test is wrong for assuming everything generated is under +# the current directory. +test = TestGyp.TestGyp(formats=['!make']) + +test.run_gyp('prog1.gyp', '--depth=..', chdir='src') + +test.relocate('src', 'relocate/src') + +test.subdir('relocate/builddir') + +# Make sure that all the built ../../etc. files only get put under builddir, +# by making all of relocate read-only and then making only builddir writable. +test.writable('relocate', False) +test.writable('relocate/builddir', True) + +# Suppress the test infrastructure's setting SYMROOT on the command line. +test.build('prog1.gyp', SYMROOT=None, chdir='relocate/src') + +expect1 = """\ +Hello from prog1.c +Hello from func1.c +""" + +expect2 = """\ +Hello from subdir2/prog2.c +Hello from func2.c +""" + +expect3 = """\ +Hello from subdir2/subdir3/prog3.c +Hello from func3.c +""" + +expect4 = """\ +Hello from subdir2/subdir3/subdir4/prog4.c +Hello from func4.c +""" + +expect5 = """\ +Hello from subdir2/subdir3/subdir4/subdir5/prog5.c +Hello from func5.c +""" + +def run_builddir(prog, expect): + dir = 'relocate/builddir/Default/' + test.run(program=test.workpath(dir + prog), stdout=expect) + +run_builddir('prog1', expect1) +run_builddir('prog2', expect2) +run_builddir('prog3', expect3) +run_builddir('prog4', expect4) +run_builddir('prog5', expect5) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/builddir/src/builddir.gypi b/Source/ThirdParty/gyp/test/builddir/src/builddir.gypi new file mode 100644 index 000000000..e3c61475b --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/builddir.gypi @@ -0,0 +1,21 @@ +# Copyright (c) 2009 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. + +{ + 'target_defaults': { + 'configurations': { + 'Default': { + 'msvs_configuration_attributes': { + 'OutputDirectory': '<(DEPTH)\\builddir\Default', + }, + }, + }, + }, + 'scons_settings': { + 'sconsbuild_dir': '<(DEPTH)/builddir', + }, + 'xcode_settings': { + 'SYMROOT': '<(DEPTH)/builddir', + }, +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/func1.c b/Source/ThirdParty/gyp/test/builddir/src/func1.c new file mode 100644 index 000000000..b8e6a0695 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/func1.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void func1(void) +{ + printf("Hello from func1.c\n"); +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/func2.c b/Source/ThirdParty/gyp/test/builddir/src/func2.c new file mode 100644 index 000000000..14aabac47 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/func2.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void func2(void) +{ + printf("Hello from func2.c\n"); +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/func3.c b/Source/ThirdParty/gyp/test/builddir/src/func3.c new file mode 100644 index 000000000..3b4edeae6 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/func3.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void func3(void) +{ + printf("Hello from func3.c\n"); +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/func4.c b/Source/ThirdParty/gyp/test/builddir/src/func4.c new file mode 100644 index 000000000..732891b79 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/func4.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void func4(void) +{ + printf("Hello from func4.c\n"); +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/func5.c b/Source/ThirdParty/gyp/test/builddir/src/func5.c new file mode 100644 index 000000000..18fdfabbb --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/func5.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void func5(void) +{ + printf("Hello from func5.c\n"); +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/prog1.c b/Source/ThirdParty/gyp/test/builddir/src/prog1.c new file mode 100644 index 000000000..674ca747b --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/prog1.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void func1(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from prog1.c\n"); + func1(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/prog1.gyp b/Source/ThirdParty/gyp/test/builddir/src/prog1.gyp new file mode 100644 index 000000000..5b96f035e --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/prog1.gyp @@ -0,0 +1,30 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + 'builddir.gypi', + ], + 'targets': [ + { + 'target_name': 'pull_in_all', + 'type': 'none', + 'dependencies': [ + 'prog1', + 'subdir2/prog2.gyp:prog2', + 'subdir2/subdir3/prog3.gyp:prog3', + 'subdir2/subdir3/subdir4/prog4.gyp:prog4', + 'subdir2/subdir3/subdir4/subdir5/prog5.gyp:prog5', + ], + }, + { + 'target_name': 'prog1', + 'type': 'executable', + 'sources': [ + 'prog1.c', + 'func1.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/subdir2/prog2.c b/Source/ThirdParty/gyp/test/builddir/src/subdir2/prog2.c new file mode 100644 index 000000000..bbdf4f060 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/subdir2/prog2.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void func2(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from subdir2/prog2.c\n"); + func2(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/subdir2/prog2.gyp b/Source/ThirdParty/gyp/test/builddir/src/subdir2/prog2.gyp new file mode 100644 index 000000000..96299b646 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/subdir2/prog2.gyp @@ -0,0 +1,19 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../builddir.gypi', + ], + 'targets': [ + { + 'target_name': 'prog2', + 'type': 'executable', + 'sources': [ + 'prog2.c', + '../func2.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/prog3.c b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/prog3.c new file mode 100644 index 000000000..10c530b23 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/prog3.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void func3(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from subdir2/subdir3/prog3.c\n"); + func3(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/prog3.gyp b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/prog3.gyp new file mode 100644 index 000000000..d7df43c7b --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/prog3.gyp @@ -0,0 +1,19 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../../builddir.gypi', + ], + 'targets': [ + { + 'target_name': 'prog3', + 'type': 'executable', + 'sources': [ + 'prog3.c', + '../../func3.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.c b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.c new file mode 100644 index 000000000..dcba9a9d4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void func4(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from subdir2/subdir3/subdir4/prog4.c\n"); + func4(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.gyp b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.gyp new file mode 100644 index 000000000..862a8a18c --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/prog4.gyp @@ -0,0 +1,19 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../../../builddir.gypi', + ], + 'targets': [ + { + 'target_name': 'prog4', + 'type': 'executable', + 'sources': [ + 'prog4.c', + '../../../func4.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.c b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.c new file mode 100644 index 000000000..69132e576 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void func5(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from subdir2/subdir3/subdir4/subdir5/prog5.c\n"); + func5(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.gyp b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.gyp new file mode 100644 index 000000000..fe1c9cbf5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/builddir/src/subdir2/subdir3/subdir4/subdir5/prog5.gyp @@ -0,0 +1,19 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../../../../builddir.gypi', + ], + 'targets': [ + { + 'target_name': 'prog5', + 'type': 'executable', + 'sources': [ + 'prog5.c', + '../../../../func5.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/cflags/cflags.c b/Source/ThirdParty/gyp/test/cflags/cflags.c new file mode 100644 index 000000000..c1e245207 --- /dev/null +++ b/Source/ThirdParty/gyp/test/cflags/cflags.c @@ -0,0 +1,15 @@ +/* Copyright (c) 2010 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> + +int main(int argc, char *argv[]) +{ +#ifdef __OPTIMIZE__ + printf("Using an optimization flag\n"); +#else + printf("Using no optimization flag\n"); +#endif + return 0; +} diff --git a/Source/ThirdParty/gyp/test/cflags/cflags.gyp b/Source/ThirdParty/gyp/test/cflags/cflags.gyp new file mode 100644 index 000000000..9003fb167 --- /dev/null +++ b/Source/ThirdParty/gyp/test/cflags/cflags.gyp @@ -0,0 +1,16 @@ +# Copyright (c) 2010 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': 'cflags', + 'type': 'executable', + 'opt': '-Os', + 'sources': [ + 'cflags.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/cflags/gyptest-cflags.py b/Source/ThirdParty/gyp/test/cflags/gyptest-cflags.py new file mode 100644 index 000000000..acc424a2c --- /dev/null +++ b/Source/ThirdParty/gyp/test/cflags/gyptest-cflags.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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 build of an executable with C++ define specified by a gyp define, and +the use of the environment during regeneration when the gyp file changes. +""" + +import os +import TestGyp + +env_stack = [] + + +def PushEnv(): + env_copy = os.environ.copy() + env_stack.append(env_copy) + +def PopEnv(): + os.eniron=env_stack.pop() + +# Regenerating build files when a gyp file changes is currently only supported +# by the make generator. +test = TestGyp.TestGyp(formats=['make']) + +try: + PushEnv() + os.environ['CFLAGS'] = '-O0' + test.run_gyp('cflags.gyp') +finally: + # We clear the environ after calling gyp. When the auto-regeneration happens, + # the same define should be reused anyway. Reset to empty string first in + # case the platform doesn't support unsetenv. + PopEnv() + +test.build('cflags.gyp') + +expect = """\ +Using no optimization flag +""" +test.run_built_executable('cflags', stdout=expect) + +test.sleep() + +try: + PushEnv() + os.environ['CFLAGS'] = '-O2' + test.run_gyp('cflags.gyp') +finally: + # We clear the environ after calling gyp. When the auto-regeneration happens, + # the same define should be reused anyway. Reset to empty string first in + # case the platform doesn't support unsetenv. + PopEnv() + +test.build('cflags.gyp') + +expect = """\ +Using an optimization flag +""" +test.run_built_executable('cflags', stdout=expect) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/compilable/gyptest-headers.py b/Source/ThirdParty/gyp/test/compilable/gyptest-headers.py new file mode 100644 index 000000000..91760216f --- /dev/null +++ b/Source/ThirdParty/gyp/test/compilable/gyptest-headers.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 .hpp files are ignored when included in the source list on all +platforms. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('headers.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('headers.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from program.c +Hello from lib1.c +""" +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/compilable/src/headers.gyp b/Source/ThirdParty/gyp/test/compilable/src/headers.gyp new file mode 100644 index 000000000..b6c2a8857 --- /dev/null +++ b/Source/ThirdParty/gyp/test/compilable/src/headers.gyp @@ -0,0 +1,26 @@ +# Copyright (c) 2009 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': 'program', + 'type': 'executable', + 'dependencies': [ + 'lib1' + ], + 'sources': [ + 'program.cpp', + ], + }, + { + 'target_name': 'lib1', + 'type': 'static_library', + 'sources': [ + 'lib1.hpp', + 'lib1.cpp', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/compilable/src/lib1.cpp b/Source/ThirdParty/gyp/test/compilable/src/lib1.cpp new file mode 100644 index 000000000..51bc31a40 --- /dev/null +++ b/Source/ThirdParty/gyp/test/compilable/src/lib1.cpp @@ -0,0 +1,7 @@ +#include <stdio.h> +#include "lib1.hpp" + +void lib1_function(void) { + fprintf(stdout, "Hello from lib1.c\n"); + fflush(stdout); +} diff --git a/Source/ThirdParty/gyp/test/compilable/src/lib1.hpp b/Source/ThirdParty/gyp/test/compilable/src/lib1.hpp new file mode 100644 index 000000000..72e63e8ac --- /dev/null +++ b/Source/ThirdParty/gyp/test/compilable/src/lib1.hpp @@ -0,0 +1,6 @@ +#ifndef _lib1_hpp +#define _lib1_hpp + +extern void lib1_function(void); + +#endif diff --git a/Source/ThirdParty/gyp/test/compilable/src/program.cpp b/Source/ThirdParty/gyp/test/compilable/src/program.cpp new file mode 100644 index 000000000..81420bad4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/compilable/src/program.cpp @@ -0,0 +1,9 @@ +#include <stdio.h> +#include "lib1.hpp" + +int main(int argc, char *argv[]) { + fprintf(stdout, "Hello from program.c\n"); + fflush(stdout); + lib1_function(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/configurations/basics/configurations.c b/Source/ThirdParty/gyp/test/configurations/basics/configurations.c new file mode 100644 index 000000000..6c1f90016 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/basics/configurations.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ +#ifdef FOO + printf("Foo configuration\n"); +#endif +#ifdef DEBUG + printf("Debug configuration\n"); +#endif +#ifdef RELEASE + printf("Release configuration\n"); +#endif + return 0; +} diff --git a/Source/ThirdParty/gyp/test/configurations/basics/configurations.gyp b/Source/ThirdParty/gyp/test/configurations/basics/configurations.gyp new file mode 100644 index 000000000..93f1d8d5c --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/basics/configurations.gyp @@ -0,0 +1,32 @@ +# Copyright (c) 2009 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': 'configurations', + 'type': 'executable', + 'sources': [ + 'configurations.c', + ], + 'configurations': { + 'Debug': { + 'defines': [ + 'DEBUG', + ], + }, + 'Release': { + 'defines': [ + 'RELEASE', + ], + }, + 'Foo': { + 'defines': [ + 'FOO', + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/basics/gyptest-configurations.py b/Source/ThirdParty/gyp/test/configurations/basics/gyptest-configurations.py new file mode 100644 index 000000000..27cd2e87d --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/basics/gyptest-configurations.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 build of an executable in three different configurations. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('configurations.gyp') + +test.set_configuration('Release') +test.build('configurations.gyp') +test.run_built_executable('configurations', stdout="Release configuration\n") + +test.set_configuration('Debug') +test.build('configurations.gyp') +test.run_built_executable('configurations', stdout="Debug configuration\n") + +test.set_configuration('Foo') +test.build('configurations.gyp') +test.run_built_executable('configurations', stdout="Foo configuration\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/configurations/inheritance/configurations.c b/Source/ThirdParty/gyp/test/configurations/inheritance/configurations.c new file mode 100644 index 000000000..2d5565eeb --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/inheritance/configurations.c @@ -0,0 +1,21 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ +#ifdef BASE + printf("Base configuration\n"); +#endif +#ifdef COMMON + printf("Common configuration\n"); +#endif +#ifdef COMMON2 + printf("Common2 configuration\n"); +#endif +#ifdef DEBUG + printf("Debug configuration\n"); +#endif +#ifdef RELEASE + printf("Release configuration\n"); +#endif + return 0; +} diff --git a/Source/ThirdParty/gyp/test/configurations/inheritance/configurations.gyp b/Source/ThirdParty/gyp/test/configurations/inheritance/configurations.gyp new file mode 100644 index 000000000..9441376b4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/inheritance/configurations.gyp @@ -0,0 +1,40 @@ +# Copyright (c) 2009 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. + +{ + 'target_defaults': { + 'configurations': { + 'Base': { + 'abstract': 1, + 'defines': ['BASE'], + }, + 'Common': { + 'abstract': 1, + 'inherit_from': ['Base'], + 'defines': ['COMMON'], + }, + 'Common2': { + 'abstract': 1, + 'defines': ['COMMON2'], + }, + 'Debug': { + 'inherit_from': ['Common', 'Common2'], + 'defines': ['DEBUG'], + }, + 'Release': { + 'inherit_from': ['Common', 'Common2'], + 'defines': ['RELEASE'], + }, + }, + }, + 'targets': [ + { + 'target_name': 'configurations', + 'type': 'executable', + 'sources': [ + 'configurations.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/inheritance/gyptest-inheritance.py b/Source/ThirdParty/gyp/test/configurations/inheritance/gyptest-inheritance.py new file mode 100644 index 000000000..22c73a375 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/inheritance/gyptest-inheritance.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 build of an executable in three different configurations. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('configurations.gyp') + +test.set_configuration('Release') +test.build('configurations.gyp') +test.run_built_executable('configurations', + stdout=('Base configuration\n' + 'Common configuration\n' + 'Common2 configuration\n' + 'Release configuration\n')) + +test.set_configuration('Debug') +test.build('configurations.gyp') +test.run_built_executable('configurations', + stdout=('Base configuration\n' + 'Common configuration\n' + 'Common2 configuration\n' + 'Debug configuration\n')) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/actions.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/actions.gyp new file mode 100644 index 000000000..a6e42089e --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/actions.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'actions': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/all_dependent_settings.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/all_dependent_settings.gyp new file mode 100644 index 000000000..b16a245df --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/all_dependent_settings.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'all_dependent_settings': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/configurations.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/configurations.gyp new file mode 100644 index 000000000..2cfc96004 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/configurations.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'configurations': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/dependencies.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/dependencies.gyp new file mode 100644 index 000000000..74633f3f1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/dependencies.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'dependencies': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/direct_dependent_settings.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/direct_dependent_settings.gyp new file mode 100644 index 000000000..8a0f2e95e --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/direct_dependent_settings.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'direct_dependent_settings': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/gyptest-configurations.py b/Source/ThirdParty/gyp/test/configurations/invalid/gyptest-configurations.py new file mode 100644 index 000000000..d76cdedb0 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/gyptest-configurations.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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 build of an executable in three different configurations. +""" + +import TestGyp + +# Keys that do not belong inside a configuration dictionary. +invalid_configuration_keys = [ + 'actions', + 'all_dependent_settings', + 'configurations', + 'dependencies', + 'direct_dependent_settings', + 'libraries', + 'link_settings', + 'sources', + 'target_name', + 'type', +] + +test = TestGyp.TestGyp() + +if test.format == 'scons': + test.skip_test('TODO: http://code.google.com/p/gyp/issues/detail?id=176\n') + +for test_key in invalid_configuration_keys: + test.run_gyp('%s.gyp' % test_key, status=1, stderr=None) + expect = ['%s not allowed in the Debug configuration, found in target ' + '%s.gyp:configurations#target' % (test_key, test_key)] + test.must_contain_all_lines(test.stderr(), expect) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/libraries.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/libraries.gyp new file mode 100644 index 000000000..c4014ed40 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/libraries.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'libraries': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/link_settings.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/link_settings.gyp new file mode 100644 index 000000000..2f0e1c46f --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/link_settings.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'link_settings': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/sources.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/sources.gyp new file mode 100644 index 000000000..b38cca038 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/sources.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'sources': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/target_name.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/target_name.gyp new file mode 100644 index 000000000..83baad95d --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/target_name.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'target_name': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/invalid/type.gyp b/Source/ThirdParty/gyp/test/configurations/invalid/type.gyp new file mode 100644 index 000000000..bc55898b8 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/invalid/type.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'configurations', + 'type': 'none', + 'configurations': { + 'Debug': { + 'type': [ + ], + }, + } + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/target_platform/configurations.gyp b/Source/ThirdParty/gyp/test/configurations/target_platform/configurations.gyp new file mode 100644 index 000000000..d15429f4e --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/target_platform/configurations.gyp @@ -0,0 +1,58 @@ +# Copyright (c) 2009 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. + +{ + 'target_defaults': { + 'configurations': { + 'Debug_Win32': { + 'msvs_configuration_platform': 'Win32', + }, + 'Debug_x64': { + 'msvs_configuration_platform': 'x64', + }, + }, + }, + 'targets': [ + { + 'target_name': 'left', + 'type': 'static_library', + 'sources': [ + 'left.c', + ], + 'configurations': { + 'Debug_Win32': { + 'msvs_target_platform': 'x64', + }, + }, + }, + { + 'target_name': 'right', + 'type': 'static_library', + 'sources': [ + 'right.c', + ], + }, + { + 'target_name': 'front_left', + 'type': 'executable', + 'dependencies': ['left'], + 'sources': [ + 'front.c', + ], + 'configurations': { + 'Debug_Win32': { + 'msvs_target_platform': 'x64', + }, + }, + }, + { + 'target_name': 'front_right', + 'type': 'executable', + 'dependencies': ['right'], + 'sources': [ + 'front.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/target_platform/front.c b/Source/ThirdParty/gyp/test/configurations/target_platform/front.c new file mode 100644 index 000000000..12b1d0aa3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/target_platform/front.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +const char *message(void); + +int main(int argc, char *argv[]) { + printf("%s\n", message()); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/configurations/target_platform/gyptest-target_platform.py b/Source/ThirdParty/gyp/test/configurations/target_platform/gyptest-target_platform.py new file mode 100644 index 000000000..ae4e9e5a2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/target_platform/gyptest-target_platform.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Tests the msvs specific msvs_target_platform option. +""" + +import TestGyp +import TestCommon + + +def RunX64(exe, stdout): + try: + test.run_built_executable(exe, stdout=stdout) + except WindowsError, e: + # Assume the exe is 64-bit if it can't load on 32-bit systems. + # Both versions of the error are required because different versions + # of python seem to return different errors for invalid exe type. + if e.errno != 193 and '[Error 193]' not in str(e): + raise + + +test = TestGyp.TestGyp(formats=['msvs']) + +test.run_gyp('configurations.gyp') + +test.set_configuration('Debug|x64') +test.build('configurations.gyp', rebuild=True) +RunX64('front_left', stdout=('left\n')) +RunX64('front_right', stdout=('right\n')) + +test.set_configuration('Debug|Win32') +test.build('configurations.gyp', rebuild=True) +RunX64('front_left', stdout=('left\n')) +test.run_built_executable('front_right', stdout=('right\n')) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/configurations/target_platform/left.c b/Source/ThirdParty/gyp/test/configurations/target_platform/left.c new file mode 100644 index 000000000..1ce2ea122 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/target_platform/left.c @@ -0,0 +1,3 @@ +const char *message(void) { + return "left"; +} diff --git a/Source/ThirdParty/gyp/test/configurations/target_platform/right.c b/Source/ThirdParty/gyp/test/configurations/target_platform/right.c new file mode 100644 index 000000000..b1578492f --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/target_platform/right.c @@ -0,0 +1,3 @@ +const char *message(void) { + return "right"; +} diff --git a/Source/ThirdParty/gyp/test/configurations/x64/configurations.c b/Source/ThirdParty/gyp/test/configurations/x64/configurations.c new file mode 100644 index 000000000..72c97e31d --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/x64/configurations.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) { + if (sizeof(void*) == 4) { + printf("Running Win32\n"); + } else if (sizeof(void*) == 8) { + printf("Running x64\n"); + } else { + printf("Unexpected platform\n"); + } + return 0; +} diff --git a/Source/ThirdParty/gyp/test/configurations/x64/configurations.gyp b/Source/ThirdParty/gyp/test/configurations/x64/configurations.gyp new file mode 100644 index 000000000..06ffa3758 --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/x64/configurations.gyp @@ -0,0 +1,26 @@ +# Copyright (c) 2009 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. + +{ + 'target_defaults': { + 'configurations': { + 'Debug': { + 'msvs_configuration_platform': 'Win32', + }, + 'Debug_x64': { + 'inherit_from': ['Debug'], + 'msvs_configuration_platform': 'x64', + }, + }, + }, + 'targets': [ + { + 'target_name': 'configurations', + 'type': 'executable', + 'sources': [ + 'configurations.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/configurations/x64/gyptest-x86.py b/Source/ThirdParty/gyp/test/configurations/x64/gyptest-x86.py new file mode 100644 index 000000000..254ea6fbc --- /dev/null +++ b/Source/ThirdParty/gyp/test/configurations/x64/gyptest-x86.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 build of an executable in three different configurations. +""" + +import TestGyp + +test = TestGyp.TestGyp(formats=['msvs']) + +test.run_gyp('configurations.gyp') + +for platform in ['Win32', 'x64']: + test.set_configuration('Debug|%s' % platform) + test.build('configurations.gyp', rebuild=True) + try: + test.run_built_executable('configurations', + stdout=('Running %s\n' % platform)) + except WindowsError, e: + # Assume the exe is 64-bit if it can't load on 32-bit systems. + if platform == 'x64' and (e.errno == 193 or '[Error 193]' in str(e)): + continue + raise + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/copies-link/gyptest-copies-link.py b/Source/ThirdParty/gyp/test/copies-link/gyptest-copies-link.py new file mode 100644 index 000000000..fe7b6025c --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies-link/gyptest-copies-link.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 file copies using the build tool default. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('copies-link.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('copies-link.gyp', chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/copies-link/src/copies-link.gyp b/Source/ThirdParty/gyp/test/copies-link/src/copies-link.gyp new file mode 100644 index 000000000..9d2530a6e --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies-link/src/copies-link.gyp @@ -0,0 +1,61 @@ +# Copyright (c) 2009 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': 'func1', + 'type': 'static_library', + 'sources': ['func1.c'], + }, + { + 'target_name': 'clone_func1', + 'type': 'none', + 'dependencies': ['func1'], + 'actions': [ + { + 'action_name': 'cloning library', + 'inputs': [ + '<(LIB_DIR)/<(STATIC_LIB_PREFIX)func1<(STATIC_LIB_SUFFIX)' + ], + 'outputs': ['<(PRODUCT_DIR)/alternate/' + '<(STATIC_LIB_PREFIX)cloned<(STATIC_LIB_SUFFIX)'], + 'destination': '<(PRODUCT_DIR)', + 'action': ['python', 'copy.py', '<@(_inputs)', '<@(_outputs)'], + 'msvs_cygwin_shell': 0, + }, + ], + }, + { + 'target_name': 'copy_cloned', + 'type': 'none', + 'dependencies': ['clone_func1'], + 'copies': [ + { + 'destination': '<(LIB_DIR)', + 'files': [ + '<(PRODUCT_DIR)/alternate/' + '<(STATIC_LIB_PREFIX)cloned<(STATIC_LIB_SUFFIX)', + ], + }, + ], + }, + { + 'target_name': 'use_cloned', + 'type': 'executable', + 'sources': ['main.c'], + 'dependencies': ['copy_cloned'], + 'link_settings': { + 'conditions': [ + ['OS=="win"', { + 'libraries': ['-l"<(LIB_DIR)/cloned.lib"'], + }, { + 'libraries': ['-lcloned'], + 'ldflags': ['-L <(LIB_DIR)'], + }], + ], + }, + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/copies-link/src/copy.py b/Source/ThirdParty/gyp/test/copies-link/src/copy.py new file mode 100644 index 000000000..a1dd8718a --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies-link/src/copy.py @@ -0,0 +1,21 @@ +#!/usr/bin/python + +# Copyright (c) 2009 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. + +import shutil +import sys + + +def main(argv): + if len(argv) != 3: + print 'USAGE: copy.py <src> <dst>' + return 1 + + shutil.copy(argv[1], argv[2]) + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/Source/ThirdParty/gyp/test/copies-link/src/func1.c b/Source/ThirdParty/gyp/test/copies-link/src/func1.c new file mode 100644 index 000000000..cceccdd66 --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies-link/src/func1.c @@ -0,0 +1,5 @@ +#include <stdio.h> + +void func1(void) { + printf("hello from func1\n"); +} diff --git a/Source/ThirdParty/gyp/test/copies-link/src/main.c b/Source/ThirdParty/gyp/test/copies-link/src/main.c new file mode 100644 index 000000000..56fd2f04a --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies-link/src/main.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +extern void func1(void); + +int main(int argc, char *argv[]) { + printf("hello from link1\n"); + func1(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/copies/gyptest-all.py b/Source/ThirdParty/gyp/test/copies/gyptest-all.py new file mode 100644 index 000000000..8542ab7b9 --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/gyptest-all.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 file copies using an explicit build target of 'all'. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('copies.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('copies.gyp', test.ALL, chdir='relocate/src') + +test.must_match(['relocate', 'src', 'copies-out', 'file1'], 'file1 contents\n') + +test.built_file_must_match('copies-out/file2', + 'file2 contents\n', + chdir='relocate/src') + +test.built_file_must_match('copies-out/directory/file3', + 'file3 contents\n', + chdir='relocate/src') +test.built_file_must_match('copies-out/directory/file4', + 'file4 contents\n', + chdir='relocate/src') +test.built_file_must_match('copies-out/directory/subdir/file5', + 'file5 contents\n', + chdir='relocate/src') +test.built_file_must_match('copies-out/subdir/file6', + 'file6 contents\n', + chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/copies/gyptest-default.py b/Source/ThirdParty/gyp/test/copies/gyptest-default.py new file mode 100644 index 000000000..a5d1bf9c3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/gyptest-default.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 file copies using the build tool default. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('copies.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('copies.gyp', chdir='relocate/src') + +test.must_match(['relocate', 'src', 'copies-out', 'file1'], 'file1 contents\n') + +test.built_file_must_match('copies-out/file2', + 'file2 contents\n', + chdir='relocate/src') + +test.built_file_must_match('copies-out/directory/file3', + 'file3 contents\n', + chdir='relocate/src') +test.built_file_must_match('copies-out/directory/file4', + 'file4 contents\n', + chdir='relocate/src') +test.built_file_must_match('copies-out/directory/subdir/file5', + 'file5 contents\n', + chdir='relocate/src') +test.built_file_must_match('copies-out/subdir/file6', + 'file6 contents\n', + chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/copies/src/copies.gyp b/Source/ThirdParty/gyp/test/copies/src/copies.gyp new file mode 100644 index 000000000..ce2e0cabc --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/src/copies.gyp @@ -0,0 +1,70 @@ +# Copyright (c) 2009 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': 'copies1', + 'type': 'none', + 'copies': [ + { + 'destination': 'copies-out', + 'files': [ + 'file1', + ], + }, + ], + }, + { + 'target_name': 'copies2', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/copies-out', + 'files': [ + 'file2', + ], + }, + ], + }, + # Copy a directory tree. + { + 'target_name': 'copies_recursive', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/copies-out', + 'files': [ + 'directory/', + ], + }, + ], + }, + # Copy a directory from deeper in the tree (this should not reproduce the + # entire directory path in the destination, only the final directory). + { + 'target_name': 'copies_recursive_depth', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/copies-out', + 'files': [ + 'parentdir/subdir/', + ], + }, + ], + }, + # Verify that a null 'files' list doesn't gag the generators. + { + 'target_name': 'copies_null', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/copies-null', + 'files': [], + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/copies/src/directory/file3 b/Source/ThirdParty/gyp/test/copies/src/directory/file3 new file mode 100644 index 000000000..43f16f352 --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/src/directory/file3 @@ -0,0 +1 @@ +file3 contents diff --git a/Source/ThirdParty/gyp/test/copies/src/directory/file4 b/Source/ThirdParty/gyp/test/copies/src/directory/file4 new file mode 100644 index 000000000..5f7270a08 --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/src/directory/file4 @@ -0,0 +1 @@ +file4 contents diff --git a/Source/ThirdParty/gyp/test/copies/src/directory/subdir/file5 b/Source/ThirdParty/gyp/test/copies/src/directory/subdir/file5 new file mode 100644 index 000000000..41f47186b --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/src/directory/subdir/file5 @@ -0,0 +1 @@ +file5 contents diff --git a/Source/ThirdParty/gyp/test/copies/src/file1 b/Source/ThirdParty/gyp/test/copies/src/file1 new file mode 100644 index 000000000..84d55c575 --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/src/file1 @@ -0,0 +1 @@ +file1 contents diff --git a/Source/ThirdParty/gyp/test/copies/src/file2 b/Source/ThirdParty/gyp/test/copies/src/file2 new file mode 100644 index 000000000..af1b8ae35 --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/src/file2 @@ -0,0 +1 @@ +file2 contents diff --git a/Source/ThirdParty/gyp/test/copies/src/parentdir/subdir/file6 b/Source/ThirdParty/gyp/test/copies/src/parentdir/subdir/file6 new file mode 100644 index 000000000..f5d575734 --- /dev/null +++ b/Source/ThirdParty/gyp/test/copies/src/parentdir/subdir/file6 @@ -0,0 +1 @@ +file6 contents diff --git a/Source/ThirdParty/gyp/test/cxxflags/cxxflags.cc b/Source/ThirdParty/gyp/test/cxxflags/cxxflags.cc new file mode 100644 index 000000000..c1e245207 --- /dev/null +++ b/Source/ThirdParty/gyp/test/cxxflags/cxxflags.cc @@ -0,0 +1,15 @@ +/* Copyright (c) 2010 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> + +int main(int argc, char *argv[]) +{ +#ifdef __OPTIMIZE__ + printf("Using an optimization flag\n"); +#else + printf("Using no optimization flag\n"); +#endif + return 0; +} diff --git a/Source/ThirdParty/gyp/test/cxxflags/cxxflags.gyp b/Source/ThirdParty/gyp/test/cxxflags/cxxflags.gyp new file mode 100644 index 000000000..24d883aae --- /dev/null +++ b/Source/ThirdParty/gyp/test/cxxflags/cxxflags.gyp @@ -0,0 +1,16 @@ +# Copyright (c) 2010 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': 'cxxflags', + 'type': 'executable', + 'opt': '-Os', + 'sources': [ + 'cxxflags.cc', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/cxxflags/gyptest-cxxflags.py b/Source/ThirdParty/gyp/test/cxxflags/gyptest-cxxflags.py new file mode 100644 index 000000000..2e5a6d947 --- /dev/null +++ b/Source/ThirdParty/gyp/test/cxxflags/gyptest-cxxflags.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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 build of an executable with C++ define specified by a gyp define, and +the use of the environment during regeneration when the gyp file changes. +""" + +import os +import TestGyp + +env_stack = [] + + +def PushEnv(): + env_copy = os.environ.copy() + env_stack.append(env_copy) + +def PopEnv(): + os.eniron=env_stack.pop() + +# Regenerating build files when a gyp file changes is currently only supported +# by the make generator. +test = TestGyp.TestGyp(formats=['make']) + +try: + PushEnv() + os.environ['CXXFLAGS'] = '-O0' + test.run_gyp('cxxflags.gyp') +finally: + # We clear the environ after calling gyp. When the auto-regeneration happens, + # the same define should be reused anyway. Reset to empty string first in + # case the platform doesn't support unsetenv. + PopEnv() + +test.build('cxxflags.gyp') + +expect = """\ +Using no optimization flag +""" +test.run_built_executable('cxxflags', stdout=expect) + +test.sleep() + +try: + PushEnv() + os.environ['CXXFLAGS'] = '-O2' + test.run_gyp('cxxflags.gyp') +finally: + # We clear the environ after calling gyp. When the auto-regeneration happens, + # the same define should be reused anyway. Reset to empty string first in + # case the platform doesn't support unsetenv. + PopEnv() + +test.build('cxxflags.gyp') + +expect = """\ +Using an optimization flag +""" +test.run_built_executable('cxxflags', stdout=expect) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/defines-escaping/defines-escaping.c b/Source/ThirdParty/gyp/test/defines-escaping/defines-escaping.c new file mode 100644 index 000000000..440757222 --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines-escaping/defines-escaping.c @@ -0,0 +1,11 @@ +/* Copyright (c) 2010 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> + +int main(int argc, char *argv[]) +{ + printf(TEST_FORMAT, TEST_ARGS); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/defines-escaping/defines-escaping.gyp b/Source/ThirdParty/gyp/test/defines-escaping/defines-escaping.gyp new file mode 100644 index 000000000..6f0f3fde4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines-escaping/defines-escaping.gyp @@ -0,0 +1,19 @@ +# Copyright (c) 2009 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': 'defines_escaping', + 'type': 'executable', + 'sources': [ + 'defines-escaping.c', + ], + 'defines': [ + 'TEST_FORMAT="<(test_format)"', + 'TEST_ARGS=<(test_args)', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/defines-escaping/gyptest-defines-escaping.py b/Source/ThirdParty/gyp/test/defines-escaping/gyptest-defines-escaping.py new file mode 100644 index 000000000..69574b3b3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines-escaping/gyptest-defines-escaping.py @@ -0,0 +1,182 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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 build of an executable with C++ define specified by a gyp define using +various special characters such as quotes, commas, etc. +""" + +import os +import TestGyp + +test = TestGyp.TestGyp() + +# Tests string literals, percents, and backslash escapes. +try: + os.environ['GYP_DEFINES'] = ( + r"""test_format='\n%s\n' """ + r"""test_args='"Simple test of %s with a literal"'""") + test.run_gyp('defines-escaping.gyp') +finally: + del os.environ['GYP_DEFINES'] + +test.build('defines-escaping.gyp') + +expect = """ +Simple test of %s with a literal +""" +test.run_built_executable('defines_escaping', stdout=expect) + + +# Test multiple comma-and-space-separated string literals. +try: + os.environ['GYP_DEFINES'] = \ + r"""test_format='\n%s and %s\n' test_args='"foo", "bar"'""" + test.run_gyp('defines-escaping.gyp') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines-escaping.c') +test.build('defines-escaping.gyp') + +expect = """ +foo and bar +""" +test.run_built_executable('defines_escaping', stdout=expect) + + +# Test string literals containing quotes. +try: + os.environ['GYP_DEFINES'] = ( + r"""test_format='\n%s %s %s %s %s\n' """ + r"""test_args='"\"These,\"",""" + r""" "\"words,\"",""" + r""" "\"are,\"",""" + r""" "\"in,\"",""" + r""" "\"quotes.\""'""") + test.run_gyp('defines-escaping.gyp') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines-escaping.c') +test.build('defines-escaping.gyp') + +expect = """ +"These," "words," "are," "in," "quotes." +""" +test.run_built_executable('defines_escaping', stdout=expect) + + +# Test string literals containing single quotes. +try: + os.environ['GYP_DEFINES'] = ( + r"""test_format='\n%s %s %s %s %s\n' """ + r"""test_args="\"'These,'\",""" + r""" \"'words,'\",""" + r""" \"'are,'\",""" + r""" \"'in,'\",""" + r""" \"'quotes.'\"" """) + test.run_gyp('defines-escaping.gyp') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines-escaping.c') +test.build('defines-escaping.gyp') + +expect = """ +'These,' 'words,' 'are,' 'in,' 'quotes.' +""" +test.run_built_executable('defines_escaping', stdout=expect) + + +# Test string literals containing different numbers of backslashes before quotes +# (to exercise Windows' quoting behaviour). +try: + os.environ['GYP_DEFINES'] = ( + r"""test_format='\n%s\n%s\n%s\n' """ + r"""test_args='"\\\"1 visible slash\\\"",""" + r""" "\\\\\"2 visible slashes\\\\\"",""" + r""" "\\\\\\\"3 visible slashes\\\\\\\""'""") + test.run_gyp('defines-escaping.gyp') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines-escaping.c') +test.build('defines-escaping.gyp') + +expect = r""" +\"1 visible slash\" +\\"2 visible slashes\\" +\\\"3 visible slashes\\\" +""" +test.run_built_executable('defines_escaping', stdout=expect) + + +# Test that various scary sequences are passed unfettered. +try: + os.environ['GYP_DEFINES'] = ( + r"""test_format='\n%s\n' """ + r"""test_args='"$foo, " `foo`;"'""") + test.run_gyp('defines-escaping.gyp') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines-escaping.c') +test.build('defines-escaping.gyp') + +expect = """ +$foo, " `foo`; +""" +test.run_built_executable('defines_escaping', stdout=expect) + + +# VisualStudio 2010 can't handle passing %PATH% +if not (test.format == 'msvs' and test.uses_msbuild): + try: + os.environ['GYP_DEFINES'] = ( + """test_format='%s' """ + """test_args='"%PATH%"'""") + test.run_gyp('defines-escaping.gyp') + finally: + del os.environ['GYP_DEFINES'] + + test.sleep() + test.touch('defines-escaping.c') + test.build('defines-escaping.gyp') + + expect = "%PATH%" + test.run_built_executable('defines_escaping', stdout=expect) + + +# Test commas and semi-colons preceded by backslashes (to exercise Windows' +# quoting behaviour). +try: + os.environ['GYP_DEFINES'] = ( + r"""test_format='\n%s\n%s\n' """ + r"""test_args='"\\, \\\\;",""" + # Same thing again, but enclosed in visible quotes. + r""" "\"\\, \\\\;\""'""") + test.run_gyp('defines-escaping.gyp') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines-escaping.c') +test.build('defines-escaping.gyp') + +expect = r""" +\, \\; +"\, \\;" +""" +test.run_built_executable('defines_escaping', stdout=expect) + +# We deliberately do not test having an odd number of quotes in a string +# literal because that isn't feasible in MSVS. diff --git a/Source/ThirdParty/gyp/test/defines/defines-env.gyp b/Source/ThirdParty/gyp/test/defines/defines-env.gyp new file mode 100644 index 000000000..1781546ae --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines/defines-env.gyp @@ -0,0 +1,22 @@ +# Copyright (c) 2009 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. + +{ + 'variables': { + 'value%': '5', + }, + 'targets': [ + { + 'target_name': 'defines', + 'type': 'executable', + 'sources': [ + 'defines.c', + ], + 'defines': [ + 'VALUE=<(value)', + ], + }, + ], +} + diff --git a/Source/ThirdParty/gyp/test/defines/defines.c b/Source/ThirdParty/gyp/test/defines/defines.c new file mode 100644 index 000000000..33657ac2c --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines/defines.c @@ -0,0 +1,14 @@ +/* Copyright (c) 2009 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> + +int main(int argc, char *argv[]) +{ +#ifdef FOO + printf("FOO is defined\n"); +#endif + printf("VALUE is %d\n", VALUE); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/defines/defines.gyp b/Source/ThirdParty/gyp/test/defines/defines.gyp new file mode 100644 index 000000000..3db66e54c --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines/defines.gyp @@ -0,0 +1,36 @@ +# Copyright (c) 2009 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': 'defines', + 'type': 'executable', + 'sources': [ + 'defines.c', + ], + 'defines': [ + 'FOO', + 'VALUE=1', + ], + }, + ], + 'conditions': [ + ['OS=="fakeos"', { + 'targets': [ + { + 'target_name': 'fakeosprogram', + 'type': 'executable', + 'sources': [ + 'defines.c', + ], + 'defines': [ + 'FOO', + 'VALUE=1', + ], + }, + ], + }], + ], +} diff --git a/Source/ThirdParty/gyp/test/defines/gyptest-define-override.py b/Source/ThirdParty/gyp/test/defines/gyptest-define-override.py new file mode 100644 index 000000000..82e325af2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines/gyptest-define-override.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 a default gyp define can be overridden. +""" + +import os +import TestGyp + +test = TestGyp.TestGyp() + +# Command-line define +test.run_gyp('defines.gyp', '-D', 'OS=fakeos') +test.build('defines.gyp') +test.built_file_must_exist('fakeosprogram', type=test.EXECUTABLE) +# Clean up the exe so subsequent tests don't find an old exe. +os.remove(test.built_file_path('fakeosprogram', type=test.EXECUTABLE)) + +# Without "OS" override, fokeosprogram shouldn't be built. +test.run_gyp('defines.gyp') +test.build('defines.gyp') +test.built_file_must_not_exist('fakeosprogram', type=test.EXECUTABLE) + +# Environment define +os.environ['GYP_DEFINES'] = 'OS=fakeos' +test.run_gyp('defines.gyp') +test.build('defines.gyp') +test.built_file_must_exist('fakeosprogram', type=test.EXECUTABLE) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/defines/gyptest-defines-env-regyp.py b/Source/ThirdParty/gyp/test/defines/gyptest-defines-env-regyp.py new file mode 100644 index 000000000..70c9ba780 --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines/gyptest-defines-env-regyp.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 build of an executable with C++ define specified by a gyp define, and +the use of the environment during regeneration when the gyp file changes. +""" + +import os +import TestGyp + +# Regenerating build files when a gyp file changes is currently only supported +# by the make generator. +test = TestGyp.TestGyp(formats=['make']) + +try: + os.environ['GYP_DEFINES'] = 'value=50' + test.run_gyp('defines.gyp') +finally: + # We clear the environ after calling gyp. When the auto-regeneration happens, + # the same define should be reused anyway. Reset to empty string first in + # case the platform doesn't support unsetenv. + os.environ['GYP_DEFINES'] = '' + del os.environ['GYP_DEFINES'] + +test.build('defines.gyp') + +expect = """\ +FOO is defined +VALUE is 1 +""" +test.run_built_executable('defines', stdout=expect) + +# Sleep so that the changed gyp file will have a newer timestamp than the +# previously generated build files. +test.sleep() +test.write('defines.gyp', test.read('defines-env.gyp')) + +test.build('defines.gyp', test.ALL) + +expect = """\ +VALUE is 50 +""" +test.run_built_executable('defines', stdout=expect) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/defines/gyptest-defines-env.py b/Source/ThirdParty/gyp/test/defines/gyptest-defines-env.py new file mode 100644 index 000000000..6b4e7175a --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines/gyptest-defines-env.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 build of an executable with C++ define specified by a gyp define. +""" + +import os +import TestGyp + +test = TestGyp.TestGyp() + +# With the value only given in environment, it should be used. +try: + os.environ['GYP_DEFINES'] = 'value=10' + test.run_gyp('defines-env.gyp') +finally: + del os.environ['GYP_DEFINES'] + +test.build('defines-env.gyp') + +expect = """\ +VALUE is 10 +""" +test.run_built_executable('defines', stdout=expect) + + +# With the value given in both command line and environment, +# command line should take precedence. +try: + os.environ['GYP_DEFINES'] = 'value=20' + test.run_gyp('defines-env.gyp', '-Dvalue=25') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines.c') +test.build('defines-env.gyp') + +expect = """\ +VALUE is 25 +""" +test.run_built_executable('defines', stdout=expect) + + +# With the value only given in environment, it should be ignored if +# --ignore-environment is specified. +try: + os.environ['GYP_DEFINES'] = 'value=30' + test.run_gyp('defines-env.gyp', '--ignore-environment') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines.c') +test.build('defines-env.gyp') + +expect = """\ +VALUE is 5 +""" +test.run_built_executable('defines', stdout=expect) + + +# With the value given in both command line and environment, and +# --ignore-environment also specified, command line should still be used. +try: + os.environ['GYP_DEFINES'] = 'value=40' + test.run_gyp('defines-env.gyp', '--ignore-environment', '-Dvalue=45') +finally: + del os.environ['GYP_DEFINES'] + +test.sleep() +test.touch('defines.c') +test.build('defines-env.gyp') + +expect = """\ +VALUE is 45 +""" +test.run_built_executable('defines', stdout=expect) + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/defines/gyptest-defines.py b/Source/ThirdParty/gyp/test/defines/gyptest-defines.py new file mode 100644 index 000000000..a21a6176f --- /dev/null +++ b/Source/ThirdParty/gyp/test/defines/gyptest-defines.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 build of an executable with C++ defines. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('defines.gyp') + +test.build('defines.gyp') + +expect = """\ +FOO is defined +VALUE is 1 +""" +test.run_built_executable('defines', stdout=expect) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/dependencies/a.c b/Source/ThirdParty/gyp/test/dependencies/a.c new file mode 100755 index 000000000..3bba111d2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/a.c @@ -0,0 +1,9 @@ +/* Copyright (c) 2009 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. */ + +extern int funcB(); + +int funcA() { + return funcB(); +} diff --git a/Source/ThirdParty/gyp/test/dependencies/b/b.c b/Source/ThirdParty/gyp/test/dependencies/b/b.c new file mode 100755 index 000000000..b5e771bcc --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/b/b.c @@ -0,0 +1,3 @@ +int funcB() { + return 2; +} diff --git a/Source/ThirdParty/gyp/test/dependencies/b/b.gyp b/Source/ThirdParty/gyp/test/dependencies/b/b.gyp new file mode 100755 index 000000000..f09e1ff13 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/b/b.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'b', + 'type': 'static_library', + 'sources': [ + 'b.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/dependencies/c/c.c b/Source/ThirdParty/gyp/test/dependencies/c/c.c new file mode 100644 index 000000000..4949daf3e --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/c/c.c @@ -0,0 +1,4 @@ +int funcC() { + return 3 + // Intentional syntax error. This file should never be compiled, so this + // shouldn't be a problem. diff --git a/Source/ThirdParty/gyp/test/dependencies/c/c.gyp b/Source/ThirdParty/gyp/test/dependencies/c/c.gyp new file mode 100644 index 000000000..eabebea9e --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/c/c.gyp @@ -0,0 +1,22 @@ +# Copyright (c) 2009 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': 'c_unused', + 'type': 'static_library', + 'sources': [ + 'c.c', + ], + }, + { + 'target_name': 'd', + 'type': 'static_library', + 'sources': [ + 'd.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/dependencies/c/d.c b/Source/ThirdParty/gyp/test/dependencies/c/d.c new file mode 100644 index 000000000..05465fc1a --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/c/d.c @@ -0,0 +1,3 @@ +int funcD() { + return 4; +} diff --git a/Source/ThirdParty/gyp/test/dependencies/extra_targets.gyp b/Source/ThirdParty/gyp/test/dependencies/extra_targets.gyp new file mode 100644 index 000000000..c1a26de42 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/extra_targets.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2009 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': 'a', + 'type': 'static_library', + 'sources': [ + 'a.c', + ], + # This only depends on the "d" target; other targets in c.gyp + # should not become part of the build (unlike with 'c/c.gyp:*'). + 'dependencies': ['c/c.gyp:d'], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/dependencies/gyptest-extra-targets.py b/Source/ThirdParty/gyp/test/dependencies/gyptest-extra-targets.py new file mode 100644 index 000000000..3752f7445 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/gyptest-extra-targets.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Verify that dependencies don't pull unused targets into the build. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('extra_targets.gyp') + +# This should fail if it tries to build 'c_unused' since 'c/c.c' has a syntax +# error and won't compile. +test.build('extra_targets.gyp', test.ALL) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/dependencies/gyptest-lib-only.py b/Source/ThirdParty/gyp/test/dependencies/gyptest-lib-only.py new file mode 100755 index 000000000..d90d88fe8 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/gyptest-lib-only.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Verify that a link time only dependency will get pulled into the set of built +targets, even if no executable uses it. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('lib_only.gyp') + +test.build('lib_only.gyp', test.ALL) + +# Make doesn't put static libs in a common 'lib' directory, like it does with +# shared libs, so check in the obj path corresponding to the source path. +test.built_file_must_exist('a', type=test.STATIC_LIB, libdir='obj.target') + +# TODO(bradnelson/mark): +# On linux and windows a library target will at least pull its link dependencies +# into the generated sln/_main.scons, since not doing so confuses users. +# This is not currently implemented on mac, which has the opposite behavior. +if test.format == 'xcode': + test.built_file_must_not_exist('b', type=test.STATIC_LIB) +else: + test.built_file_must_exist('b', type=test.STATIC_LIB, libdir='obj.target/b') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/dependencies/lib_only.gyp b/Source/ThirdParty/gyp/test/dependencies/lib_only.gyp new file mode 100755 index 000000000..f6c84dea6 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependencies/lib_only.gyp @@ -0,0 +1,16 @@ +# Copyright (c) 2009 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': 'a', + 'type': 'static_library', + 'sources': [ + 'a.c', + ], + 'dependencies': ['b/b.gyp:b'], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/dependency-copy/gyptest-copy.py b/Source/ThirdParty/gyp/test/dependency-copy/gyptest-copy.py new file mode 100644 index 000000000..5ba7c73d4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependency-copy/gyptest-copy.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 dependencies do the copy step. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('copies.gyp', chdir='src') + +test.build('copies.gyp', 'proj2', chdir='src') + +test.run_built_executable('proj1', + chdir='src', + stdout="Hello from file1.c\n") +test.run_built_executable('proj2', + chdir='src', + stdout="Hello from file2.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/dependency-copy/src/copies.gyp b/Source/ThirdParty/gyp/test/dependency-copy/src/copies.gyp new file mode 100644 index 000000000..4176b1878 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependency-copy/src/copies.gyp @@ -0,0 +1,25 @@ +# Copyright (c) 2009 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': 'proj1', + 'type': 'executable', + 'sources': [ + 'file1.c', + ], + }, + { + 'target_name': 'proj2', + 'type': 'executable', + 'sources': [ + 'file2.c', + ], + 'dependencies': [ + 'proj1', + ] + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/dependency-copy/src/file1.c b/Source/ThirdParty/gyp/test/dependency-copy/src/file1.c new file mode 100644 index 000000000..3caf5d634 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependency-copy/src/file1.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from file1.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/dependency-copy/src/file2.c b/Source/ThirdParty/gyp/test/dependency-copy/src/file2.c new file mode 100644 index 000000000..ed45cc012 --- /dev/null +++ b/Source/ThirdParty/gyp/test/dependency-copy/src/file2.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from file2.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/exclusion/exclusion.gyp b/Source/ThirdParty/gyp/test/exclusion/exclusion.gyp new file mode 100644 index 000000000..1232dabae --- /dev/null +++ b/Source/ThirdParty/gyp/test/exclusion/exclusion.gyp @@ -0,0 +1,23 @@ +# Copyright (c) 2010 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': 'hello', + 'type': 'executable', + 'sources': [ + 'hello.c', + 'bogus.c', + 'also/not/real.c', + 'also/not/real2.c', + ], + 'sources!': [ + 'bogus.c', + 'also/not/real.c', + 'also/not/real2.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/exclusion/gyptest-exclusion.py b/Source/ThirdParty/gyp/test/exclusion/gyptest-exclusion.py new file mode 100644 index 000000000..1fc32bf87 --- /dev/null +++ b/Source/ThirdParty/gyp/test/exclusion/gyptest-exclusion.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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 exclusions (e.g. sources!) are respected. Excluded sources +that do not exist should not prevent the build from succeeding. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('exclusion.gyp') +test.build('exclusion.gyp') + +# executables +test.built_file_must_exist('hello' + test._exe, test.EXECUTABLE, bare=True) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/exclusion/hello.c b/Source/ThirdParty/gyp/test/exclusion/hello.c new file mode 100644 index 000000000..30e8d5416 --- /dev/null +++ b/Source/ThirdParty/gyp/test/exclusion/hello.c @@ -0,0 +1,15 @@ +/* Copyright (c) 2010 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> + +int func1(void) { + return 42; +} + +int main(int argc, char *argv[]) { + printf("Hello, world!\n"); + printf("%d\n", func1()); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/actions.gyp b/Source/ThirdParty/gyp/test/generator-output/actions/actions.gyp new file mode 100644 index 000000000..dded59aff --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/actions.gyp @@ -0,0 +1,16 @@ +# Copyright (c) 2009 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': 'pull_in_all_actions', + 'type': 'none', + 'dependencies': [ + 'subdir1/executable.gyp:*', + 'subdir2/none.gyp:*', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/actions-out/README.txt b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/actions-out/README.txt new file mode 100644 index 000000000..1b052c9a2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/actions-out/README.txt @@ -0,0 +1,4 @@ +A place-holder for this Xcode build output directory, so that the
+test script can verify that .xcodeproj files are not created in
+their normal location by making the src/ read-only, and then
+selectively making this build directory writable.
diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/executable.gyp b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/executable.gyp new file mode 100644 index 000000000..6bdd60a1f --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/executable.gyp @@ -0,0 +1,44 @@ +# Copyright (c) 2009 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': 'program', + 'type': 'executable', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'program.c', + ], + 'actions': [ + { + 'action_name': 'make-prog1', + 'inputs': [ + 'make-prog1.py', + ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/prog1.c', + ], + 'action': [ + 'python', '<(_inputs)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + { + 'action_name': 'make-prog2', + 'inputs': [ + 'make-prog2.py', + ], + 'outputs': [ + 'actions-out/prog2.c', + ], + 'action': [ + 'python', '<(_inputs)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/make-prog1.py b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/make-prog1.py new file mode 100644 index 000000000..7ea1d8a2d --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/make-prog1.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = r""" +#include <stdio.h> + +void prog1(void) +{ + printf("Hello from make-prog1.py\n"); +} +""" + +open(sys.argv[1], 'w').write(contents) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/make-prog2.py b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/make-prog2.py new file mode 100644 index 000000000..0bfe4973c --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/make-prog2.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = r""" +#include <stdio.h> + +void prog2(void) +{ + printf("Hello from make-prog2.py\n"); +} +""" + +open(sys.argv[1], 'w').write(contents) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/program.c b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/program.c new file mode 100644 index 000000000..d5f661d90 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/subdir1/program.c @@ -0,0 +1,12 @@ +#include <stdio.h>
+
+extern void prog1(void);
+extern void prog2(void);
+
+int main(int argc, char *argv[])
+{
+ printf("Hello from program.c\n");
+ prog1();
+ prog2();
+ return 0;
+}
diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/actions-out/README.txt b/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/actions-out/README.txt new file mode 100644 index 000000000..1b052c9a2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/actions-out/README.txt @@ -0,0 +1,4 @@ +A place-holder for this Xcode build output directory, so that the
+test script can verify that .xcodeproj files are not created in
+their normal location by making the src/ read-only, and then
+selectively making this build directory writable.
diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/make-file.py b/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/make-file.py new file mode 100644 index 000000000..fff065314 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/make-file.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = "Hello from make-file.py\n" + +open(sys.argv[1], 'wb').write(contents) diff --git a/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/none.gyp b/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/none.gyp new file mode 100644 index 000000000..f98f52753 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/actions/subdir2/none.gyp @@ -0,0 +1,31 @@ +# Copyright (c) 2009 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': 'file', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'actions': [ + { + 'action_name': 'make-file', + 'inputs': [ + 'make-file.py', + ], + 'outputs': [ + 'actions-out/file.out', + # TODO: enhance testing infrastructure to test this + # without having to hard-code the intermediate dir paths. + #'<(INTERMEDIATE_DIR)/file.out', + ], + 'action': [ + 'python', '<(_inputs)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + } + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/copies/copies-out/README.txt b/Source/ThirdParty/gyp/test/generator-output/copies/copies-out/README.txt new file mode 100644 index 000000000..90ef88619 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/copies/copies-out/README.txt @@ -0,0 +1,4 @@ +A place-holder for this Xcode build output directory, so that the +test script can verify that .xcodeproj files are not created in +their normal location by making the src/ read-only, and then +selectively making this build directory writable. diff --git a/Source/ThirdParty/gyp/test/generator-output/copies/copies.gyp b/Source/ThirdParty/gyp/test/generator-output/copies/copies.gyp new file mode 100644 index 000000000..479a3d9b6 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/copies/copies.gyp @@ -0,0 +1,50 @@ +# Copyright (c) 2009 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': 'pull_in_subdir', + 'type': 'none', + 'dependencies': [ + 'subdir/subdir.gyp:*', + ], + }, + { + 'target_name': 'copies1', + 'type': 'none', + 'copies': [ + { + 'destination': 'copies-out', + 'files': [ + 'file1', + ], + }, + ], + }, + { + 'target_name': 'copies2', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/copies-out', + 'files': [ + 'file2', + ], + }, + ], + }, + # Verify that a null 'files' list doesn't gag the generators. + { + 'target_name': 'copies_null', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/copies-null', + 'files': [], + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/copies/file1 b/Source/ThirdParty/gyp/test/generator-output/copies/file1 new file mode 100644 index 000000000..84d55c575 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/copies/file1 @@ -0,0 +1 @@ +file1 contents diff --git a/Source/ThirdParty/gyp/test/generator-output/copies/file2 b/Source/ThirdParty/gyp/test/generator-output/copies/file2 new file mode 100644 index 000000000..af1b8ae35 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/copies/file2 @@ -0,0 +1 @@ +file2 contents diff --git a/Source/ThirdParty/gyp/test/generator-output/copies/subdir/copies-out/README.txt b/Source/ThirdParty/gyp/test/generator-output/copies/subdir/copies-out/README.txt new file mode 100644 index 000000000..90ef88619 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/copies/subdir/copies-out/README.txt @@ -0,0 +1,4 @@ +A place-holder for this Xcode build output directory, so that the +test script can verify that .xcodeproj files are not created in +their normal location by making the src/ read-only, and then +selectively making this build directory writable. diff --git a/Source/ThirdParty/gyp/test/generator-output/copies/subdir/file3 b/Source/ThirdParty/gyp/test/generator-output/copies/subdir/file3 new file mode 100644 index 000000000..43f16f352 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/copies/subdir/file3 @@ -0,0 +1 @@ +file3 contents diff --git a/Source/ThirdParty/gyp/test/generator-output/copies/subdir/file4 b/Source/ThirdParty/gyp/test/generator-output/copies/subdir/file4 new file mode 100644 index 000000000..5f7270a08 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/copies/subdir/file4 @@ -0,0 +1 @@ +file4 contents diff --git a/Source/ThirdParty/gyp/test/generator-output/copies/subdir/subdir.gyp b/Source/ThirdParty/gyp/test/generator-output/copies/subdir/subdir.gyp new file mode 100644 index 000000000..af031d283 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/copies/subdir/subdir.gyp @@ -0,0 +1,32 @@ +# Copyright (c) 2009 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': 'copies3', + 'type': 'none', + 'copies': [ + { + 'destination': 'copies-out', + 'files': [ + 'file3', + ], + }, + ], + }, + { + 'target_name': 'copies4', + 'type': 'none', + 'copies': [ + { + 'destination': '<(PRODUCT_DIR)/copies-out', + 'files': [ + 'file4', + ], + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/gyptest-actions.py b/Source/ThirdParty/gyp/test/generator-output/gyptest-actions.py new file mode 100644 index 000000000..73ac5ae96 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/gyptest-actions.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 --generator-output= behavior when using actions. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +# All the generated files should go under 'gypfiles'. The source directory +# ('actions') should be untouched. +test.writable(test.workpath('actions'), False) +test.run_gyp('actions.gyp', + '--generator-output=' + test.workpath('gypfiles'), + chdir='actions') + +test.writable(test.workpath('actions'), True) + +test.relocate('actions', 'relocate/actions') +test.relocate('gypfiles', 'relocate/gypfiles') + +test.writable(test.workpath('relocate/actions'), False) + +# Some of the action outputs use "pure" relative paths (i.e. without prefixes +# like <(INTERMEDIATE_DIR) or <(PROGRAM_DIR)). Even though we are building under +# 'gypfiles', such outputs will still be created relative to the original .gyp +# sources. Projects probably wouldn't normally do this, since it kind of defeats +# the purpose of '--generator-output', but it is supported behaviour. +test.writable(test.workpath('relocate/actions/build'), True) +test.writable(test.workpath('relocate/actions/subdir1/build'), True) +test.writable(test.workpath('relocate/actions/subdir1/actions-out'), True) +test.writable(test.workpath('relocate/actions/subdir2/build'), True) +test.writable(test.workpath('relocate/actions/subdir2/actions-out'), True) + +test.build('actions.gyp', test.ALL, chdir='relocate/gypfiles') + +expect = """\ +Hello from program.c +Hello from make-prog1.py +Hello from make-prog2.py +""" + +if test.format == 'xcode': + chdir = 'relocate/actions/subdir1' +else: + chdir = 'relocate/gypfiles' +test.run_built_executable('program', chdir=chdir, stdout=expect) + +test.must_match('relocate/actions/subdir2/actions-out/file.out', + "Hello from make-file.py\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/generator-output/gyptest-copies.py b/Source/ThirdParty/gyp/test/generator-output/gyptest-copies.py new file mode 100644 index 000000000..414b7c371 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/gyptest-copies.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 file copies using an explicit build target of 'all'. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.writable(test.workpath('copies'), False) + +test.run_gyp('copies.gyp', + '--generator-output=' + test.workpath('gypfiles'), + chdir='copies') + +test.writable(test.workpath('copies'), True) + +test.relocate('copies', 'relocate/copies') +test.relocate('gypfiles', 'relocate/gypfiles') + +test.writable(test.workpath('relocate/copies'), False) + +test.writable(test.workpath('relocate/copies/build'), True) +test.writable(test.workpath('relocate/copies/copies-out'), True) +test.writable(test.workpath('relocate/copies/subdir/build'), True) +test.writable(test.workpath('relocate/copies/subdir/copies-out'), True) + +test.build('copies.gyp', test.ALL, chdir='relocate/gypfiles') + +test.must_match(['relocate', 'copies', 'copies-out', 'file1'], + "file1 contents\n") + +if test.format == 'xcode': + chdir = 'relocate/copies/build' +elif test.format == 'make': + chdir = 'relocate/gypfiles/out' +else: + chdir = 'relocate/gypfiles' +test.must_match([chdir, 'Default', 'copies-out', 'file2'], "file2 contents\n") + +test.must_match(['relocate', 'copies', 'subdir', 'copies-out', 'file3'], + "file3 contents\n") + +if test.format == 'xcode': + chdir = 'relocate/copies/subdir/build' +elif test.format == 'make': + chdir = 'relocate/gypfiles/out' +else: + chdir = 'relocate/gypfiles' +test.must_match([chdir, 'Default', 'copies-out', 'file4'], "file4 contents\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/generator-output/gyptest-relocate.py b/Source/ThirdParty/gyp/test/generator-output/gyptest-relocate.py new file mode 100644 index 000000000..dd1c2bd6b --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/gyptest-relocate.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 a project hierarchy created with the --generator-output= +option can be built even when it's relocated to a different path. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.writable(test.workpath('src'), False) + +test.run_gyp('prog1.gyp', + '-Dset_symroot=1', + '--generator-output=' + test.workpath('gypfiles'), + chdir='src') + +test.writable(test.workpath('src'), True) + +test.relocate('src', 'relocate/src') +test.relocate('gypfiles', 'relocate/gypfiles') + +test.writable(test.workpath('relocate/src'), False) + +test.writable(test.workpath('relocate/src/build'), True) +test.writable(test.workpath('relocate/src/subdir2/build'), True) +test.writable(test.workpath('relocate/src/subdir3/build'), True) + +test.build('prog1.gyp', test.ALL, chdir='relocate/gypfiles') + +chdir = 'relocate/gypfiles' + +expect = """\ +Hello from %s +Hello from inc.h +Hello from inc1/include1.h +Hello from inc2/include2.h +Hello from inc3/include3.h +Hello from subdir2/deeper/deeper.h +""" + +if test.format == 'xcode': + chdir = 'relocate/src' +test.run_built_executable('prog1', chdir=chdir, stdout=expect % 'prog1.c') + +if test.format == 'xcode': + chdir = 'relocate/src/subdir2' +test.run_built_executable('prog2', chdir=chdir, stdout=expect % 'prog2.c') + +if test.format == 'xcode': + chdir = 'relocate/src/subdir3' +test.run_built_executable('prog3', chdir=chdir, stdout=expect % 'prog3.c') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/generator-output/gyptest-rules.py b/Source/ThirdParty/gyp/test/generator-output/gyptest-rules.py new file mode 100644 index 000000000..05b674ffa --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/gyptest-rules.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 --generator-output= behavior when using rules. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.writable(test.workpath('rules'), False) + +test.run_gyp('rules.gyp', + '--generator-output=' + test.workpath('gypfiles'), + chdir='rules') + +test.writable(test.workpath('rules'), True) + +test.relocate('rules', 'relocate/rules') +test.relocate('gypfiles', 'relocate/gypfiles') + +test.writable(test.workpath('relocate/rules'), False) + +test.writable(test.workpath('relocate/rules/build'), True) +test.writable(test.workpath('relocate/rules/subdir1/build'), True) +test.writable(test.workpath('relocate/rules/subdir2/build'), True) +test.writable(test.workpath('relocate/rules/subdir2/rules-out'), True) + +test.build('rules.gyp', test.ALL, chdir='relocate/gypfiles') + +expect = """\ +Hello from program.c +Hello from function1.in1 +Hello from function2.in1 +Hello from define3.in0 +Hello from define4.in0 +""" + +if test.format == 'xcode': + chdir = 'relocate/rules/subdir1' +else: + chdir = 'relocate/gypfiles' +test.run_built_executable('program', chdir=chdir, stdout=expect) + +test.must_match('relocate/rules/subdir2/rules-out/file1.out', + "Hello from file1.in0\n") +test.must_match('relocate/rules/subdir2/rules-out/file2.out', + "Hello from file2.in0\n") +test.must_match('relocate/rules/subdir2/rules-out/file3.out', + "Hello from file3.in1\n") +test.must_match('relocate/rules/subdir2/rules-out/file4.out', + "Hello from file4.in1\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/generator-output/gyptest-subdir2-deep.py b/Source/ThirdParty/gyp/test/generator-output/gyptest-subdir2-deep.py new file mode 100644 index 000000000..ea1b472eb --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/gyptest-subdir2-deep.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a target from a .gyp file a few subdirectories +deep when the --generator-output= option is used to put the build +configuration files in a separate directory tree. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.writable(test.workpath('src'), False) + +test.writable(test.workpath('src/subdir2/deeper/build'), True) + +test.run_gyp('deeper.gyp', + '-Dset_symroot=1', + '--generator-output=' + test.workpath('gypfiles'), + chdir='src/subdir2/deeper') + +test.build('deeper.gyp', test.ALL, chdir='gypfiles') + +chdir = 'gypfiles' + +if test.format == 'xcode': + chdir = 'src/subdir2/deeper' +test.run_built_executable('deeper', + chdir=chdir, + stdout="Hello from deeper.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/generator-output/gyptest-top-all.py b/Source/ThirdParty/gyp/test/generator-output/gyptest-top-all.py new file mode 100644 index 000000000..902ceb279 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/gyptest-top-all.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a project hierarchy created when the --generator-output= +option is used to put the build configuration files in a separate +directory tree. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.writable(test.workpath('src'), False) + +test.run_gyp('prog1.gyp', + '-Dset_symroot=1', + '--generator-output=' + test.workpath('gypfiles'), + chdir='src') + +test.writable(test.workpath('src/build'), True) +test.writable(test.workpath('src/subdir2/build'), True) +test.writable(test.workpath('src/subdir3/build'), True) + +test.build('prog1.gyp', test.ALL, chdir='gypfiles') + +chdir = 'gypfiles' + +expect = """\ +Hello from %s +Hello from inc.h +Hello from inc1/include1.h +Hello from inc2/include2.h +Hello from inc3/include3.h +Hello from subdir2/deeper/deeper.h +""" + +if test.format == 'xcode': + chdir = 'src' +test.run_built_executable('prog1', chdir=chdir, stdout=expect % 'prog1.c') + +if test.format == 'xcode': + chdir = 'src/subdir2' +test.run_built_executable('prog2', chdir=chdir, stdout=expect % 'prog2.c') + +if test.format == 'xcode': + chdir = 'src/subdir3' +test.run_built_executable('prog3', chdir=chdir, stdout=expect % 'prog3.c') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/copy-file.py b/Source/ThirdParty/gyp/test/generator-output/rules/copy-file.py new file mode 100644 index 000000000..938c336ad --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/copy-file.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +import sys + +contents = open(sys.argv[1], 'r').read() +open(sys.argv[2], 'wb').write(contents) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/rules.gyp b/Source/ThirdParty/gyp/test/generator-output/rules/rules.gyp new file mode 100644 index 000000000..dded59aff --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/rules.gyp @@ -0,0 +1,16 @@ +# Copyright (c) 2009 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': 'pull_in_all_actions', + 'type': 'none', + 'dependencies': [ + 'subdir1/executable.gyp:*', + 'subdir2/none.gyp:*', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/define3.in0 b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/define3.in0 new file mode 100644 index 000000000..cc29c643f --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/define3.in0 @@ -0,0 +1 @@ +#define STRING3 "Hello from define3.in0\n" diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/define4.in0 b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/define4.in0 new file mode 100644 index 000000000..c9b0467b3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/define4.in0 @@ -0,0 +1 @@ +#define STRING4 "Hello from define4.in0\n" diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/executable.gyp b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/executable.gyp new file mode 100644 index 000000000..2fd89a0d5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/executable.gyp @@ -0,0 +1,59 @@ +# Copyright (c) 2009 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': 'program', + 'type': 'executable', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'program.c', + 'function1.in1', + 'function2.in1', + 'define3.in0', + 'define4.in0', + ], + 'include_dirs': [ + '<(INTERMEDIATE_DIR)', + ], + 'rules': [ + { + 'rule_name': 'copy_file_0', + 'extension': 'in0', + 'inputs': [ + '../copy-file.py', + ], + 'outputs': [ + # TODO: fix SCons and Make to support generated files not + # in a variable-named path like <(INTERMEDIATE_DIR) + #'<(RULE_INPUT_ROOT).c', + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).h', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 0, + }, + { + 'rule_name': 'copy_file_1', + 'extension': 'in1', + 'inputs': [ + '../copy-file.py', + ], + 'outputs': [ + # TODO: fix SCons and Make to support generated files not + # in a variable-named path like <(INTERMEDIATE_DIR) + #'<(RULE_INPUT_ROOT).c', + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/function1.in1 b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/function1.in1 new file mode 100644 index 000000000..545e7ca16 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/function1.in1 @@ -0,0 +1,6 @@ +#include <stdio.h> + +void function1(void) +{ + printf("Hello from function1.in1\n"); +} diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/function2.in1 b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/function2.in1 new file mode 100644 index 000000000..6bad43f9c --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/function2.in1 @@ -0,0 +1,6 @@ +#include <stdio.h> + +void function2(void) +{ + printf("Hello from function2.in1\n"); +} diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/program.c b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/program.c new file mode 100644 index 000000000..27fd31ed4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir1/program.c @@ -0,0 +1,18 @@ +#include <stdio.h> +#include "define3.h" +#include "define4.h" + +extern void function1(void); +extern void function2(void); +extern void function3(void); +extern void function4(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from program.c\n"); + function1(); + function2(); + printf("%s", STRING3); + printf("%s", STRING4); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file1.in0 b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file1.in0 new file mode 100644 index 000000000..7aca64f4c --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file1.in0 @@ -0,0 +1 @@ +Hello from file1.in0 diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file2.in0 b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file2.in0 new file mode 100644 index 000000000..80a281a2a --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file2.in0 @@ -0,0 +1 @@ +Hello from file2.in0 diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file3.in1 b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file3.in1 new file mode 100644 index 000000000..60ae2e793 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file3.in1 @@ -0,0 +1 @@ +Hello from file3.in1 diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file4.in1 b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file4.in1 new file mode 100644 index 000000000..5a3c30720 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/file4.in1 @@ -0,0 +1 @@ +Hello from file4.in1 diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/none.gyp b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/none.gyp new file mode 100644 index 000000000..664cbd9cb --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/none.gyp @@ -0,0 +1,49 @@ +# Copyright (c) 2009 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': 'files', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'file1.in0', + 'file2.in0', + 'file3.in1', + 'file4.in1', + ], + 'rules': [ + { + 'rule_name': 'copy_file_0', + 'extension': 'in0', + 'inputs': [ + '../copy-file.py', + ], + 'outputs': [ + 'rules-out/<(RULE_INPUT_ROOT).out', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 0, + }, + { + 'rule_name': 'copy_file_1', + 'extension': 'in1', + 'inputs': [ + '../copy-file.py', + ], + 'outputs': [ + 'rules-out/<(RULE_INPUT_ROOT).out', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/rules-out/README.txt b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/rules-out/README.txt new file mode 100644 index 000000000..1b052c9a2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/rules/subdir2/rules-out/README.txt @@ -0,0 +1,4 @@ +A place-holder for this Xcode build output directory, so that the
+test script can verify that .xcodeproj files are not created in
+their normal location by making the src/ read-only, and then
+selectively making this build directory writable.
diff --git a/Source/ThirdParty/gyp/test/generator-output/src/inc.h b/Source/ThirdParty/gyp/test/generator-output/src/inc.h new file mode 100644 index 000000000..57aa1a5a7 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/inc.h @@ -0,0 +1 @@ +#define INC_STRING "inc.h" diff --git a/Source/ThirdParty/gyp/test/generator-output/src/inc1/include1.h b/Source/ThirdParty/gyp/test/generator-output/src/inc1/include1.h new file mode 100644 index 000000000..1d59065fc --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/inc1/include1.h @@ -0,0 +1 @@ +#define INCLUDE1_STRING "inc1/include1.h" diff --git a/Source/ThirdParty/gyp/test/generator-output/src/prog1.c b/Source/ThirdParty/gyp/test/generator-output/src/prog1.c new file mode 100644 index 000000000..656f81d5f --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/prog1.c @@ -0,0 +1,18 @@ +#include <stdio.h> + +#include "inc.h" +#include "include1.h" +#include "include2.h" +#include "include3.h" +#include "deeper.h" + +int main(int argc, char *argv[]) +{ + printf("Hello from prog1.c\n"); + printf("Hello from %s\n", INC_STRING); + printf("Hello from %s\n", INCLUDE1_STRING); + printf("Hello from %s\n", INCLUDE2_STRING); + printf("Hello from %s\n", INCLUDE3_STRING); + printf("Hello from %s\n", DEEPER_STRING); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/generator-output/src/prog1.gyp b/Source/ThirdParty/gyp/test/generator-output/src/prog1.gyp new file mode 100644 index 000000000..d50e6fb0a --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/prog1.gyp @@ -0,0 +1,28 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + 'symroot.gypi', + ], + 'targets': [ + { + 'target_name': 'prog1', + 'type': 'executable', + 'dependencies': [ + 'subdir2/prog2.gyp:prog2', + ], + 'include_dirs': [ + '.', + 'inc1', + 'subdir2/inc2', + 'subdir3/inc3', + 'subdir2/deeper', + ], + 'sources': [ + 'prog1.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.c b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.c new file mode 100644 index 000000000..56c49d1f7 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from deeper.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.gyp b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.gyp new file mode 100644 index 000000000..864877087 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../../symroot.gypi', + ], + 'targets': [ + { + 'target_name': 'deeper', + 'type': 'executable', + 'sources': [ + 'deeper.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.h b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.h new file mode 100644 index 000000000..f6484a0fe --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/deeper/deeper.h @@ -0,0 +1 @@ +#define DEEPER_STRING "subdir2/deeper/deeper.h" diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir2/inc2/include2.h b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/inc2/include2.h new file mode 100644 index 000000000..1ccfa5dea --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/inc2/include2.h @@ -0,0 +1 @@ +#define INCLUDE2_STRING "inc2/include2.h" diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir2/prog2.c b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/prog2.c new file mode 100644 index 000000000..38d6c84d1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/prog2.c @@ -0,0 +1,18 @@ +#include <stdio.h> + +#include "inc.h" +#include "include1.h" +#include "include2.h" +#include "include3.h" +#include "deeper.h" + +int main(int argc, char *argv[]) +{ + printf("Hello from prog2.c\n"); + printf("Hello from %s\n", INC_STRING); + printf("Hello from %s\n", INCLUDE1_STRING); + printf("Hello from %s\n", INCLUDE2_STRING); + printf("Hello from %s\n", INCLUDE3_STRING); + printf("Hello from %s\n", DEEPER_STRING); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir2/prog2.gyp b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/prog2.gyp new file mode 100644 index 000000000..7176ed8be --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir2/prog2.gyp @@ -0,0 +1,28 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../symroot.gypi', + ], + 'targets': [ + { + 'target_name': 'prog2', + 'type': 'executable', + 'include_dirs': [ + '..', + '../inc1', + 'inc2', + '../subdir3/inc3', + 'deeper', + ], + 'dependencies': [ + '../subdir3/prog3.gyp:prog3', + ], + 'sources': [ + 'prog2.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir3/inc3/include3.h b/Source/ThirdParty/gyp/test/generator-output/src/subdir3/inc3/include3.h new file mode 100644 index 000000000..bf53bf1f0 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir3/inc3/include3.h @@ -0,0 +1 @@ +#define INCLUDE3_STRING "inc3/include3.h" diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir3/prog3.c b/Source/ThirdParty/gyp/test/generator-output/src/subdir3/prog3.c new file mode 100644 index 000000000..7848b45ab --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir3/prog3.c @@ -0,0 +1,18 @@ +#include <stdio.h> + +#include "inc.h" +#include "include1.h" +#include "include2.h" +#include "include3.h" +#include "deeper.h" + +int main(int argc, char *argv[]) +{ + printf("Hello from prog3.c\n"); + printf("Hello from %s\n", INC_STRING); + printf("Hello from %s\n", INCLUDE1_STRING); + printf("Hello from %s\n", INCLUDE2_STRING); + printf("Hello from %s\n", INCLUDE3_STRING); + printf("Hello from %s\n", DEEPER_STRING); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/generator-output/src/subdir3/prog3.gyp b/Source/ThirdParty/gyp/test/generator-output/src/subdir3/prog3.gyp new file mode 100644 index 000000000..46c5e000a --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/subdir3/prog3.gyp @@ -0,0 +1,25 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../symroot.gypi', + ], + 'targets': [ + { + 'target_name': 'prog3', + 'type': 'executable', + 'include_dirs': [ + '..', + '../inc1', + '../subdir2/inc2', + 'inc3', + '../subdir2/deeper', + ], + 'sources': [ + 'prog3.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/generator-output/src/symroot.gypi b/Source/ThirdParty/gyp/test/generator-output/src/symroot.gypi new file mode 100644 index 000000000..519916427 --- /dev/null +++ b/Source/ThirdParty/gyp/test/generator-output/src/symroot.gypi @@ -0,0 +1,16 @@ +# Copyright (c) 2009 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. + +{ + 'variables': { + 'set_symroot%': 0, + }, + 'conditions': [ + ['set_symroot == 1', { + 'xcode_settings': { + 'SYMROOT': '<(DEPTH)/build', + }, + }], + ], +} diff --git a/Source/ThirdParty/gyp/test/hello/gyptest-all.py b/Source/ThirdParty/gyp/test/hello/gyptest-all.py new file mode 100644 index 000000000..9ecff556e --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/gyptest-all.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 an explicit build target of 'all'. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('hello.gyp') + +test.build('hello.gyp', test.ALL) + +test.run_built_executable('hello', stdout="Hello, world!\n") + +test.up_to_date('hello.gyp', test.ALL) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/hello/gyptest-default.py b/Source/ThirdParty/gyp/test/hello/gyptest-default.py new file mode 100644 index 000000000..76fffb3ea --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/gyptest-default.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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() + +test.run_gyp('hello.gyp') + +test.build('hello.gyp') + +test.run_built_executable('hello', stdout="Hello, world!\n") + +test.up_to_date('hello.gyp', test.DEFAULT) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/hello/gyptest-disable-regyp.py b/Source/ThirdParty/gyp/test/hello/gyptest-disable-regyp.py new file mode 100644 index 000000000..1e4b30667 --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/gyptest-disable-regyp.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 Makefiles don't get rebuilt when a source gyp file changes and +the disable_regeneration generator flag is set. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('hello.gyp', '-Gauto_regeneration=0') + +test.build('hello.gyp', test.ALL) + +test.run_built_executable('hello', stdout="Hello, world!\n") + +# Sleep so that the changed gyp file will have a newer timestamp than the +# previously generated build files. +test.sleep() +test.write('hello.gyp', test.read('hello2.gyp')) + +test.build('hello.gyp', test.ALL) + +# Should still be the old executable, as regeneration was disabled. +test.run_built_executable('hello', stdout="Hello, world!\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/hello/gyptest-regyp.py b/Source/ThirdParty/gyp/test/hello/gyptest-regyp.py new file mode 100644 index 000000000..827c7235c --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/gyptest-regyp.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 Makefiles get rebuilt when a source gyp file changes. +""" + +import TestGyp + +# Regenerating build files when a gyp file changes is currently only supported +# by the make generator. +test = TestGyp.TestGyp(formats=['make']) + +test.run_gyp('hello.gyp') + +test.build('hello.gyp', test.ALL) + +test.run_built_executable('hello', stdout="Hello, world!\n") + +# Sleep so that the changed gyp file will have a newer timestamp than the +# previously generated build files. +test.sleep() +test.write('hello.gyp', test.read('hello2.gyp')) + +test.build('hello.gyp', test.ALL) + +test.run_built_executable('hello', stdout="Hello, two!\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/hello/gyptest-target.py b/Source/ThirdParty/gyp/test/hello/gyptest-target.py new file mode 100755 index 000000000..2f0a2a33d --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/gyptest-target.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 an explicit build target of 'hello'. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('hello.gyp') + +test.build('hello.gyp', 'hello') + +test.run_built_executable('hello', stdout="Hello, world!\n") + +test.up_to_date('hello.gyp', 'hello') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/hello/hello.c b/Source/ThirdParty/gyp/test/hello/hello.c new file mode 100644 index 000000000..8dbecc049 --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/hello.c @@ -0,0 +1,11 @@ +/* Copyright (c) 2009 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> + +int main(int argc, char *argv[]) +{ + printf("Hello, world!\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/hello/hello.gyp b/Source/ThirdParty/gyp/test/hello/hello.gyp new file mode 100644 index 000000000..1974d51cc --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/hello.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'hello', + 'type': 'executable', + 'sources': [ + 'hello.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/hello/hello2.c b/Source/ThirdParty/gyp/test/hello/hello2.c new file mode 100644 index 000000000..19ef3fbd5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/hello2.c @@ -0,0 +1,11 @@ +/* Copyright (c) 2009 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> + +int main(int argc, char *argv[]) +{ + printf("Hello, two!\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/hello/hello2.gyp b/Source/ThirdParty/gyp/test/hello/hello2.gyp new file mode 100644 index 000000000..25b08caf3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/hello/hello2.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'hello', + 'type': 'executable', + 'sources': [ + 'hello2.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/home_dot_gyp/gyptest-home-includes-regyp.py b/Source/ThirdParty/gyp/test/home_dot_gyp/gyptest-home-includes-regyp.py new file mode 100644 index 000000000..a2b9f3018 --- /dev/null +++ b/Source/ThirdParty/gyp/test/home_dot_gyp/gyptest-home-includes-regyp.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 inclusion of $HOME/.gyp/includes.gypi works properly with relocation +and with regeneration. +""" + +import os +import TestGyp + +# Regenerating build files when a gyp file changes is currently only supported +# by the make generator. +test = TestGyp.TestGyp(formats=['make']) + +os.environ['HOME'] = os.path.abspath('home') + +test.run_gyp('all.gyp', chdir='src') + +# After relocating, we should still be able to build (build file shouldn't +# contain relative reference to ~/.gyp/includes.gypi) +test.relocate('src', 'relocate/src') + +test.build('all.gyp', test.ALL, chdir='relocate/src') + +test.run_built_executable('printfoo', + chdir='relocate/src', + stdout="FOO is fromhome\n"); + +# Building should notice any changes to ~/.gyp/includes.gypi and regyp. +test.sleep() + +test.write('home/.gyp/include.gypi', test.read('home2/.gyp/include.gypi')) + +test.build('all.gyp', test.ALL, chdir='relocate/src') + +test.run_built_executable('printfoo', + chdir='relocate/src', + stdout="FOO is fromhome2\n"); + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/home_dot_gyp/gyptest-home-includes.py b/Source/ThirdParty/gyp/test/home_dot_gyp/gyptest-home-includes.py new file mode 100644 index 000000000..6a0e9651f --- /dev/null +++ b/Source/ThirdParty/gyp/test/home_dot_gyp/gyptest-home-includes.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 inclusion of $HOME/.gyp/includes.gypi works. +""" + +import os +import TestGyp + +test = TestGyp.TestGyp() + +os.environ['HOME'] = os.path.abspath('home') + +test.run_gyp('all.gyp', chdir='src') + +# After relocating, we should still be able to build (build file shouldn't +# contain relative reference to ~/.gyp/includes.gypi) +test.relocate('src', 'relocate/src') + +test.build('all.gyp', test.ALL, chdir='relocate/src') + +test.run_built_executable('printfoo', + chdir='relocate/src', + stdout="FOO is fromhome\n"); + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/home_dot_gyp/home/.gyp/include.gypi b/Source/ThirdParty/gyp/test/home_dot_gyp/home/.gyp/include.gypi new file mode 100644 index 000000000..fcfb39bef --- /dev/null +++ b/Source/ThirdParty/gyp/test/home_dot_gyp/home/.gyp/include.gypi @@ -0,0 +1,5 @@ +{ + 'variables': { + 'foo': '"fromhome"', + }, +} diff --git a/Source/ThirdParty/gyp/test/home_dot_gyp/home2/.gyp/include.gypi b/Source/ThirdParty/gyp/test/home_dot_gyp/home2/.gyp/include.gypi new file mode 100644 index 000000000..f0d84b31a --- /dev/null +++ b/Source/ThirdParty/gyp/test/home_dot_gyp/home2/.gyp/include.gypi @@ -0,0 +1,5 @@ +{ + 'variables': { + 'foo': '"fromhome2"', + }, +} diff --git a/Source/ThirdParty/gyp/test/home_dot_gyp/src/all.gyp b/Source/ThirdParty/gyp/test/home_dot_gyp/src/all.gyp new file mode 100644 index 000000000..14b6aea28 --- /dev/null +++ b/Source/ThirdParty/gyp/test/home_dot_gyp/src/all.gyp @@ -0,0 +1,22 @@ +# Copyright (c) 2009 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. + +{ + 'variables': { + 'foo%': '"fromdefault"', + }, + 'targets': [ + { + 'target_name': 'printfoo', + 'type': 'executable', + 'sources': [ + 'printfoo.c', + ], + 'defines': [ + 'FOO=<(foo)', + ], + }, + ], +} + diff --git a/Source/ThirdParty/gyp/test/home_dot_gyp/src/printfoo.c b/Source/ThirdParty/gyp/test/home_dot_gyp/src/printfoo.c new file mode 100644 index 000000000..92d2cbacb --- /dev/null +++ b/Source/ThirdParty/gyp/test/home_dot_gyp/src/printfoo.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("FOO is %s\n", FOO); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/include_dirs/gyptest-all.py b/Source/ThirdParty/gyp/test/include_dirs/gyptest-all.py new file mode 100644 index 000000000..94a1338d4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/gyptest-all.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 use of include_dirs when using an explicit build target of 'all'. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +if test.format == 'scons': + test.skip_test('TODO: http://code.google.com/p/gyp/issues/detail?id=176\n') + +test.run_gyp('includes.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('includes.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from includes.c +Hello from inc.h +Hello from include1.h +Hello from subdir/inc2/include2.h +Hello from shadow2/shadow.h +""" +test.run_built_executable('includes', stdout=expect, chdir='relocate/src') + +if test.format == 'xcode': + chdir='relocate/src/subdir' +else: + chdir='relocate/src' + +expect = """\ +Hello from subdir/subdir_includes.c +Hello from subdir/inc.h +Hello from include1.h +Hello from subdir/inc2/include2.h +""" +test.run_built_executable('subdir_includes', stdout=expect, chdir=chdir) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/include_dirs/gyptest-default.py b/Source/ThirdParty/gyp/test/include_dirs/gyptest-default.py new file mode 100644 index 000000000..42acd1f96 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/gyptest-default.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 use of include_dirs when using the default build target. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +if test.format == 'scons': + test.skip_test('TODO: http://code.google.com/p/gyp/issues/detail?id=176\n') + +test.run_gyp('includes.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('includes.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from includes.c +Hello from inc.h +Hello from include1.h +Hello from subdir/inc2/include2.h +Hello from shadow2/shadow.h +""" +test.run_built_executable('includes', stdout=expect, chdir='relocate/src') + +if test.format == 'xcode': + chdir='relocate/src/subdir' +else: + chdir='relocate/src' + +expect = """\ +Hello from subdir/subdir_includes.c +Hello from subdir/inc.h +Hello from include1.h +Hello from subdir/inc2/include2.h +""" +test.run_built_executable('subdir_includes', stdout=expect, chdir=chdir) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/inc.h b/Source/ThirdParty/gyp/test/include_dirs/src/inc.h new file mode 100644 index 000000000..0398d6915 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/inc.h @@ -0,0 +1 @@ +#define INC_STRING "inc.h" diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/inc1/include1.h b/Source/ThirdParty/gyp/test/include_dirs/src/inc1/include1.h new file mode 100644 index 000000000..43356b5f4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/inc1/include1.h @@ -0,0 +1 @@ +#define INCLUDE1_STRING "include1.h" diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/includes.c b/Source/ThirdParty/gyp/test/include_dirs/src/includes.c new file mode 100644 index 000000000..e2afbd3ed --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/includes.c @@ -0,0 +1,19 @@ +#include <stdio.h> + +#include "inc.h" +#include "include1.h" +#include "include2.h" +#include "shadow.h" + +int main(int argc, char *argv[]) +{ + printf("Hello from includes.c\n"); + printf("Hello from %s\n", INC_STRING); + printf("Hello from %s\n", INCLUDE1_STRING); + printf("Hello from %s\n", INCLUDE2_STRING); + /* Test that include_dirs happen first: The gyp file has a -Ishadow1 + cflag and an include_dir of shadow2. Including shadow.h should get + the shadow.h from the include_dir. */ + printf("Hello from %s\n", SHADOW_STRING); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/includes.gyp b/Source/ThirdParty/gyp/test/include_dirs/src/includes.gyp new file mode 100644 index 000000000..359269020 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/includes.gyp @@ -0,0 +1,27 @@ +# Copyright (c) 2009 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': 'includes', + 'type': 'executable', + 'dependencies': [ + 'subdir/subdir_includes.gyp:subdir_includes', + ], + 'cflags': [ + '-Ishadow1', + ], + 'include_dirs': [ + '.', + 'inc1', + 'shadow2', + 'subdir/inc2', + ], + 'sources': [ + 'includes.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/shadow1/shadow.h b/Source/ThirdParty/gyp/test/include_dirs/src/shadow1/shadow.h new file mode 100644 index 000000000..80f6de20b --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/shadow1/shadow.h @@ -0,0 +1 @@ +#define SHADOW_STRING "shadow1/shadow.h" diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/shadow2/shadow.h b/Source/ThirdParty/gyp/test/include_dirs/src/shadow2/shadow.h new file mode 100644 index 000000000..fad5ccd08 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/shadow2/shadow.h @@ -0,0 +1 @@ +#define SHADOW_STRING "shadow2/shadow.h" diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/subdir/inc.h b/Source/ThirdParty/gyp/test/include_dirs/src/subdir/inc.h new file mode 100644 index 000000000..0a68d7b36 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/subdir/inc.h @@ -0,0 +1 @@ +#define INC_STRING "subdir/inc.h" diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/subdir/inc2/include2.h b/Source/ThirdParty/gyp/test/include_dirs/src/subdir/inc2/include2.h new file mode 100644 index 000000000..721577eff --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/subdir/inc2/include2.h @@ -0,0 +1 @@ +#define INCLUDE2_STRING "subdir/inc2/include2.h" diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/subdir/subdir_includes.c b/Source/ThirdParty/gyp/test/include_dirs/src/subdir/subdir_includes.c new file mode 100644 index 000000000..727f68220 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/subdir/subdir_includes.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +#include "inc.h" +#include "include1.h" +#include "include2.h" + +int main(int argc, char *argv[]) +{ + printf("Hello from subdir/subdir_includes.c\n"); + printf("Hello from %s\n", INC_STRING); + printf("Hello from %s\n", INCLUDE1_STRING); + printf("Hello from %s\n", INCLUDE2_STRING); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/include_dirs/src/subdir/subdir_includes.gyp b/Source/ThirdParty/gyp/test/include_dirs/src/subdir/subdir_includes.gyp new file mode 100644 index 000000000..257d052c3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/include_dirs/src/subdir/subdir_includes.gyp @@ -0,0 +1,20 @@ +# Copyright (c) 2009 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': 'subdir_includes', + 'type': 'executable', + 'include_dirs': [ + '.', + '../inc1', + 'inc2', + ], + 'sources': [ + 'subdir_includes.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/lib/README.txt b/Source/ThirdParty/gyp/test/lib/README.txt new file mode 100644 index 000000000..b3d724574 --- /dev/null +++ b/Source/ThirdParty/gyp/test/lib/README.txt @@ -0,0 +1,17 @@ +Supporting modules for GYP testing. + + TestCmd.py + TestCommon.py + + Modules for generic testing of command-line utilities, + specifically including the ability to copy a test configuration + to temporary directories (with default cleanup on exit) as part + of running test scripts that invoke commands, compare actual + against expected output, etc. + + Our copies of these come from the SCons project, + http://www.scons.org/. + + TestGyp.py + + Modules for GYP-specific tests, of course. diff --git a/Source/ThirdParty/gyp/test/lib/TestCmd.py b/Source/ThirdParty/gyp/test/lib/TestCmd.py new file mode 100644 index 000000000..029c1d05f --- /dev/null +++ b/Source/ThirdParty/gyp/test/lib/TestCmd.py @@ -0,0 +1,1591 @@ +""" +TestCmd.py: a testing framework for commands and scripts. + +The TestCmd module provides a framework for portable automated testing +of executable commands and scripts (in any language, not just Python), +especially commands and scripts that require file system interaction. + +In addition to running tests and evaluating conditions, the TestCmd +module manages and cleans up one or more temporary workspace +directories, and provides methods for creating files and directories in +those workspace directories from in-line data, here-documents), allowing +tests to be completely self-contained. + +A TestCmd environment object is created via the usual invocation: + + import TestCmd + test = TestCmd.TestCmd() + +There are a bunch of keyword arguments available at instantiation: + + test = TestCmd.TestCmd(description = 'string', + program = 'program_or_script_to_test', + interpreter = 'script_interpreter', + workdir = 'prefix', + subdir = 'subdir', + verbose = Boolean, + match = default_match_function, + diff = default_diff_function, + combine = Boolean) + +There are a bunch of methods that let you do different things: + + test.verbose_set(1) + + test.description_set('string') + + test.program_set('program_or_script_to_test') + + test.interpreter_set('script_interpreter') + test.interpreter_set(['script_interpreter', 'arg']) + + test.workdir_set('prefix') + test.workdir_set('') + + test.workpath('file') + test.workpath('subdir', 'file') + + test.subdir('subdir', ...) + + test.rmdir('subdir', ...) + + test.write('file', "contents\n") + test.write(['subdir', 'file'], "contents\n") + + test.read('file') + test.read(['subdir', 'file']) + test.read('file', mode) + test.read(['subdir', 'file'], mode) + + test.writable('dir', 1) + test.writable('dir', None) + + test.preserve(condition, ...) + + test.cleanup(condition) + + test.command_args(program = 'program_or_script_to_run', + interpreter = 'script_interpreter', + arguments = 'arguments to pass to program') + + test.run(program = 'program_or_script_to_run', + interpreter = 'script_interpreter', + arguments = 'arguments to pass to program', + chdir = 'directory_to_chdir_to', + stdin = 'input to feed to the program\n') + universal_newlines = True) + + p = test.start(program = 'program_or_script_to_run', + interpreter = 'script_interpreter', + arguments = 'arguments to pass to program', + universal_newlines = None) + + test.finish(self, p) + + test.pass_test() + test.pass_test(condition) + test.pass_test(condition, function) + + test.fail_test() + test.fail_test(condition) + test.fail_test(condition, function) + test.fail_test(condition, function, skip) + + test.no_result() + test.no_result(condition) + test.no_result(condition, function) + test.no_result(condition, function, skip) + + test.stdout() + test.stdout(run) + + test.stderr() + test.stderr(run) + + test.symlink(target, link) + + test.banner(string) + test.banner(string, width) + + test.diff(actual, expected) + + test.match(actual, expected) + + test.match_exact("actual 1\nactual 2\n", "expected 1\nexpected 2\n") + test.match_exact(["actual 1\n", "actual 2\n"], + ["expected 1\n", "expected 2\n"]) + + test.match_re("actual 1\nactual 2\n", regex_string) + test.match_re(["actual 1\n", "actual 2\n"], list_of_regexes) + + test.match_re_dotall("actual 1\nactual 2\n", regex_string) + test.match_re_dotall(["actual 1\n", "actual 2\n"], list_of_regexes) + + test.tempdir() + test.tempdir('temporary-directory') + + test.sleep() + test.sleep(seconds) + + test.where_is('foo') + test.where_is('foo', 'PATH1:PATH2') + test.where_is('foo', 'PATH1;PATH2', '.suffix3;.suffix4') + + test.unlink('file') + test.unlink('subdir', 'file') + +The TestCmd module provides pass_test(), fail_test(), and no_result() +unbound functions that report test results for use with the Aegis change +management system. These methods terminate the test immediately, +reporting PASSED, FAILED, or NO RESULT respectively, and exiting with +status 0 (success), 1 or 2 respectively. This allows for a distinction +between an actual failed test and a test that could not be properly +evaluated because of an external condition (such as a full file system +or incorrect permissions). + + import TestCmd + + TestCmd.pass_test() + TestCmd.pass_test(condition) + TestCmd.pass_test(condition, function) + + TestCmd.fail_test() + TestCmd.fail_test(condition) + TestCmd.fail_test(condition, function) + TestCmd.fail_test(condition, function, skip) + + TestCmd.no_result() + TestCmd.no_result(condition) + TestCmd.no_result(condition, function) + TestCmd.no_result(condition, function, skip) + +The TestCmd module also provides unbound functions that handle matching +in the same way as the match_*() methods described above. + + import TestCmd + + test = TestCmd.TestCmd(match = TestCmd.match_exact) + + test = TestCmd.TestCmd(match = TestCmd.match_re) + + test = TestCmd.TestCmd(match = TestCmd.match_re_dotall) + +The TestCmd module provides unbound functions that can be used for the +"diff" argument to TestCmd.TestCmd instantiation: + + import TestCmd + + test = TestCmd.TestCmd(match = TestCmd.match_re, + diff = TestCmd.diff_re) + + test = TestCmd.TestCmd(diff = TestCmd.simple_diff) + +The "diff" argument can also be used with standard difflib functions: + + import difflib + + test = TestCmd.TestCmd(diff = difflib.context_diff) + + test = TestCmd.TestCmd(diff = difflib.unified_diff) + +Lastly, the where_is() method also exists in an unbound function +version. + + import TestCmd + + TestCmd.where_is('foo') + TestCmd.where_is('foo', 'PATH1:PATH2') + TestCmd.where_is('foo', 'PATH1;PATH2', '.suffix3;.suffix4') +""" + +# Copyright 2000-2010 Steven Knight +# This module is free software, and you may redistribute it and/or modify +# it under the same terms as Python itself, so long as this copyright message +# and disclaimer are retained in their original form. +# +# IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +# SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF +# THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, +# AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, +# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +__author__ = "Steven Knight <knight at baldmt dot com>" +__revision__ = "TestCmd.py 0.37.D001 2010/01/11 16:55:50 knight" +__version__ = "0.37" + +import errno +import os +import os.path +import re +import shutil +import stat +import string +import sys +import tempfile +import time +import traceback +import types +import UserList + +__all__ = [ + 'diff_re', + 'fail_test', + 'no_result', + 'pass_test', + 'match_exact', + 'match_re', + 'match_re_dotall', + 'python_executable', + 'TestCmd' +] + +try: + import difflib +except ImportError: + __all__.append('simple_diff') + +def is_List(e): + return type(e) is types.ListType \ + or isinstance(e, UserList.UserList) + +try: + from UserString import UserString +except ImportError: + class UserString: + pass + +if hasattr(types, 'UnicodeType'): + def is_String(e): + return type(e) is types.StringType \ + or type(e) is types.UnicodeType \ + or isinstance(e, UserString) +else: + def is_String(e): + return type(e) is types.StringType or isinstance(e, UserString) + +tempfile.template = 'testcmd.' +if os.name in ('posix', 'nt'): + tempfile.template = 'testcmd.' + str(os.getpid()) + '.' +else: + tempfile.template = 'testcmd.' + +re_space = re.compile('\s') + +_Cleanup = [] + +_chain_to_exitfunc = None + +def _clean(): + global _Cleanup + cleanlist = filter(None, _Cleanup) + del _Cleanup[:] + cleanlist.reverse() + for test in cleanlist: + test.cleanup() + if _chain_to_exitfunc: + _chain_to_exitfunc() + +try: + import atexit +except ImportError: + # TODO(1.5): atexit requires python 2.0, so chain sys.exitfunc + try: + _chain_to_exitfunc = sys.exitfunc + except AttributeError: + pass + sys.exitfunc = _clean +else: + atexit.register(_clean) + +try: + zip +except NameError: + def zip(*lists): + result = [] + for i in xrange(min(map(len, lists))): + result.append(tuple(map(lambda l, i=i: l[i], lists))) + return result + +class Collector: + def __init__(self, top): + self.entries = [top] + def __call__(self, arg, dirname, names): + pathjoin = lambda n, d=dirname: os.path.join(d, n) + self.entries.extend(map(pathjoin, names)) + +def _caller(tblist, skip): + string = "" + arr = [] + for file, line, name, text in tblist: + if file[-10:] == "TestCmd.py": + break + arr = [(file, line, name, text)] + arr + atfrom = "at" + for file, line, name, text in arr[skip:]: + if name in ("?", "<module>"): + name = "" + else: + name = " (" + name + ")" + string = string + ("%s line %d of %s%s\n" % (atfrom, line, file, name)) + atfrom = "\tfrom" + return string + +def fail_test(self = None, condition = 1, function = None, skip = 0): + """Cause the test to fail. + + By default, the fail_test() method reports that the test FAILED + and exits with a status of 1. If a condition argument is supplied, + the test fails only if the condition is true. + """ + if not condition: + return + if not function is None: + function() + of = "" + desc = "" + sep = " " + if not self is None: + if self.program: + of = " of " + self.program + sep = "\n\t" + if self.description: + desc = " [" + self.description + "]" + sep = "\n\t" + + at = _caller(traceback.extract_stack(), skip) + sys.stderr.write("FAILED test" + of + desc + sep + at) + + sys.exit(1) + +def no_result(self = None, condition = 1, function = None, skip = 0): + """Causes a test to exit with no valid result. + + By default, the no_result() method reports NO RESULT for the test + and exits with a status of 2. If a condition argument is supplied, + the test fails only if the condition is true. + """ + if not condition: + return + if not function is None: + function() + of = "" + desc = "" + sep = " " + if not self is None: + if self.program: + of = " of " + self.program + sep = "\n\t" + if self.description: + desc = " [" + self.description + "]" + sep = "\n\t" + + at = _caller(traceback.extract_stack(), skip) + sys.stderr.write("NO RESULT for test" + of + desc + sep + at) + + sys.exit(2) + +def pass_test(self = None, condition = 1, function = None): + """Causes a test to pass. + + By default, the pass_test() method reports PASSED for the test + and exits with a status of 0. If a condition argument is supplied, + the test passes only if the condition is true. + """ + if not condition: + return + if not function is None: + function() + sys.stderr.write("PASSED\n") + sys.exit(0) + +def match_exact(lines = None, matches = None): + """ + """ + if not is_List(lines): + lines = string.split(lines, "\n") + if not is_List(matches): + matches = string.split(matches, "\n") + if len(lines) != len(matches): + return + for i in range(len(lines)): + if lines[i] != matches[i]: + return + return 1 + +def match_re(lines = None, res = None): + """ + """ + if not is_List(lines): + lines = string.split(lines, "\n") + if not is_List(res): + res = string.split(res, "\n") + if len(lines) != len(res): + return + for i in range(len(lines)): + s = "^" + res[i] + "$" + try: + expr = re.compile(s) + except re.error, e: + msg = "Regular expression error in %s: %s" + raise re.error, msg % (repr(s), e[0]) + if not expr.search(lines[i]): + return + return 1 + +def match_re_dotall(lines = None, res = None): + """ + """ + if not type(lines) is type(""): + lines = string.join(lines, "\n") + if not type(res) is type(""): + res = string.join(res, "\n") + s = "^" + res + "$" + try: + expr = re.compile(s, re.DOTALL) + except re.error, e: + msg = "Regular expression error in %s: %s" + raise re.error, msg % (repr(s), e[0]) + if expr.match(lines): + return 1 + +try: + import difflib +except ImportError: + pass +else: + def simple_diff(a, b, fromfile='', tofile='', + fromfiledate='', tofiledate='', n=3, lineterm='\n'): + """ + A function with the same calling signature as difflib.context_diff + (diff -c) and difflib.unified_diff (diff -u) but which prints + output like the simple, unadorned 'diff" command. + """ + sm = difflib.SequenceMatcher(None, a, b) + def comma(x1, x2): + return x1+1 == x2 and str(x2) or '%s,%s' % (x1+1, x2) + result = [] + for op, a1, a2, b1, b2 in sm.get_opcodes(): + if op == 'delete': + result.append("%sd%d" % (comma(a1, a2), b1)) + result.extend(map(lambda l: '< ' + l, a[a1:a2])) + elif op == 'insert': + result.append("%da%s" % (a1, comma(b1, b2))) + result.extend(map(lambda l: '> ' + l, b[b1:b2])) + elif op == 'replace': + result.append("%sc%s" % (comma(a1, a2), comma(b1, b2))) + result.extend(map(lambda l: '< ' + l, a[a1:a2])) + result.append('---') + result.extend(map(lambda l: '> ' + l, b[b1:b2])) + return result + +def diff_re(a, b, fromfile='', tofile='', + fromfiledate='', tofiledate='', n=3, lineterm='\n'): + """ + A simple "diff" of two sets of lines when the expected lines + are regular expressions. This is a really dumb thing that + just compares each line in turn, so it doesn't look for + chunks of matching lines and the like--but at least it lets + you know exactly which line first didn't compare correctl... + """ + result = [] + diff = len(a) - len(b) + if diff < 0: + a = a + ['']*(-diff) + elif diff > 0: + b = b + ['']*diff + i = 0 + for aline, bline in zip(a, b): + s = "^" + aline + "$" + try: + expr = re.compile(s) + except re.error, e: + msg = "Regular expression error in %s: %s" + raise re.error, msg % (repr(s), e[0]) + if not expr.search(bline): + result.append("%sc%s" % (i+1, i+1)) + result.append('< ' + repr(a[i])) + result.append('---') + result.append('> ' + repr(b[i])) + i = i+1 + return result + +if os.name == 'java': + + python_executable = os.path.join(sys.prefix, 'jython') + +else: + + python_executable = sys.executable + +if sys.platform == 'win32': + + default_sleep_seconds = 2 + + def where_is(file, path=None, pathext=None): + if path is None: + path = os.environ['PATH'] + if is_String(path): + path = string.split(path, os.pathsep) + if pathext is None: + pathext = os.environ['PATHEXT'] + if is_String(pathext): + pathext = string.split(pathext, os.pathsep) + for ext in pathext: + if string.lower(ext) == string.lower(file[-len(ext):]): + pathext = [''] + break + for dir in path: + f = os.path.join(dir, file) + for ext in pathext: + fext = f + ext + if os.path.isfile(fext): + return fext + return None + +else: + + def where_is(file, path=None, pathext=None): + if path is None: + path = os.environ['PATH'] + if is_String(path): + path = string.split(path, os.pathsep) + for dir in path: + f = os.path.join(dir, file) + if os.path.isfile(f): + try: + st = os.stat(f) + except OSError: + continue + if stat.S_IMODE(st[stat.ST_MODE]) & 0111: + return f + return None + + default_sleep_seconds = 1 + + + +try: + import subprocess +except ImportError: + # The subprocess module doesn't exist in this version of Python, + # so we're going to cobble up something that looks just enough + # like its API for our purposes below. + import new + + subprocess = new.module('subprocess') + + subprocess.PIPE = 'PIPE' + subprocess.STDOUT = 'STDOUT' + subprocess.mswindows = (sys.platform == 'win32') + + try: + import popen2 + popen2.Popen3 + except AttributeError: + class Popen3: + universal_newlines = 1 + def __init__(self, command, **kw): + if sys.platform == 'win32' and command[0] == '"': + command = '"' + command + '"' + (stdin, stdout, stderr) = os.popen3(' ' + command) + self.stdin = stdin + self.stdout = stdout + self.stderr = stderr + def close_output(self): + self.stdout.close() + self.resultcode = self.stderr.close() + def wait(self): + resultcode = self.resultcode + if os.WIFEXITED(resultcode): + return os.WEXITSTATUS(resultcode) + elif os.WIFSIGNALED(resultcode): + return os.WTERMSIG(resultcode) + else: + return None + + else: + try: + popen2.Popen4 + except AttributeError: + # A cribbed Popen4 class, with some retrofitted code from + # the Python 1.5 Popen3 class methods to do certain things + # by hand. + class Popen4(popen2.Popen3): + childerr = None + + def __init__(self, cmd, bufsize=-1): + p2cread, p2cwrite = os.pipe() + c2pread, c2pwrite = os.pipe() + self.pid = os.fork() + if self.pid == 0: + # Child + os.dup2(p2cread, 0) + os.dup2(c2pwrite, 1) + os.dup2(c2pwrite, 2) + for i in range(3, popen2.MAXFD): + try: + os.close(i) + except: pass + try: + os.execvp(cmd[0], cmd) + finally: + os._exit(1) + # Shouldn't come here, I guess + os._exit(1) + os.close(p2cread) + self.tochild = os.fdopen(p2cwrite, 'w', bufsize) + os.close(c2pwrite) + self.fromchild = os.fdopen(c2pread, 'r', bufsize) + popen2._active.append(self) + + popen2.Popen4 = Popen4 + + class Popen3(popen2.Popen3, popen2.Popen4): + universal_newlines = 1 + def __init__(self, command, **kw): + if kw.get('stderr') == 'STDOUT': + apply(popen2.Popen4.__init__, (self, command, 1)) + else: + apply(popen2.Popen3.__init__, (self, command, 1)) + self.stdin = self.tochild + self.stdout = self.fromchild + self.stderr = self.childerr + def wait(self, *args, **kw): + resultcode = apply(popen2.Popen3.wait, (self,)+args, kw) + if os.WIFEXITED(resultcode): + return os.WEXITSTATUS(resultcode) + elif os.WIFSIGNALED(resultcode): + return os.WTERMSIG(resultcode) + else: + return None + + subprocess.Popen = Popen3 + + + +# From Josiah Carlson, +# ASPN : Python Cookbook : Module to allow Asynchronous subprocess use on Windows and Posix platforms +# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554 + +PIPE = subprocess.PIPE + +if subprocess.mswindows: + from win32file import ReadFile, WriteFile + from win32pipe import PeekNamedPipe + import msvcrt +else: + import select + import fcntl + + try: fcntl.F_GETFL + except AttributeError: fcntl.F_GETFL = 3 + + try: fcntl.F_SETFL + except AttributeError: fcntl.F_SETFL = 4 + +class Popen(subprocess.Popen): + def recv(self, maxsize=None): + return self._recv('stdout', maxsize) + + def recv_err(self, maxsize=None): + return self._recv('stderr', maxsize) + + def send_recv(self, input='', maxsize=None): + return self.send(input), self.recv(maxsize), self.recv_err(maxsize) + + def get_conn_maxsize(self, which, maxsize): + if maxsize is None: + maxsize = 1024 + elif maxsize < 1: + maxsize = 1 + return getattr(self, which), maxsize + + def _close(self, which): + getattr(self, which).close() + setattr(self, which, None) + + if subprocess.mswindows: + def send(self, input): + if not self.stdin: + return None + + try: + x = msvcrt.get_osfhandle(self.stdin.fileno()) + (errCode, written) = WriteFile(x, input) + except ValueError: + return self._close('stdin') + except (subprocess.pywintypes.error, Exception), why: + if why[0] in (109, errno.ESHUTDOWN): + return self._close('stdin') + raise + + return written + + def _recv(self, which, maxsize): + conn, maxsize = self.get_conn_maxsize(which, maxsize) + if conn is None: + return None + + try: + x = msvcrt.get_osfhandle(conn.fileno()) + (read, nAvail, nMessage) = PeekNamedPipe(x, 0) + if maxsize < nAvail: + nAvail = maxsize + if nAvail > 0: + (errCode, read) = ReadFile(x, nAvail, None) + except ValueError: + return self._close(which) + except (subprocess.pywintypes.error, Exception), why: + if why[0] in (109, errno.ESHUTDOWN): + return self._close(which) + raise + + #if self.universal_newlines: + # read = self._translate_newlines(read) + return read + + else: + def send(self, input): + if not self.stdin: + return None + + if not select.select([], [self.stdin], [], 0)[1]: + return 0 + + try: + written = os.write(self.stdin.fileno(), input) + except OSError, why: + if why[0] == errno.EPIPE: #broken pipe + return self._close('stdin') + raise + + return written + + def _recv(self, which, maxsize): + conn, maxsize = self.get_conn_maxsize(which, maxsize) + if conn is None: + return None + + try: + flags = fcntl.fcntl(conn, fcntl.F_GETFL) + except TypeError: + flags = None + else: + if not conn.closed: + fcntl.fcntl(conn, fcntl.F_SETFL, flags| os.O_NONBLOCK) + + try: + if not select.select([conn], [], [], 0)[0]: + return '' + + r = conn.read(maxsize) + if not r: + return self._close(which) + + #if self.universal_newlines: + # r = self._translate_newlines(r) + return r + finally: + if not conn.closed and not flags is None: + fcntl.fcntl(conn, fcntl.F_SETFL, flags) + +disconnect_message = "Other end disconnected!" + +def recv_some(p, t=.1, e=1, tr=5, stderr=0): + if tr < 1: + tr = 1 + x = time.time()+t + y = [] + r = '' + pr = p.recv + if stderr: + pr = p.recv_err + while time.time() < x or r: + r = pr() + if r is None: + if e: + raise Exception(disconnect_message) + else: + break + elif r: + y.append(r) + else: + time.sleep(max((x-time.time())/tr, 0)) + return ''.join(y) + +# TODO(3.0: rewrite to use memoryview() +def send_all(p, data): + while len(data): + sent = p.send(data) + if sent is None: + raise Exception(disconnect_message) + data = buffer(data, sent) + + + +try: + object +except NameError: + class object: + pass + + + +class TestCmd(object): + """Class TestCmd + """ + + def __init__(self, description = None, + program = None, + interpreter = None, + workdir = None, + subdir = None, + verbose = None, + match = None, + diff = None, + combine = 0, + universal_newlines = 1): + self._cwd = os.getcwd() + self.description_set(description) + self.program_set(program) + self.interpreter_set(interpreter) + if verbose is None: + try: + verbose = max( 0, int(os.environ.get('TESTCMD_VERBOSE', 0)) ) + except ValueError: + verbose = 0 + self.verbose_set(verbose) + self.combine = combine + self.universal_newlines = universal_newlines + if not match is None: + self.match_function = match + else: + self.match_function = match_re + if not diff is None: + self.diff_function = diff + else: + try: + difflib + except NameError: + pass + else: + self.diff_function = simple_diff + #self.diff_function = difflib.context_diff + #self.diff_function = difflib.unified_diff + self._dirlist = [] + self._preserve = {'pass_test': 0, 'fail_test': 0, 'no_result': 0} + if os.environ.has_key('PRESERVE') and not os.environ['PRESERVE'] is '': + self._preserve['pass_test'] = os.environ['PRESERVE'] + self._preserve['fail_test'] = os.environ['PRESERVE'] + self._preserve['no_result'] = os.environ['PRESERVE'] + else: + try: + self._preserve['pass_test'] = os.environ['PRESERVE_PASS'] + except KeyError: + pass + try: + self._preserve['fail_test'] = os.environ['PRESERVE_FAIL'] + except KeyError: + pass + try: + self._preserve['no_result'] = os.environ['PRESERVE_NO_RESULT'] + except KeyError: + pass + self._stdout = [] + self._stderr = [] + self.status = None + self.condition = 'no_result' + self.workdir_set(workdir) + self.subdir(subdir) + + def __del__(self): + self.cleanup() + + def __repr__(self): + return "%x" % id(self) + + banner_char = '=' + banner_width = 80 + + def banner(self, s, width=None): + if width is None: + width = self.banner_width + return s + self.banner_char * (width - len(s)) + + if os.name == 'posix': + + def escape(self, arg): + "escape shell special characters" + slash = '\\' + special = '"$' + + arg = string.replace(arg, slash, slash+slash) + for c in special: + arg = string.replace(arg, c, slash+c) + + if re_space.search(arg): + arg = '"' + arg + '"' + return arg + + else: + + # Windows does not allow special characters in file names + # anyway, so no need for an escape function, we will just quote + # the arg. + def escape(self, arg): + if re_space.search(arg): + arg = '"' + arg + '"' + return arg + + def canonicalize(self, path): + if is_List(path): + path = apply(os.path.join, tuple(path)) + if not os.path.isabs(path): + path = os.path.join(self.workdir, path) + return path + + def chmod(self, path, mode): + """Changes permissions on the specified file or directory + path name.""" + path = self.canonicalize(path) + os.chmod(path, mode) + + def cleanup(self, condition = None): + """Removes any temporary working directories for the specified + TestCmd environment. If the environment variable PRESERVE was + set when the TestCmd environment was created, temporary working + directories are not removed. If any of the environment variables + PRESERVE_PASS, PRESERVE_FAIL, or PRESERVE_NO_RESULT were set + when the TestCmd environment was created, then temporary working + directories are not removed if the test passed, failed, or had + no result, respectively. Temporary working directories are also + preserved for conditions specified via the preserve method. + + Typically, this method is not called directly, but is used when + the script exits to clean up temporary working directories as + appropriate for the exit status. + """ + if not self._dirlist: + return + os.chdir(self._cwd) + self.workdir = None + if condition is None: + condition = self.condition + if self._preserve[condition]: + for dir in self._dirlist: + print "Preserved directory", dir + else: + list = self._dirlist[:] + list.reverse() + for dir in list: + self.writable(dir, 1) + shutil.rmtree(dir, ignore_errors = 1) + self._dirlist = [] + + try: + global _Cleanup + _Cleanup.remove(self) + except (AttributeError, ValueError): + pass + + def command_args(self, program = None, + interpreter = None, + arguments = None): + if program: + if type(program) == type('') and not os.path.isabs(program): + program = os.path.join(self._cwd, program) + else: + program = self.program + if not interpreter: + interpreter = self.interpreter + if not type(program) in [type([]), type(())]: + program = [program] + cmd = list(program) + if interpreter: + if not type(interpreter) in [type([]), type(())]: + interpreter = [interpreter] + cmd = list(interpreter) + cmd + if arguments: + if type(arguments) == type(''): + arguments = string.split(arguments) + cmd.extend(arguments) + return cmd + + def description_set(self, description): + """Set the description of the functionality being tested. + """ + self.description = description + + try: + difflib + except NameError: + def diff(self, a, b, name, *args, **kw): + print self.banner('Expected %s' % name) + print a + print self.banner('Actual %s' % name) + print b + else: + def diff(self, a, b, name, *args, **kw): + print self.banner(name) + args = (a.splitlines(), b.splitlines()) + args + lines = apply(self.diff_function, args, kw) + for l in lines: + print l + + def fail_test(self, condition = 1, function = None, skip = 0): + """Cause the test to fail. + """ + if not condition: + return + self.condition = 'fail_test' + fail_test(self = self, + condition = condition, + function = function, + skip = skip) + + def interpreter_set(self, interpreter): + """Set the program to be used to interpret the program + under test as a script. + """ + self.interpreter = interpreter + + def match(self, lines, matches): + """Compare actual and expected file contents. + """ + return self.match_function(lines, matches) + + def match_exact(self, lines, matches): + """Compare actual and expected file contents. + """ + return match_exact(lines, matches) + + def match_re(self, lines, res): + """Compare actual and expected file contents. + """ + return match_re(lines, res) + + def match_re_dotall(self, lines, res): + """Compare actual and expected file contents. + """ + return match_re_dotall(lines, res) + + def no_result(self, condition = 1, function = None, skip = 0): + """Report that the test could not be run. + """ + if not condition: + return + self.condition = 'no_result' + no_result(self = self, + condition = condition, + function = function, + skip = skip) + + def pass_test(self, condition = 1, function = None): + """Cause the test to pass. + """ + if not condition: + return + self.condition = 'pass_test' + pass_test(self = self, condition = condition, function = function) + + def preserve(self, *conditions): + """Arrange for the temporary working directories for the + specified TestCmd environment to be preserved for one or more + conditions. If no conditions are specified, arranges for + the temporary working directories to be preserved for all + conditions. + """ + if conditions is (): + conditions = ('pass_test', 'fail_test', 'no_result') + for cond in conditions: + self._preserve[cond] = 1 + + def program_set(self, program): + """Set the executable program or script to be tested. + """ + if program and not os.path.isabs(program): + program = os.path.join(self._cwd, program) + self.program = program + + def read(self, file, mode = 'rb'): + """Reads and returns the contents of the specified file name. + The file name may be a list, in which case the elements are + concatenated with the os.path.join() method. The file is + assumed to be under the temporary working directory unless it + is an absolute path name. The I/O mode for the file may + be specified; it must begin with an 'r'. The default is + 'rb' (binary read). + """ + file = self.canonicalize(file) + if mode[0] != 'r': + raise ValueError, "mode must begin with 'r'" + return open(file, mode).read() + + def rmdir(self, dir): + """Removes the specified dir name. + The dir name may be a list, in which case the elements are + concatenated with the os.path.join() method. The dir is + assumed to be under the temporary working directory unless it + is an absolute path name. + The dir must be empty. + """ + dir = self.canonicalize(dir) + os.rmdir(dir) + + def start(self, program = None, + interpreter = None, + arguments = None, + universal_newlines = None, + **kw): + """ + Starts a program or script for the test environment. + + The specified program will have the original directory + prepended unless it is enclosed in a [list]. + """ + cmd = self.command_args(program, interpreter, arguments) + cmd_string = string.join(map(self.escape, cmd), ' ') + if self.verbose: + sys.stderr.write(cmd_string + "\n") + if universal_newlines is None: + universal_newlines = self.universal_newlines + + # On Windows, if we make stdin a pipe when we plan to send + # no input, and the test program exits before + # Popen calls msvcrt.open_osfhandle, that call will fail. + # So don't use a pipe for stdin if we don't need one. + stdin = kw.get('stdin', None) + if stdin is not None: + stdin = subprocess.PIPE + + combine = kw.get('combine', self.combine) + if combine: + stderr_value = subprocess.STDOUT + else: + stderr_value = subprocess.PIPE + + return Popen(cmd, + stdin=stdin, + stdout=subprocess.PIPE, + stderr=stderr_value, + universal_newlines=universal_newlines) + + def finish(self, popen, **kw): + """ + Finishes and waits for the process being run under control of + the specified popen argument, recording the exit status, + standard output and error output. + """ + popen.stdin.close() + self.status = popen.wait() + if not self.status: + self.status = 0 + self._stdout.append(popen.stdout.read()) + if popen.stderr: + stderr = popen.stderr.read() + else: + stderr = '' + self._stderr.append(stderr) + + def run(self, program = None, + interpreter = None, + arguments = None, + chdir = None, + stdin = None, + universal_newlines = None): + """Runs a test of the program or script for the test + environment. Standard output and error output are saved for + future retrieval via the stdout() and stderr() methods. + + The specified program will have the original directory + prepended unless it is enclosed in a [list]. + """ + if chdir: + oldcwd = os.getcwd() + if not os.path.isabs(chdir): + chdir = os.path.join(self.workpath(chdir)) + if self.verbose: + sys.stderr.write("chdir(" + chdir + ")\n") + os.chdir(chdir) + p = self.start(program, + interpreter, + arguments, + universal_newlines, + stdin=stdin) + if stdin: + if is_List(stdin): + for line in stdin: + p.stdin.write(line) + else: + p.stdin.write(stdin) + p.stdin.close() + + out = p.stdout.read() + if p.stderr is None: + err = '' + else: + err = p.stderr.read() + try: + close_output = p.close_output + except AttributeError: + p.stdout.close() + if not p.stderr is None: + p.stderr.close() + else: + close_output() + + self._stdout.append(out) + self._stderr.append(err) + + self.status = p.wait() + if not self.status: + self.status = 0 + + if chdir: + os.chdir(oldcwd) + if self.verbose >= 2: + write = sys.stdout.write + write('============ STATUS: %d\n' % self.status) + out = self.stdout() + if out or self.verbose >= 3: + write('============ BEGIN STDOUT (len=%d):\n' % len(out)) + write(out) + write('============ END STDOUT\n') + err = self.stderr() + if err or self.verbose >= 3: + write('============ BEGIN STDERR (len=%d)\n' % len(err)) + write(err) + write('============ END STDERR\n') + + def sleep(self, seconds = default_sleep_seconds): + """Sleeps at least the specified number of seconds. If no + number is specified, sleeps at least the minimum number of + seconds necessary to advance file time stamps on the current + system. Sleeping more seconds is all right. + """ + time.sleep(seconds) + + def stderr(self, run = None): + """Returns the error output from the specified run number. + If there is no specified run number, then returns the error + output of the last run. If the run number is less than zero, + then returns the error output from that many runs back from the + current run. + """ + if not run: + run = len(self._stderr) + elif run < 0: + run = len(self._stderr) + run + run = run - 1 + return self._stderr[run] + + def stdout(self, run = None): + """Returns the standard output from the specified run number. + If there is no specified run number, then returns the standard + output of the last run. If the run number is less than zero, + then returns the standard output from that many runs back from + the current run. + """ + if not run: + run = len(self._stdout) + elif run < 0: + run = len(self._stdout) + run + run = run - 1 + return self._stdout[run] + + def subdir(self, *subdirs): + """Create new subdirectories under the temporary working + directory, one for each argument. An argument may be a list, + in which case the list elements are concatenated using the + os.path.join() method. Subdirectories multiple levels deep + must be created using a separate argument for each level: + + test.subdir('sub', ['sub', 'dir'], ['sub', 'dir', 'ectory']) + + Returns the number of subdirectories actually created. + """ + count = 0 + for sub in subdirs: + if sub is None: + continue + if is_List(sub): + sub = apply(os.path.join, tuple(sub)) + new = os.path.join(self.workdir, sub) + try: + os.mkdir(new) + except OSError: + pass + else: + count = count + 1 + return count + + def symlink(self, target, link): + """Creates a symlink to the specified target. + The link name may be a list, in which case the elements are + concatenated with the os.path.join() method. The link is + assumed to be under the temporary working directory unless it + is an absolute path name. The target is *not* assumed to be + under the temporary working directory. + """ + link = self.canonicalize(link) + os.symlink(target, link) + + def tempdir(self, path=None): + """Creates a temporary directory. + A unique directory name is generated if no path name is specified. + The directory is created, and will be removed when the TestCmd + object is destroyed. + """ + if path is None: + try: + path = tempfile.mktemp(prefix=tempfile.template) + except TypeError: + path = tempfile.mktemp() + os.mkdir(path) + + # Symlinks in the path will report things + # differently from os.getcwd(), so chdir there + # and back to fetch the canonical path. + cwd = os.getcwd() + try: + os.chdir(path) + path = os.getcwd() + finally: + os.chdir(cwd) + + # Uppercase the drive letter since the case of drive + # letters is pretty much random on win32: + drive,rest = os.path.splitdrive(path) + if drive: + path = string.upper(drive) + rest + + # + self._dirlist.append(path) + global _Cleanup + try: + _Cleanup.index(self) + except ValueError: + _Cleanup.append(self) + + return path + + def touch(self, path, mtime=None): + """Updates the modification time on the specified file or + directory path name. The default is to update to the + current time if no explicit modification time is specified. + """ + path = self.canonicalize(path) + atime = os.path.getatime(path) + if mtime is None: + mtime = time.time() + os.utime(path, (atime, mtime)) + + def unlink(self, file): + """Unlinks the specified file name. + The file name may be a list, in which case the elements are + concatenated with the os.path.join() method. The file is + assumed to be under the temporary working directory unless it + is an absolute path name. + """ + file = self.canonicalize(file) + os.unlink(file) + + def verbose_set(self, verbose): + """Set the verbose level. + """ + self.verbose = verbose + + def where_is(self, file, path=None, pathext=None): + """Find an executable file. + """ + if is_List(file): + file = apply(os.path.join, tuple(file)) + if not os.path.isabs(file): + file = where_is(file, path, pathext) + return file + + def workdir_set(self, path): + """Creates a temporary working directory with the specified + path name. If the path is a null string (''), a unique + directory name is created. + """ + if (path != None): + if path == '': + path = None + path = self.tempdir(path) + self.workdir = path + + def workpath(self, *args): + """Returns the absolute path name to a subdirectory or file + within the current temporary working directory. Concatenates + the temporary working directory name with the specified + arguments using the os.path.join() method. + """ + return apply(os.path.join, (self.workdir,) + tuple(args)) + + def readable(self, top, read=1): + """Make the specified directory tree readable (read == 1) + or not (read == None). + + This method has no effect on Windows systems, which use a + completely different mechanism to control file readability. + """ + + if sys.platform == 'win32': + return + + if read: + def do_chmod(fname): + try: st = os.stat(fname) + except OSError: pass + else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]|stat.S_IREAD)) + else: + def do_chmod(fname): + try: st = os.stat(fname) + except OSError: pass + else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]&~stat.S_IREAD)) + + if os.path.isfile(top): + # If it's a file, that's easy, just chmod it. + do_chmod(top) + elif read: + # It's a directory and we're trying to turn on read + # permission, so it's also pretty easy, just chmod the + # directory and then chmod every entry on our walk down the + # tree. Because os.path.walk() is top-down, we'll enable + # read permission on any directories that have it disabled + # before os.path.walk() tries to list their contents. + do_chmod(top) + + def chmod_entries(arg, dirname, names, do_chmod=do_chmod): + for n in names: + do_chmod(os.path.join(dirname, n)) + + os.path.walk(top, chmod_entries, None) + else: + # It's a directory and we're trying to turn off read + # permission, which means we have to chmod the directoreis + # in the tree bottom-up, lest disabling read permission from + # the top down get in the way of being able to get at lower + # parts of the tree. But os.path.walk() visits things top + # down, so we just use an object to collect a list of all + # of the entries in the tree, reverse the list, and then + # chmod the reversed (bottom-up) list. + col = Collector(top) + os.path.walk(top, col, None) + col.entries.reverse() + for d in col.entries: do_chmod(d) + + def writable(self, top, write=1): + """Make the specified directory tree writable (write == 1) + or not (write == None). + """ + + if sys.platform == 'win32': + + if write: + def do_chmod(fname): + try: os.chmod(fname, stat.S_IWRITE) + except OSError: pass + else: + def do_chmod(fname): + try: os.chmod(fname, stat.S_IREAD) + except OSError: pass + + else: + + if write: + def do_chmod(fname): + try: st = os.stat(fname) + except OSError: pass + else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]|0200)) + else: + def do_chmod(fname): + try: st = os.stat(fname) + except OSError: pass + else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]&~0200)) + + if os.path.isfile(top): + do_chmod(top) + else: + col = Collector(top) + os.path.walk(top, col, None) + for d in col.entries: do_chmod(d) + + def executable(self, top, execute=1): + """Make the specified directory tree executable (execute == 1) + or not (execute == None). + + This method has no effect on Windows systems, which use a + completely different mechanism to control file executability. + """ + + if sys.platform == 'win32': + return + + if execute: + def do_chmod(fname): + try: st = os.stat(fname) + except OSError: pass + else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]|stat.S_IEXEC)) + else: + def do_chmod(fname): + try: st = os.stat(fname) + except OSError: pass + else: os.chmod(fname, stat.S_IMODE(st[stat.ST_MODE]&~stat.S_IEXEC)) + + if os.path.isfile(top): + # If it's a file, that's easy, just chmod it. + do_chmod(top) + elif execute: + # It's a directory and we're trying to turn on execute + # permission, so it's also pretty easy, just chmod the + # directory and then chmod every entry on our walk down the + # tree. Because os.path.walk() is top-down, we'll enable + # execute permission on any directories that have it disabled + # before os.path.walk() tries to list their contents. + do_chmod(top) + + def chmod_entries(arg, dirname, names, do_chmod=do_chmod): + for n in names: + do_chmod(os.path.join(dirname, n)) + + os.path.walk(top, chmod_entries, None) + else: + # It's a directory and we're trying to turn off execute + # permission, which means we have to chmod the directories + # in the tree bottom-up, lest disabling execute permission from + # the top down get in the way of being able to get at lower + # parts of the tree. But os.path.walk() visits things top + # down, so we just use an object to collect a list of all + # of the entries in the tree, reverse the list, and then + # chmod the reversed (bottom-up) list. + col = Collector(top) + os.path.walk(top, col, None) + col.entries.reverse() + for d in col.entries: do_chmod(d) + + def write(self, file, content, mode = 'wb'): + """Writes the specified content text (second argument) to the + specified file name (first argument). The file name may be + a list, in which case the elements are concatenated with the + os.path.join() method. The file is created under the temporary + working directory. Any subdirectories in the path must already + exist. The I/O mode for the file may be specified; it must + begin with a 'w'. The default is 'wb' (binary write). + """ + file = self.canonicalize(file) + if mode[0] != 'w': + raise ValueError, "mode must begin with 'w'" + open(file, mode).write(content) + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/Source/ThirdParty/gyp/test/lib/TestCommon.py b/Source/ThirdParty/gyp/test/lib/TestCommon.py new file mode 100644 index 000000000..4aa7185a2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/lib/TestCommon.py @@ -0,0 +1,581 @@ +""" +TestCommon.py: a testing framework for commands and scripts + with commonly useful error handling + +The TestCommon module provides a simple, high-level interface for writing +tests of executable commands and scripts, especially commands and scripts +that interact with the file system. All methods throw exceptions and +exit on failure, with useful error messages. This makes a number of +explicit checks unnecessary, making the test scripts themselves simpler +to write and easier to read. + +The TestCommon class is a subclass of the TestCmd class. In essence, +TestCommon is a wrapper that handles common TestCmd error conditions in +useful ways. You can use TestCommon directly, or subclass it for your +program and add additional (or override) methods to tailor it to your +program's specific needs. Alternatively, the TestCommon class serves +as a useful example of how to define your own TestCmd subclass. + +As a subclass of TestCmd, TestCommon provides access to all of the +variables and methods from the TestCmd module. Consequently, you can +use any variable or method documented in the TestCmd module without +having to explicitly import TestCmd. + +A TestCommon environment object is created via the usual invocation: + + import TestCommon + test = TestCommon.TestCommon() + +You can use all of the TestCmd keyword arguments when instantiating a +TestCommon object; see the TestCmd documentation for details. + +Here is an overview of the methods and keyword arguments that are +provided by the TestCommon class: + + test.must_be_writable('file1', ['file2', ...]) + + test.must_contain('file', 'required text\n') + + test.must_contain_all_lines(output, lines, ['title', find]) + + test.must_contain_any_line(output, lines, ['title', find]) + + test.must_exist('file1', ['file2', ...]) + + test.must_match('file', "expected contents\n") + + test.must_not_be_writable('file1', ['file2', ...]) + + test.must_not_contain('file', 'banned text\n') + + test.must_not_contain_any_line(output, lines, ['title', find]) + + test.must_not_exist('file1', ['file2', ...]) + + test.run(options = "options to be prepended to arguments", + stdout = "expected standard output from the program", + stderr = "expected error output from the program", + status = expected_status, + match = match_function) + +The TestCommon module also provides the following variables + + TestCommon.python_executable + TestCommon.exe_suffix + TestCommon.obj_suffix + TestCommon.shobj_prefix + TestCommon.shobj_suffix + TestCommon.lib_prefix + TestCommon.lib_suffix + TestCommon.dll_prefix + TestCommon.dll_suffix + +""" + +# Copyright 2000-2010 Steven Knight +# This module is free software, and you may redistribute it and/or modify +# it under the same terms as Python itself, so long as this copyright message +# and disclaimer are retained in their original form. +# +# IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, +# SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF +# THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +# DAMAGE. +# +# THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, +# AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, +# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + +__author__ = "Steven Knight <knight at baldmt dot com>" +__revision__ = "TestCommon.py 0.37.D001 2010/01/11 16:55:50 knight" +__version__ = "0.37" + +import copy +import os +import os.path +import stat +import string +import sys +import types +import UserList + +from TestCmd import * +from TestCmd import __all__ + +__all__.extend([ 'TestCommon', + 'exe_suffix', + 'obj_suffix', + 'shobj_prefix', + 'shobj_suffix', + 'lib_prefix', + 'lib_suffix', + 'dll_prefix', + 'dll_suffix', + ]) + +# Variables that describe the prefixes and suffixes on this system. +if sys.platform == 'win32': + exe_suffix = '.exe' + obj_suffix = '.obj' + shobj_suffix = '.obj' + shobj_prefix = '' + lib_prefix = '' + lib_suffix = '.lib' + dll_prefix = '' + dll_suffix = '.dll' +elif sys.platform == 'cygwin': + exe_suffix = '.exe' + obj_suffix = '.o' + shobj_suffix = '.os' + shobj_prefix = '' + lib_prefix = 'lib' + lib_suffix = '.a' + dll_prefix = '' + dll_suffix = '.dll' +elif string.find(sys.platform, 'irix') != -1: + exe_suffix = '' + obj_suffix = '.o' + shobj_suffix = '.o' + shobj_prefix = '' + lib_prefix = 'lib' + lib_suffix = '.a' + dll_prefix = 'lib' + dll_suffix = '.so' +elif string.find(sys.platform, 'darwin') != -1: + exe_suffix = '' + obj_suffix = '.o' + shobj_suffix = '.os' + shobj_prefix = '' + lib_prefix = 'lib' + lib_suffix = '.a' + dll_prefix = 'lib' + dll_suffix = '.dylib' +elif string.find(sys.platform, 'sunos') != -1: + exe_suffix = '' + obj_suffix = '.o' + shobj_suffix = '.os' + shobj_prefix = 'so_' + lib_prefix = 'lib' + lib_suffix = '.a' + dll_prefix = 'lib' + dll_suffix = '.dylib' +else: + exe_suffix = '' + obj_suffix = '.o' + shobj_suffix = '.os' + shobj_prefix = '' + lib_prefix = 'lib' + lib_suffix = '.a' + dll_prefix = 'lib' + dll_suffix = '.so' + +def is_List(e): + return type(e) is types.ListType \ + or isinstance(e, UserList.UserList) + +def is_writable(f): + mode = os.stat(f)[stat.ST_MODE] + return mode & stat.S_IWUSR + +def separate_files(flist): + existing = [] + missing = [] + for f in flist: + if os.path.exists(f): + existing.append(f) + else: + missing.append(f) + return existing, missing + +if os.name == 'posix': + def _failed(self, status = 0): + if self.status is None or status is None: + return None + return _status(self) != status + def _status(self): + return self.status +elif os.name == 'nt': + def _failed(self, status = 0): + return not (self.status is None or status is None) and \ + self.status != status + def _status(self): + return self.status + +class TestCommon(TestCmd): + + # Additional methods from the Perl Test::Cmd::Common module + # that we may wish to add in the future: + # + # $test->subdir('subdir', ...); + # + # $test->copy('src_file', 'dst_file'); + + def __init__(self, **kw): + """Initialize a new TestCommon instance. This involves just + calling the base class initialization, and then changing directory + to the workdir. + """ + apply(TestCmd.__init__, [self], kw) + os.chdir(self.workdir) + + def must_be_writable(self, *files): + """Ensures that the specified file(s) exist and are writable. + An individual file can be specified as a list of directory names, + in which case the pathname will be constructed by concatenating + them. Exits FAILED if any of the files does not exist or is + not writable. + """ + files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files) + existing, missing = separate_files(files) + unwritable = filter(lambda x, iw=is_writable: not iw(x), existing) + if missing: + print "Missing files: `%s'" % string.join(missing, "', `") + if unwritable: + print "Unwritable files: `%s'" % string.join(unwritable, "', `") + self.fail_test(missing + unwritable) + + def must_contain(self, file, required, mode = 'rb'): + """Ensures that the specified file contains the required text. + """ + file_contents = self.read(file, mode) + contains = (string.find(file_contents, required) != -1) + if not contains: + print "File `%s' does not contain required string." % file + print self.banner('Required string ') + print required + print self.banner('%s contents ' % file) + print file_contents + self.fail_test(not contains) + + def must_contain_all_lines(self, output, lines, title=None, find=None): + """Ensures that the specified output string (first argument) + contains all of the specified lines (second argument). + + An optional third argument can be used to describe the type + of output being searched, and only shows up in failure output. + + An optional fourth argument can be used to supply a different + function, of the form "find(line, output), to use when searching + for lines in the output. + """ + if find is None: + find = lambda o, l: string.find(o, l) != -1 + missing = [] + for line in lines: + if not find(output, line): + missing.append(line) + + if missing: + if title is None: + title = 'output' + sys.stdout.write("Missing expected lines from %s:\n" % title) + for line in missing: + sys.stdout.write(' ' + repr(line) + '\n') + sys.stdout.write(self.banner(title + ' ')) + sys.stdout.write(output) + self.fail_test() + + def must_contain_any_line(self, output, lines, title=None, find=None): + """Ensures that the specified output string (first argument) + contains at least one of the specified lines (second argument). + + An optional third argument can be used to describe the type + of output being searched, and only shows up in failure output. + + An optional fourth argument can be used to supply a different + function, of the form "find(line, output), to use when searching + for lines in the output. + """ + if find is None: + find = lambda o, l: string.find(o, l) != -1 + for line in lines: + if find(output, line): + return + + if title is None: + title = 'output' + sys.stdout.write("Missing any expected line from %s:\n" % title) + for line in lines: + sys.stdout.write(' ' + repr(line) + '\n') + sys.stdout.write(self.banner(title + ' ')) + sys.stdout.write(output) + self.fail_test() + + def must_contain_lines(self, lines, output, title=None): + # Deprecated; retain for backwards compatibility. + return self.must_contain_all_lines(output, lines, title) + + def must_exist(self, *files): + """Ensures that the specified file(s) must exist. An individual + file be specified as a list of directory names, in which case the + pathname will be constructed by concatenating them. Exits FAILED + if any of the files does not exist. + """ + files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files) + missing = filter(lambda x: not os.path.exists(x), files) + if missing: + print "Missing files: `%s'" % string.join(missing, "', `") + self.fail_test(missing) + + def must_match(self, file, expect, mode = 'rb'): + """Matches the contents of the specified file (first argument) + against the expected contents (second argument). The expected + contents are a list of lines or a string which will be split + on newlines. + """ + file_contents = self.read(file, mode) + try: + self.fail_test(not self.match(file_contents, expect)) + except KeyboardInterrupt: + raise + except: + print "Unexpected contents of `%s'" % file + self.diff(expect, file_contents, 'contents ') + raise + + def must_not_contain(self, file, banned, mode = 'rb'): + """Ensures that the specified file doesn't contain the banned text. + """ + file_contents = self.read(file, mode) + contains = (string.find(file_contents, banned) != -1) + if contains: + print "File `%s' contains banned string." % file + print self.banner('Banned string ') + print banned + print self.banner('%s contents ' % file) + print file_contents + self.fail_test(contains) + + def must_not_contain_any_line(self, output, lines, title=None, find=None): + """Ensures that the specified output string (first argument) + does not contain any of the specified lines (second argument). + + An optional third argument can be used to describe the type + of output being searched, and only shows up in failure output. + + An optional fourth argument can be used to supply a different + function, of the form "find(line, output), to use when searching + for lines in the output. + """ + if find is None: + find = lambda o, l: string.find(o, l) != -1 + unexpected = [] + for line in lines: + if find(output, line): + unexpected.append(line) + + if unexpected: + if title is None: + title = 'output' + sys.stdout.write("Unexpected lines in %s:\n" % title) + for line in unexpected: + sys.stdout.write(' ' + repr(line) + '\n') + sys.stdout.write(self.banner(title + ' ')) + sys.stdout.write(output) + self.fail_test() + + def must_not_contain_lines(self, lines, output, title=None): + return self.must_not_contain_any_line(output, lines, title) + + def must_not_exist(self, *files): + """Ensures that the specified file(s) must not exist. + An individual file be specified as a list of directory names, in + which case the pathname will be constructed by concatenating them. + Exits FAILED if any of the files exists. + """ + files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files) + existing = filter(os.path.exists, files) + if existing: + print "Unexpected files exist: `%s'" % string.join(existing, "', `") + self.fail_test(existing) + + + def must_not_be_writable(self, *files): + """Ensures that the specified file(s) exist and are not writable. + An individual file can be specified as a list of directory names, + in which case the pathname will be constructed by concatenating + them. Exits FAILED if any of the files does not exist or is + writable. + """ + files = map(lambda x: is_List(x) and apply(os.path.join, x) or x, files) + existing, missing = separate_files(files) + writable = filter(is_writable, existing) + if missing: + print "Missing files: `%s'" % string.join(missing, "', `") + if writable: + print "Writable files: `%s'" % string.join(writable, "', `") + self.fail_test(missing + writable) + + def _complete(self, actual_stdout, expected_stdout, + actual_stderr, expected_stderr, status, match): + """ + Post-processes running a subcommand, checking for failure + status and displaying output appropriately. + """ + if _failed(self, status): + expect = '' + if status != 0: + expect = " (expected %s)" % str(status) + print "%s returned %s%s" % (self.program, str(_status(self)), expect) + print self.banner('STDOUT ') + print actual_stdout + print self.banner('STDERR ') + print actual_stderr + self.fail_test() + if not expected_stdout is None and not match(actual_stdout, expected_stdout): + self.diff(expected_stdout, actual_stdout, 'STDOUT ') + if actual_stderr: + print self.banner('STDERR ') + print actual_stderr + self.fail_test() + if not expected_stderr is None and not match(actual_stderr, expected_stderr): + print self.banner('STDOUT ') + print actual_stdout + self.diff(expected_stderr, actual_stderr, 'STDERR ') + self.fail_test() + + def start(self, program = None, + interpreter = None, + arguments = None, + universal_newlines = None, + **kw): + """ + Starts a program or script for the test environment. + + This handles the "options" keyword argument and exceptions. + """ + try: + options = kw['options'] + del kw['options'] + except KeyError: + pass + else: + if options: + if arguments is None: + arguments = options + else: + arguments = options + " " + arguments + try: + return apply(TestCmd.start, + (self, program, interpreter, arguments, universal_newlines), + kw) + except KeyboardInterrupt: + raise + except Exception, e: + print self.banner('STDOUT ') + try: + print self.stdout() + except IndexError: + pass + print self.banner('STDERR ') + try: + print self.stderr() + except IndexError: + pass + cmd_args = self.command_args(program, interpreter, arguments) + sys.stderr.write('Exception trying to execute: %s\n' % cmd_args) + raise e + + def finish(self, popen, stdout = None, stderr = '', status = 0, **kw): + """ + Finishes and waits for the process being run under control of + the specified popen argument. Additional arguments are similar + to those of the run() method: + + stdout The expected standard output from + the command. A value of None means + don't test standard output. + + stderr The expected error output from + the command. A value of None means + don't test error output. + + status The expected exit status from the + command. A value of None means don't + test exit status. + """ + apply(TestCmd.finish, (self, popen,), kw) + match = kw.get('match', self.match) + self._complete(self.stdout(), stdout, + self.stderr(), stderr, status, match) + + def run(self, options = None, arguments = None, + stdout = None, stderr = '', status = 0, **kw): + """Runs the program under test, checking that the test succeeded. + + The arguments are the same as the base TestCmd.run() method, + with the addition of: + + options Extra options that get appended to the beginning + of the arguments. + + stdout The expected standard output from + the command. A value of None means + don't test standard output. + + stderr The expected error output from + the command. A value of None means + don't test error output. + + status The expected exit status from the + command. A value of None means don't + test exit status. + + By default, this expects a successful exit (status = 0), does + not test standard output (stdout = None), and expects that error + output is empty (stderr = ""). + """ + if options: + if arguments is None: + arguments = options + else: + arguments = options + " " + arguments + kw['arguments'] = arguments + try: + match = kw['match'] + del kw['match'] + except KeyError: + match = self.match + apply(TestCmd.run, [self], kw) + self._complete(self.stdout(), stdout, + self.stderr(), stderr, status, match) + + def skip_test(self, message="Skipping test.\n"): + """Skips a test. + + Proper test-skipping behavior is dependent on the external + TESTCOMMON_PASS_SKIPS environment variable. If set, we treat + the skip as a PASS (exit 0), and otherwise treat it as NO RESULT. + In either case, we print the specified message as an indication + that the substance of the test was skipped. + + (This was originally added to support development under Aegis. + Technically, skipping a test is a NO RESULT, but Aegis would + treat that as a test failure and prevent the change from going to + the next step. Since we ddn't want to force anyone using Aegis + to have to install absolutely every tool used by the tests, we + would actually report to Aegis that a skipped test has PASSED + so that the workflow isn't held up.) + """ + if message: + sys.stdout.write(message) + sys.stdout.flush() + pass_skips = os.environ.get('TESTCOMMON_PASS_SKIPS') + if pass_skips in [None, 0, '0']: + # skip=1 means skip this function when showing where this + # result came from. They only care about the line where the + # script called test.skip_test(), not the line number where + # we call test.no_result(). + self.no_result(skip=1) + else: + # We're under the development directory for this change, + # so this is an Aegis invocation; pass the test (exit 0). + self.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/Source/ThirdParty/gyp/test/lib/TestGyp.py b/Source/ThirdParty/gyp/test/lib/TestGyp.py new file mode 100644 index 000000000..23228d2fa --- /dev/null +++ b/Source/ThirdParty/gyp/test/lib/TestGyp.py @@ -0,0 +1,724 @@ +#!/usr/bin/python + +# Copyright (c) 2009 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. + +""" +TestGyp.py: a testing framework for GYP integration tests. +""" + +import os +import re +import shutil +import stat +import sys + +import TestCommon +from TestCommon import __all__ + +__all__.extend([ + 'TestGyp', +]) + + +class TestGypBase(TestCommon.TestCommon): + """ + Class for controlling end-to-end tests of gyp generators. + + Instantiating this class will create a temporary directory and + arrange for its destruction (via the TestCmd superclass) and + copy all of the non-gyptest files in the directory hierarchy of the + executing script. + + The default behavior is to test the 'gyp' or 'gyp.bat' file in the + current directory. An alternative may be specified explicitly on + instantiation, or by setting the TESTGYP_GYP environment variable. + + This class should be subclassed for each supported gyp generator + (format). Various abstract methods below define calling signatures + used by the test scripts to invoke builds on the generated build + configuration and to run executables generated by those builds. + """ + + build_tool = None + build_tool_list = [] + + _exe = TestCommon.exe_suffix + _obj = TestCommon.obj_suffix + shobj_ = TestCommon.shobj_prefix + _shobj = TestCommon.shobj_suffix + lib_ = TestCommon.lib_prefix + _lib = TestCommon.lib_suffix + dll_ = TestCommon.dll_prefix + _dll = TestCommon.dll_suffix + + # Constants to represent different targets. + ALL = '__all__' + DEFAULT = '__default__' + + # Constants for different target types. + EXECUTABLE = '__executable__' + STATIC_LIB = '__static_lib__' + SHARED_LIB = '__shared_lib__' + + def __init__(self, gyp=None, *args, **kw): + self.origin_cwd = os.path.abspath(os.path.dirname(sys.argv[0])) + + if not gyp: + gyp = os.environ.get('TESTGYP_GYP') + if not gyp: + if sys.platform == 'win32': + gyp = 'gyp.bat' + else: + gyp = 'gyp' + self.gyp = os.path.abspath(gyp) + + self.initialize_build_tool() + + if not kw.has_key('match'): + kw['match'] = TestCommon.match_exact + + if not kw.has_key('workdir'): + # Default behavior: the null string causes TestCmd to create + # a temporary directory for us. + kw['workdir'] = '' + + formats = kw.get('formats', []) + if kw.has_key('formats'): + del kw['formats'] + + super(TestGypBase, self).__init__(*args, **kw) + + excluded_formats = set([f for f in formats if f[0] == '!']) + included_formats = set(formats) - excluded_formats + if ('!'+self.format in excluded_formats or + included_formats and self.format not in included_formats): + msg = 'Invalid test for %r format; skipping test.\n' + self.skip_test(msg % self.format) + + self.copy_test_configuration(self.origin_cwd, self.workdir) + self.set_configuration(None) + + def built_file_must_exist(self, name, type=None, **kw): + """ + Fails the test if the specified built file name does not exist. + """ + return self.must_exist(self.built_file_path(name, type, **kw)) + + def built_file_must_not_exist(self, name, type=None, **kw): + """ + Fails the test if the specified built file name exists. + """ + return self.must_not_exist(self.built_file_path(name, type, **kw)) + + def built_file_must_match(self, name, contents, **kw): + """ + Fails the test if the contents of the specified built file name + do not match the specified contents. + """ + return self.must_match(self.built_file_path(name, **kw), contents) + + def built_file_must_not_match(self, name, contents, **kw): + """ + Fails the test if the contents of the specified built file name + match the specified contents. + """ + return self.must_not_match(self.built_file_path(name, **kw), contents) + + def copy_test_configuration(self, source_dir, dest_dir): + """ + Copies the test configuration from the specified source_dir + (the directory in which the test script lives) to the + specified dest_dir (a temporary working directory). + + This ignores all files and directories that begin with + the string 'gyptest', and all '.svn' subdirectories. + """ + for root, dirs, files in os.walk(source_dir): + if '.svn' in dirs: + dirs.remove('.svn') + dirs = [ d for d in dirs if not d.startswith('gyptest') ] + files = [ f for f in files if not f.startswith('gyptest') ] + for dirname in dirs: + source = os.path.join(root, dirname) + destination = source.replace(source_dir, dest_dir) + os.mkdir(destination) + if sys.platform != 'win32': + shutil.copystat(source, destination) + for filename in files: + source = os.path.join(root, filename) + destination = source.replace(source_dir, dest_dir) + shutil.copy2(source, destination) + + def initialize_build_tool(self): + """ + Initializes the .build_tool attribute. + + Searches the .build_tool_list for an executable name on the user's + $PATH. The first tool on the list is used as-is if nothing is found + on the current $PATH. + """ + for build_tool in self.build_tool_list: + if not build_tool: + continue + if os.path.isabs(build_tool): + self.build_tool = build_tool + return + build_tool = self.where_is(build_tool) + if build_tool: + self.build_tool = build_tool + return + + if self.build_tool_list: + self.build_tool = self.build_tool_list[0] + + def relocate(self, source, destination): + """ + Renames (relocates) the specified source (usually a directory) + to the specified destination, creating the destination directory + first if necessary. + + Note: Don't use this as a generic "rename" operation. In the + future, "relocating" parts of a GYP tree may affect the state of + the test to modify the behavior of later method calls. + """ + destination_dir = os.path.dirname(destination) + if not os.path.exists(destination_dir): + self.subdir(destination_dir) + os.rename(source, destination) + + def report_not_up_to_date(self): + """ + Reports that a build is not up-to-date. + + This provides common reporting for formats that have complicated + conditions for checking whether a build is up-to-date. Formats + that expect exact output from the command (make, scons) can + just set stdout= when they call the run_build() method. + """ + print "Build is not up-to-date:" + print self.banner('STDOUT ') + print self.stdout() + stderr = self.stderr() + if stderr: + print self.banner('STDERR ') + print stderr + + def run_gyp(self, gyp_file, *args, **kw): + """ + Runs gyp against the specified gyp_file with the specified args. + """ + # TODO: --depth=. works around Chromium-specific tree climbing. + args = ('--depth=.', '--format='+self.format, gyp_file) + args + return self.run(program=self.gyp, arguments=args, **kw) + + def run(self, *args, **kw): + """ + Executes a program by calling the superclass .run() method. + + This exists to provide a common place to filter out keyword + arguments implemented in this layer, without having to update + the tool-specific subclasses or clutter the tests themselves + with platform-specific code. + """ + if kw.has_key('SYMROOT'): + del kw['SYMROOT'] + super(TestGypBase, self).run(*args, **kw) + + def set_configuration(self, configuration): + """ + Sets the configuration, to be used for invoking the build + tool and testing potential built output. + """ + self.configuration = configuration + + def configuration_dirname(self): + if self.configuration: + return self.configuration.split('|')[0] + else: + return 'Default' + + def configuration_buildname(self): + if self.configuration: + return self.configuration + else: + return 'Default' + + # + # Abstract methods to be defined by format-specific subclasses. + # + + def build(self, gyp_file, target=None, **kw): + """ + Runs a build of the specified target against the configuration + generated from the specified gyp_file. + + A 'target' argument of None or the special value TestGyp.DEFAULT + specifies the default argument for the underlying build tool. + A 'target' argument of TestGyp.ALL specifies the 'all' target + (if any) of the underlying build tool. + """ + raise NotImplementedError + + def built_file_path(self, name, type=None, **kw): + """ + Returns a path to the specified file name, of the specified type. + """ + raise NotImplementedError + + def built_file_basename(self, name, type=None, **kw): + """ + Returns the base name of the specified file name, of the specified type. + + A bare=True keyword argument specifies that prefixes and suffixes shouldn't + be applied. + """ + if not kw.get('bare'): + if type == self.EXECUTABLE: + name = name + self._exe + elif type == self.STATIC_LIB: + name = self.lib_ + name + self._lib + elif type == self.SHARED_LIB: + name = self.dll_ + name + self._dll + return name + + def run_built_executable(self, name, *args, **kw): + """ + Runs an executable program built from a gyp-generated configuration. + + The specified name should be independent of any particular generator. + Subclasses should find the output executable in the appropriate + output build directory, tack on any necessary executable suffix, etc. + """ + raise NotImplementedError + + def up_to_date(self, gyp_file, target=None, **kw): + """ + Verifies that a build of the specified target is up to date. + + The subclass should implement this by calling build() + (or a reasonable equivalent), checking whatever conditions + will tell it the build was an "up to date" null build, and + failing if it isn't. + """ + raise NotImplementedError + + +class TestGypGypd(TestGypBase): + """ + Subclass for testing the GYP 'gypd' generator (spit out the + internal data structure as pretty-printed Python). + """ + format = 'gypd' + + +class TestGypMake(TestGypBase): + """ + Subclass for testing the GYP Make generator. + """ + format = 'make' + build_tool_list = ['make'] + ALL = 'all' + def build(self, gyp_file, target=None, **kw): + """ + Runs a Make build using the Makefiles generated from the specified + gyp_file. + """ + arguments = kw.get('arguments', [])[:] + if self.configuration: + arguments.append('BUILDTYPE=' + self.configuration) + if target not in (None, self.DEFAULT): + arguments.append(target) + # Sub-directory builds provide per-gyp Makefiles (i.e. + # Makefile.gyp_filename), so use that if there is no Makefile. + chdir = kw.get('chdir', '') + if not os.path.exists(os.path.join(chdir, 'Makefile')): + print "NO Makefile in " + os.path.join(chdir, 'Makefile') + arguments.insert(0, '-f') + arguments.insert(1, os.path.splitext(gyp_file)[0] + '.Makefile') + kw['arguments'] = arguments + return self.run(program=self.build_tool, **kw) + def up_to_date(self, gyp_file, target=None, **kw): + """ + Verifies that a build of the specified Make target is up to date. + """ + if target in (None, self.DEFAULT): + message_target = 'all' + else: + message_target = target + kw['stdout'] = "make: Nothing to be done for `%s'.\n" % message_target + return self.build(gyp_file, target, **kw) + def run_built_executable(self, name, *args, **kw): + """ + Runs an executable built by Make. + """ + configuration = self.configuration_dirname() + libdir = os.path.join('out', configuration, 'lib') + # TODO(piman): when everything is cross-compile safe, remove lib.target + os.environ['LD_LIBRARY_PATH'] = libdir + '.host:' + libdir + '.target' + # Enclosing the name in a list avoids prepending the original dir. + program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] + return self.run(program=program, *args, **kw) + def built_file_path(self, name, type=None, **kw): + """ + Returns a path to the specified file name, of the specified type, + as built by Make. + + Built files are in the subdirectory 'out/{configuration}'. + The default is 'out/Default'. + + A chdir= keyword argument specifies the source directory + relative to which the output subdirectory can be found. + + "type" values of STATIC_LIB or SHARED_LIB append the necessary + prefixes and suffixes to a platform-independent library base name. + + A libdir= keyword argument specifies a library subdirectory other + than the default 'obj.target'. + """ + result = [] + chdir = kw.get('chdir') + if chdir: + result.append(chdir) + configuration = self.configuration_dirname() + result.extend(['out', configuration]) + if type == self.STATIC_LIB: + result.append(kw.get('libdir', 'obj.target')) + elif type == self.SHARED_LIB: + result.append(kw.get('libdir', 'lib.target')) + result.append(self.built_file_basename(name, type, **kw)) + return self.workpath(*result) + + +class TestGypMSVS(TestGypBase): + """ + Subclass for testing the GYP Visual Studio generator. + """ + format = 'msvs' + + u = r'=== Build: (\d+) succeeded, 0 failed, (\d+) up-to-date, 0 skipped ===' + up_to_date_re = re.compile(u, re.M) + + # Initial None element will indicate to our .initialize_build_tool() + # method below that 'devenv' was not found on %PATH%. + # + # Note: we must use devenv.com to be able to capture build output. + # Directly executing devenv.exe only sends output to BuildLog.htm. + build_tool_list = [None, 'devenv.com'] + + def initialize_build_tool(self): + """ Initializes the Visual Studio .build_tool and .uses_msbuild parameters. + + We use the value specified by GYP_MSVS_VERSION. If not specified, we + search %PATH% and %PATHEXT% for a devenv.{exe,bat,...} executable. + Failing that, we search for likely deployment paths. + """ + super(TestGypMSVS, self).initialize_build_tool() + possible_roots = ['C:\\Program Files (x86)', 'C:\\Program Files'] + possible_paths = { + '2010': r'Microsoft Visual Studio 10.0\Common7\IDE\devenv.com', + '2008': r'Microsoft Visual Studio 9.0\Common7\IDE\devenv.com', + '2005': r'Microsoft Visual Studio 8\Common7\IDE\devenv.com'} + msvs_version = os.environ.get('GYP_MSVS_VERSION', 'auto') + if msvs_version in possible_paths: + # Check that the path to the specified GYP_MSVS_VERSION exists. + path = possible_paths[msvs_version] + for r in possible_roots: + bt = os.path.join(r, path) + if os.path.exists(bt): + self.build_tool = bt + self.uses_msbuild = msvs_version >= '2010' + return + else: + print ('Warning: Environment variable GYP_MSVS_VERSION specifies "%s" ' + 'but corresponding "%s" was not found.' % (msvs_version, path)) + if self.build_tool: + # We found 'devenv' on the path, use that and try to guess the version. + for version, path in possible_paths.iteritems(): + if self.build_tool.find(path) >= 0: + self.uses_msbuild = version >= '2010' + return + else: + # If not, assume not MSBuild. + self.uses_msbuild = False + return + # Neither GYP_MSVS_VERSION nor the path help us out. Iterate through + # the choices looking for a match. + for version, path in possible_paths.iteritems(): + for r in possible_roots: + bt = os.path.join(r, path) + if os.path.exists(bt): + self.build_tool = bt + self.uses_msbuild = msvs_version >= '2010' + return + print 'Error: could not find devenv' + sys.exit(1) + def build(self, gyp_file, target=None, rebuild=False, **kw): + """ + Runs a Visual Studio build using the configuration generated + from the specified gyp_file. + """ + configuration = self.configuration_buildname() + if rebuild: + build = '/Rebuild' + else: + build = '/Build' + arguments = kw.get('arguments', [])[:] + arguments.extend([gyp_file.replace('.gyp', '.sln'), + build, configuration]) + # Note: the Visual Studio generator doesn't add an explicit 'all' + # target, so we just treat it the same as the default. + if target not in (None, self.ALL, self.DEFAULT): + arguments.extend(['/Project', target]) + if self.configuration: + arguments.extend(['/ProjectConfig', self.configuration]) + kw['arguments'] = arguments + return self.run(program=self.build_tool, **kw) + def up_to_date(self, gyp_file, target=None, **kw): + """ + Verifies that a build of the specified Visual Studio target is up to date. + """ + result = self.build(gyp_file, target, **kw) + if not result: + stdout = self.stdout() + m = self.up_to_date_re.search(stdout) + up_to_date = False + if m: + succeeded = m.group(1) + up_to_date = m.group(2) + up_to_date = succeeded == '0' and up_to_date == '1' + # Figuring out if the build is up to date changed with VS2010. + # For builds that should be up to date, I sometimes get + # "1 succeeded and 0 up to date". As an ad-hoc measure, we check + # this and also verify that th number of output lines is small. + # I don't know if this is caused by VS itself or is due to + # interaction with virus checkers. + if self.uses_msbuild and (succeeded == '1' and + up_to_date == '0' and + stdout.count('\n') <= 6): + up_to_date = True + if not up_to_date: + self.report_not_up_to_date() + self.fail_test() + return result + def run_built_executable(self, name, *args, **kw): + """ + Runs an executable built by Visual Studio. + """ + configuration = self.configuration_dirname() + # Enclosing the name in a list avoids prepending the original dir. + program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] + return self.run(program=program, *args, **kw) + def built_file_path(self, name, type=None, **kw): + """ + Returns a path to the specified file name, of the specified type, + as built by Visual Studio. + + Built files are in a subdirectory that matches the configuration + name. The default is 'Default'. + + A chdir= keyword argument specifies the source directory + relative to which the output subdirectory can be found. + + "type" values of STATIC_LIB or SHARED_LIB append the necessary + prefixes and suffixes to a platform-independent library base name. + """ + result = [] + chdir = kw.get('chdir') + if chdir: + result.append(chdir) + result.append(self.configuration_dirname()) + if type == self.STATIC_LIB: + result.append('lib') + result.append(self.built_file_basename(name, type, **kw)) + return self.workpath(*result) + + +class TestGypSCons(TestGypBase): + """ + Subclass for testing the GYP SCons generator. + """ + format = 'scons' + build_tool_list = ['scons', 'scons.py'] + ALL = 'all' + def build(self, gyp_file, target=None, **kw): + """ + Runs a scons build using the SCons configuration generated from the + specified gyp_file. + """ + arguments = kw.get('arguments', [])[:] + dirname = os.path.dirname(gyp_file) + if dirname: + arguments.extend(['-C', dirname]) + if self.configuration: + arguments.append('--mode=' + self.configuration) + if target not in (None, self.DEFAULT): + arguments.append(target) + kw['arguments'] = arguments + return self.run(program=self.build_tool, **kw) + def up_to_date(self, gyp_file, target=None, **kw): + """ + Verifies that a build of the specified SCons target is up to date. + """ + if target in (None, self.DEFAULT): + up_to_date_targets = 'all' + else: + up_to_date_targets = target + up_to_date_lines = [] + for arg in up_to_date_targets.split(): + up_to_date_lines.append("scons: `%s' is up to date.\n" % arg) + kw['stdout'] = ''.join(up_to_date_lines) + arguments = kw.get('arguments', [])[:] + arguments.append('-Q') + kw['arguments'] = arguments + return self.build(gyp_file, target, **kw) + def run_built_executable(self, name, *args, **kw): + """ + Runs an executable built by scons. + """ + configuration = self.configuration_dirname() + os.environ['LD_LIBRARY_PATH'] = os.path.join(configuration, 'lib') + # Enclosing the name in a list avoids prepending the original dir. + program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] + return self.run(program=program, *args, **kw) + def built_file_path(self, name, type=None, **kw): + """ + Returns a path to the specified file name, of the specified type, + as built by Scons. + + Built files are in a subdirectory that matches the configuration + name. The default is 'Default'. + + A chdir= keyword argument specifies the source directory + relative to which the output subdirectory can be found. + + "type" values of STATIC_LIB or SHARED_LIB append the necessary + prefixes and suffixes to a platform-independent library base name. + """ + result = [] + chdir = kw.get('chdir') + if chdir: + result.append(chdir) + result.append(self.configuration_dirname()) + if type in (self.STATIC_LIB, self.SHARED_LIB): + result.append('lib') + result.append(self.built_file_basename(name, type, **kw)) + return self.workpath(*result) + + +class TestGypXcode(TestGypBase): + """ + Subclass for testing the GYP Xcode generator. + """ + format = 'xcode' + build_tool_list = ['xcodebuild'] + + phase_script_execution = ("\n" + "PhaseScriptExecution /\\S+/Script-[0-9A-F]+\\.sh\n" + " cd /\\S+\n" + " /bin/sh -c /\\S+/Script-[0-9A-F]+\\.sh\n" + "(make: Nothing to be done for `all'\\.\n)?") + + strip_up_to_date_expressions = [ + # Various actions or rules can run even when the overall build target + # is up to date. Strip those phases' GYP-generated output. + re.compile(phase_script_execution, re.S), + + # The message from distcc_pump can trail the "BUILD SUCCEEDED" + # message, so strip that, too. + re.compile('__________Shutting down distcc-pump include server\n', re.S), + ] + + up_to_date_endings = ( + 'Checking Dependencies...\n** BUILD SUCCEEDED **\n', # Xcode 3.0/3.1 + 'Check dependencies\n** BUILD SUCCEEDED **\n\n', # Xcode 3.2 + ) + + def build(self, gyp_file, target=None, **kw): + """ + Runs an xcodebuild using the .xcodeproj generated from the specified + gyp_file. + """ + # Be sure we're working with a copy of 'arguments' since we modify it. + # The caller may not be expecting it to be modified. + arguments = kw.get('arguments', [])[:] + arguments.extend(['-project', gyp_file.replace('.gyp', '.xcodeproj')]) + if target == self.ALL: + arguments.append('-alltargets',) + elif target not in (None, self.DEFAULT): + arguments.extend(['-target', target]) + if self.configuration: + arguments.extend(['-configuration', self.configuration]) + symroot = kw.get('SYMROOT', '$SRCROOT/build') + if symroot: + arguments.append('SYMROOT='+symroot) + kw['arguments'] = arguments + return self.run(program=self.build_tool, **kw) + def up_to_date(self, gyp_file, target=None, **kw): + """ + Verifies that a build of the specified Xcode target is up to date. + """ + result = self.build(gyp_file, target, **kw) + if not result: + output = self.stdout() + for expression in self.strip_up_to_date_expressions: + output = expression.sub('', output) + if not output.endswith(self.up_to_date_endings): + self.report_not_up_to_date() + self.fail_test() + return result + def run_built_executable(self, name, *args, **kw): + """ + Runs an executable built by xcodebuild. + """ + configuration = self.configuration_dirname() + os.environ['DYLD_LIBRARY_PATH'] = os.path.join('build', configuration) + # Enclosing the name in a list avoids prepending the original dir. + program = [self.built_file_path(name, type=self.EXECUTABLE, **kw)] + return self.run(program=program, *args, **kw) + def built_file_path(self, name, type=None, **kw): + """ + Returns a path to the specified file name, of the specified type, + as built by Xcode. + + Built files are in the subdirectory 'build/{configuration}'. + The default is 'build/Default'. + + A chdir= keyword argument specifies the source directory + relative to which the output subdirectory can be found. + + "type" values of STATIC_LIB or SHARED_LIB append the necessary + prefixes and suffixes to a platform-independent library base name. + """ + result = [] + chdir = kw.get('chdir') + if chdir: + result.append(chdir) + configuration = self.configuration_dirname() + result.extend(['build', configuration]) + result.append(self.built_file_basename(name, type, **kw)) + return self.workpath(*result) + + +format_class_list = [ + TestGypGypd, + TestGypMake, + TestGypMSVS, + TestGypSCons, + TestGypXcode, +] + +def TestGyp(*args, **kw): + """ + Returns an appropriate TestGyp* instance for a specified GYP format. + """ + format = kw.get('format') + if format: + del kw['format'] + else: + format = os.environ.get('TESTGYP_FORMAT') + for format_class in format_class_list: + if format == format_class.format: + return format_class(*args, **kw) + raise Exception, "unknown format %r" % format diff --git a/Source/ThirdParty/gyp/test/library/gyptest-shared-obj-install-path.py b/Source/ThirdParty/gyp/test/library/gyptest-shared-obj-install-path.py new file mode 100644 index 000000000..2cf1a2845 --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/gyptest-shared-obj-install-path.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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 .so files that are order only dependencies are specified by +their install location rather than by their alias. +""" + +# Python 2.5 needs this for the with statement. +from __future__ import with_statement + +import os +import TestGyp + +test = TestGyp.TestGyp(formats=['make']) + +test.run_gyp('shared_dependency.gyp', + chdir='src') +test.relocate('src', 'relocate/src') + +test.build('shared_dependency.gyp', test.ALL, chdir='relocate/src') + +with open('relocate/src/Makefile') as makefile: + make_contents = makefile.read() + +# If we remove the code to generate lib1, Make should still be able +# to build lib2 since lib1.so already exists. +make_contents = make_contents.replace('include lib1.target.mk', '') +with open('relocate/src/Makefile', 'w') as makefile: + makefile.write(make_contents) + +test.build('shared_dependency.gyp', test.ALL, chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/library/gyptest-shared.py b/Source/ThirdParty/gyp/test/library/gyptest-shared.py new file mode 100644 index 000000000..a1d2985d9 --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/gyptest-shared.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 simple build of a "Hello, world!" program with shared libraries, +including verifying that libraries are rebuilt correctly when functions +move between libraries. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('library.gyp', + '-Dlibrary=shared_library', + '-Dmoveable_function=lib1', + chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('library.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from program.c +Hello from lib1.c +Hello from lib2.c +Hello from lib1_moveable.c +""" +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + + +test.run_gyp('library.gyp', + '-Dlibrary=shared_library', + '-Dmoveable_function=lib2', + chdir='relocate/src') + +# Update program.c to force a rebuild. +test.sleep() +contents = test.read('relocate/src/program.c') +contents = contents.replace('Hello', 'Hello again') +test.write('relocate/src/program.c', contents) + +test.build('library.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello again from program.c +Hello from lib1.c +Hello from lib2.c +Hello from lib2_moveable.c +""" +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + + +test.run_gyp('library.gyp', + '-Dlibrary=shared_library', + '-Dmoveable_function=lib1', + chdir='relocate/src') + +# Update program.c to force a rebuild. +test.sleep() +contents = test.read('relocate/src/program.c') +contents = contents.replace('again', 'again again') +test.write('relocate/src/program.c', contents) + +# TODO(sgk): we have to force a rebuild of lib2 so that it weeds out +# the "moved" module. This should be done in gyp by adding a dependency +# on the generated .vcproj file itself. +test.touch('relocate/src/lib2.c') + +test.build('library.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello again again from program.c +Hello from lib1.c +Hello from lib2.c +Hello from lib1_moveable.c +""" +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/library/gyptest-static.py b/Source/ThirdParty/gyp/test/library/gyptest-static.py new file mode 100644 index 000000000..4bc71c496 --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/gyptest-static.py @@ -0,0 +1,84 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 simple build of a "Hello, world!" program with static libraries, +including verifying that libraries are rebuilt correctly when functions +move between libraries. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('library.gyp', + '-Dlibrary=static_library', + '-Dmoveable_function=lib1', + chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('library.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from program.c +Hello from lib1.c +Hello from lib2.c +Hello from lib1_moveable.c +""" +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + + +test.run_gyp('library.gyp', + '-Dlibrary=static_library', + '-Dmoveable_function=lib2', + chdir='relocate/src') + +# Update program.c to force a rebuild. +test.sleep() +contents = test.read('relocate/src/program.c') +contents = contents.replace('Hello', 'Hello again') +test.write('relocate/src/program.c', contents) + +test.build('library.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello again from program.c +Hello from lib1.c +Hello from lib2.c +Hello from lib2_moveable.c +""" +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + + +test.run_gyp('library.gyp', + '-Dlibrary=static_library', + '-Dmoveable_function=lib1', + chdir='relocate/src') + +# Update program.c and lib2.c to force a rebuild. +test.sleep() +contents = test.read('relocate/src/program.c') +contents = contents.replace('again', 'again again') +test.write('relocate/src/program.c', contents) + +# TODO(sgk): we have to force a rebuild of lib2 so that it weeds out +# the "moved" module. This should be done in gyp by adding a dependency +# on the generated .vcproj file itself. +test.touch('relocate/src/lib2.c') + +test.build('library.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello again again from program.c +Hello from lib1.c +Hello from lib2.c +Hello from lib1_moveable.c +""" +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/library/src/lib1.c b/Source/ThirdParty/gyp/test/library/src/lib1.c new file mode 100644 index 000000000..3866b1b84 --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/src/lib1.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif +void lib1_function(void) +{ + fprintf(stdout, "Hello from lib1.c\n"); + fflush(stdout); +} diff --git a/Source/ThirdParty/gyp/test/library/src/lib1_moveable.c b/Source/ThirdParty/gyp/test/library/src/lib1_moveable.c new file mode 100644 index 000000000..5d3cc1d9a --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/src/lib1_moveable.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif +void moveable_function(void) +{ + fprintf(stdout, "Hello from lib1_moveable.c\n"); + fflush(stdout); +} diff --git a/Source/ThirdParty/gyp/test/library/src/lib2.c b/Source/ThirdParty/gyp/test/library/src/lib2.c new file mode 100644 index 000000000..21dda7265 --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/src/lib2.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif +void lib2_function(void) +{ + fprintf(stdout, "Hello from lib2.c\n"); + fflush(stdout); +} diff --git a/Source/ThirdParty/gyp/test/library/src/lib2_moveable.c b/Source/ThirdParty/gyp/test/library/src/lib2_moveable.c new file mode 100644 index 000000000..f645071d1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/src/lib2_moveable.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif +void moveable_function(void) +{ + fprintf(stdout, "Hello from lib2_moveable.c\n"); + fflush(stdout); +} diff --git a/Source/ThirdParty/gyp/test/library/src/library.gyp b/Source/ThirdParty/gyp/test/library/src/library.gyp new file mode 100644 index 000000000..51f59bc45 --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/src/library.gyp @@ -0,0 +1,58 @@ +# Copyright (c) 2009 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. + +{ + 'variables': { + 'moveable_function%': 0, + }, + 'targets': [ + { + 'target_name': 'program', + 'type': 'executable', + 'dependencies': [ + 'lib1', + 'lib2', + ], + 'sources': [ + 'program.c', + ], + }, + { + 'target_name': 'lib1', + 'type': 'static_library', + 'sources': [ + 'lib1.c', + ], + 'conditions': [ + ['moveable_function=="lib1"', { + 'sources': [ + 'lib1_moveable.c', + ], + }], + ], + }, + { + 'target_name': 'lib2', + 'type': 'static_library', + 'sources': [ + 'lib2.c', + ], + 'conditions': [ + ['moveable_function=="lib2"', { + 'sources': [ + 'lib2_moveable.c', + ], + }], + ], + }, + ], + 'conditions': [ + ['OS=="linux"', { + 'target_defaults': { + # Support 64-bit shared libs (also works fine for 32-bit). + 'cflags': ['-fPIC'], + }, + }], + ], +} diff --git a/Source/ThirdParty/gyp/test/library/src/program.c b/Source/ThirdParty/gyp/test/library/src/program.c new file mode 100644 index 000000000..d7712cced --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/src/program.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +extern void lib1_function(void); +extern void lib2_function(void); +extern void moveable_function(void); + +int main(int argc, char *argv[]) +{ + fprintf(stdout, "Hello from program.c\n"); + fflush(stdout); + lib1_function(); + lib2_function(); + moveable_function(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/library/src/shared_dependency.gyp b/Source/ThirdParty/gyp/test/library/src/shared_dependency.gyp new file mode 100644 index 000000000..7d29f5de5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/library/src/shared_dependency.gyp @@ -0,0 +1,33 @@ +# Copyright (c) 2009 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': 'lib1', + 'type': 'shared_library', + 'sources': [ + 'lib1.c', + ], + }, + { + 'target_name': 'lib2', + 'type': 'shared_library', + 'sources': [ + 'lib2.c', + ], + 'dependencies': [ + 'lib1', + ], + }, + ], + 'conditions': [ + ['OS=="linux"', { + 'target_defaults': { + # Support 64-bit shared libs (also works fine for 32-bit). + 'cflags': ['-fPIC'], + }, + }], + ], +} diff --git a/Source/ThirdParty/gyp/test/link-objects/base.c b/Source/ThirdParty/gyp/test/link-objects/base.c new file mode 100644 index 000000000..2bc29a1b1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/link-objects/base.c @@ -0,0 +1,6 @@ +void extra(); + +int main(int argc, char** argv) { + extra(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/link-objects/extra.c b/Source/ThirdParty/gyp/test/link-objects/extra.c new file mode 100644 index 000000000..1d7ee09b1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/link-objects/extra.c @@ -0,0 +1,5 @@ +#include <stdio.h> + +void extra() { + printf("PASS\n"); +} diff --git a/Source/ThirdParty/gyp/test/link-objects/gyptest-all.py b/Source/ThirdParty/gyp/test/link-objects/gyptest-all.py new file mode 100644 index 000000000..b58a3963d --- /dev/null +++ b/Source/ThirdParty/gyp/test/link-objects/gyptest-all.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Put an object file on the sources list. +Expect the result to link ok. +""" + +import TestGyp + +# Currently only works under the make build. +test = TestGyp.TestGyp(formats=['make']) + +test.run_gyp('link-objects.gyp') + +test.build('link-objects.gyp', test.ALL) + +test.run_built_executable('link-objects', stdout="PASS\n") + +test.up_to_date('link-objects.gyp', test.ALL) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/link-objects/link-objects.gyp b/Source/ThirdParty/gyp/test/link-objects/link-objects.gyp new file mode 100644 index 000000000..ab7285553 --- /dev/null +++ b/Source/ThirdParty/gyp/test/link-objects/link-objects.gyp @@ -0,0 +1,24 @@ +# Copyright (c) 2009 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': 'link-objects', + 'type': 'executable', + 'actions': [ + { + 'action_name': 'build extra object', + 'inputs': ['extra.c'], + 'outputs': ['extra.o'], + 'action': ['gcc', '-o', 'extra.o', '-c', 'extra.c'], + 'process_outputs_as_sources': 1, + }, + ], + 'sources': [ + 'base.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/make/dependencies.gyp b/Source/ThirdParty/gyp/test/make/dependencies.gyp new file mode 100644 index 000000000..e2bee24fc --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/dependencies.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'main', + 'type': 'executable', + 'sources': [ + 'main.cc', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/make/gyptest-dependencies.py b/Source/ThirdParty/gyp/test/make/gyptest-dependencies.py new file mode 100644 index 000000000..76cfd0e81 --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/gyptest-dependencies.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 .d files and all.deps are properly generated. +""" + +import os +import TestGyp + +# .d files are only used by the make build. +test = TestGyp.TestGyp(formats=['make']) + +test.run_gyp('dependencies.gyp') + +test.build('dependencies.gyp', test.ALL) + +deps_file = test.built_file_path(".deps/out/Default/obj.target/main/main.o.d") +test.must_contain(deps_file, "main.h") + +# Build a second time to make sure we generate all.deps. +test.build('dependencies.gyp', test.ALL) + +all_deps_file = test.built_file_path(".deps/all.deps") +test.must_contain(all_deps_file, "main.h") +test.must_contain(all_deps_file, "cmd_") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/make/gyptest-noload.py b/Source/ThirdParty/gyp/test/make/gyptest-noload.py new file mode 100644 index 000000000..1f5103315 --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/gyptest-noload.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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. + +""" +Tests the use of the NO_LOAD flag which makes loading sub .mk files +optional. +""" + +# Python 2.5 needs this for the with statement. +from __future__ import with_statement + +import os +import TestGyp + +test = TestGyp.TestGyp(formats=['make']) + +test.run_gyp('all.gyp', chdir='noload') + +test.relocate('noload', 'relocate/noload') + +test.build('build/all.gyp', test.ALL, chdir='relocate/noload') +test.run_built_executable('exe', chdir='relocate/noload', + stdout='Hello from shared.c.\n') + +# Just sanity test that NO_LOAD=lib doesn't break anything. +test.build('build/all.gyp', test.ALL, chdir='relocate/noload', + arguments=['NO_LOAD=lib']) +test.run_built_executable('exe', chdir='relocate/noload', + stdout='Hello from shared.c.\n') +test.build('build/all.gyp', test.ALL, chdir='relocate/noload', + arguments=['NO_LOAD=z']) +test.run_built_executable('exe', chdir='relocate/noload', + stdout='Hello from shared.c.\n') + +# Make sure we can rebuild without reloading the sub .mk file. +with open('relocate/noload/main.c', 'a') as src_file: + src_file.write("\n") +test.build('build/all.gyp', test.ALL, chdir='relocate/noload', + arguments=['NO_LOAD=lib']) +test.run_built_executable('exe', chdir='relocate/noload', + stdout='Hello from shared.c.\n') + +# Change shared.c, but verify that it doesn't get rebuild if we don't load it. +with open('relocate/noload/lib/shared.c', 'w') as shared_file: + shared_file.write( + '#include "shared.h"\n' + 'const char kSharedStr[] = "modified";\n' + ) +test.build('build/all.gyp', test.ALL, chdir='relocate/noload', + arguments=['NO_LOAD=lib']) +test.run_built_executable('exe', chdir='relocate/noload', + stdout='Hello from shared.c.\n') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/make/main.cc b/Source/ThirdParty/gyp/test/make/main.cc new file mode 100644 index 000000000..70ac6e46a --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/main.cc @@ -0,0 +1,12 @@ +/* Copyright (c) 2009 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> + +#include "main.h" + +int main(int argc, char *argv[]) { + printf("hello world\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/make/main.h b/Source/ThirdParty/gyp/test/make/main.h new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/main.h diff --git a/Source/ThirdParty/gyp/test/make/noload/all.gyp b/Source/ThirdParty/gyp/test/make/noload/all.gyp new file mode 100644 index 000000000..1617a9e97 --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/noload/all.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2010 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': 'exe', + 'type': 'executable', + 'sources': [ + 'main.c', + ], + 'dependencies': [ + 'lib/shared.gyp:shared', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/make/noload/lib/shared.c b/Source/ThirdParty/gyp/test/make/noload/lib/shared.c new file mode 100644 index 000000000..51776c5ac --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/noload/lib/shared.c @@ -0,0 +1,3 @@ +#include "shared.h" + +const char kSharedStr[] = "shared.c"; diff --git a/Source/ThirdParty/gyp/test/make/noload/lib/shared.gyp b/Source/ThirdParty/gyp/test/make/noload/lib/shared.gyp new file mode 100644 index 000000000..8a8841b3a --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/noload/lib/shared.gyp @@ -0,0 +1,16 @@ +# Copyright (c) 2009 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': 'shared', + 'type': 'shared_library', + 'sources': [ + 'shared.c', + 'shared.h', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/make/noload/lib/shared.h b/Source/ThirdParty/gyp/test/make/noload/lib/shared.h new file mode 100644 index 000000000..a21da7538 --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/noload/lib/shared.h @@ -0,0 +1 @@ +extern const char kSharedStr[]; diff --git a/Source/ThirdParty/gyp/test/make/noload/main.c b/Source/ThirdParty/gyp/test/make/noload/main.c new file mode 100644 index 000000000..46d3c52c2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/make/noload/main.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +#include "lib/shared.h" + +int main(int argc, char *argv[]) +{ + printf("Hello from %s.\n", kSharedStr); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/module/gyptest-default.py b/Source/ThirdParty/gyp/test/module/gyptest-default.py new file mode 100644 index 000000000..6b1c9b6a8 --- /dev/null +++ b/Source/ThirdParty/gyp/test/module/gyptest-default.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 simple build of a "Hello, world!" program with loadable modules. The +default for all platforms should be to output the loadable modules to the same +path as the executable. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('module.gyp', chdir='src') + +test.build('module.gyp', test.ALL, chdir='src') + +expect = """\ +Hello from program.c +Hello from lib1.c +Hello from lib2.c +""" +test.run_built_executable('program', chdir='src', stdout=expect) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/module/src/lib1.c b/Source/ThirdParty/gyp/test/module/src/lib1.c new file mode 100644 index 000000000..8de0e94be --- /dev/null +++ b/Source/ThirdParty/gyp/test/module/src/lib1.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif +void module_main(void) +{ + fprintf(stdout, "Hello from lib1.c\n"); + fflush(stdout); +} diff --git a/Source/ThirdParty/gyp/test/module/src/lib2.c b/Source/ThirdParty/gyp/test/module/src/lib2.c new file mode 100644 index 000000000..266396dc9 --- /dev/null +++ b/Source/ThirdParty/gyp/test/module/src/lib2.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif +void module_main(void) +{ + fprintf(stdout, "Hello from lib2.c\n"); + fflush(stdout); +} diff --git a/Source/ThirdParty/gyp/test/module/src/module.gyp b/Source/ThirdParty/gyp/test/module/src/module.gyp new file mode 100644 index 000000000..bb43c3023 --- /dev/null +++ b/Source/ThirdParty/gyp/test/module/src/module.gyp @@ -0,0 +1,55 @@ +# Copyright (c) 2009 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. + +{ + 'target_defaults': { + 'conditions': [ + ['OS=="win"', { + 'defines': ['PLATFORM_WIN'], + }], + ['OS=="mac"', { + 'defines': ['PLATFORM_MAC'], + }], + ['OS=="linux"', { + 'defines': ['PLATFORM_LINUX'], + # Support 64-bit shared libs (also works fine for 32-bit). + 'cflags': ['-fPIC'], + 'ldflags': ['-ldl'], + }], + ], + }, + 'targets': [ + { + 'target_name': 'program', + 'type': 'executable', + 'dependencies': [ + 'lib1', + 'lib2', + ], + 'sources': [ + 'program.c', + ], + }, + { + 'target_name': 'lib1', + 'type': 'loadable_module', + 'product_name': 'lib1', + 'product_prefix': '', + 'xcode_settings': {'OTHER_LDFLAGS': ['-dynamiclib'], 'MACH_O_TYPE': ''}, + 'sources': [ + 'lib1.c', + ], + }, + { + 'target_name': 'lib2', + 'product_name': 'lib2', + 'product_prefix': '', + 'type': 'loadable_module', + 'xcode_settings': {'OTHER_LDFLAGS': ['-dynamiclib'], 'MACH_O_TYPE': ''}, + 'sources': [ + 'lib2.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/module/src/program.c b/Source/ThirdParty/gyp/test/module/src/program.c new file mode 100644 index 000000000..b2f332091 --- /dev/null +++ b/Source/ThirdParty/gyp/test/module/src/program.c @@ -0,0 +1,111 @@ +#include <stdio.h> +#include <stdlib.h> + +#if defined(PLATFORM_WIN) +#include <windows.h> +#elif defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) +#include <dlfcn.h> +#include <libgen.h> +#include <string.h> +#include <sys/param.h> +#define MAX_PATH PATH_MAX +#endif + +#if defined(PLATFORM_WIN) +#define MODULE_SUFFIX ".dll" +#elif defined(PLATFORM_MAC) +#define MODULE_SUFFIX ".so" +#elif defined(PLATFORM_LINUX) +#define MODULE_SUFFIX ".so" +#endif + +typedef void (*module_symbol)(void); +char bin_path[MAX_PATH + 1]; + + +void CallModule(const char* module) { + char module_path[MAX_PATH + 1]; + const char* module_function = "module_main"; + module_symbol funcptr; +#if defined(PLATFORM_WIN) + HMODULE dl; + char drive[_MAX_DRIVE]; + char dir[_MAX_DIR]; + + if (_splitpath_s(bin_path, drive, _MAX_DRIVE, dir, _MAX_DIR, + NULL, 0, NULL, 0)) { + fprintf(stderr, "Failed to split executable path.\n"); + return; + } + if (_makepath_s(module_path, MAX_PATH, drive, dir, module, MODULE_SUFFIX)) { + fprintf(stderr, "Failed to calculate module path.\n"); + return; + } + + dl = LoadLibrary(module_path); + if (!dl) { + fprintf(stderr, "Failed to open module: %s\n", module_path); + return; + } + + funcptr = (module_symbol) GetProcAddress(dl, module_function); + if (!funcptr) { + fprintf(stderr, "Failed to find symbol: %s\n", module_function); + return; + } + funcptr(); + + FreeLibrary(dl); +#elif defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) + void* dl; + char* path_copy = strdup(bin_path); + char* bin_dir = dirname(path_copy); + int path_size = snprintf(module_path, MAX_PATH, "%s/%s%s", bin_dir, module, + MODULE_SUFFIX); + free(path_copy); + if (path_size < 0 || path_size > MAX_PATH) { + fprintf(stderr, "Failed to calculate module path.\n"); + return; + } + module_path[path_size] = 0; + + dl = dlopen(module_path, RTLD_LAZY); + if (!dl) { + fprintf(stderr, "Failed to open module: %s\n", module_path); + return; + } + + funcptr = dlsym(dl, module_function); + if (!funcptr) { + fprintf(stderr, "Failed to find symbol: %s\n", module_function); + return; + } + funcptr(); + + dlclose(dl); +#endif +} + +int main(int argc, char *argv[]) +{ + fprintf(stdout, "Hello from program.c\n"); + fflush(stdout); + +#if defined(PLATFORM_WIN) + if (!GetModuleFileName(NULL, bin_path, MAX_PATH)) { + fprintf(stderr, "Failed to determine executable path.\n"); + return; + } +#elif defined(PLATFORM_MAC) || defined(PLATFORM_LINUX) + // Using argv[0] should be OK here since we control how the tests run, and + // can avoid exec and such issues that make it unreliable. + if (!realpath(argv[0], bin_path)) { + fprintf(stderr, "Failed to determine executable path (%s).\n", argv[0]); + return; + } +#endif + + CallModule("lib1"); + CallModule("lib2"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/msvs/express/base/base.gyp b/Source/ThirdParty/gyp/test/msvs/express/base/base.gyp new file mode 100644 index 000000000..b7c9fc6d8 --- /dev/null +++ b/Source/ThirdParty/gyp/test/msvs/express/base/base.gyp @@ -0,0 +1,22 @@ +# Copyright (c) 2009 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': 'a', + 'type': 'static_library', + 'sources': [ + 'a.c', + ], + }, + { + 'target_name': 'b', + 'type': 'static_library', + 'sources': [ + 'b.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/msvs/express/express.gyp b/Source/ThirdParty/gyp/test/msvs/express/express.gyp new file mode 100644 index 000000000..917abe2cc --- /dev/null +++ b/Source/ThirdParty/gyp/test/msvs/express/express.gyp @@ -0,0 +1,19 @@ +# Copyright (c) 2009 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': 'express', + 'type': 'executable', + 'dependencies': [ + 'base/base.gyp:a', + 'base/base.gyp:b', + ], + 'sources': [ + 'main.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/msvs/express/gyptest-express.py b/Source/ThirdParty/gyp/test/msvs/express/gyptest-express.py new file mode 100644 index 000000000..54c06f664 --- /dev/null +++ b/Source/ThirdParty/gyp/test/msvs/express/gyptest-express.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 flat solutions get generated for Express versions of +Visual Studio. +""" + +import TestGyp + +test = TestGyp.TestGyp(formats=['msvs']) + +test.run_gyp('express.gyp', '-G', 'msvs_version=2005') +test.must_contain('express.sln', '(base)') + +test.run_gyp('express.gyp', '-G', 'msvs_version=2008') +test.must_contain('express.sln', '(base)') + +test.run_gyp('express.gyp', '-G', 'msvs_version=2005e') +test.must_not_contain('express.sln', '(base)') + +test.run_gyp('express.gyp', '-G', 'msvs_version=2008e') +test.must_not_contain('express.sln', '(base)') + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/msvs/precompiled/gyptest-all.py b/Source/ThirdParty/gyp/test/msvs/precompiled/gyptest-all.py new file mode 100644 index 000000000..c8d566afe --- /dev/null +++ b/Source/ThirdParty/gyp/test/msvs/precompiled/gyptest-all.py @@ -0,0 +1,23 @@ +#!/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 that precompiled headers can be specified. +""" + +import TestGyp + +test = TestGyp.TestGyp(formats=['msvs']) + +test.run_gyp('hello.gyp') + +test.build('hello.gyp', 'hello') + +test.run_built_executable('hello', stdout="Hello, world!\nHello, two!\n") + +test.up_to_date('hello.gyp', test.ALL) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/msvs/precompiled/hello.c b/Source/ThirdParty/gyp/test/msvs/precompiled/hello.c new file mode 100644 index 000000000..d1abbb9e5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/msvs/precompiled/hello.c @@ -0,0 +1,14 @@ +/* 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. */ + +// Note the abscence of a stdio.h include. This will be inserted because of the +// precompiled header. + +extern int hello2(); + +int main(int argc, char *argv[]) { + printf("Hello, world!\n"); + hello2(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/msvs/precompiled/hello.gyp b/Source/ThirdParty/gyp/test/msvs/precompiled/hello.gyp new file mode 100644 index 000000000..b9533efd8 --- /dev/null +++ b/Source/ThirdParty/gyp/test/msvs/precompiled/hello.gyp @@ -0,0 +1,19 @@ +# 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. + +{ + 'targets': [ + { + 'target_name': 'hello', + 'type': 'executable', + 'sources': [ + 'hello.c', + 'hello2.c', + 'precomp.c', + ], + 'msvs_precompiled_header': 'stdio.h', + 'msvs_precompiled_source': 'precomp.c', + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/msvs/precompiled/hello2.c b/Source/ThirdParty/gyp/test/msvs/precompiled/hello2.c new file mode 100644 index 000000000..d6d53111f --- /dev/null +++ b/Source/ThirdParty/gyp/test/msvs/precompiled/hello2.c @@ -0,0 +1,13 @@ +/* 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. */ + +// Unlike hello.c, this file specifies the headers. + +#include <windows.h> +#include <stdio.h> + +int hello2() { + printf("Hello, two!\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/msvs/precompiled/precomp.c b/Source/ThirdParty/gyp/test/msvs/precompiled/precomp.c new file mode 100644 index 000000000..517c61a36 --- /dev/null +++ b/Source/ThirdParty/gyp/test/msvs/precompiled/precomp.c @@ -0,0 +1,8 @@ +/* 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. */ + +// The precompiled header does not have to be the first one in the file. + +#include <windows.h> +#include <stdio.h> diff --git a/Source/ThirdParty/gyp/test/multiple-targets/gyptest-all.py b/Source/ThirdParty/gyp/test/multiple-targets/gyptest-all.py new file mode 100644 index 000000000..9f157c4f8 --- /dev/null +++ b/Source/ThirdParty/gyp/test/multiple-targets/gyptest-all.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('multiple.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +# TODO(sgk): remove stderr=None when the --generator-output= support +# gets rid of the scons warning +test.build('multiple.gyp', test.ALL, chdir='relocate/src', stderr=None) + +expect1 = """\ +hello from prog1.c +hello from common.c +""" + +expect2 = """\ +hello from prog2.c +hello from common.c +""" + +test.run_built_executable('prog1', stdout=expect1, chdir='relocate/src') +test.run_built_executable('prog2', stdout=expect2, chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/multiple-targets/gyptest-default.py b/Source/ThirdParty/gyp/test/multiple-targets/gyptest-default.py new file mode 100644 index 000000000..8d5072d23 --- /dev/null +++ b/Source/ThirdParty/gyp/test/multiple-targets/gyptest-default.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('multiple.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +# TODO(sgk): remove stderr=None when the --generator-output= support +# gets rid of the scons warning +test.build('multiple.gyp', chdir='relocate/src', stderr=None) + +expect1 = """\ +hello from prog1.c +hello from common.c +""" + +expect2 = """\ +hello from prog2.c +hello from common.c +""" + +test.run_built_executable('prog1', stdout=expect1, chdir='relocate/src') +test.run_built_executable('prog2', stdout=expect2, chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/multiple-targets/src/common.c b/Source/ThirdParty/gyp/test/multiple-targets/src/common.c new file mode 100644 index 000000000..f1df7c143 --- /dev/null +++ b/Source/ThirdParty/gyp/test/multiple-targets/src/common.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +void common(void) +{ + printf("hello from common.c\n"); + return; +} diff --git a/Source/ThirdParty/gyp/test/multiple-targets/src/multiple.gyp b/Source/ThirdParty/gyp/test/multiple-targets/src/multiple.gyp new file mode 100644 index 000000000..3db4ea30c --- /dev/null +++ b/Source/ThirdParty/gyp/test/multiple-targets/src/multiple.gyp @@ -0,0 +1,24 @@ +# Copyright (c) 2009 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': 'prog1', + 'type': 'executable', + 'sources': [ + 'prog1.c', + 'common.c', + ], + }, + { + 'target_name': 'prog2', + 'type': 'executable', + 'sources': [ + 'prog2.c', + 'common.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/multiple-targets/src/prog1.c b/Source/ThirdParty/gyp/test/multiple-targets/src/prog1.c new file mode 100644 index 000000000..d55f8af1d --- /dev/null +++ b/Source/ThirdParty/gyp/test/multiple-targets/src/prog1.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void common(void); + +int main(int argc, char *argv[]) +{ + printf("hello from prog1.c\n"); + common(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/multiple-targets/src/prog2.c b/Source/ThirdParty/gyp/test/multiple-targets/src/prog2.c new file mode 100644 index 000000000..760590eb6 --- /dev/null +++ b/Source/ThirdParty/gyp/test/multiple-targets/src/prog2.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void common(void); + +int main(int argc, char *argv[]) +{ + printf("hello from prog2.c\n"); + common(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/no-output/gyptest-no-output.py b/Source/ThirdParty/gyp/test/no-output/gyptest-no-output.py new file mode 100644 index 000000000..8431241c5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/no-output/gyptest-no-output.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Verified things don't explode when there are targets without outputs. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('nooutput.gyp', chdir='src') +test.relocate('src', 'relocate/src') +test.build('nooutput.gyp', chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/no-output/src/nooutput.gyp b/Source/ThirdParty/gyp/test/no-output/src/nooutput.gyp new file mode 100644 index 000000000..c40124efc --- /dev/null +++ b/Source/ThirdParty/gyp/test/no-output/src/nooutput.gyp @@ -0,0 +1,17 @@ +# Copyright (c) 2009 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': 'no_output', + 'type': 'none', + 'direct_dependent_settings': { + 'defines': [ + 'NADA', + ], + }, + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/product/gyptest-product.py b/Source/ThirdParty/gyp/test/product/gyptest-product.py new file mode 100644 index 000000000..e9790f30d --- /dev/null +++ b/Source/ThirdParty/gyp/test/product/gyptest-product.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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() + +test.run_gyp('product.gyp') +test.build('product.gyp') + +# executables +test.built_file_must_exist('alt1' + test._exe, test.EXECUTABLE, bare=True) +test.built_file_must_exist('hello2.stuff', test.EXECUTABLE, bare=True) +test.built_file_must_exist('yoalt3.stuff', test.EXECUTABLE, bare=True) + +# shared libraries +test.built_file_must_exist(test.dll_ + 'alt4' + test._dll, + test.SHARED_LIB, bare=True) +test.built_file_must_exist(test.dll_ + 'hello5.stuff', + test.SHARED_LIB, bare=True) +test.built_file_must_exist('yoalt6.stuff', test.SHARED_LIB, bare=True) + +# static libraries +test.built_file_must_exist(test.lib_ + 'alt7' + test._lib, + test.STATIC_LIB, bare=True) +test.built_file_must_exist(test.lib_ + 'hello8.stuff', + test.STATIC_LIB, bare=True) +test.built_file_must_exist('yoalt9.stuff', test.STATIC_LIB, bare=True) + +# alternate product_dir +test.built_file_must_exist('bob/yoalt10.stuff', test.EXECUTABLE, bare=True) +test.built_file_must_exist('bob/yoalt11.stuff', test.EXECUTABLE, bare=True) +test.built_file_must_exist('bob/yoalt12.stuff', test.EXECUTABLE, bare=True) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/product/hello.c b/Source/ThirdParty/gyp/test/product/hello.c new file mode 100644 index 000000000..94798f3e7 --- /dev/null +++ b/Source/ThirdParty/gyp/test/product/hello.c @@ -0,0 +1,15 @@ +/* Copyright (c) 2009 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> + +int func1(void) { + return 42; +} + +int main(int argc, char *argv[]) { + printf("Hello, world!\n"); + printf("%d\n", func1()); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/product/product.gyp b/Source/ThirdParty/gyp/test/product/product.gyp new file mode 100644 index 000000000..c25eaaacb --- /dev/null +++ b/Source/ThirdParty/gyp/test/product/product.gyp @@ -0,0 +1,128 @@ +# Copyright (c) 2009 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': 'hello1', + 'product_name': 'alt1', + 'type': 'executable', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello2', + 'product_extension': 'stuff', + 'type': 'executable', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello3', + 'product_name': 'alt3', + 'product_extension': 'stuff', + 'product_prefix': 'yo', + 'type': 'executable', + 'sources': [ + 'hello.c', + ], + }, + + { + 'target_name': 'hello4', + 'product_name': 'alt4', + 'type': 'shared_library', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello5', + 'product_extension': 'stuff', + 'type': 'shared_library', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello6', + 'product_name': 'alt6', + 'product_extension': 'stuff', + 'product_prefix': 'yo', + 'type': 'shared_library', + 'sources': [ + 'hello.c', + ], + }, + + { + 'target_name': 'hello7', + 'product_name': 'alt7', + 'type': 'static_library', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello8', + 'product_extension': 'stuff', + 'type': 'static_library', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello9', + 'product_name': 'alt9', + 'product_extension': 'stuff', + 'product_prefix': 'yo', + 'type': 'static_library', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello10', + 'product_name': 'alt10', + 'product_extension': 'stuff', + 'product_prefix': 'yo', + 'product_dir': '<(PRODUCT_DIR)/bob', + 'type': 'executable', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello11', + 'product_name': 'alt11', + 'product_extension': 'stuff', + 'product_prefix': 'yo', + 'product_dir': '<(PRODUCT_DIR)/bob', + 'type': 'shared_library', + 'sources': [ + 'hello.c', + ], + }, + { + 'target_name': 'hello12', + 'product_name': 'alt12', + 'product_extension': 'stuff', + 'product_prefix': 'yo', + 'product_dir': '<(PRODUCT_DIR)/bob', + 'type': 'static_library', + 'sources': [ + 'hello.c', + ], + }, + ], + 'conditions': [ + ['OS=="linux"', { + 'target_defaults': { + 'cflags': ['-fPIC'], + }, + }], + ], +} diff --git a/Source/ThirdParty/gyp/test/rules-rebuild/gyptest-all.py b/Source/ThirdParty/gyp/test/rules-rebuild/gyptest-all.py new file mode 100644 index 000000000..ec1c74661 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules-rebuild/gyptest-all.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 a rule that generates multiple outputs rebuilds +correctly when the inputs change. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('same_target.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + + +test.build('same_target.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from main.c +Hello from prog1.in! +Hello from prog2.in! +""" + +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + +test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') + + +test.sleep() +contents = test.read(['relocate', 'src', 'prog1.in']) +contents = contents.replace('!', ' AGAIN!') +test.write(['relocate', 'src', 'prog1.in'], contents) + +test.build('same_target.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from main.c +Hello from prog1.in AGAIN! +Hello from prog2.in! +""" + +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + +test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') + + +test.sleep() +contents = test.read(['relocate', 'src', 'prog2.in']) +contents = contents.replace('!', ' AGAIN!') +test.write(['relocate', 'src', 'prog2.in'], contents) + +test.build('same_target.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from main.c +Hello from prog1.in AGAIN! +Hello from prog2.in AGAIN! +""" + +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + +test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/rules-rebuild/gyptest-default.py b/Source/ThirdParty/gyp/test/rules-rebuild/gyptest-default.py new file mode 100644 index 000000000..74440d157 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules-rebuild/gyptest-default.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 a rule that generates multiple outputs rebuilds +correctly when the inputs change. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('same_target.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + + +test.build('same_target.gyp', chdir='relocate/src') + +expect = """\ +Hello from main.c +Hello from prog1.in! +Hello from prog2.in! +""" + +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + +test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') + + +test.sleep() +contents = test.read(['relocate', 'src', 'prog1.in']) +contents = contents.replace('!', ' AGAIN!') +test.write(['relocate', 'src', 'prog1.in'], contents) + +test.build('same_target.gyp', chdir='relocate/src') + +expect = """\ +Hello from main.c +Hello from prog1.in AGAIN! +Hello from prog2.in! +""" + +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + +test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') + + +test.sleep() +contents = test.read(['relocate', 'src', 'prog2.in']) +contents = contents.replace('!', ' AGAIN!') +test.write(['relocate', 'src', 'prog2.in'], contents) + +test.build('same_target.gyp', chdir='relocate/src') + +expect = """\ +Hello from main.c +Hello from prog1.in AGAIN! +Hello from prog2.in AGAIN! +""" + +test.run_built_executable('program', chdir='relocate/src', stdout=expect) + +test.up_to_date('same_target.gyp', 'program', chdir='relocate/src') + + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/rules-rebuild/src/main.c b/Source/ThirdParty/gyp/test/rules-rebuild/src/main.c new file mode 100644 index 000000000..bdc5ec875 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules-rebuild/src/main.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +extern void prog1(void); +extern void prog2(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from main.c\n"); + prog1(); + prog2(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/rules-rebuild/src/make-sources.py b/Source/ThirdParty/gyp/test/rules-rebuild/src/make-sources.py new file mode 100644 index 000000000..6fce558b2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules-rebuild/src/make-sources.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import sys + +assert len(sys.argv) == 4, sys.argv + +(in_file, c_file, h_file) = sys.argv[1:] + +def write_file(filename, contents): + open(filename, 'wb').write(contents) + +write_file(c_file, open(in_file, 'rb').read()) + +write_file(h_file, '#define NAME "%s"\n' % in_file) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/rules-rebuild/src/prog1.in b/Source/ThirdParty/gyp/test/rules-rebuild/src/prog1.in new file mode 100644 index 000000000..191b00ef1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules-rebuild/src/prog1.in @@ -0,0 +1,7 @@ +#include <stdio.h> +#include "prog1.h" + +void prog1(void) +{ + printf("Hello from %s!\n", NAME); +} diff --git a/Source/ThirdParty/gyp/test/rules-rebuild/src/prog2.in b/Source/ThirdParty/gyp/test/rules-rebuild/src/prog2.in new file mode 100644 index 000000000..7bfac5104 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules-rebuild/src/prog2.in @@ -0,0 +1,7 @@ +#include <stdio.h> +#include "prog2.h" + +void prog2(void) +{ + printf("Hello from %s!\n", NAME); +} diff --git a/Source/ThirdParty/gyp/test/rules-rebuild/src/same_target.gyp b/Source/ThirdParty/gyp/test/rules-rebuild/src/same_target.gyp new file mode 100644 index 000000000..22ba56056 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules-rebuild/src/same_target.gyp @@ -0,0 +1,31 @@ +{ + 'targets': [ + { + 'target_name': 'program', + 'type': 'executable', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'main.c', + 'prog1.in', + 'prog2.in', + ], + 'rules': [ + { + 'rule_name': 'make_sources', + 'extension': 'in', + 'inputs': [ + 'make-sources.py', + ], + 'outputs': [ + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c', + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).h', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_NAME)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/rules/gyptest-all.py b/Source/ThirdParty/gyp/test/rules/gyptest-all.py new file mode 100644 index 000000000..8a69d6040 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/gyptest-all.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 simple rules when using an explicit build target of 'all'. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('actions.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('actions.gyp', test.ALL, chdir='relocate/src') + +expect = """\ +Hello from program.c +Hello from function1.in +Hello from function2.in +""" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir1' +else: + chdir = 'relocate/src' +test.run_built_executable('program', chdir=chdir, stdout=expect) + +expect = """\ +Hello from program.c +Hello from function3.in +""" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir3' +else: + chdir = 'relocate/src' +test.run_built_executable('program2', chdir=chdir, stdout=expect) + +test.must_match('relocate/src/subdir2/file1.out', "Hello from file1.in\n") +test.must_match('relocate/src/subdir2/file2.out', "Hello from file2.in\n") + +test.must_match('relocate/src/subdir2/file1.out2', "Hello from file1.in\n") +test.must_match('relocate/src/subdir2/file2.out2', "Hello from file2.in\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/rules/gyptest-default.py b/Source/ThirdParty/gyp/test/rules/gyptest-default.py new file mode 100644 index 000000000..ef5fc61fd --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/gyptest-default.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 simple rules when using an explicit build target of 'all'. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('actions.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('actions.gyp', chdir='relocate/src') + +expect = """\ +Hello from program.c +Hello from function1.in +Hello from function2.in +""" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir1' +else: + chdir = 'relocate/src' +test.run_built_executable('program', chdir=chdir, stdout=expect) + +expect = """\ +Hello from program.c +Hello from function3.in +""" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir3' +else: + chdir = 'relocate/src' +test.run_built_executable('program2', chdir=chdir, stdout=expect) + +test.must_match('relocate/src/subdir2/file1.out', "Hello from file1.in\n") +test.must_match('relocate/src/subdir2/file2.out', "Hello from file2.in\n") + +test.must_match('relocate/src/subdir2/file1.out2', "Hello from file1.in\n") +test.must_match('relocate/src/subdir2/file2.out2', "Hello from file2.in\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/rules/src/actions.gyp b/Source/ThirdParty/gyp/test/rules/src/actions.gyp new file mode 100644 index 000000000..d5c32cf6c --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/actions.gyp @@ -0,0 +1,19 @@ +# Copyright (c) 2009 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': 'pull_in_all_actions', + 'type': 'none', + 'dependencies': [ + 'subdir1/executable.gyp:*', + 'subdir2/never_used.gyp:*', + 'subdir2/no_inputs.gyp:*', + 'subdir2/none.gyp:*', + 'subdir3/executable2.gyp:*', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/rules/src/copy-file.py b/Source/ThirdParty/gyp/test/rules/src/copy-file.py new file mode 100644 index 000000000..5a5feae1f --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/copy-file.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. +import sys + +contents = open(sys.argv[1], 'r').read() +open(sys.argv[2], 'wb').write(contents) + +sys.exit(0) diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir1/executable.gyp b/Source/ThirdParty/gyp/test/rules/src/subdir1/executable.gyp new file mode 100644 index 000000000..302857789 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir1/executable.gyp @@ -0,0 +1,37 @@ +# Copyright (c) 2009 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': 'program', + 'type': 'executable', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'program.c', + 'function1.in', + 'function2.in', + ], + 'rules': [ + { + 'rule_name': 'copy_file', + 'extension': 'in', + 'inputs': [ + '../copy-file.py', + ], + 'outputs': [ + # TODO: fix SCons and Make to support generated files not + # in a variable-named path like <(INTERMEDIATE_DIR) + #'<(RULE_INPUT_ROOT).c', + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).c', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir1/function1.in b/Source/ThirdParty/gyp/test/rules/src/subdir1/function1.in new file mode 100644 index 000000000..60ff28949 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir1/function1.in @@ -0,0 +1,6 @@ +#include <stdio.h> + +void function1(void) +{ + printf("Hello from function1.in\n"); +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir1/function2.in b/Source/ThirdParty/gyp/test/rules/src/subdir1/function2.in new file mode 100644 index 000000000..0fcfc03fd --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir1/function2.in @@ -0,0 +1,6 @@ +#include <stdio.h> + +void function2(void) +{ + printf("Hello from function2.in\n"); +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir1/program.c b/Source/ThirdParty/gyp/test/rules/src/subdir1/program.c new file mode 100644 index 000000000..258d7f99e --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir1/program.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +extern void function1(void); +extern void function2(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from program.c\n"); + function1(); + function2(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir2/file1.in b/Source/ThirdParty/gyp/test/rules/src/subdir2/file1.in new file mode 100644 index 000000000..86ac3ad38 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir2/file1.in @@ -0,0 +1 @@ +Hello from file1.in diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir2/file2.in b/Source/ThirdParty/gyp/test/rules/src/subdir2/file2.in new file mode 100644 index 000000000..bf83d8ece --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir2/file2.in @@ -0,0 +1 @@ +Hello from file2.in diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir2/never_used.gyp b/Source/ThirdParty/gyp/test/rules/src/subdir2/never_used.gyp new file mode 100644 index 000000000..17f6f5537 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir2/never_used.gyp @@ -0,0 +1,31 @@ +# Copyright (c) 2009 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 that the case where there is a rule that doesn't apply to anything. +{ + 'targets': [ + { + 'target_name': 'files_no_input2', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'file1.in', + 'file2.in', + ], + 'rules': [ + { + 'rule_name': 'copy_file3', + 'extension': 'in2', + 'outputs': [ + '<(RULE_INPUT_ROOT).out3', + ], + 'action': [ + 'python', '../copy-file.py', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir2/no_inputs.gyp b/Source/ThirdParty/gyp/test/rules/src/subdir2/no_inputs.gyp new file mode 100644 index 000000000..e61a1a3ff --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir2/no_inputs.gyp @@ -0,0 +1,32 @@ +# Copyright (c) 2009 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 that the case where there are no inputs (other than the +# file the rule applies to). +{ + 'targets': [ + { + 'target_name': 'files_no_input', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'file1.in', + 'file2.in', + ], + 'rules': [ + { + 'rule_name': 'copy_file2', + 'extension': 'in', + 'outputs': [ + '<(RULE_INPUT_ROOT).out2', + ], + 'action': [ + 'python', '../copy-file.py', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir2/none.gyp b/Source/ThirdParty/gyp/test/rules/src/subdir2/none.gyp new file mode 100644 index 000000000..38bcdabdf --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir2/none.gyp @@ -0,0 +1,33 @@ +# Copyright (c) 2009 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': 'files', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'file1.in', + 'file2.in', + ], + 'rules': [ + { + 'rule_name': 'copy_file', + 'extension': 'in', + 'inputs': [ + '../copy-file.py', + ], + 'outputs': [ + '<(RULE_INPUT_ROOT).out', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir3/executable2.gyp b/Source/ThirdParty/gyp/test/rules/src/subdir3/executable2.gyp new file mode 100644 index 000000000..a2a528fc7 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir3/executable2.gyp @@ -0,0 +1,37 @@ +# Copyright (c) 2009 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. + +# This one tests that rules are properly written if extensions are different +# between the target's sources (program.c) and the generated files +# (function3.cc) + +{ + 'targets': [ + { + 'target_name': 'program2', + 'type': 'executable', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'program.c', + 'function3.in', + ], + 'rules': [ + { + 'rule_name': 'copy_file', + 'extension': 'in', + 'inputs': [ + '../copy-file.py', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).cc', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir3/function3.in b/Source/ThirdParty/gyp/test/rules/src/subdir3/function3.in new file mode 100644 index 000000000..99f46ab05 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir3/function3.in @@ -0,0 +1,6 @@ +#include <stdio.h> + +extern "C" void function3(void) +{ + printf("Hello from function3.in\n"); +} diff --git a/Source/ThirdParty/gyp/test/rules/src/subdir3/program.c b/Source/ThirdParty/gyp/test/rules/src/subdir3/program.c new file mode 100644 index 000000000..94f6c5091 --- /dev/null +++ b/Source/ThirdParty/gyp/test/rules/src/subdir3/program.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void function3(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from program.c\n"); + function3(); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/same-gyp-name/gyptest-all.py b/Source/ThirdParty/gyp/test/same-gyp-name/gyptest-all.py new file mode 100644 index 000000000..76456885e --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-gyp-name/gyptest-all.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Build a .gyp that depends on 2 gyp files with the same name. +""" + +import TestGyp + +# This causes a problem on XCode (duplicate ID). +# See http://code.google.com/p/gyp/issues/detail?id=114 +test = TestGyp.TestGyp(formats=['msvs', 'scons', 'make']) + +test.run_gyp('all.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('all.gyp', test.ALL, chdir='relocate/src') + +expect1 = """\ +Hello from main1.cc +""" + +expect2 = """\ +Hello from main2.cc +""" + +test.run_built_executable('program1', chdir='relocate/src', stdout=expect1) +test.run_built_executable('program2', chdir='relocate/src', stdout=expect2) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/same-gyp-name/gyptest-default.py b/Source/ThirdParty/gyp/test/same-gyp-name/gyptest-default.py new file mode 100644 index 000000000..c1031f86b --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-gyp-name/gyptest-default.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Build a .gyp that depends on 2 gyp files with the same name. +""" + +import TestGyp + +# This causes a problem on XCode (duplicate ID). +# See http://code.google.com/p/gyp/issues/detail?id=114 +test = TestGyp.TestGyp(formats=['msvs', 'scons', 'make']) + +test.run_gyp('all.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('all.gyp', chdir='relocate/src') + +expect1 = """\ +Hello from main1.cc +""" + +expect2 = """\ +Hello from main2.cc +""" + +test.run_built_executable('program1', chdir='relocate/src', stdout=expect1) +test.run_built_executable('program2', chdir='relocate/src', stdout=expect2) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/same-gyp-name/src/all.gyp b/Source/ThirdParty/gyp/test/same-gyp-name/src/all.gyp new file mode 100644 index 000000000..229f02ea8 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-gyp-name/src/all.gyp @@ -0,0 +1,16 @@ +# Copyright (c) 2009 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': 'all_exes', + 'type': 'none', + 'dependencies': [ + 'subdir1/executable.gyp:*', + 'subdir2/executable.gyp:*', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir1/executable.gyp b/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir1/executable.gyp new file mode 100644 index 000000000..82483b4c6 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir1/executable.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'program1', + 'type': 'executable', + 'sources': [ + 'main1.cc', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir1/main1.cc b/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir1/main1.cc new file mode 100644 index 000000000..364555832 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir1/main1.cc @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main() { + printf("Hello from main1.cc\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir2/executable.gyp b/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir2/executable.gyp new file mode 100644 index 000000000..e3537013e --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir2/executable.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'program2', + 'type': 'executable', + 'sources': [ + 'main2.cc', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir2/main2.cc b/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir2/main2.cc new file mode 100644 index 000000000..0c724dee3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-gyp-name/src/subdir2/main2.cc @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main() { + printf("Hello from main2.cc\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/same-name/gyptest-all.py b/Source/ThirdParty/gyp/test/same-name/gyptest-all.py new file mode 100644 index 000000000..4c215027c --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-name/gyptest-all.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Build a .gyp with two targets that share a common .c source file. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('all.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('all.gyp', test.ALL, chdir='relocate/src') + +expect1 = """\ +Hello from prog1.c +Hello prog1 from func.c +""" + +expect2 = """\ +Hello from prog2.c +Hello prog2 from func.c +""" + +test.run_built_executable('prog1', chdir='relocate/src', stdout=expect1) +test.run_built_executable('prog2', chdir='relocate/src', stdout=expect2) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/same-name/gyptest-default.py b/Source/ThirdParty/gyp/test/same-name/gyptest-default.py new file mode 100644 index 000000000..98757c269 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-name/gyptest-default.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Build a .gyp with two targets that share a common .c source file. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('all.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('all.gyp', chdir='relocate/src') + +expect1 = """\ +Hello from prog1.c +Hello prog1 from func.c +""" + +expect2 = """\ +Hello from prog2.c +Hello prog2 from func.c +""" + +test.run_built_executable('prog1', chdir='relocate/src', stdout=expect1) +test.run_built_executable('prog2', chdir='relocate/src', stdout=expect2) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/same-name/src/all.gyp b/Source/ThirdParty/gyp/test/same-name/src/all.gyp new file mode 100644 index 000000000..44e104982 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-name/src/all.gyp @@ -0,0 +1,38 @@ +# Copyright (c) 2009 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': 'prog1', + 'type': 'executable', + 'defines': [ + 'PROG="prog1"', + ], + 'sources': [ + 'prog1.c', + 'func.c', + # Uncomment to test same-named files in different directories, + # which Visual Studio doesn't support. + #'subdir1/func.c', + #'subdir2/func.c', + ], + }, + { + 'target_name': 'prog2', + 'type': 'executable', + 'defines': [ + 'PROG="prog2"', + ], + 'sources': [ + 'prog2.c', + 'func.c', + # Uncomment to test same-named files in different directories, + # which Visual Studio doesn't support. + #'subdir1/func.c', + #'subdir2/func.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/same-name/src/func.c b/Source/ThirdParty/gyp/test/same-name/src/func.c new file mode 100644 index 000000000..e069c692a --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-name/src/func.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void func(void) +{ + printf("Hello %s from func.c\n", PROG); +} diff --git a/Source/ThirdParty/gyp/test/same-name/src/prog1.c b/Source/ThirdParty/gyp/test/same-name/src/prog1.c new file mode 100644 index 000000000..c8940fedc --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-name/src/prog1.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +extern void func(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from prog1.c\n"); + func(); + /* + * Uncomment to test same-named files in different directories, + * which Visual Studio doesn't support. + subdir1_func(); + subdir2_func(); + */ + return 0; +} diff --git a/Source/ThirdParty/gyp/test/same-name/src/prog2.c b/Source/ThirdParty/gyp/test/same-name/src/prog2.c new file mode 100644 index 000000000..e6605c2bd --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-name/src/prog2.c @@ -0,0 +1,16 @@ +#include <stdio.h> + +extern void func(void); + +int main(int argc, char *argv[]) +{ + printf("Hello from prog2.c\n"); + func(); + /* + * Uncomment to test same-named files in different directories, + * which Visual Studio doesn't support. + subdir1_func(); + subdir2_func(); + */ + return 0; +} diff --git a/Source/ThirdParty/gyp/test/same-name/src/subdir1/func.c b/Source/ThirdParty/gyp/test/same-name/src/subdir1/func.c new file mode 100644 index 000000000..b73450d10 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-name/src/subdir1/func.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void subdir1_func(void) +{ + printf("Hello %s from subdir1/func.c\n", PROG); +} diff --git a/Source/ThirdParty/gyp/test/same-name/src/subdir2/func.c b/Source/ThirdParty/gyp/test/same-name/src/subdir2/func.c new file mode 100644 index 000000000..0248b5720 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-name/src/subdir2/func.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +void subdir2_func(void) +{ + printf("Hello %s from subdir2/func.c\n", PROG); +} diff --git a/Source/ThirdParty/gyp/test/same-target-name/gyptest-same-target-name.py b/Source/ThirdParty/gyp/test/same-target-name/gyptest-same-target-name.py new file mode 100644 index 000000000..bfe5540f3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-target-name/gyptest-same-target-name.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +# Copyright (c) 2010 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. + +""" +Check that duplicate targets in a directory gives an error. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +# Require that gyp files with duplicate targets spit out an error. +test.run_gyp('all.gyp', chdir='src', status=1, stderr=None) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/same-target-name/src/all.gyp b/Source/ThirdParty/gyp/test/same-target-name/src/all.gyp new file mode 100644 index 000000000..ac16976da --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-target-name/src/all.gyp @@ -0,0 +1,16 @@ +# Copyright (c) 2010 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': 'all_exes', + 'type': 'none', + 'dependencies': [ + 'executable1.gyp:*', + 'executable2.gyp:*', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/same-target-name/src/executable1.gyp b/Source/ThirdParty/gyp/test/same-target-name/src/executable1.gyp new file mode 100644 index 000000000..3c492c1b3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-target-name/src/executable1.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2010 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': 'program', + 'type': 'executable', + 'sources': [ + 'main1.cc', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/same-target-name/src/executable2.gyp b/Source/ThirdParty/gyp/test/same-target-name/src/executable2.gyp new file mode 100644 index 000000000..41e84a61c --- /dev/null +++ b/Source/ThirdParty/gyp/test/same-target-name/src/executable2.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2010 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': 'program', + 'type': 'executable', + 'sources': [ + 'main2.cc', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/scons_tools/gyptest-tools.py b/Source/ThirdParty/gyp/test/scons_tools/gyptest-tools.py new file mode 100755 index 000000000..e97f5e631 --- /dev/null +++ b/Source/ThirdParty/gyp/test/scons_tools/gyptest-tools.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 a scons build picks up tools modules specified +via 'scons_tools' in the 'scons_settings' dictionary. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('tools.gyp') + +test.build('tools.gyp', test.ALL) + +if test.format == 'scons': + expect = "Hello, world!\n" +else: + expect = "" +test.run_built_executable('tools', stdout=expect) + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/scons_tools/site_scons/site_tools/this_tool.py b/Source/ThirdParty/gyp/test/scons_tools/site_scons/site_tools/this_tool.py new file mode 100644 index 000000000..10c89476d --- /dev/null +++ b/Source/ThirdParty/gyp/test/scons_tools/site_scons/site_tools/this_tool.py @@ -0,0 +1,10 @@ +# Copyright (c) 2009 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. + +# SCons "tool" module that simply sets a -D value. +def generate(env): + env['CPPDEFINES'] = ['THIS_TOOL'] + +def exists(env): + pass diff --git a/Source/ThirdParty/gyp/test/scons_tools/tools.c b/Source/ThirdParty/gyp/test/scons_tools/tools.c new file mode 100644 index 000000000..78dc0e31e --- /dev/null +++ b/Source/ThirdParty/gyp/test/scons_tools/tools.c @@ -0,0 +1,13 @@ +/* Copyright (c) 2009 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> + +int main(int argc, char *argv[]) +{ +#ifdef THIS_TOOL + printf("Hello, world!\n"); +#endif + return 0; +} diff --git a/Source/ThirdParty/gyp/test/scons_tools/tools.gyp b/Source/ThirdParty/gyp/test/scons_tools/tools.gyp new file mode 100644 index 000000000..736ba3f22 --- /dev/null +++ b/Source/ThirdParty/gyp/test/scons_tools/tools.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2009 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': 'tools', + 'type': 'executable', + 'sources': [ + 'tools.c', + ], + }, + ], + 'scons_settings': { + 'tools': ['default', 'this_tool'], + }, +} diff --git a/Source/ThirdParty/gyp/test/sibling/gyptest-all.py b/Source/ThirdParty/gyp/test/sibling/gyptest-all.py new file mode 100644 index 000000000..c04c2d486 --- /dev/null +++ b/Source/ThirdParty/gyp/test/sibling/gyptest-all.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('build/all.gyp', chdir='src') + +test.build('build/all.gyp', test.ALL, chdir='src') + +chdir = 'src/build' + +# The top-level Makefile is in the directory where gyp was run. +# TODO(mmoss) Should the Makefile go in the directory of the passed in .gyp +# file? What about when passing in multiple .gyp files? Would sub-project +# Makefiles (see http://codereview.chromium.org/340008 comments) solve this? +if test.format == 'make': + chdir = 'src' + +if test.format == 'xcode': + chdir = 'src/prog1' +test.run_built_executable('prog1', + chdir=chdir, + stdout="Hello from prog1.c\n") + +if test.format == 'xcode': + chdir = 'src/prog2' +test.run_built_executable('prog2', + chdir=chdir, + stdout="Hello from prog2.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/sibling/gyptest-relocate.py b/Source/ThirdParty/gyp/test/sibling/gyptest-relocate.py new file mode 100644 index 000000000..176545fa6 --- /dev/null +++ b/Source/ThirdParty/gyp/test/sibling/gyptest-relocate.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('build/all.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('build/all.gyp', test.ALL, chdir='relocate/src') + +chdir = 'relocate/src/build' + +# The top-level Makefile is in the directory where gyp was run. +# TODO(mmoss) Should the Makefile go in the directory of the passed in .gyp +# file? What about when passing in multiple .gyp files? Would sub-project +# Makefiles (see http://codereview.chromium.org/340008 comments) solve this? +if test.format == 'make': + chdir = 'relocate/src' + +if test.format == 'xcode': + chdir = 'relocate/src/prog1' +test.run_built_executable('prog1', + chdir=chdir, + stdout="Hello from prog1.c\n") + +if test.format == 'xcode': + chdir = 'relocate/src/prog2' +test.run_built_executable('prog2', + chdir=chdir, + stdout="Hello from prog2.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/sibling/src/prog1/prog1.c b/Source/ThirdParty/gyp/test/sibling/src/prog1/prog1.c new file mode 100644 index 000000000..161ae8a38 --- /dev/null +++ b/Source/ThirdParty/gyp/test/sibling/src/prog1/prog1.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from prog1.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/sibling/src/prog1/prog1.gyp b/Source/ThirdParty/gyp/test/sibling/src/prog1/prog1.gyp new file mode 100644 index 000000000..fbe38b97a --- /dev/null +++ b/Source/ThirdParty/gyp/test/sibling/src/prog1/prog1.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'prog1', + 'type': 'executable', + 'sources': [ + 'prog1.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/sibling/src/prog2/prog2.c b/Source/ThirdParty/gyp/test/sibling/src/prog2/prog2.c new file mode 100644 index 000000000..7635ae8c1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/sibling/src/prog2/prog2.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from prog2.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/sibling/src/prog2/prog2.gyp b/Source/ThirdParty/gyp/test/sibling/src/prog2/prog2.gyp new file mode 100644 index 000000000..593454836 --- /dev/null +++ b/Source/ThirdParty/gyp/test/sibling/src/prog2/prog2.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'prog2', + 'type': 'executable', + 'sources': [ + 'prog2.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/small/gyptest-small.py b/Source/ThirdParty/gyp/test/small/gyptest-small.py new file mode 100755 index 000000000..38299b3a7 --- /dev/null +++ b/Source/ThirdParty/gyp/test/small/gyptest-small.py @@ -0,0 +1,49 @@ +#!/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. + +""" +Runs small tests. +""" + +import imp +import os +import sys +import unittest + +import TestGyp + + +test = TestGyp.TestGyp() + +# Add pylib/gyp to the import path (so tests can import their dependencies). +sys.path.append(os.path.join(test._cwd, 'pylib', 'gyp')) + +# Add new test suites here. +files_to_test = [ + 'pylib/gyp/MSVSSettings_test.py', + 'pylib/gyp/easy_xml_test.py', +] + +# Collect all the suites from the above files. +suites = [] +for filename in files_to_test: + # Carve the module name out of the path. + name = os.path.splitext(os.path.split(filename)[1])[0] + # Find the complete module path. + full_filename = os.path.join(test._cwd, filename) + # Load the module. + module = imp.load_source(name, full_filename) + # Add it to the list of test suites. + suites.append(unittest.defaultTestLoader.loadTestsFromModule(module)) +# Create combined suite. +all_tests = unittest.TestSuite(suites) + +# Run all the tests. +result = unittest.TextTestRunner(verbosity=2).run(all_tests) +if result.failures or result.errors: + test.fail_test() + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/subdirectory/gyptest-SYMROOT-all.py b/Source/ThirdParty/gyp/test/subdirectory/gyptest-SYMROOT-all.py new file mode 100644 index 000000000..b7509041a --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/gyptest-SYMROOT-all.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a target and a subsidiary dependent target from a +.gyp file in a subdirectory, without specifying an explicit output build +directory, and using the generated solution or project file at the top +of the tree as the entry point. + +The configuration sets the Xcode SYMROOT variable and uses --depth= +to make Xcode behave like the other build tools--that is, put all +built targets in a single output build directory at the top of the tree. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('prog1.gyp', '-Dset_symroot=1', '--depth=.', chdir='src') + +test.relocate('src', 'relocate/src') + +# Suppress the test infrastructure's setting SYMROOT on the command line. +test.build('prog1.gyp', test.ALL, SYMROOT=None, chdir='relocate/src') + +test.run_built_executable('prog1', + stdout="Hello from prog1.c\n", + chdir='relocate/src') +test.run_built_executable('prog2', + stdout="Hello from prog2.c\n", + chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/subdirectory/gyptest-SYMROOT-default.py b/Source/ThirdParty/gyp/test/subdirectory/gyptest-SYMROOT-default.py new file mode 100644 index 000000000..c64ae7da3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/gyptest-SYMROOT-default.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a target and a subsidiary dependent target from a +.gyp file in a subdirectory, without specifying an explicit output build +directory, and using the generated solution or project file at the top +of the tree as the entry point. + +The configuration sets the Xcode SYMROOT variable and uses --depth= +to make Xcode behave like the other build tools--that is, put all +built targets in a single output build directory at the top of the tree. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('prog1.gyp', '-Dset_symroot=1', '--depth=.', chdir='src') + +test.relocate('src', 'relocate/src') + +# Suppress the test infrastructure's setting SYMROOT on the command line. +test.build('prog1.gyp', SYMROOT=None, chdir='relocate/src') + +test.run_built_executable('prog1', + stdout="Hello from prog1.c\n", + chdir='relocate/src') + +test.run_built_executable('prog2', + stdout="Hello from prog2.c\n", + chdir='relocate/src') + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir-all.py b/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir-all.py new file mode 100644 index 000000000..fbaef322c --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir-all.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a subsidiary dependent target from a .gyp file in a +subdirectory, without specifying an explicit output build directory, +and using the subdirectory's solution or project file as the entry point. +""" + +import TestGyp +import errno + +test = TestGyp.TestGyp() + +test.run_gyp('prog1.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +chdir = 'relocate/src/subdir' +target = test.ALL + +test.build('prog2.gyp', target, chdir=chdir) + +test.built_file_must_not_exist('prog1', type=test.EXECUTABLE, chdir=chdir) + +test.run_built_executable('prog2', + chdir=chdir, + stdout="Hello from prog2.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir-default.py b/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir-default.py new file mode 100644 index 000000000..6372ea2a3 --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir-default.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a subsidiary dependent target from a .gyp file in a +subdirectory, without specifying an explicit output build directory, +and using the subdirectory's solution or project file as the entry point. +""" + +import TestGyp +import errno + +test = TestGyp.TestGyp() + +test.run_gyp('prog1.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +chdir = 'relocate/src/subdir' + +test.build('prog2.gyp', chdir=chdir) + +test.built_file_must_not_exist('prog1', type=test.EXECUTABLE, chdir=chdir) + +test.run_built_executable('prog2', + chdir=chdir, + stdout="Hello from prog2.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir2-deep.py b/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir2-deep.py new file mode 100644 index 000000000..48548982f --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/gyptest-subdir2-deep.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a project rooted several layers under src_dir works. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('prog3.gyp', chdir='src/subdir/subdir2') + +test.relocate('src', 'relocate/src') + +test.build('prog3.gyp', test.ALL, chdir='relocate/src/subdir/subdir2') + +test.run_built_executable('prog3', + chdir='relocate/src/subdir/subdir2', + stdout="Hello from prog3.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/subdirectory/gyptest-top-all.py b/Source/ThirdParty/gyp/test/subdirectory/gyptest-top-all.py new file mode 100644 index 000000000..a29a41b4d --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/gyptest-top-all.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a target and a subsidiary dependent target from a +.gyp file in a subdirectory, without specifying an explicit output build +directory, and using the generated solution or project file at the top +of the tree as the entry point. + +There is a difference here in the default behavior of the underlying +build tools. Specifically, when building the entire "solution", Xcode +puts the output of each project relative to the .xcodeproj directory, +while Visual Studio (and our implementations of SCons and Make) put it +in a build directory relative to the "solution"--that is, the entry-point +from which you built the entire tree. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('prog1.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('prog1.gyp', test.ALL, chdir='relocate/src') + +test.run_built_executable('prog1', + stdout="Hello from prog1.c\n", + chdir='relocate/src') + +if test.format == 'xcode': + chdir = 'relocate/src/subdir' +else: + chdir = 'relocate/src' +test.run_built_executable('prog2', + chdir=chdir, + stdout="Hello from prog2.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/subdirectory/gyptest-top-default.py b/Source/ThirdParty/gyp/test/subdirectory/gyptest-top-default.py new file mode 100644 index 000000000..ac5f60dbc --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/gyptest-top-default.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a target and a subsidiary dependent target from a +.gyp file in a subdirectory, without specifying an explicit output build +directory, and using the generated solution or project file at the top +of the tree as the entry point. + +There is a difference here in the default behavior of the underlying +build tools. Specifically, when building the entire "solution", Xcode +puts the output of each project relative to the .xcodeproj directory, +while Visual Studio (and our implementations of SCons and Make) put it +in a build directory relative to the "solution"--that is, the entry-point +from which you built the entire tree. +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('prog1.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('prog1.gyp', chdir='relocate/src') + +test.run_built_executable('prog1', + stdout="Hello from prog1.c\n", + chdir='relocate/src') + +if test.format == 'xcode': + chdir = 'relocate/src/subdir' +else: + chdir = 'relocate/src' +test.run_built_executable('prog2', + chdir=chdir, + stdout="Hello from prog2.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/subdirectory/src/prog1.c b/Source/ThirdParty/gyp/test/subdirectory/src/prog1.c new file mode 100644 index 000000000..161ae8a38 --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/src/prog1.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from prog1.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/subdirectory/src/prog1.gyp b/Source/ThirdParty/gyp/test/subdirectory/src/prog1.gyp new file mode 100644 index 000000000..2aa66ce7d --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/src/prog1.gyp @@ -0,0 +1,21 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + 'symroot.gypi', + ], + 'targets': [ + { + 'target_name': 'prog1', + 'type': 'executable', + 'dependencies': [ + 'subdir/prog2.gyp:prog2', + ], + 'sources': [ + 'prog1.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/subdirectory/src/subdir/prog2.c b/Source/ThirdParty/gyp/test/subdirectory/src/subdir/prog2.c new file mode 100644 index 000000000..7635ae8c1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/src/subdir/prog2.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from prog2.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/subdirectory/src/subdir/prog2.gyp b/Source/ThirdParty/gyp/test/subdirectory/src/subdir/prog2.gyp new file mode 100644 index 000000000..c6cd35f7f --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/src/subdir/prog2.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../symroot.gypi', + ], + 'targets': [ + { + 'target_name': 'prog2', + 'type': 'executable', + 'sources': [ + 'prog2.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/subdirectory/src/subdir/subdir2/prog3.c b/Source/ThirdParty/gyp/test/subdirectory/src/subdir/subdir2/prog3.c new file mode 100644 index 000000000..7cfb0fa94 --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/src/subdir/subdir2/prog3.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from prog3.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/subdirectory/src/subdir/subdir2/prog3.gyp b/Source/ThirdParty/gyp/test/subdirectory/src/subdir/subdir2/prog3.gyp new file mode 100644 index 000000000..b49fb5911 --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/src/subdir/subdir2/prog3.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2009 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. + +{ + 'includes': [ + '../../symroot.gypi', + ], + 'targets': [ + { + 'target_name': 'prog3', + 'type': 'executable', + 'sources': [ + 'prog3.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/subdirectory/src/symroot.gypi b/Source/ThirdParty/gyp/test/subdirectory/src/symroot.gypi new file mode 100644 index 000000000..519916427 --- /dev/null +++ b/Source/ThirdParty/gyp/test/subdirectory/src/symroot.gypi @@ -0,0 +1,16 @@ +# Copyright (c) 2009 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. + +{ + 'variables': { + 'set_symroot%': 0, + }, + 'conditions': [ + ['set_symroot == 1', { + 'xcode_settings': { + 'SYMROOT': '<(DEPTH)/build', + }, + }], + ], +} diff --git a/Source/ThirdParty/gyp/test/toolsets/gyptest-toolsets.py b/Source/ThirdParty/gyp/test/toolsets/gyptest-toolsets.py new file mode 100644 index 000000000..19737f83d --- /dev/null +++ b/Source/ThirdParty/gyp/test/toolsets/gyptest-toolsets.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 toolsets are correctly applied +""" + +import TestGyp + +# Multiple toolsets are currently only supported by the make generator. +test = TestGyp.TestGyp(formats=['make']) + +test.run_gyp('toolsets.gyp') + +test.build('toolsets.gyp', test.ALL) + +test.run_built_executable('host-main', stdout="Host\n") +test.run_built_executable('target-main', stdout="Target\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/toolsets/main.cc b/Source/ThirdParty/gyp/test/toolsets/main.cc new file mode 100644 index 000000000..0f353ae54 --- /dev/null +++ b/Source/ThirdParty/gyp/test/toolsets/main.cc @@ -0,0 +1,11 @@ +/* Copyright (c) 2009 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> + +const char *GetToolset(); + +int main(int argc, char *argv[]) { + printf("%s\n", GetToolset()); +} diff --git a/Source/ThirdParty/gyp/test/toolsets/toolsets.cc b/Source/ThirdParty/gyp/test/toolsets/toolsets.cc new file mode 100644 index 000000000..a45fa029c --- /dev/null +++ b/Source/ThirdParty/gyp/test/toolsets/toolsets.cc @@ -0,0 +1,11 @@ +/* Copyright (c) 2009 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. */ + +const char *GetToolset() { +#ifdef TARGET + return "Target"; +#else + return "Host"; +#endif +} diff --git a/Source/ThirdParty/gyp/test/toolsets/toolsets.gyp b/Source/ThirdParty/gyp/test/toolsets/toolsets.gyp new file mode 100644 index 000000000..e41b928de --- /dev/null +++ b/Source/ThirdParty/gyp/test/toolsets/toolsets.gyp @@ -0,0 +1,38 @@ +# Copyright (c) 2009 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. + +{ + 'target_defaults': { + 'target_conditions': [ + ['_toolset=="target"', {'defines': ['TARGET']}] + ] + }, + 'targets': [ + { + 'target_name': 'toolsets', + 'type': 'static_library', + 'toolsets': ['target', 'host'], + 'sources': [ + 'toolsets.cc', + ], + }, + { + 'target_name': 'host-main', + 'type': 'executable', + 'toolsets': ['host'], + 'dependencies': ['toolsets'], + 'sources': [ + 'main.cc', + ], + }, + { + 'target_name': 'target-main', + 'type': 'executable', + 'dependencies': ['toolsets'], + 'sources': [ + 'main.cc', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/toplevel-dir/gyptest-toplevel-dir.py b/Source/ThirdParty/gyp/test/toplevel-dir/gyptest-toplevel-dir.py new file mode 100644 index 000000000..61986cdaa --- /dev/null +++ b/Source/ThirdParty/gyp/test/toplevel-dir/gyptest-toplevel-dir.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 building a subsidiary dependent target from a .gyp file in a +subdirectory, without specifying an explicit output build directory, +and using the subdirectory's solution or project file as the entry point. +""" + +import TestGyp +import errno + +test = TestGyp.TestGyp(formats=['make']) + +# We want our Makefile to be one dir up from main.gyp. +test.run_gyp('main.gyp', '--toplevel-dir=..', chdir='src/sub1') + +toplevel_dir = 'src' + +test.build('all', chdir=toplevel_dir) + +test.built_file_must_exist('prog1', type=test.EXECUTABLE, chdir=toplevel_dir) + +test.run_built_executable('prog1', + chdir=toplevel_dir, + stdout="Hello from prog1.c\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/toplevel-dir/src/sub1/main.gyp b/Source/ThirdParty/gyp/test/toplevel-dir/src/sub1/main.gyp new file mode 100644 index 000000000..33219010e --- /dev/null +++ b/Source/ThirdParty/gyp/test/toplevel-dir/src/sub1/main.gyp @@ -0,0 +1,18 @@ +# Copyright (c) 2009 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': 'prog1', + 'type': 'executable', + 'dependencies': [ + '<(DEPTH)/../sub2/prog2.gyp:prog2', + ], + 'sources': [ + 'prog1.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/toplevel-dir/src/sub1/prog1.c b/Source/ThirdParty/gyp/test/toplevel-dir/src/sub1/prog1.c new file mode 100644 index 000000000..161ae8a38 --- /dev/null +++ b/Source/ThirdParty/gyp/test/toplevel-dir/src/sub1/prog1.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from prog1.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/toplevel-dir/src/sub2/prog2.c b/Source/ThirdParty/gyp/test/toplevel-dir/src/sub2/prog2.c new file mode 100644 index 000000000..7635ae8c1 --- /dev/null +++ b/Source/ThirdParty/gyp/test/toplevel-dir/src/sub2/prog2.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ + printf("Hello from prog2.c\n"); + return 0; +} diff --git a/Source/ThirdParty/gyp/test/toplevel-dir/src/sub2/prog2.gyp b/Source/ThirdParty/gyp/test/toplevel-dir/src/sub2/prog2.gyp new file mode 100644 index 000000000..593454836 --- /dev/null +++ b/Source/ThirdParty/gyp/test/toplevel-dir/src/sub2/prog2.gyp @@ -0,0 +1,15 @@ +# Copyright (c) 2009 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': 'prog2', + 'type': 'executable', + 'sources': [ + 'prog2.c', + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gyp b/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gyp new file mode 100644 index 000000000..822ae4f05 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gyp @@ -0,0 +1,128 @@ +# Copyright (c) 2009 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. + +# This is a simple test file to make sure that variable substitution +# happens correctly. Run "run_tests.py" using python to generate the +# output from this gyp file. + +{ + 'variables': { + 'pi': 'import math; print math.pi', + 'third_letters': "<(other_letters)HIJK", + 'letters_list': 'ABCD', + 'other_letters': '<(letters_list)EFG', + 'check_included': '<(included_variable)', + 'check_lists': [ + '<(included_variable)', + '<(third_letters)', + ], + 'check_int': 5, + 'check_str_int': '6', + 'check_list_int': [ + 7, + '8', + 9, + ], + 'not_int_1': ' 10', + 'not_int_2': '11 ', + 'not_int_3': '012', + 'not_int_4': '13.0', + 'not_int_5': '+14', + 'negative_int': '-15', + 'zero_int': '0', + }, + 'includes': [ + 'commands.gypi', + ], + 'targets': [ + { + 'target_name': 'foo', + 'type': 'none', + 'variables': { + 'var1': '<!(["python", "-c", "<(pi)"])', + 'var2': '<!(python -c "print \'<!(python -c "<(pi)") <(letters_list)\'")', + 'var3': '<!(python -c "print \'<(letters_list)\'")', + 'var4': '<(<!(python -c "print \'letters_list\'"))', + 'var5': 'letters_', + 'var6': 'list', + 'var7': '<(check_int)', + 'var8': '<(check_int)blah', + 'var9': '<(check_str_int)', + 'var10': '<(check_list_int)', + 'var11': ['<@(check_list_int)'], + 'var12': '<(not_int_1)', + 'var13': '<(not_int_2)', + 'var14': '<(not_int_3)', + 'var15': '<(not_int_4)', + 'var16': '<(not_int_5)', + 'var17': '<(negative_int)', + 'var18': '<(zero_int)', + # A second set with different names to make sure they only execute the + # commands once. + 'var1prime': '<!(["python", "-c", "<(pi)"])', + 'var2prime': '<!(python -c "print \'<!(python -c "<(pi)") <(letters_list)\'")', + 'var3prime': '<!(python -c "print \'<(letters_list)\'")', + 'var4prime': '<(<!(python -c "print \'letters_list\'"))', + }, + 'actions': [ + { + 'action_name': 'test_action', + 'variables': { + 'var7': '<!(echo <(var5)<(var6))', + }, + 'inputs' : [ + '<(var2)', + ], + 'outputs': [ + '<(var4)', + '<(var7)', + ], + 'action': [ + 'echo', + '<(_inputs)', + '<(_outputs)', + ], + }, + # Again with the same vars to make sure the right things happened. + { + 'action_name': 'test_action_prime', + 'variables': { + 'var7': '<!(echo <(var5)<(var6))', + }, + 'inputs' : [ + '<(var2)', + ], + 'outputs': [ + '<(var4)', + '<(var7)', + ], + 'action': [ + 'echo', + '<(_inputs)', + '<(_outputs)', + ], + }, + # And one more time with the other vars... + { + 'action_name': 'test_action_prime_prime', + 'variables': { + 'var7': '<!(echo <(var5)<(var6))', + }, + 'inputs' : [ + '<(var2prime)', + ], + 'outputs': [ + '<(var4prime)', + '<(var7)', + ], + 'action': [ + 'echo', + '<(_inputs)', + '<(_outputs)', + ], + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gyp.stdout b/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gyp.stdout new file mode 100644 index 000000000..6cbe797fd --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gyp.stdout @@ -0,0 +1,405 @@ +GENERAL: running with these options: +GENERAL: check: None +GENERAL: circular_check: True +GENERAL: debug: ['variables', 'general'] +GENERAL: defines: None +GENERAL: depth: '.' +GENERAL: formats: ['gypd'] +GENERAL: generator_flags: [] +GENERAL: generator_output: None +GENERAL: includes: None +GENERAL: msvs_version: None +GENERAL: suffix: '' +GENERAL: toplevel_dir: None +GENERAL: use_environment: True +GENERAL: cmdline_default_variables: {} +GENERAL: generator_flags: {} +VARIABLES: Expanding '0' to 0 +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '-15' to -15 +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFG', recursing. +VARIABLES: Expanding 'ABCDEFG' to 'ABCDEFG' +VARIABLES: Expanding '<(letters_list)EFG' to 'ABCDEFG' +VARIABLES: Expanding '012' to '012' +VARIABLES: Matches: {'content': 'other_letters', 'is_array': '', 'type': '<', 'replace': '<(other_letters)'} +VARIABLES: Expanding 'other_letters' to 'other_letters' +VARIABLES: Found output '<(letters_list)EFGHIJK', recursing. +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFGHIJK', recursing. +VARIABLES: Expanding 'ABCDEFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(letters_list)EFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(other_letters)HIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding 'import math; print math.pi' to 'import math; print math.pi' +VARIABLES: Matches: {'content': 'included_variable', 'is_array': '', 'type': '<', 'replace': '<(included_variable)'} +VARIABLES: Expanding 'included_variable' to 'included_variable' +VARIABLES: Found output 'XYZ', recursing. +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding '<(included_variable)' to 'XYZ' +VARIABLES: Expanding '6' to 6 +VARIABLES: Matches: {'content': 'included_variable', 'is_array': '', 'type': '<', 'replace': '<(included_variable)'} +VARIABLES: Expanding 'included_variable' to 'included_variable' +VARIABLES: Found output 'XYZ', recursing. +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding '<(included_variable)' to 'XYZ' +VARIABLES: Matches: {'content': 'third_letters', 'is_array': '', 'type': '<', 'replace': '<(third_letters)'} +VARIABLES: Expanding 'third_letters' to 'third_letters' +VARIABLES: Found output '<(other_letters)HIJK', recursing. +VARIABLES: Matches: {'content': 'other_letters', 'is_array': '', 'type': '<', 'replace': '<(other_letters)'} +VARIABLES: Expanding 'other_letters' to 'other_letters' +VARIABLES: Found output '<(letters_list)EFGHIJK', recursing. +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFGHIJK', recursing. +VARIABLES: Expanding 'ABCDEFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(letters_list)EFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(other_letters)HIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(third_letters)' to 'ABCDEFGHIJK' +VARIABLES: Expanding '8' to 8 +VARIABLES: Expanding '.' to '.' +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Matches: {'content': 'python -c "print \'<!(python -c "<(pi', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'<!(python -c "<(pi)'} +VARIABLES: Matches: {'content': 'python -c "<(pi', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "<(pi)'} +VARIABLES: Matches: {'content': 'pi', 'is_array': '', 'type': '<', 'replace': '<(pi)'} +VARIABLES: Expanding 'pi' to 'pi' +VARIABLES: Found output 'python -c "import math; print math.pi"', recursing. +VARIABLES: Expanding 'python -c "import math; print math.pi"' to 'python -c "import math; print math.pi"' +VARIABLES: Expanding 'python -c "<(pi)"' to 'python -c "import math; print math.pi"' +VARIABLES: Executing command 'python -c "import math; print math.pi"' in directory 'None' +VARIABLES: Found output 'python -c "print \'3.14159265359 ABCD\'"', recursing. +VARIABLES: Expanding 'python -c "print \'3.14159265359 ABCD\'"' to 'python -c "print \'3.14159265359 ABCD\'"' +VARIABLES: Expanding 'python -c "print \'<!(python -c "<(pi)") ABCD\'"' to 'python -c "print \'3.14159265359 ABCD\'"' +VARIABLES: Executing command 'python -c "print '3.14159265359 ABCD'"' in directory 'None' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<!(python -c "print \'<!(python -c "<(pi)") <(letters_list)\'")' to '3.14159265359 ABCD' +VARIABLES: Matches: {'content': '"python", "-c", "<(pi', 'is_array': '[', 'type': '<!', 'replace': '<!(["python", "-c", "<(pi)'} +VARIABLES: Matches: {'content': 'pi', 'is_array': '', 'type': '<', 'replace': '<(pi)'} +VARIABLES: Expanding 'pi' to 'pi' +VARIABLES: Found output '["python", "-c", "import math; print math.pi"]', recursing. +VARIABLES: Expanding '["python", "-c", "import math; print math.pi"]' to '["python", "-c", "import math; print math.pi"]' +VARIABLES: Expanding '["python", "-c", "<(pi)"]' to '["python", "-c", "import math; print math.pi"]' +VARIABLES: Executing command '['python', '-c', 'import math; print math.pi']' in directory 'None' +VARIABLES: Found output '3.14159265359', recursing. +VARIABLES: Expanding '3.14159265359' to '3.14159265359' +VARIABLES: Expanding '<!(["python", "-c", "<(pi)"])' to '3.14159265359' +VARIABLES: Expanding 'letters_' to 'letters_' +VARIABLES: Matches: {'content': '<!(python -c "print \'letters_list\'"', 'is_array': '', 'type': '<', 'replace': '<(<!(python -c "print \'letters_list\'")'} +VARIABLES: Matches: {'content': 'python -c "print \'letters_list\'"', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'letters_list\'")'} +VARIABLES: Expanding 'python -c "print \'letters_list\'"' to 'python -c "print \'letters_list\'"' +VARIABLES: Executing command 'python -c "print 'letters_list'"' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(python -c "print \'letters_list\'")' to 'letters_list' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(<!(python -c "print \'letters_list\'"))' to 'ABCD' +VARIABLES: Matches: {'content': 'check_int', 'is_array': '', 'type': '<', 'replace': '<(check_int)'} +VARIABLES: Expanding 'check_int' to 'check_int' +VARIABLES: Found output '5', recursing. +VARIABLES: Expanding '5' to 5 +VARIABLES: Expanding '<(check_int)' to 5 +VARIABLES: Expanding 'list' to 'list' +VARIABLES: Matches: {'content': '"python", "-c", "<(pi', 'is_array': '[', 'type': '<!', 'replace': '<!(["python", "-c", "<(pi)'} +VARIABLES: Matches: {'content': 'pi', 'is_array': '', 'type': '<', 'replace': '<(pi)'} +VARIABLES: Expanding 'pi' to 'pi' +VARIABLES: Found output '["python", "-c", "import math; print math.pi"]', recursing. +VARIABLES: Expanding '["python", "-c", "import math; print math.pi"]' to '["python", "-c", "import math; print math.pi"]' +VARIABLES: Expanding '["python", "-c", "<(pi)"]' to '["python", "-c", "import math; print math.pi"]' +VARIABLES: Had cache value for command '['python', '-c', 'import math; print math.pi']' in directory 'None' +VARIABLES: Found output '3.14159265359', recursing. +VARIABLES: Expanding '3.14159265359' to '3.14159265359' +VARIABLES: Expanding '<!(["python", "-c", "<(pi)"])' to '3.14159265359' +VARIABLES: Matches: {'content': 'python -c "print \'<(letters_list', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'<(letters_list)'} +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'python -c "print \'ABCD\'"', recursing. +VARIABLES: Expanding 'python -c "print \'ABCD\'"' to 'python -c "print \'ABCD\'"' +VARIABLES: Expanding 'python -c "print \'<(letters_list)\'"' to 'python -c "print \'ABCD\'"' +VARIABLES: Executing command 'python -c "print 'ABCD'"' in directory 'None' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<!(python -c "print \'<(letters_list)\'")' to 'ABCD' +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Matches: {'content': 'python -c "print \'<!(python -c "<(pi', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'<!(python -c "<(pi)'} +VARIABLES: Matches: {'content': 'python -c "<(pi', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "<(pi)'} +VARIABLES: Matches: {'content': 'pi', 'is_array': '', 'type': '<', 'replace': '<(pi)'} +VARIABLES: Expanding 'pi' to 'pi' +VARIABLES: Found output 'python -c "import math; print math.pi"', recursing. +VARIABLES: Expanding 'python -c "import math; print math.pi"' to 'python -c "import math; print math.pi"' +VARIABLES: Expanding 'python -c "<(pi)"' to 'python -c "import math; print math.pi"' +VARIABLES: Had cache value for command 'python -c "import math; print math.pi"' in directory 'None' +VARIABLES: Found output 'python -c "print \'3.14159265359 ABCD\'"', recursing. +VARIABLES: Expanding 'python -c "print \'3.14159265359 ABCD\'"' to 'python -c "print \'3.14159265359 ABCD\'"' +VARIABLES: Expanding 'python -c "print \'<!(python -c "<(pi)") ABCD\'"' to 'python -c "print \'3.14159265359 ABCD\'"' +VARIABLES: Had cache value for command 'python -c "print '3.14159265359 ABCD'"' in directory 'None' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<!(python -c "print \'<!(python -c "<(pi)") <(letters_list)\'")' to '3.14159265359 ABCD' +VARIABLES: Matches: {'content': 'check_str_int', 'is_array': '', 'type': '<', 'replace': '<(check_str_int)'} +VARIABLES: Expanding 'check_str_int' to 'check_str_int' +VARIABLES: Found output '6', recursing. +VARIABLES: Expanding '6' to 6 +VARIABLES: Expanding '<(check_str_int)' to 6 +VARIABLES: Matches: {'content': 'check_int', 'is_array': '', 'type': '<', 'replace': '<(check_int)'} +VARIABLES: Expanding 'check_int' to 'check_int' +VARIABLES: Found output '5blah', recursing. +VARIABLES: Expanding '5blah' to '5blah' +VARIABLES: Expanding '<(check_int)blah' to '5blah' +VARIABLES: Matches: {'content': '<!(python -c "print \'letters_list\'"', 'is_array': '', 'type': '<', 'replace': '<(<!(python -c "print \'letters_list\'")'} +VARIABLES: Matches: {'content': 'python -c "print \'letters_list\'"', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'letters_list\'")'} +VARIABLES: Expanding 'python -c "print \'letters_list\'"' to 'python -c "print \'letters_list\'"' +VARIABLES: Had cache value for command 'python -c "print 'letters_list'"' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(python -c "print \'letters_list\'")' to 'letters_list' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(<!(python -c "print \'letters_list\'"))' to 'ABCD' +VARIABLES: Matches: {'content': 'python -c "print \'<(letters_list', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'<(letters_list)'} +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'python -c "print \'ABCD\'"', recursing. +VARIABLES: Expanding 'python -c "print \'ABCD\'"' to 'python -c "print \'ABCD\'"' +VARIABLES: Expanding 'python -c "print \'<(letters_list)\'"' to 'python -c "print \'ABCD\'"' +VARIABLES: Had cache value for command 'python -c "print 'ABCD'"' in directory 'None' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<!(python -c "print \'<(letters_list)\'")' to 'ABCD' +VARIABLES: Matches: {'content': 'not_int_4', 'is_array': '', 'type': '<', 'replace': '<(not_int_4)'} +VARIABLES: Expanding 'not_int_4' to 'not_int_4' +VARIABLES: Found output '13.0', recursing. +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding '<(not_int_4)' to '13.0' +VARIABLES: Matches: {'content': 'not_int_3', 'is_array': '', 'type': '<', 'replace': '<(not_int_3)'} +VARIABLES: Expanding 'not_int_3' to 'not_int_3' +VARIABLES: Found output '012', recursing. +VARIABLES: Expanding '012' to '012' +VARIABLES: Expanding '<(not_int_3)' to '012' +VARIABLES: Matches: {'content': 'negative_int', 'is_array': '', 'type': '<', 'replace': '<(negative_int)'} +VARIABLES: Expanding 'negative_int' to 'negative_int' +VARIABLES: Found output '-15', recursing. +VARIABLES: Expanding '-15' to -15 +VARIABLES: Expanding '<(negative_int)' to -15 +VARIABLES: Matches: {'content': 'not_int_5', 'is_array': '', 'type': '<', 'replace': '<(not_int_5)'} +VARIABLES: Expanding 'not_int_5' to 'not_int_5' +VARIABLES: Found output '+14', recursing. +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '<(not_int_5)' to '+14' +VARIABLES: Matches: {'content': 'check_list_int', 'is_array': '', 'type': '<', 'replace': '<(check_list_int)'} +VARIABLES: Expanding 'check_list_int' to 'check_list_int' +VARIABLES: Found output '7 8 9', recursing. +VARIABLES: Expanding '7 8 9' to '7 8 9' +VARIABLES: Expanding '<(check_list_int)' to '7 8 9' +VARIABLES: Matches: {'content': 'not_int_2', 'is_array': '', 'type': '<', 'replace': '<(not_int_2)'} +VARIABLES: Expanding 'not_int_2' to 'not_int_2' +VARIABLES: Found output '11 ', recursing. +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding '<(not_int_2)' to '11 ' +VARIABLES: Matches: {'content': 'not_int_1', 'is_array': '', 'type': '<', 'replace': '<(not_int_1)'} +VARIABLES: Expanding 'not_int_1' to 'not_int_1' +VARIABLES: Found output ' 10', recursing. +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Expanding '<(not_int_1)' to ' 10' +VARIABLES: Matches: {'content': 'zero_int', 'is_array': '', 'type': '<', 'replace': '<(zero_int)'} +VARIABLES: Expanding 'zero_int' to 'zero_int' +VARIABLES: Found output '0', recursing. +VARIABLES: Expanding '0' to 0 +VARIABLES: Expanding '<(zero_int)' to 0 +VARIABLES: Matches: {'content': 'check_list_int', 'is_array': '', 'type': '<@', 'replace': '<@(check_list_int)'} +VARIABLES: Expanding 'check_list_int' to 'check_list_int' +VARIABLES: Found output [7, 8, 9], recursing. +VARIABLES: Expanding 7 to 7 +VARIABLES: Expanding 8 to 8 +VARIABLES: Expanding 9 to 9 +VARIABLES: Expanding '<@(check_list_int)' to [7, 8, 9] +VARIABLES: Expanding 'foo' to 'foo' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Matches: {'content': 'var6', 'is_array': '', 'type': '<', 'replace': '<(var6)'} +VARIABLES: Expanding 'var6' to 'var6' +VARIABLES: Matches: {'content': 'echo <(var5', 'is_array': '', 'type': '<!', 'replace': '<!(echo <(var5)'} +VARIABLES: Matches: {'content': 'var5', 'is_array': '', 'type': '<', 'replace': '<(var5)'} +VARIABLES: Expanding 'var5' to 'var5' +VARIABLES: Found output 'echo letters_list', recursing. +VARIABLES: Expanding 'echo letters_list' to 'echo letters_list' +VARIABLES: Expanding 'echo <(var5)list' to 'echo letters_list' +VARIABLES: Executing command 'echo letters_list' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(echo <(var5)<(var6))' to 'letters_list' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Matches: {'content': '_inputs', 'is_array': '', 'type': '<', 'replace': '<(_inputs)'} +VARIABLES: Expanding '_inputs' to '_inputs' +VARIABLES: Matches: {'content': 'var2', 'is_array': '', 'type': '<', 'replace': '<(var2)'} +VARIABLES: Expanding 'var2' to 'var2' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<(var2)' to '3.14159265359 ABCD' +VARIABLES: Found output '"3.14159265359 ABCD"', recursing. +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding '<(_inputs)' to '"3.14159265359 ABCD"' +VARIABLES: Matches: {'content': '_outputs', 'is_array': '', 'type': '<', 'replace': '<(_outputs)'} +VARIABLES: Expanding '_outputs' to '_outputs' +VARIABLES: Matches: {'content': 'var4', 'is_array': '', 'type': '<', 'replace': '<(var4)'} +VARIABLES: Expanding 'var4' to 'var4' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(var4)' to 'ABCD' +VARIABLES: Matches: {'content': 'var7', 'is_array': '', 'type': '<', 'replace': '<(var7)'} +VARIABLES: Expanding 'var7' to 'var7' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<(var7)' to 'letters_list' +VARIABLES: Found output 'ABCD letters_list', recursing. +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '<(_outputs)' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Matches: {'content': 'var6', 'is_array': '', 'type': '<', 'replace': '<(var6)'} +VARIABLES: Expanding 'var6' to 'var6' +VARIABLES: Matches: {'content': 'echo <(var5', 'is_array': '', 'type': '<!', 'replace': '<!(echo <(var5)'} +VARIABLES: Matches: {'content': 'var5', 'is_array': '', 'type': '<', 'replace': '<(var5)'} +VARIABLES: Expanding 'var5' to 'var5' +VARIABLES: Found output 'echo letters_list', recursing. +VARIABLES: Expanding 'echo letters_list' to 'echo letters_list' +VARIABLES: Expanding 'echo <(var5)list' to 'echo letters_list' +VARIABLES: Had cache value for command 'echo letters_list' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(echo <(var5)<(var6))' to 'letters_list' +VARIABLES: Expanding 'test_action_prime' to 'test_action_prime' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Matches: {'content': '_inputs', 'is_array': '', 'type': '<', 'replace': '<(_inputs)'} +VARIABLES: Expanding '_inputs' to '_inputs' +VARIABLES: Matches: {'content': 'var2', 'is_array': '', 'type': '<', 'replace': '<(var2)'} +VARIABLES: Expanding 'var2' to 'var2' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<(var2)' to '3.14159265359 ABCD' +VARIABLES: Found output '"3.14159265359 ABCD"', recursing. +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding '<(_inputs)' to '"3.14159265359 ABCD"' +VARIABLES: Matches: {'content': '_outputs', 'is_array': '', 'type': '<', 'replace': '<(_outputs)'} +VARIABLES: Expanding '_outputs' to '_outputs' +VARIABLES: Matches: {'content': 'var4', 'is_array': '', 'type': '<', 'replace': '<(var4)'} +VARIABLES: Expanding 'var4' to 'var4' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(var4)' to 'ABCD' +VARIABLES: Matches: {'content': 'var7', 'is_array': '', 'type': '<', 'replace': '<(var7)'} +VARIABLES: Expanding 'var7' to 'var7' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<(var7)' to 'letters_list' +VARIABLES: Found output 'ABCD letters_list', recursing. +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '<(_outputs)' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Matches: {'content': 'var6', 'is_array': '', 'type': '<', 'replace': '<(var6)'} +VARIABLES: Expanding 'var6' to 'var6' +VARIABLES: Matches: {'content': 'echo <(var5', 'is_array': '', 'type': '<!', 'replace': '<!(echo <(var5)'} +VARIABLES: Matches: {'content': 'var5', 'is_array': '', 'type': '<', 'replace': '<(var5)'} +VARIABLES: Expanding 'var5' to 'var5' +VARIABLES: Found output 'echo letters_list', recursing. +VARIABLES: Expanding 'echo letters_list' to 'echo letters_list' +VARIABLES: Expanding 'echo <(var5)list' to 'echo letters_list' +VARIABLES: Had cache value for command 'echo letters_list' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(echo <(var5)<(var6))' to 'letters_list' +VARIABLES: Expanding 'test_action_prime_prime' to 'test_action_prime_prime' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Matches: {'content': '_inputs', 'is_array': '', 'type': '<', 'replace': '<(_inputs)'} +VARIABLES: Expanding '_inputs' to '_inputs' +VARIABLES: Matches: {'content': 'var2prime', 'is_array': '', 'type': '<', 'replace': '<(var2prime)'} +VARIABLES: Expanding 'var2prime' to 'var2prime' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<(var2prime)' to '3.14159265359 ABCD' +VARIABLES: Found output '"3.14159265359 ABCD"', recursing. +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding '<(_inputs)' to '"3.14159265359 ABCD"' +VARIABLES: Matches: {'content': '_outputs', 'is_array': '', 'type': '<', 'replace': '<(_outputs)'} +VARIABLES: Expanding '_outputs' to '_outputs' +VARIABLES: Matches: {'content': 'var4prime', 'is_array': '', 'type': '<', 'replace': '<(var4prime)'} +VARIABLES: Expanding 'var4prime' to 'var4prime' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(var4prime)' to 'ABCD' +VARIABLES: Matches: {'content': 'var7', 'is_array': '', 'type': '<', 'replace': '<(var7)'} +VARIABLES: Expanding 'var7' to 'var7' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<(var7)' to 'letters_list' +VARIABLES: Found output 'ABCD letters_list', recursing. +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '<(_outputs)' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'dummy' to 'dummy' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'commands-repeated.gyp' to 'commands-repeated.gyp' +VARIABLES: Expanding 'commands.gypi' to 'commands.gypi' +VARIABLES: Expanding 'dummy' to 'dummy' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '3.14159265359' to '3.14159265359' +VARIABLES: Expanding 'letters_' to 'letters_' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'list' to 'list' +VARIABLES: Expanding '3.14159265359' to '3.14159265359' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '5blah' to '5blah' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding '012' to '012' +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '7 8 9' to '7 8 9' +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Expanding 'foo' to 'foo' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'test_action_prime' to 'test_action_prime' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'test_action_prime_prime' to 'test_action_prime_prime' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' diff --git a/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gypd.golden b/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gypd.golden new file mode 100644 index 000000000..96615b663 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/commands-repeated.gypd.golden @@ -0,0 +1,72 @@ +{'_DEPTH': '.', + 'included_files': ['commands-repeated.gyp', 'commands.gypi'], + 'targets': [{'actions': [{'action': ['echo', + '"3.14159265359 ABCD"', + 'ABCD letters_list'], + 'action_name': 'test_action', + 'inputs': ['3.14159265359 ABCD'], + 'outputs': ['ABCD', 'letters_list'], + 'variables': {'var7': 'letters_list'}}, + {'action': ['echo', + '"3.14159265359 ABCD"', + 'ABCD letters_list'], + 'action_name': 'test_action_prime', + 'inputs': ['3.14159265359 ABCD'], + 'outputs': ['ABCD', 'letters_list'], + 'variables': {'var7': 'letters_list'}}, + {'action': ['echo', + '"3.14159265359 ABCD"', + 'ABCD letters_list'], + 'action_name': 'test_action_prime_prime', + 'inputs': ['3.14159265359 ABCD'], + 'outputs': ['ABCD', 'letters_list'], + 'variables': {'var7': 'letters_list'}}], + 'configurations': {'Default': {}}, + 'default_configuration': 'Default', + 'target_name': 'foo', + 'toolset': 'target', + 'type': 'none', + 'variables': {'var1': '3.14159265359', + 'var10': '7 8 9', + 'var11': ['7', '8', '9'], + 'var12': ' 10', + 'var13': '11 ', + 'var14': '012', + 'var15': '13.0', + 'var16': '+14', + 'var17': '-15', + 'var18': '0', + 'var1prime': '3.14159265359', + 'var2': '3.14159265359 ABCD', + 'var2prime': '3.14159265359 ABCD', + 'var3': 'ABCD', + 'var3prime': 'ABCD', + 'var4': 'ABCD', + 'var4prime': 'ABCD', + 'var5': 'letters_', + 'var6': 'list', + 'var7': '5', + 'var8': '5blah', + 'var9': '6'}}, + {'configurations': {'Default': {}}, + 'default_configuration': 'Default', + 'target_name': 'dummy', + 'toolset': 'target', + 'type': 'none'}], + 'variables': {'check_included': 'XYZ', + 'check_int': '5', + 'check_list_int': ['7', '8', '9'], + 'check_lists': ['XYZ', 'ABCDEFGHIJK'], + 'check_str_int': '6', + 'included_variable': 'XYZ', + 'letters_list': 'ABCD', + 'negative_int': '-15', + 'not_int_1': ' 10', + 'not_int_2': '11 ', + 'not_int_3': '012', + 'not_int_4': '13.0', + 'not_int_5': '+14', + 'other_letters': 'ABCDEFG', + 'pi': 'import math; print math.pi', + 'third_letters': 'ABCDEFGHIJK', + 'zero_int': '0'}} diff --git a/Source/ThirdParty/gyp/test/variables/commands/commands.gyp b/Source/ThirdParty/gyp/test/variables/commands/commands.gyp new file mode 100644 index 000000000..113e4a279 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/commands.gyp @@ -0,0 +1,84 @@ +# Copyright (c) 2009 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. + +# This is a simple test file to make sure that variable substitution +# happens correctly. Run "run_tests.py" using python to generate the +# output from this gyp file. + +{ + 'variables': { + 'pi': 'import math; print math.pi', + 'third_letters': "<(other_letters)HIJK", + 'letters_list': 'ABCD', + 'other_letters': '<(letters_list)EFG', + 'check_included': '<(included_variable)', + 'check_lists': [ + '<(included_variable)', + '<(third_letters)', + ], + 'check_int': 5, + 'check_str_int': '6', + 'check_list_int': [ + 7, + '8', + 9, + ], + 'not_int_1': ' 10', + 'not_int_2': '11 ', + 'not_int_3': '012', + 'not_int_4': '13.0', + 'not_int_5': '+14', + 'negative_int': '-15', + 'zero_int': '0', + }, + 'includes': [ + 'commands.gypi', + ], + 'targets': [ + { + 'target_name': 'foo', + 'type': 'none', + 'variables': { + 'var1': '<!(["python", "-c", "<(pi)"])', + 'var2': '<!(python -c "print \'<!(python -c "<(pi)") <(letters_list)\'")', + 'var3': '<!(python -c "print \'<(letters_list)\'")', + 'var4': '<(<!(python -c "print \'letters_list\'"))', + 'var5': 'letters_', + 'var6': 'list', + 'var7': '<(check_int)', + 'var8': '<(check_int)blah', + 'var9': '<(check_str_int)', + 'var10': '<(check_list_int)', + 'var11': ['<@(check_list_int)'], + 'var12': '<(not_int_1)', + 'var13': '<(not_int_2)', + 'var14': '<(not_int_3)', + 'var15': '<(not_int_4)', + 'var16': '<(not_int_5)', + 'var17': '<(negative_int)', + 'var18': '<(zero_int)', + }, + 'actions': [ + { + 'action_name': 'test_action', + 'variables': { + 'var7': '<!(echo <(var5)<(var6))', + }, + 'inputs' : [ + '<(var2)', + ], + 'outputs': [ + '<(var4)', + '<(var7)', + ], + 'action': [ + 'echo', + '<(_inputs)', + '<(_outputs)', + ], + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/variables/commands/commands.gyp.ignore-env.stdout b/Source/ThirdParty/gyp/test/variables/commands/commands.gyp.ignore-env.stdout new file mode 100644 index 000000000..7f7df790d --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/commands.gyp.ignore-env.stdout @@ -0,0 +1,254 @@ +GENERAL: running with these options: +GENERAL: check: None +GENERAL: circular_check: True +GENERAL: debug: ['variables', 'general'] +GENERAL: defines: None +GENERAL: depth: '.' +GENERAL: formats: ['gypd'] +GENERAL: generator_flags: [] +GENERAL: generator_output: None +GENERAL: includes: None +GENERAL: msvs_version: None +GENERAL: suffix: '' +GENERAL: toplevel_dir: None +GENERAL: use_environment: False +GENERAL: cmdline_default_variables: {} +GENERAL: generator_flags: {} +VARIABLES: Expanding '0' to 0 +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '-15' to -15 +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFG', recursing. +VARIABLES: Expanding 'ABCDEFG' to 'ABCDEFG' +VARIABLES: Expanding '<(letters_list)EFG' to 'ABCDEFG' +VARIABLES: Expanding '012' to '012' +VARIABLES: Matches: {'content': 'other_letters', 'is_array': '', 'type': '<', 'replace': '<(other_letters)'} +VARIABLES: Expanding 'other_letters' to 'other_letters' +VARIABLES: Found output '<(letters_list)EFGHIJK', recursing. +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFGHIJK', recursing. +VARIABLES: Expanding 'ABCDEFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(letters_list)EFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(other_letters)HIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding 'import math; print math.pi' to 'import math; print math.pi' +VARIABLES: Matches: {'content': 'included_variable', 'is_array': '', 'type': '<', 'replace': '<(included_variable)'} +VARIABLES: Expanding 'included_variable' to 'included_variable' +VARIABLES: Found output 'XYZ', recursing. +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding '<(included_variable)' to 'XYZ' +VARIABLES: Expanding '6' to 6 +VARIABLES: Matches: {'content': 'included_variable', 'is_array': '', 'type': '<', 'replace': '<(included_variable)'} +VARIABLES: Expanding 'included_variable' to 'included_variable' +VARIABLES: Found output 'XYZ', recursing. +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding '<(included_variable)' to 'XYZ' +VARIABLES: Matches: {'content': 'third_letters', 'is_array': '', 'type': '<', 'replace': '<(third_letters)'} +VARIABLES: Expanding 'third_letters' to 'third_letters' +VARIABLES: Found output '<(other_letters)HIJK', recursing. +VARIABLES: Matches: {'content': 'other_letters', 'is_array': '', 'type': '<', 'replace': '<(other_letters)'} +VARIABLES: Expanding 'other_letters' to 'other_letters' +VARIABLES: Found output '<(letters_list)EFGHIJK', recursing. +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFGHIJK', recursing. +VARIABLES: Expanding 'ABCDEFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(letters_list)EFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(other_letters)HIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(third_letters)' to 'ABCDEFGHIJK' +VARIABLES: Expanding '8' to 8 +VARIABLES: Expanding '.' to '.' +VARIABLES: Expanding 'letters_' to 'letters_' +VARIABLES: Matches: {'content': '<!(python -c "print \'letters_list\'"', 'is_array': '', 'type': '<', 'replace': '<(<!(python -c "print \'letters_list\'")'} +VARIABLES: Matches: {'content': 'python -c "print \'letters_list\'"', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'letters_list\'")'} +VARIABLES: Expanding 'python -c "print \'letters_list\'"' to 'python -c "print \'letters_list\'"' +VARIABLES: Executing command 'python -c "print 'letters_list'"' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(python -c "print \'letters_list\'")' to 'letters_list' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(<!(python -c "print \'letters_list\'"))' to 'ABCD' +VARIABLES: Matches: {'content': 'check_int', 'is_array': '', 'type': '<', 'replace': '<(check_int)'} +VARIABLES: Expanding 'check_int' to 'check_int' +VARIABLES: Found output '5', recursing. +VARIABLES: Expanding '5' to 5 +VARIABLES: Expanding '<(check_int)' to 5 +VARIABLES: Expanding 'list' to 'list' +VARIABLES: Matches: {'content': '"python", "-c", "<(pi', 'is_array': '[', 'type': '<!', 'replace': '<!(["python", "-c", "<(pi)'} +VARIABLES: Matches: {'content': 'pi', 'is_array': '', 'type': '<', 'replace': '<(pi)'} +VARIABLES: Expanding 'pi' to 'pi' +VARIABLES: Found output '["python", "-c", "import math; print math.pi"]', recursing. +VARIABLES: Expanding '["python", "-c", "import math; print math.pi"]' to '["python", "-c", "import math; print math.pi"]' +VARIABLES: Expanding '["python", "-c", "<(pi)"]' to '["python", "-c", "import math; print math.pi"]' +VARIABLES: Executing command '['python', '-c', 'import math; print math.pi']' in directory 'None' +VARIABLES: Found output '3.14159265359', recursing. +VARIABLES: Expanding '3.14159265359' to '3.14159265359' +VARIABLES: Expanding '<!(["python", "-c", "<(pi)"])' to '3.14159265359' +VARIABLES: Matches: {'content': 'python -c "print \'<(letters_list', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'<(letters_list)'} +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'python -c "print \'ABCD\'"', recursing. +VARIABLES: Expanding 'python -c "print \'ABCD\'"' to 'python -c "print \'ABCD\'"' +VARIABLES: Expanding 'python -c "print \'<(letters_list)\'"' to 'python -c "print \'ABCD\'"' +VARIABLES: Executing command 'python -c "print 'ABCD'"' in directory 'None' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<!(python -c "print \'<(letters_list)\'")' to 'ABCD' +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Matches: {'content': 'python -c "print \'<!(python -c "<(pi', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'<!(python -c "<(pi)'} +VARIABLES: Matches: {'content': 'python -c "<(pi', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "<(pi)'} +VARIABLES: Matches: {'content': 'pi', 'is_array': '', 'type': '<', 'replace': '<(pi)'} +VARIABLES: Expanding 'pi' to 'pi' +VARIABLES: Found output 'python -c "import math; print math.pi"', recursing. +VARIABLES: Expanding 'python -c "import math; print math.pi"' to 'python -c "import math; print math.pi"' +VARIABLES: Expanding 'python -c "<(pi)"' to 'python -c "import math; print math.pi"' +VARIABLES: Executing command 'python -c "import math; print math.pi"' in directory 'None' +VARIABLES: Found output 'python -c "print \'3.14159265359 ABCD\'"', recursing. +VARIABLES: Expanding 'python -c "print \'3.14159265359 ABCD\'"' to 'python -c "print \'3.14159265359 ABCD\'"' +VARIABLES: Expanding 'python -c "print \'<!(python -c "<(pi)") ABCD\'"' to 'python -c "print \'3.14159265359 ABCD\'"' +VARIABLES: Executing command 'python -c "print '3.14159265359 ABCD'"' in directory 'None' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<!(python -c "print \'<!(python -c "<(pi)") <(letters_list)\'")' to '3.14159265359 ABCD' +VARIABLES: Matches: {'content': 'check_str_int', 'is_array': '', 'type': '<', 'replace': '<(check_str_int)'} +VARIABLES: Expanding 'check_str_int' to 'check_str_int' +VARIABLES: Found output '6', recursing. +VARIABLES: Expanding '6' to 6 +VARIABLES: Expanding '<(check_str_int)' to 6 +VARIABLES: Matches: {'content': 'check_int', 'is_array': '', 'type': '<', 'replace': '<(check_int)'} +VARIABLES: Expanding 'check_int' to 'check_int' +VARIABLES: Found output '5blah', recursing. +VARIABLES: Expanding '5blah' to '5blah' +VARIABLES: Expanding '<(check_int)blah' to '5blah' +VARIABLES: Matches: {'content': 'not_int_4', 'is_array': '', 'type': '<', 'replace': '<(not_int_4)'} +VARIABLES: Expanding 'not_int_4' to 'not_int_4' +VARIABLES: Found output '13.0', recursing. +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding '<(not_int_4)' to '13.0' +VARIABLES: Matches: {'content': 'not_int_3', 'is_array': '', 'type': '<', 'replace': '<(not_int_3)'} +VARIABLES: Expanding 'not_int_3' to 'not_int_3' +VARIABLES: Found output '012', recursing. +VARIABLES: Expanding '012' to '012' +VARIABLES: Expanding '<(not_int_3)' to '012' +VARIABLES: Matches: {'content': 'negative_int', 'is_array': '', 'type': '<', 'replace': '<(negative_int)'} +VARIABLES: Expanding 'negative_int' to 'negative_int' +VARIABLES: Found output '-15', recursing. +VARIABLES: Expanding '-15' to -15 +VARIABLES: Expanding '<(negative_int)' to -15 +VARIABLES: Matches: {'content': 'not_int_5', 'is_array': '', 'type': '<', 'replace': '<(not_int_5)'} +VARIABLES: Expanding 'not_int_5' to 'not_int_5' +VARIABLES: Found output '+14', recursing. +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '<(not_int_5)' to '+14' +VARIABLES: Matches: {'content': 'check_list_int', 'is_array': '', 'type': '<', 'replace': '<(check_list_int)'} +VARIABLES: Expanding 'check_list_int' to 'check_list_int' +VARIABLES: Found output '7 8 9', recursing. +VARIABLES: Expanding '7 8 9' to '7 8 9' +VARIABLES: Expanding '<(check_list_int)' to '7 8 9' +VARIABLES: Matches: {'content': 'not_int_2', 'is_array': '', 'type': '<', 'replace': '<(not_int_2)'} +VARIABLES: Expanding 'not_int_2' to 'not_int_2' +VARIABLES: Found output '11 ', recursing. +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding '<(not_int_2)' to '11 ' +VARIABLES: Matches: {'content': 'not_int_1', 'is_array': '', 'type': '<', 'replace': '<(not_int_1)'} +VARIABLES: Expanding 'not_int_1' to 'not_int_1' +VARIABLES: Found output ' 10', recursing. +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Expanding '<(not_int_1)' to ' 10' +VARIABLES: Matches: {'content': 'zero_int', 'is_array': '', 'type': '<', 'replace': '<(zero_int)'} +VARIABLES: Expanding 'zero_int' to 'zero_int' +VARIABLES: Found output '0', recursing. +VARIABLES: Expanding '0' to 0 +VARIABLES: Expanding '<(zero_int)' to 0 +VARIABLES: Matches: {'content': 'check_list_int', 'is_array': '', 'type': '<@', 'replace': '<@(check_list_int)'} +VARIABLES: Expanding 'check_list_int' to 'check_list_int' +VARIABLES: Found output [7, 8, 9], recursing. +VARIABLES: Expanding 7 to 7 +VARIABLES: Expanding 8 to 8 +VARIABLES: Expanding 9 to 9 +VARIABLES: Expanding '<@(check_list_int)' to [7, 8, 9] +VARIABLES: Expanding 'foo' to 'foo' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Matches: {'content': 'var6', 'is_array': '', 'type': '<', 'replace': '<(var6)'} +VARIABLES: Expanding 'var6' to 'var6' +VARIABLES: Matches: {'content': 'echo <(var5', 'is_array': '', 'type': '<!', 'replace': '<!(echo <(var5)'} +VARIABLES: Matches: {'content': 'var5', 'is_array': '', 'type': '<', 'replace': '<(var5)'} +VARIABLES: Expanding 'var5' to 'var5' +VARIABLES: Found output 'echo letters_list', recursing. +VARIABLES: Expanding 'echo letters_list' to 'echo letters_list' +VARIABLES: Expanding 'echo <(var5)list' to 'echo letters_list' +VARIABLES: Executing command 'echo letters_list' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(echo <(var5)<(var6))' to 'letters_list' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Matches: {'content': '_inputs', 'is_array': '', 'type': '<', 'replace': '<(_inputs)'} +VARIABLES: Expanding '_inputs' to '_inputs' +VARIABLES: Matches: {'content': 'var2', 'is_array': '', 'type': '<', 'replace': '<(var2)'} +VARIABLES: Expanding 'var2' to 'var2' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<(var2)' to '3.14159265359 ABCD' +VARIABLES: Found output '"3.14159265359 ABCD"', recursing. +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding '<(_inputs)' to '"3.14159265359 ABCD"' +VARIABLES: Matches: {'content': '_outputs', 'is_array': '', 'type': '<', 'replace': '<(_outputs)'} +VARIABLES: Expanding '_outputs' to '_outputs' +VARIABLES: Matches: {'content': 'var4', 'is_array': '', 'type': '<', 'replace': '<(var4)'} +VARIABLES: Expanding 'var4' to 'var4' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(var4)' to 'ABCD' +VARIABLES: Matches: {'content': 'var7', 'is_array': '', 'type': '<', 'replace': '<(var7)'} +VARIABLES: Expanding 'var7' to 'var7' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<(var7)' to 'letters_list' +VARIABLES: Found output 'ABCD letters_list', recursing. +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '<(_outputs)' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'dummy' to 'dummy' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'commands.gyp' to 'commands.gyp' +VARIABLES: Expanding 'commands.gypi' to 'commands.gypi' +VARIABLES: Expanding 'dummy' to 'dummy' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'letters_' to 'letters_' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'list' to 'list' +VARIABLES: Expanding '3.14159265359' to '3.14159265359' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '5blah' to '5blah' +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding '012' to '012' +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '7 8 9' to '7 8 9' +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Expanding 'foo' to 'foo' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' diff --git a/Source/ThirdParty/gyp/test/variables/commands/commands.gyp.stdout b/Source/ThirdParty/gyp/test/variables/commands/commands.gyp.stdout new file mode 100644 index 000000000..3db5f64d5 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/commands.gyp.stdout @@ -0,0 +1,254 @@ +GENERAL: running with these options: +GENERAL: check: None +GENERAL: circular_check: True +GENERAL: debug: ['variables', 'general'] +GENERAL: defines: None +GENERAL: depth: '.' +GENERAL: formats: ['gypd'] +GENERAL: generator_flags: [] +GENERAL: generator_output: None +GENERAL: includes: None +GENERAL: msvs_version: None +GENERAL: suffix: '' +GENERAL: toplevel_dir: None +GENERAL: use_environment: True +GENERAL: cmdline_default_variables: {} +GENERAL: generator_flags: {} +VARIABLES: Expanding '0' to 0 +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '-15' to -15 +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFG', recursing. +VARIABLES: Expanding 'ABCDEFG' to 'ABCDEFG' +VARIABLES: Expanding '<(letters_list)EFG' to 'ABCDEFG' +VARIABLES: Expanding '012' to '012' +VARIABLES: Matches: {'content': 'other_letters', 'is_array': '', 'type': '<', 'replace': '<(other_letters)'} +VARIABLES: Expanding 'other_letters' to 'other_letters' +VARIABLES: Found output '<(letters_list)EFGHIJK', recursing. +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFGHIJK', recursing. +VARIABLES: Expanding 'ABCDEFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(letters_list)EFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(other_letters)HIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding 'import math; print math.pi' to 'import math; print math.pi' +VARIABLES: Matches: {'content': 'included_variable', 'is_array': '', 'type': '<', 'replace': '<(included_variable)'} +VARIABLES: Expanding 'included_variable' to 'included_variable' +VARIABLES: Found output 'XYZ', recursing. +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding '<(included_variable)' to 'XYZ' +VARIABLES: Expanding '6' to 6 +VARIABLES: Matches: {'content': 'included_variable', 'is_array': '', 'type': '<', 'replace': '<(included_variable)'} +VARIABLES: Expanding 'included_variable' to 'included_variable' +VARIABLES: Found output 'XYZ', recursing. +VARIABLES: Expanding 'XYZ' to 'XYZ' +VARIABLES: Expanding '<(included_variable)' to 'XYZ' +VARIABLES: Matches: {'content': 'third_letters', 'is_array': '', 'type': '<', 'replace': '<(third_letters)'} +VARIABLES: Expanding 'third_letters' to 'third_letters' +VARIABLES: Found output '<(other_letters)HIJK', recursing. +VARIABLES: Matches: {'content': 'other_letters', 'is_array': '', 'type': '<', 'replace': '<(other_letters)'} +VARIABLES: Expanding 'other_letters' to 'other_letters' +VARIABLES: Found output '<(letters_list)EFGHIJK', recursing. +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'ABCDEFGHIJK', recursing. +VARIABLES: Expanding 'ABCDEFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(letters_list)EFGHIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(other_letters)HIJK' to 'ABCDEFGHIJK' +VARIABLES: Expanding '<(third_letters)' to 'ABCDEFGHIJK' +VARIABLES: Expanding '8' to 8 +VARIABLES: Expanding '.' to '.' +VARIABLES: Expanding 'letters_' to 'letters_' +VARIABLES: Matches: {'content': '<!(python -c "print \'letters_list\'"', 'is_array': '', 'type': '<', 'replace': '<(<!(python -c "print \'letters_list\'")'} +VARIABLES: Matches: {'content': 'python -c "print \'letters_list\'"', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'letters_list\'")'} +VARIABLES: Expanding 'python -c "print \'letters_list\'"' to 'python -c "print \'letters_list\'"' +VARIABLES: Executing command 'python -c "print 'letters_list'"' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(python -c "print \'letters_list\'")' to 'letters_list' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(<!(python -c "print \'letters_list\'"))' to 'ABCD' +VARIABLES: Matches: {'content': 'check_int', 'is_array': '', 'type': '<', 'replace': '<(check_int)'} +VARIABLES: Expanding 'check_int' to 'check_int' +VARIABLES: Found output '5', recursing. +VARIABLES: Expanding '5' to 5 +VARIABLES: Expanding '<(check_int)' to 5 +VARIABLES: Expanding 'list' to 'list' +VARIABLES: Matches: {'content': '"python", "-c", "<(pi', 'is_array': '[', 'type': '<!', 'replace': '<!(["python", "-c", "<(pi)'} +VARIABLES: Matches: {'content': 'pi', 'is_array': '', 'type': '<', 'replace': '<(pi)'} +VARIABLES: Expanding 'pi' to 'pi' +VARIABLES: Found output '["python", "-c", "import math; print math.pi"]', recursing. +VARIABLES: Expanding '["python", "-c", "import math; print math.pi"]' to '["python", "-c", "import math; print math.pi"]' +VARIABLES: Expanding '["python", "-c", "<(pi)"]' to '["python", "-c", "import math; print math.pi"]' +VARIABLES: Executing command '['python', '-c', 'import math; print math.pi']' in directory 'None' +VARIABLES: Found output '3.14159265359', recursing. +VARIABLES: Expanding '3.14159265359' to '3.14159265359' +VARIABLES: Expanding '<!(["python", "-c", "<(pi)"])' to '3.14159265359' +VARIABLES: Matches: {'content': 'python -c "print \'<(letters_list', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'<(letters_list)'} +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Found output 'python -c "print \'ABCD\'"', recursing. +VARIABLES: Expanding 'python -c "print \'ABCD\'"' to 'python -c "print \'ABCD\'"' +VARIABLES: Expanding 'python -c "print \'<(letters_list)\'"' to 'python -c "print \'ABCD\'"' +VARIABLES: Executing command 'python -c "print 'ABCD'"' in directory 'None' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<!(python -c "print \'<(letters_list)\'")' to 'ABCD' +VARIABLES: Matches: {'content': 'letters_list', 'is_array': '', 'type': '<', 'replace': '<(letters_list)'} +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Matches: {'content': 'python -c "print \'<!(python -c "<(pi', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "print \'<!(python -c "<(pi)'} +VARIABLES: Matches: {'content': 'python -c "<(pi', 'is_array': '', 'type': '<!', 'replace': '<!(python -c "<(pi)'} +VARIABLES: Matches: {'content': 'pi', 'is_array': '', 'type': '<', 'replace': '<(pi)'} +VARIABLES: Expanding 'pi' to 'pi' +VARIABLES: Found output 'python -c "import math; print math.pi"', recursing. +VARIABLES: Expanding 'python -c "import math; print math.pi"' to 'python -c "import math; print math.pi"' +VARIABLES: Expanding 'python -c "<(pi)"' to 'python -c "import math; print math.pi"' +VARIABLES: Executing command 'python -c "import math; print math.pi"' in directory 'None' +VARIABLES: Found output 'python -c "print \'3.14159265359 ABCD\'"', recursing. +VARIABLES: Expanding 'python -c "print \'3.14159265359 ABCD\'"' to 'python -c "print \'3.14159265359 ABCD\'"' +VARIABLES: Expanding 'python -c "print \'<!(python -c "<(pi)") ABCD\'"' to 'python -c "print \'3.14159265359 ABCD\'"' +VARIABLES: Executing command 'python -c "print '3.14159265359 ABCD'"' in directory 'None' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<!(python -c "print \'<!(python -c "<(pi)") <(letters_list)\'")' to '3.14159265359 ABCD' +VARIABLES: Matches: {'content': 'check_str_int', 'is_array': '', 'type': '<', 'replace': '<(check_str_int)'} +VARIABLES: Expanding 'check_str_int' to 'check_str_int' +VARIABLES: Found output '6', recursing. +VARIABLES: Expanding '6' to 6 +VARIABLES: Expanding '<(check_str_int)' to 6 +VARIABLES: Matches: {'content': 'check_int', 'is_array': '', 'type': '<', 'replace': '<(check_int)'} +VARIABLES: Expanding 'check_int' to 'check_int' +VARIABLES: Found output '5blah', recursing. +VARIABLES: Expanding '5blah' to '5blah' +VARIABLES: Expanding '<(check_int)blah' to '5blah' +VARIABLES: Matches: {'content': 'not_int_4', 'is_array': '', 'type': '<', 'replace': '<(not_int_4)'} +VARIABLES: Expanding 'not_int_4' to 'not_int_4' +VARIABLES: Found output '13.0', recursing. +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding '<(not_int_4)' to '13.0' +VARIABLES: Matches: {'content': 'not_int_3', 'is_array': '', 'type': '<', 'replace': '<(not_int_3)'} +VARIABLES: Expanding 'not_int_3' to 'not_int_3' +VARIABLES: Found output '012', recursing. +VARIABLES: Expanding '012' to '012' +VARIABLES: Expanding '<(not_int_3)' to '012' +VARIABLES: Matches: {'content': 'negative_int', 'is_array': '', 'type': '<', 'replace': '<(negative_int)'} +VARIABLES: Expanding 'negative_int' to 'negative_int' +VARIABLES: Found output '-15', recursing. +VARIABLES: Expanding '-15' to -15 +VARIABLES: Expanding '<(negative_int)' to -15 +VARIABLES: Matches: {'content': 'not_int_5', 'is_array': '', 'type': '<', 'replace': '<(not_int_5)'} +VARIABLES: Expanding 'not_int_5' to 'not_int_5' +VARIABLES: Found output '+14', recursing. +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '<(not_int_5)' to '+14' +VARIABLES: Matches: {'content': 'check_list_int', 'is_array': '', 'type': '<', 'replace': '<(check_list_int)'} +VARIABLES: Expanding 'check_list_int' to 'check_list_int' +VARIABLES: Found output '7 8 9', recursing. +VARIABLES: Expanding '7 8 9' to '7 8 9' +VARIABLES: Expanding '<(check_list_int)' to '7 8 9' +VARIABLES: Matches: {'content': 'not_int_2', 'is_array': '', 'type': '<', 'replace': '<(not_int_2)'} +VARIABLES: Expanding 'not_int_2' to 'not_int_2' +VARIABLES: Found output '11 ', recursing. +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding '<(not_int_2)' to '11 ' +VARIABLES: Matches: {'content': 'not_int_1', 'is_array': '', 'type': '<', 'replace': '<(not_int_1)'} +VARIABLES: Expanding 'not_int_1' to 'not_int_1' +VARIABLES: Found output ' 10', recursing. +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Expanding '<(not_int_1)' to ' 10' +VARIABLES: Matches: {'content': 'zero_int', 'is_array': '', 'type': '<', 'replace': '<(zero_int)'} +VARIABLES: Expanding 'zero_int' to 'zero_int' +VARIABLES: Found output '0', recursing. +VARIABLES: Expanding '0' to 0 +VARIABLES: Expanding '<(zero_int)' to 0 +VARIABLES: Matches: {'content': 'check_list_int', 'is_array': '', 'type': '<@', 'replace': '<@(check_list_int)'} +VARIABLES: Expanding 'check_list_int' to 'check_list_int' +VARIABLES: Found output [7, 8, 9], recursing. +VARIABLES: Expanding 7 to 7 +VARIABLES: Expanding 8 to 8 +VARIABLES: Expanding 9 to 9 +VARIABLES: Expanding '<@(check_list_int)' to [7, 8, 9] +VARIABLES: Expanding 'foo' to 'foo' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Matches: {'content': 'var6', 'is_array': '', 'type': '<', 'replace': '<(var6)'} +VARIABLES: Expanding 'var6' to 'var6' +VARIABLES: Matches: {'content': 'echo <(var5', 'is_array': '', 'type': '<!', 'replace': '<!(echo <(var5)'} +VARIABLES: Matches: {'content': 'var5', 'is_array': '', 'type': '<', 'replace': '<(var5)'} +VARIABLES: Expanding 'var5' to 'var5' +VARIABLES: Found output 'echo letters_list', recursing. +VARIABLES: Expanding 'echo letters_list' to 'echo letters_list' +VARIABLES: Expanding 'echo <(var5)list' to 'echo letters_list' +VARIABLES: Executing command 'echo letters_list' in directory 'None' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<!(echo <(var5)<(var6))' to 'letters_list' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Matches: {'content': '_inputs', 'is_array': '', 'type': '<', 'replace': '<(_inputs)'} +VARIABLES: Expanding '_inputs' to '_inputs' +VARIABLES: Matches: {'content': 'var2', 'is_array': '', 'type': '<', 'replace': '<(var2)'} +VARIABLES: Expanding 'var2' to 'var2' +VARIABLES: Found output '3.14159265359 ABCD', recursing. +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '<(var2)' to '3.14159265359 ABCD' +VARIABLES: Found output '"3.14159265359 ABCD"', recursing. +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding '<(_inputs)' to '"3.14159265359 ABCD"' +VARIABLES: Matches: {'content': '_outputs', 'is_array': '', 'type': '<', 'replace': '<(_outputs)'} +VARIABLES: Expanding '_outputs' to '_outputs' +VARIABLES: Matches: {'content': 'var4', 'is_array': '', 'type': '<', 'replace': '<(var4)'} +VARIABLES: Expanding 'var4' to 'var4' +VARIABLES: Found output 'ABCD', recursing. +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '<(var4)' to 'ABCD' +VARIABLES: Matches: {'content': 'var7', 'is_array': '', 'type': '<', 'replace': '<(var7)'} +VARIABLES: Expanding 'var7' to 'var7' +VARIABLES: Found output 'letters_list', recursing. +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding '<(var7)' to 'letters_list' +VARIABLES: Found output 'ABCD letters_list', recursing. +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '<(_outputs)' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'dummy' to 'dummy' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'commands.gyp' to 'commands.gyp' +VARIABLES: Expanding 'commands.gypi' to 'commands.gypi' +VARIABLES: Expanding 'dummy' to 'dummy' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'letters_' to 'letters_' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'list' to 'list' +VARIABLES: Expanding '3.14159265359' to '3.14159265359' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding '5blah' to '5blah' +VARIABLES: Expanding '13.0' to '13.0' +VARIABLES: Expanding '012' to '012' +VARIABLES: Expanding '+14' to '+14' +VARIABLES: Expanding '7 8 9' to '7 8 9' +VARIABLES: Expanding '11 ' to '11 ' +VARIABLES: Expanding ' 10' to ' 10' +VARIABLES: Expanding 'foo' to 'foo' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'letters_list' to 'letters_list' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'echo' to 'echo' +VARIABLES: Expanding '"3.14159265359 ABCD"' to '"3.14159265359 ABCD"' +VARIABLES: Expanding 'ABCD letters_list' to 'ABCD letters_list' +VARIABLES: Expanding '3.14159265359 ABCD' to '3.14159265359 ABCD' +VARIABLES: Expanding 'ABCD' to 'ABCD' +VARIABLES: Expanding 'letters_list' to 'letters_list' diff --git a/Source/ThirdParty/gyp/test/variables/commands/commands.gypd.golden b/Source/ThirdParty/gyp/test/variables/commands/commands.gypd.golden new file mode 100644 index 000000000..e9aaf0202 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/commands.gypd.golden @@ -0,0 +1,54 @@ +{'_DEPTH': '.', + 'included_files': ['commands.gyp', 'commands.gypi'], + 'targets': [{'actions': [{'action': ['echo', + '"3.14159265359 ABCD"', + 'ABCD letters_list'], + 'action_name': 'test_action', + 'inputs': ['3.14159265359 ABCD'], + 'outputs': ['ABCD', 'letters_list'], + 'variables': {'var7': 'letters_list'}}], + 'configurations': {'Default': {}}, + 'default_configuration': 'Default', + 'target_name': 'foo', + 'toolset': 'target', + 'type': 'none', + 'variables': {'var1': '3.14159265359', + 'var10': '7 8 9', + 'var11': ['7', '8', '9'], + 'var12': ' 10', + 'var13': '11 ', + 'var14': '012', + 'var15': '13.0', + 'var16': '+14', + 'var17': '-15', + 'var18': '0', + 'var2': '3.14159265359 ABCD', + 'var3': 'ABCD', + 'var4': 'ABCD', + 'var5': 'letters_', + 'var6': 'list', + 'var7': '5', + 'var8': '5blah', + 'var9': '6'}}, + {'configurations': {'Default': {}}, + 'default_configuration': 'Default', + 'target_name': 'dummy', + 'toolset': 'target', + 'type': 'none'}], + 'variables': {'check_included': 'XYZ', + 'check_int': '5', + 'check_list_int': ['7', '8', '9'], + 'check_lists': ['XYZ', 'ABCDEFGHIJK'], + 'check_str_int': '6', + 'included_variable': 'XYZ', + 'letters_list': 'ABCD', + 'negative_int': '-15', + 'not_int_1': ' 10', + 'not_int_2': '11 ', + 'not_int_3': '012', + 'not_int_4': '13.0', + 'not_int_5': '+14', + 'other_letters': 'ABCDEFG', + 'pi': 'import math; print math.pi', + 'third_letters': 'ABCDEFGHIJK', + 'zero_int': '0'}} diff --git a/Source/ThirdParty/gyp/test/variables/commands/commands.gypi b/Source/ThirdParty/gyp/test/variables/commands/commands.gypi new file mode 100644 index 000000000..6b2249715 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/commands.gypi @@ -0,0 +1,16 @@ +# Copyright (c) 2009 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. + +# This file is included from commands.gyp to test evaluation order of includes. +{ + 'variables': { + 'included_variable': 'XYZ', + }, + 'targets': [ + { + 'target_name': 'dummy', + 'type': 'none', + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands-ignore-env.py b/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands-ignore-env.py new file mode 100644 index 000000000..33ce1b58f --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands-ignore-env.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 that environment variables are ignored when --ignore-environment is +specified. +""" + +import os + +import TestGyp + +os.environ['GYP_DEFINES'] = 'FOO=BAR' +os.environ['GYP_GENERATORS'] = 'foo' +os.environ['GYP_GENERATOR_FLAGS'] = 'genflag=foo' +os.environ['GYP_GENERATOR_OUTPUT'] = 'somedir' + +test = TestGyp.TestGyp(format='gypd') + +expect = test.read('commands.gyp.ignore-env.stdout').replace('\r', '') + +# Set $HOME so that gyp doesn't read the user's actual +# ~/.gyp/include.gypi file, which may contain variables +# and other settings that would change the output. +os.environ['HOME'] = test.workpath() + +test.run_gyp('commands.gyp', + '--debug', 'variables', '--debug', 'general', + '--ignore-environment', + stdout=expect) + +# Verify the commands.gypd against the checked-in expected contents. +# +# Normally, we should canonicalize line endings in the expected +# contents file setting the Subversion svn:eol-style to native, +# but that would still fail if multiple systems are sharing a single +# workspace on a network-mounted file system. Consequently, we +# massage the Windows line endings ('\r\n') in the output to the +# checked-in UNIX endings ('\n'). + +contents = test.read('commands.gypd').replace('\r', '') +expect = test.read('commands.gypd.golden').replace('\r', '') +if not test.match(contents, expect): + print "Unexpected contents of `commands.gypd'" + test.diff(expect, contents, 'commands.gypd ') + test.fail_test() + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands-repeated.py b/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands-repeated.py new file mode 100644 index 000000000..3009afeaa --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands-repeated.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 variable expansion of '<!()' syntax commands where they are evaluated +more then once.. +""" + +import os + +import TestGyp + +test = TestGyp.TestGyp(format='gypd') + +expect = test.read('commands-repeated.gyp.stdout').replace('\r', '') + +# Set $HOME so that gyp doesn't read the user's actual +# ~/.gyp/include.gypi file, which may contain variables +# and other settings that would change the output. +os.environ['HOME'] = test.workpath() + +test.run_gyp('commands-repeated.gyp', + '--debug', 'variables', '--debug', 'general', + stdout=expect) + +# Verify the commands-repeated.gypd against the checked-in expected contents. +# +# Normally, we should canonicalize line endings in the expected +# contents file setting the Subversion svn:eol-style to native, +# but that would still fail if multiple systems are sharing a single +# workspace on a network-mounted file system. Consequently, we +# massage the Windows line endings ('\r\n') in the output to the +# checked-in UNIX endings ('\n'). + +contents = test.read('commands-repeated.gypd').replace('\r', '') +expect = test.read('commands-repeated.gypd.golden').replace('\r', '') +if not test.match(contents, expect): + print "Unexpected contents of `commands-repeated.gypd'" + test.diff(expect, contents, 'commands-repeated.gypd ') + test.fail_test() + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands.py b/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands.py new file mode 100644 index 000000000..0dc154766 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/gyptest-commands.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 variable expansion of '<!()' syntax commands. +""" + +import os + +import TestGyp + +test = TestGyp.TestGyp(format='gypd') + +expect = test.read('commands.gyp.stdout').replace('\r', '') + +# Set $HOME so that gyp doesn't read the user's actual +# ~/.gyp/include.gypi file, which may contain variables +# and other settings that would change the output. +os.environ['HOME'] = test.workpath() + +test.run_gyp('commands.gyp', + '--debug', 'variables', '--debug', 'general', + stdout=expect) + +# Verify the commands.gypd against the checked-in expected contents. +# +# Normally, we should canonicalize line endings in the expected +# contents file setting the Subversion svn:eol-style to native, +# but that would still fail if multiple systems are sharing a single +# workspace on a network-mounted file system. Consequently, we +# massage the Windows line endings ('\r\n') in the output to the +# checked-in UNIX endings ('\n'). + +contents = test.read('commands.gypd').replace('\r', '') +expect = test.read('commands.gypd.golden').replace('\r', '') +if not test.match(contents, expect): + print "Unexpected contents of `commands.gypd'" + test.diff(expect, contents, 'commands.gypd ') + test.fail_test() + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/variables/commands/update_golden b/Source/ThirdParty/gyp/test/variables/commands/update_golden new file mode 100755 index 000000000..e8da558a2 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/commands/update_golden @@ -0,0 +1,11 @@ +#!/bin/bash + +# Copyright (c) 2009 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. + +python ../../../gyp --debug variables --debug general --format gypd --depth . commands.gyp > commands.gyp.stdout +python ../../../gyp --ignore-environment --debug variables --debug general --format gypd --depth . commands.gyp > commands.gyp.ignore-env.stdout +cp -f commands.gypd commands.gypd.golden +python ../../../gyp --debug variables --debug general --format gypd --depth . commands-repeated.gyp > commands-repeated.gyp.stdout +cp -f commands-repeated.gypd commands-repeated.gypd.golden diff --git a/Source/ThirdParty/gyp/test/variables/filelist/filelist.gyp.stdout b/Source/ThirdParty/gyp/test/variables/filelist/filelist.gyp.stdout new file mode 100644 index 000000000..f541267a9 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/filelist/filelist.gyp.stdout @@ -0,0 +1,174 @@ +GENERAL: running with these options: +GENERAL: check: None +GENERAL: circular_check: True +GENERAL: debug: ['variables', 'general'] +GENERAL: defines: None +GENERAL: depth: '.' +GENERAL: formats: ['gypd'] +GENERAL: generator_flags: [] +GENERAL: generator_output: None +GENERAL: includes: None +GENERAL: msvs_version: None +GENERAL: suffix: '' +GENERAL: toplevel_dir: None +GENERAL: use_environment: True +GENERAL: cmdline_default_variables: {} +GENERAL: generator_flags: {} +VARIABLES: Expanding 'exclude' to 'exclude' +VARIABLES: Expanding 'Sch.*' to 'Sch.*' +VARIABLES: Expanding 'include' to 'include' +VARIABLES: Expanding '.*dt' to '.*dt' +VARIABLES: Expanding 'exclude' to 'exclude' +VARIABLES: Expanding 'Jer.*' to 'Jer.*' +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Astor' to 'Astor' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Jerome' to 'Jerome' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Expanding 'Schultz' to 'Schultz' +VARIABLES: Expanding 'Astor' to 'Astor' +VARIABLES: Expanding '.' to '.' +VARIABLES: Matches: {'content': 'names.txt <@(names', 'is_array': '', 'type': '<|', 'replace': '<|(names.txt <@(names)'} +VARIABLES: Matches: {'content': 'names', 'is_array': '', 'type': '<@', 'replace': '<@(names)'} +VARIABLES: Expanding 'names' to 'names' +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Found output 'names.txt John Jacob Jingleheimer Schmidt', recursing. +VARIABLES: Expanding 'names.txt John Jacob Jingleheimer Schmidt' to 'names.txt John Jacob Jingleheimer Schmidt' +VARIABLES: Expanding 'names.txt <@(names)' to 'names.txt John Jacob Jingleheimer Schmidt' +VARIABLES: Found output 'names.txt', recursing. +VARIABLES: Expanding 'names.txt' to 'names.txt' +VARIABLES: Expanding '<|(names.txt <@(names))' to 'names.txt' +VARIABLES: Expanding 'foo' to 'foo' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'python' to 'python' +VARIABLES: Expanding 'dummy.py' to 'dummy.py' +VARIABLES: Matches: {'content': 'names_listfile', 'is_array': '', 'type': '<', 'replace': '<(names_listfile)'} +VARIABLES: Expanding 'names_listfile' to 'names_listfile' +VARIABLES: Found output 'names.txt', recursing. +VARIABLES: Expanding 'names.txt' to 'names.txt' +VARIABLES: Expanding '<(names_listfile)' to 'names.txt' +VARIABLES: Matches: {'content': 'names_listfile', 'is_array': '', 'type': '<', 'replace': '<(names_listfile)'} +VARIABLES: Expanding 'names_listfile' to 'names_listfile' +VARIABLES: Found output 'names.txt', recursing. +VARIABLES: Expanding 'names.txt' to 'names.txt' +VARIABLES: Expanding '<(names_listfile)' to 'names.txt' +VARIABLES: Matches: {'content': 'cat <(names_listfile', 'is_array': '', 'type': '<!@', 'replace': '<!@(cat <(names_listfile)'} +VARIABLES: Matches: {'content': 'names_listfile', 'is_array': '', 'type': '<', 'replace': '<(names_listfile)'} +VARIABLES: Expanding 'names_listfile' to 'names_listfile' +VARIABLES: Found output 'cat names.txt', recursing. +VARIABLES: Expanding 'cat names.txt' to 'cat names.txt' +VARIABLES: Expanding 'cat <(names_listfile)' to 'cat names.txt' +VARIABLES: Executing command 'cat names.txt' in directory 'src' +VARIABLES: Found output ['John', 'Jacob', 'Jingleheimer', 'Schmidt'], recursing. +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Expanding '<!@(cat <(names_listfile))' to ['John', 'Jacob', 'Jingleheimer', 'Schmidt'] +VARIABLES: Expanding 'dummy_foo' to 'dummy_foo' +VARIABLES: Matches: {'content': 'sources.txt <@(_sources', 'is_array': '', 'type': '<|', 'replace': '<|(sources.txt <@(_sources)'} +VARIABLES: Matches: {'content': '_sources', 'is_array': '', 'type': '<@', 'replace': '<@(_sources)'} +VARIABLES: Expanding '_sources' to '_sources' +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Found output 'sources.txt John Jacob Jingleheimer Schmidt', recursing. +VARIABLES: Expanding 'sources.txt John Jacob Jingleheimer Schmidt' to 'sources.txt John Jacob Jingleheimer Schmidt' +VARIABLES: Expanding 'sources.txt <@(_sources)' to 'sources.txt John Jacob Jingleheimer Schmidt' +VARIABLES: Found output 'sources.txt', recursing. +VARIABLES: Expanding 'sources.txt' to 'sources.txt' +VARIABLES: Expanding '<|(sources.txt <@(_sources))' to 'sources.txt' +VARIABLES: Expanding 'bar' to 'bar' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'exclude' to 'exclude' +VARIABLES: Expanding 'Sch.*' to 'Sch.*' +VARIABLES: Expanding 'include' to 'include' +VARIABLES: Expanding '.*dt' to '.*dt' +VARIABLES: Expanding 'exclude' to 'exclude' +VARIABLES: Expanding 'Jer.*' to 'Jer.*' +VARIABLES: Expanding 'Astor' to 'Astor' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'python' to 'python' +VARIABLES: Expanding 'dummy.py' to 'dummy.py' +VARIABLES: Matches: {'content': 'sources_listfile', 'is_array': '', 'type': '<', 'replace': '<(sources_listfile)'} +VARIABLES: Expanding 'sources_listfile' to 'sources_listfile' +VARIABLES: Found output 'sources.txt', recursing. +VARIABLES: Expanding 'sources.txt' to 'sources.txt' +VARIABLES: Expanding '<(sources_listfile)' to 'sources.txt' +VARIABLES: Matches: {'content': 'sources_listfile', 'is_array': '', 'type': '<', 'replace': '<(sources_listfile)'} +VARIABLES: Expanding 'sources_listfile' to 'sources_listfile' +VARIABLES: Found output 'sources.txt', recursing. +VARIABLES: Expanding 'sources.txt' to 'sources.txt' +VARIABLES: Expanding '<(sources_listfile)' to 'sources.txt' +VARIABLES: Matches: {'content': 'cat <(sources_listfile', 'is_array': '', 'type': '<!@', 'replace': '<!@(cat <(sources_listfile)'} +VARIABLES: Matches: {'content': 'sources_listfile', 'is_array': '', 'type': '<', 'replace': '<(sources_listfile)'} +VARIABLES: Expanding 'sources_listfile' to 'sources_listfile' +VARIABLES: Found output 'cat sources.txt', recursing. +VARIABLES: Expanding 'cat sources.txt' to 'cat sources.txt' +VARIABLES: Expanding 'cat <(sources_listfile)' to 'cat sources.txt' +VARIABLES: Executing command 'cat sources.txt' in directory 'src' +VARIABLES: Found output ['John', 'Jacob', 'Jingleheimer', 'Schmidt'], recursing. +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Expanding '<!@(cat <(sources_listfile))' to ['John', 'Jacob', 'Jingleheimer', 'Schmidt'] +VARIABLES: Expanding 'dummy_foo' to 'dummy_foo' +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Astor' to 'Astor' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Jerome' to 'Jerome' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Expanding 'Schultz' to 'Schultz' +VARIABLES: Expanding 'filelist.gyp' to 'filelist.gyp' +VARIABLES: Expanding 'names.txt' to 'names.txt' +VARIABLES: Expanding 'foo' to 'foo' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'python' to 'python' +VARIABLES: Expanding 'dummy.py' to 'dummy.py' +VARIABLES: Expanding 'names.txt' to 'names.txt' +VARIABLES: Expanding 'names.txt' to 'names.txt' +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Expanding 'dummy_foo' to 'dummy_foo' +VARIABLES: Expanding 'sources.txt' to 'sources.txt' +VARIABLES: Expanding 'bar' to 'bar' +VARIABLES: Expanding 'target' to 'target' +VARIABLES: Expanding 'none' to 'none' +VARIABLES: Expanding 'exclude' to 'exclude' +VARIABLES: Expanding 'Sch.*' to 'Sch.*' +VARIABLES: Expanding 'include' to 'include' +VARIABLES: Expanding '.*dt' to '.*dt' +VARIABLES: Expanding 'exclude' to 'exclude' +VARIABLES: Expanding 'Jer.*' to 'Jer.*' +VARIABLES: Expanding 'Astor' to 'Astor' +VARIABLES: Expanding 'test_action' to 'test_action' +VARIABLES: Expanding 'python' to 'python' +VARIABLES: Expanding 'dummy.py' to 'dummy.py' +VARIABLES: Expanding 'sources.txt' to 'sources.txt' +VARIABLES: Expanding 'sources.txt' to 'sources.txt' +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Expanding 'dummy_foo' to 'dummy_foo' +VARIABLES: Expanding 'John' to 'John' +VARIABLES: Expanding 'Jacob' to 'Jacob' +VARIABLES: Expanding 'Astor' to 'Astor' +VARIABLES: Expanding 'Jingleheimer' to 'Jingleheimer' +VARIABLES: Expanding 'Jerome' to 'Jerome' +VARIABLES: Expanding 'Schmidt' to 'Schmidt' +VARIABLES: Expanding 'Schultz' to 'Schultz' diff --git a/Source/ThirdParty/gyp/test/variables/filelist/filelist.gypd.golden b/Source/ThirdParty/gyp/test/variables/filelist/filelist.gypd.golden new file mode 100644 index 000000000..09d911604 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/filelist/filelist.gypd.golden @@ -0,0 +1,43 @@ +{'_DEPTH': '.', + 'included_files': ['filelist.gyp'], + 'targets': [{'actions': [{'action': ['python', 'dummy.py', 'names.txt'], + 'action_name': 'test_action', + 'inputs': ['names.txt', + 'John', + 'Jacob', + 'Jingleheimer', + 'Schmidt'], + 'outputs': ['dummy_foo']}], + 'configurations': {'Default': {}}, + 'default_configuration': 'Default', + 'target_name': 'foo', + 'toolset': 'target', + 'type': 'none', + 'variables': {'names_listfile': 'names.txt'}}, + {'actions': [{'action': ['python', 'dummy.py', 'sources.txt'], + 'action_name': 'test_action', + 'inputs': ['sources.txt', + 'John', + 'Jacob', + 'Jingleheimer', + 'Schmidt'], + 'outputs': ['dummy_foo']}], + 'configurations': {'Default': {}}, + 'default_configuration': 'Default', + 'sources': ['John', 'Jacob', 'Jingleheimer', 'Schmidt'], + 'sources_excluded': ['Astor', 'Jerome', 'Schultz'], + 'target_name': 'bar', + 'toolset': 'target', + 'type': 'none', + 'variables': {'sources_listfile': 'sources.txt'}}], + 'variables': {'names': ['John', + 'Jacob', + 'Astor', + 'Jingleheimer', + 'Jerome', + 'Schmidt', + 'Schultz'], + 'names!': ['Astor'], + 'names/': [['exclude', 'Sch.*'], + ['include', '.*dt'], + ['exclude', 'Jer.*']]}} diff --git a/Source/ThirdParty/gyp/test/variables/filelist/gyptest-filelist.py b/Source/ThirdParty/gyp/test/variables/filelist/gyptest-filelist.py new file mode 100644 index 000000000..4fb0d9a93 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/filelist/gyptest-filelist.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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 variable expansion of '<|(list.txt ...)' syntax commands. +""" + +import os +import sys + +import TestGyp + +test = TestGyp.TestGyp(format='gypd') + +expect = test.read('filelist.gyp.stdout') +if sys.platform == 'win32': + expect = expect.replace('/', r'\\').replace('\r', '') + +# Set $HOME so that gyp doesn't read the user's actual +# ~/.gyp/include.gypi file, which may contain variables +# and other settings that would change the output. +os.environ['HOME'] = test.workpath() + +test.run_gyp('src/filelist.gyp', + '--debug', 'variables', '--debug', 'general', + stdout=expect) + +# Verify the filelist.gypd against the checked-in expected contents. +# +# Normally, we should canonicalize line endings in the expected +# contents file setting the Subversion svn:eol-style to native, +# but that would still fail if multiple systems are sharing a single +# workspace on a network-mounted file system. Consequently, we +# massage the Windows line endings ('\r\n') in the output to the +# checked-in UNIX endings ('\n'). + +contents = test.read('src/filelist.gypd').replace( + '\r', '').replace('\\\\', '/') +expect = test.read('filelist.gypd.golden').replace('\r', '') +if not test.match(contents, expect): + print "Unexpected contents of `src/filelist.gypd'" + test.diff(expect, contents, 'src/filelist.gypd ') + test.fail_test() + +contents = test.read('src/names.txt') +expect = 'John\nJacob\nJingleheimer\nSchmidt\n' +if not test.match(contents, expect): + print "Unexpected contents of `src/names.txt'" + test.diff(expect, contents, 'src/names.txt ') + test.fail_test() + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/variables/filelist/src/filelist.gyp b/Source/ThirdParty/gyp/test/variables/filelist/src/filelist.gyp new file mode 100644 index 000000000..df48eb3e4 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/filelist/src/filelist.gyp @@ -0,0 +1,93 @@ +# Copyright (c) 2009 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. + +# This is a test to make sure that <|(foo.txt a b c) generates +# a pre-calculated file list at gyp time and returns foo.txt. +# This feature is useful to work around limits in the number of arguments that +# can be passed to rule/action. + +{ + 'variables': { + 'names': [ + 'John', + 'Jacob', + 'Astor', + 'Jingleheimer', + 'Jerome', + 'Schmidt', + 'Schultz', + ], + 'names!': [ + 'Astor', + ], + 'names/': [ + ['exclude', 'Sch.*'], + ['include', '.*dt'], + ['exclude', 'Jer.*'], + ], + }, + 'targets': [ + { + 'target_name': 'foo', + 'type': 'none', + 'variables': { + 'names_listfile': '<|(names.txt <@(names))', + }, + 'actions': [ + { + 'action_name': 'test_action', + 'inputs' : [ + '<(names_listfile)', + '<!@(cat <(names_listfile))', + ], + 'outputs': [ + 'dummy_foo', + ], + 'action': [ + 'python', 'dummy.py', '<(names_listfile)', + ], + }, + ], + }, + { + 'target_name': 'bar', + 'type': 'none', + 'sources': [ + 'John', + 'Jacob', + 'Astor', + 'Jingleheimer', + 'Jerome', + 'Schmidt', + 'Schultz', + ], + 'sources!': [ + 'Astor', + ], + 'sources/': [ + ['exclude', 'Sch.*'], + ['include', '.*dt'], + ['exclude', 'Jer.*'], + ], + 'variables': { + 'sources_listfile': '<|(sources.txt <@(_sources))', + }, + 'actions': [ + { + 'action_name': 'test_action', + 'inputs' : [ + '<(sources_listfile)', + '<!@(cat <(sources_listfile))', + ], + 'outputs': [ + 'dummy_foo', + ], + 'action': [ + 'python', 'dummy.py', '<(sources_listfile)', + ], + }, + ], + }, + ], +} diff --git a/Source/ThirdParty/gyp/test/variables/filelist/update_golden b/Source/ThirdParty/gyp/test/variables/filelist/update_golden new file mode 100755 index 000000000..b4d489a34 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variables/filelist/update_golden @@ -0,0 +1,8 @@ +#!/bin/bash + +# Copyright (c) 2009 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. + +python ../../../gyp --debug variables --debug general --format gypd --depth . src/filelist.gyp > filelist.gyp.stdout +cp -f src/filelist.gypd filelist.gypd.golden diff --git a/Source/ThirdParty/gyp/test/variants/gyptest-variants.py b/Source/ThirdParty/gyp/test/variants/gyptest-variants.py new file mode 100644 index 000000000..ce2455f66 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variants/gyptest-variants.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +# Copyright (c) 2009 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. + +""" +Verify handling of build variants. + +TODO: Right now, only the SCons generator supports this, so the +test case is SCons-specific. In particular, it relise on SCons' +ability to rebuild in response to changes on the command line. It +may be simpler to just drop this feature if the other generators +can't be made to behave the same way. +""" + +import TestGyp + +test = TestGyp.TestGyp(formats=['scons']) + +test.run_gyp('variants.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('variants.gyp', chdir='relocate/src') + +test.run_built_executable('variants', + chdir='relocate/src', + stdout="Hello, world!\n") + +test.sleep() +test.build('variants.gyp', 'VARIANT1=1', chdir='relocate/src') + +test.run_built_executable('variants', + chdir='relocate/src', + stdout="Hello from VARIANT1\n") + +test.sleep() +test.build('variants.gyp', 'VARIANT2=1', chdir='relocate/src') + +test.run_built_executable('variants', + chdir='relocate/src', + stdout="Hello from VARIANT2\n") + +test.pass_test() diff --git a/Source/ThirdParty/gyp/test/variants/src/variants.c b/Source/ThirdParty/gyp/test/variants/src/variants.c new file mode 100644 index 000000000..3018e40df --- /dev/null +++ b/Source/ThirdParty/gyp/test/variants/src/variants.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +int main(int argc, char *argv[]) +{ +#if defined(VARIANT1) + printf("Hello from VARIANT1\n"); +#elif defined(VARIANT2) + printf("Hello from VARIANT2\n"); +#else + printf("Hello, world!\n"); +#endif + return 0; +} diff --git a/Source/ThirdParty/gyp/test/variants/src/variants.gyp b/Source/ThirdParty/gyp/test/variants/src/variants.gyp new file mode 100644 index 000000000..0305ca747 --- /dev/null +++ b/Source/ThirdParty/gyp/test/variants/src/variants.gyp @@ -0,0 +1,27 @@ +# Copyright (c) 2009 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': 'variants', + 'type': 'executable', + 'sources': [ + 'variants.c', + ], + 'variants': { + 'variant1' : { + 'defines': [ + 'VARIANT1', + ], + }, + 'variant2' : { + 'defines': [ + 'VARIANT2', + ], + }, + }, + }, + ], +} |