From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- third_party/python/gyp/test/rules/gyptest-all.py | 84 ++++++++++++++++++++++ .../python/gyp/test/rules/gyptest-default.py | 70 ++++++++++++++++++ .../python/gyp/test/rules/gyptest-input-root.py | 26 +++++++ .../gyp/test/rules/gyptest-special-variables.py | 18 +++++ third_party/python/gyp/test/rules/src/actions.gyp | 23 ++++++ third_party/python/gyp/test/rules/src/an_asm.S | 6 ++ third_party/python/gyp/test/rules/src/as.bat | 7 ++ third_party/python/gyp/test/rules/src/copy-file.py | 11 +++ .../gyp/test/rules/src/external/external.gyp | 66 +++++++++++++++++ .../python/gyp/test/rules/src/external/file1.in | 1 + .../python/gyp/test/rules/src/external/file2.in | 1 + .../python/gyp/test/rules/src/input-root.gyp | 24 +++++++ .../python/gyp/test/rules/src/noaction/file1.in | 1 + .../src/noaction/no_action_with_rules_fails.gyp | 37 ++++++++++ third_party/python/gyp/test/rules/src/rule.py | 17 +++++ third_party/python/gyp/test/rules/src/somefile.ext | 0 .../gyp/test/rules/src/special-variables.gyp | 34 +++++++++ .../gyp/test/rules/src/subdir1/executable.gyp | 37 ++++++++++ .../python/gyp/test/rules/src/subdir1/function1.in | 6 ++ .../python/gyp/test/rules/src/subdir1/function2.in | 6 ++ .../python/gyp/test/rules/src/subdir1/program.c | 12 ++++ .../src/subdir2/both_rule_and_action_input.gyp | 50 +++++++++++++ .../python/gyp/test/rules/src/subdir2/file1.in | 1 + .../python/gyp/test/rules/src/subdir2/file2.in | 1 + .../gyp/test/rules/src/subdir2/never_used.gyp | 31 ++++++++ .../gyp/test/rules/src/subdir2/no_action.gyp | 38 ++++++++++ .../gyp/test/rules/src/subdir2/no_inputs.gyp | 32 +++++++++ .../python/gyp/test/rules/src/subdir2/none.gyp | 33 +++++++++ .../python/gyp/test/rules/src/subdir2/program.c | 12 ++++ .../gyp/test/rules/src/subdir3/executable2.gyp | 37 ++++++++++ .../python/gyp/test/rules/src/subdir3/function3.in | 6 ++ .../python/gyp/test/rules/src/subdir3/program.c | 10 +++ .../gyp/test/rules/src/subdir4/asm-function.assem | 10 +++ .../gyp/test/rules/src/subdir4/build-asm.gyp | 49 +++++++++++++ .../python/gyp/test/rules/src/subdir4/program.c | 19 +++++ 35 files changed, 816 insertions(+) create mode 100755 third_party/python/gyp/test/rules/gyptest-all.py create mode 100755 third_party/python/gyp/test/rules/gyptest-default.py create mode 100755 third_party/python/gyp/test/rules/gyptest-input-root.py create mode 100644 third_party/python/gyp/test/rules/gyptest-special-variables.py create mode 100644 third_party/python/gyp/test/rules/src/actions.gyp create mode 100644 third_party/python/gyp/test/rules/src/an_asm.S create mode 100644 third_party/python/gyp/test/rules/src/as.bat create mode 100755 third_party/python/gyp/test/rules/src/copy-file.py create mode 100644 third_party/python/gyp/test/rules/src/external/external.gyp create mode 100644 third_party/python/gyp/test/rules/src/external/file1.in create mode 100644 third_party/python/gyp/test/rules/src/external/file2.in create mode 100644 third_party/python/gyp/test/rules/src/input-root.gyp create mode 100644 third_party/python/gyp/test/rules/src/noaction/file1.in create mode 100644 third_party/python/gyp/test/rules/src/noaction/no_action_with_rules_fails.gyp create mode 100755 third_party/python/gyp/test/rules/src/rule.py create mode 100644 third_party/python/gyp/test/rules/src/somefile.ext create mode 100644 third_party/python/gyp/test/rules/src/special-variables.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir1/executable.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir1/function1.in create mode 100644 third_party/python/gyp/test/rules/src/subdir1/function2.in create mode 100644 third_party/python/gyp/test/rules/src/subdir1/program.c create mode 100644 third_party/python/gyp/test/rules/src/subdir2/both_rule_and_action_input.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir2/file1.in create mode 100644 third_party/python/gyp/test/rules/src/subdir2/file2.in create mode 100644 third_party/python/gyp/test/rules/src/subdir2/never_used.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir2/no_action.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir2/no_inputs.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir2/none.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir2/program.c create mode 100644 third_party/python/gyp/test/rules/src/subdir3/executable2.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir3/function3.in create mode 100644 third_party/python/gyp/test/rules/src/subdir3/program.c create mode 100644 third_party/python/gyp/test/rules/src/subdir4/asm-function.assem create mode 100644 third_party/python/gyp/test/rules/src/subdir4/build-asm.gyp create mode 100644 third_party/python/gyp/test/rules/src/subdir4/program.c (limited to 'third_party/python/gyp/test/rules') diff --git a/third_party/python/gyp/test/rules/gyptest-all.py b/third_party/python/gyp/test/rules/gyptest-all.py new file mode 100755 index 0000000000..0520c2f6a0 --- /dev/null +++ b/third_party/python/gyp/test/rules/gyptest-all.py @@ -0,0 +1,84 @@ +#!/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 simple rules when using an explicit build target of 'all'. +""" + +from __future__ import print_function + +import sys + +if sys.platform == 'win32': + print("This test is currently disabled: https://crbug.com/483696.") + sys.exit(0) + + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('no_action_with_rules_fails.gyp', chdir='src/noaction', status=1, + stderr=None) + +test.run_gyp('actions.gyp', + '-G', 'xcode_ninja_target_pattern=^pull_in_all_actions$', + 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.must_match('relocate/src/subdir2/file1.out4', 'Hello from file1.in\n') +test.must_match('relocate/src/subdir2/file2.out4', 'Hello from file2.in\n') +test.must_match('relocate/src/subdir2/file1.copy', 'Hello from file1.in\n') + +test.must_match('relocate/src/external/file1.external_rules.out', + 'Hello from file1.in\n') +test.must_match('relocate/src/external/file2.external_rules.out', + 'Hello from file2.in\n') + +expect = """\ +Hello from program.c +Got 41. +""" + +if test.format == 'xcode': + chdir = 'relocate/src/subdir4' +else: + chdir = 'relocate/src' +test.run_built_executable('program4', chdir=chdir, stdout=expect) + +test.pass_test() diff --git a/third_party/python/gyp/test/rules/gyptest-default.py b/third_party/python/gyp/test/rules/gyptest-default.py new file mode 100755 index 0000000000..5d01094197 --- /dev/null +++ b/third_party/python/gyp/test/rules/gyptest-default.py @@ -0,0 +1,70 @@ +#!/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 simple rules when using an explicit build target of 'all'. +""" + +from __future__ import print_function + +import sys + +if sys.platform == 'win32': + print("This test is currently disabled: https://crbug.com/483696.") + sys.exit(0) + + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('actions.gyp', + '-G', 'xcode_ninja_target_pattern=^pull_in_all_actions$', + 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.must_match('relocate/src/subdir2/file1.out4', 'Hello from file1.in\n') +test.must_match('relocate/src/subdir2/file2.out4', 'Hello from file2.in\n') +test.must_match('relocate/src/subdir2/file1.copy', 'Hello from file1.in\n') + +test.must_match('relocate/src/external/file1.external_rules.out', + 'Hello from file1.in\n') +test.must_match('relocate/src/external/file2.external_rules.out', + 'Hello from file2.in\n') + +test.pass_test() diff --git a/third_party/python/gyp/test/rules/gyptest-input-root.py b/third_party/python/gyp/test/rules/gyptest-input-root.py new file mode 100755 index 0000000000..92bade6d48 --- /dev/null +++ b/third_party/python/gyp/test/rules/gyptest-input-root.py @@ -0,0 +1,26 @@ +#!/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 RULE_INPUT_ROOT isn't turned into a path in rule actions +""" + +import TestGyp + +test = TestGyp.TestGyp() + +test.run_gyp('input-root.gyp', chdir='src') + +test.relocate('src', 'relocate/src') + +test.build('input-root.gyp', target='test', chdir='relocate/src') + +expect = """\ +Hello somefile +""" + +test.run_built_executable('test', chdir='relocate/src', stdout=expect) +test.pass_test() diff --git a/third_party/python/gyp/test/rules/gyptest-special-variables.py b/third_party/python/gyp/test/rules/gyptest-special-variables.py new file mode 100644 index 0000000000..05ea7cee16 --- /dev/null +++ b/third_party/python/gyp/test/rules/gyptest-special-variables.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +# Copyright (c) 2012 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 VS variables that require special variables are expanded +correctly. """ + +import sys +import TestGyp + +if sys.platform == 'win32': + test = TestGyp.TestGyp() + + test.run_gyp('special-variables.gyp', chdir='src') + test.build('special-variables.gyp', test.ALL, chdir='src') + test.pass_test() diff --git a/third_party/python/gyp/test/rules/src/actions.gyp b/third_party/python/gyp/test/rules/src/actions.gyp new file mode 100644 index 0000000000..84376a7193 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/actions.gyp @@ -0,0 +1,23 @@ +# 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': 'pull_in_all_actions', + 'type': 'none', + 'dependencies': [ + 'subdir1/executable.gyp:*', + 'subdir2/both_rule_and_action_input.gyp:*', + 'subdir2/never_used.gyp:*', + 'subdir2/no_inputs.gyp:*', + 'subdir2/no_action.gyp:*', + 'subdir2/none.gyp:*', + 'subdir3/executable2.gyp:*', + 'subdir4/build-asm.gyp:*', + 'external/external.gyp:*', + ], + }, + ], +} diff --git a/third_party/python/gyp/test/rules/src/an_asm.S b/third_party/python/gyp/test/rules/src/an_asm.S new file mode 100644 index 0000000000..eeb1345550 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/an_asm.S @@ -0,0 +1,6 @@ +// Copyright (c) 2012 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. + +// Fake asm file. +int main() {} diff --git a/third_party/python/gyp/test/rules/src/as.bat b/third_party/python/gyp/test/rules/src/as.bat new file mode 100644 index 0000000000..903c31a726 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/as.bat @@ -0,0 +1,7 @@ +@echo off +:: 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. + +:: Fake assembler for Windows +cl /TP /c %1 /Fo%2 diff --git a/third_party/python/gyp/test/rules/src/copy-file.py b/third_party/python/gyp/test/rules/src/copy-file.py new file mode 100755 index 0000000000..7bdfbfd4bd --- /dev/null +++ b/third_party/python/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], 'w').write(contents) + +sys.exit(0) diff --git a/third_party/python/gyp/test/rules/src/external/external.gyp b/third_party/python/gyp/test/rules/src/external/external.gyp new file mode 100644 index 0000000000..b28174f57c --- /dev/null +++ b/third_party/python/gyp/test/rules/src/external/external.gyp @@ -0,0 +1,66 @@ +# 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). +{ + 'target_defaults': { + 'msvs_cygwin_dirs': ['../../../../../../<(DEPTH)/third_party/cygwin'], + }, + 'targets': [ + { + 'target_name': 'external_rules', + 'type': 'none', + 'sources': [ + 'file1.in', + 'file2.in', + ], + 'conditions': [ + ['OS=="win"', { + 'dependencies': [ + 'cygwin', + ], + }], + ], + 'rules': [ + { + 'rule_name': 'copy_file', + 'extension': 'in', + 'msvs_external_rule': 1, + 'outputs': [ + '<(RULE_INPUT_ROOT).external_rules.out', + ], + 'action': [ + 'python', '../copy-file.py', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + }, + ], + }, + ], + 'conditions': [ + ['OS=="win"', { + 'targets': [ + { + 'target_name': 'cygwin', + 'type': 'none', + 'actions': [ + { + 'action_name': 'setup_mount', + 'msvs_cygwin_shell': 0, + 'inputs': [ + '../../../../../../<(DEPTH)/third_party/cygwin/setup_mount.bat', + ], + # Visual Studio requires an output file, or else the + # custom build step won't run. + 'outputs': [ + '<(INTERMEDIATE_DIR)/_always_run_setup_mount.marker', + ], + 'action': ['<@(_inputs)'], + }, + ], + }, + ], + }], + ], +} diff --git a/third_party/python/gyp/test/rules/src/external/file1.in b/third_party/python/gyp/test/rules/src/external/file1.in new file mode 100644 index 0000000000..86ac3ad389 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/external/file1.in @@ -0,0 +1 @@ +Hello from file1.in diff --git a/third_party/python/gyp/test/rules/src/external/file2.in b/third_party/python/gyp/test/rules/src/external/file2.in new file mode 100644 index 0000000000..bf83d8ecec --- /dev/null +++ b/third_party/python/gyp/test/rules/src/external/file2.in @@ -0,0 +1 @@ +Hello from file2.in diff --git a/third_party/python/gyp/test/rules/src/input-root.gyp b/third_party/python/gyp/test/rules/src/input-root.gyp new file mode 100644 index 0000000000..b6600e767c --- /dev/null +++ b/third_party/python/gyp/test/rules/src/input-root.gyp @@ -0,0 +1,24 @@ +# 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': 'test', + 'type': 'executable', + 'sources': [ 'somefile.ext', ], + 'rules': [{ + 'rule_name': 'rule', + 'extension': 'ext', + 'inputs': [ 'rule.py', ], + 'outputs': [ '<(RULE_INPUT_ROOT).cc', ], + 'action': [ 'python', 'rule.py', '<(RULE_INPUT_ROOT)', ], + 'message': 'Processing <(RULE_INPUT_PATH)', + 'process_outputs_as_sources': 1, + # Allows the test to run without hermetic cygwin on windows. + 'msvs_cygwin_shell': 0, + }], + }, + ], +} diff --git a/third_party/python/gyp/test/rules/src/noaction/file1.in b/third_party/python/gyp/test/rules/src/noaction/file1.in new file mode 100644 index 0000000000..86ac3ad389 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/noaction/file1.in @@ -0,0 +1 @@ +Hello from file1.in diff --git a/third_party/python/gyp/test/rules/src/noaction/no_action_with_rules_fails.gyp b/third_party/python/gyp/test/rules/src/noaction/no_action_with_rules_fails.gyp new file mode 100644 index 0000000000..9b6a65629f --- /dev/null +++ b/third_party/python/gyp/test/rules/src/noaction/no_action_with_rules_fails.gyp @@ -0,0 +1,37 @@ +# Copyright (c) 2012 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 the case where there's no action but there are input rules that should +# be processed results in a gyp failure. +{ + 'targets': [ + { + 'target_name': 'extension_does_match_sources_but_no_action', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'file1.in', + ], + 'rules': [ + { + 'rule_name': 'assembled', + 'extension': 'in', + 'outputs': [ + '<(RULE_INPUT_ROOT).in', + ], + 'conditions': [ + # Always fails. + [ '"true"=="false"', { + 'action': [ + 'python', '../copy-file.py', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + 'message': 'test_rule', + }], + ], + }, + ], + }, + ], +} diff --git a/third_party/python/gyp/test/rules/src/rule.py b/third_party/python/gyp/test/rules/src/rule.py new file mode 100755 index 0000000000..8a1f36dedb --- /dev/null +++ b/third_party/python/gyp/test/rules/src/rule.py @@ -0,0 +1,17 @@ +#!/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. + +import sys + +f = open(sys.argv[1] + ".cc", "w") +f.write("""\ +#include + +int main() { + puts("Hello %s"); + return 0; +} +""" % sys.argv[1]) +f.close() diff --git a/third_party/python/gyp/test/rules/src/somefile.ext b/third_party/python/gyp/test/rules/src/somefile.ext new file mode 100644 index 0000000000..e69de29bb2 diff --git a/third_party/python/gyp/test/rules/src/special-variables.gyp b/third_party/python/gyp/test/rules/src/special-variables.gyp new file mode 100644 index 0000000000..d1443af5ba --- /dev/null +++ b/third_party/python/gyp/test/rules/src/special-variables.gyp @@ -0,0 +1,34 @@ +# Copyright (c) 2012 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': [ + { + 'rules': [ + { + 'rule_name': 'assembler (gnu-compatible)', + 'msvs_cygwin_shell': 0, + 'msvs_quote_cmd': 0, + 'extension': 'S', + 'inputs': [ + 'as.bat', + ], + 'outputs': [ + '$(IntDir)/$(InputName).obj', + ], + 'action': [ + 'as.bat', + '$(InputPath)', + '$(IntDir)/$(InputName).obj', + ], + 'message': 'Building assembly language file $(InputPath)', + 'process_outputs_as_sources': 1, + }, + ], + 'target_name': 'test', + 'type': 'static_library', + 'sources': [ 'an_asm.S' ], + }, + ], +} diff --git a/third_party/python/gyp/test/rules/src/subdir1/executable.gyp b/third_party/python/gyp/test/rules/src/subdir1/executable.gyp new file mode 100644 index 0000000000..c34cce5a92 --- /dev/null +++ b/third_party/python/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 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/third_party/python/gyp/test/rules/src/subdir1/function1.in b/third_party/python/gyp/test/rules/src/subdir1/function1.in new file mode 100644 index 0000000000..60ff28949b --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir1/function1.in @@ -0,0 +1,6 @@ +#include + +void function1(void) +{ + printf("Hello from function1.in\n"); +} diff --git a/third_party/python/gyp/test/rules/src/subdir1/function2.in b/third_party/python/gyp/test/rules/src/subdir1/function2.in new file mode 100644 index 0000000000..0fcfc03fdb --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir1/function2.in @@ -0,0 +1,6 @@ +#include + +void function2(void) +{ + printf("Hello from function2.in\n"); +} diff --git a/third_party/python/gyp/test/rules/src/subdir1/program.c b/third_party/python/gyp/test/rules/src/subdir1/program.c new file mode 100644 index 0000000000..6b11ff9f67 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir1/program.c @@ -0,0 +1,12 @@ +#include + +extern void function1(void); +extern void function2(void); + +int main(void) +{ + printf("Hello from program.c\n"); + function1(); + function2(); + return 0; +} diff --git a/third_party/python/gyp/test/rules/src/subdir2/both_rule_and_action_input.gyp b/third_party/python/gyp/test/rules/src/subdir2/both_rule_and_action_input.gyp new file mode 100644 index 0000000000..e5e6f3ec2b --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir2/both_rule_and_action_input.gyp @@ -0,0 +1,50 @@ +# Copyright (c) 2014 Google Inc. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Tests that if a rule input is also an action input, both the rule and action +# are executed +{ + 'targets': [ + { + 'target_name': 'files_both_rule_and_action_input', + 'type': 'executable', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'program.c', + 'file1.in', + 'file2.in', + ], + 'rules': [ + { + 'rule_name': 'copy_file', + 'extension': 'in', + 'inputs': [ + '../copy-file.py', + ], + 'outputs': [ + '<(RULE_INPUT_ROOT).out4', + ], + 'action': [ + 'python', '<(_inputs)', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + }, + ], + 'actions': [ + { + 'action_name': 'copy_file1_in', + 'inputs': [ + '../copy-file.py', + 'file1.in', + ], + 'outputs': [ + 'file1.copy', + ], + 'action': [ + 'python', '<@(_inputs)', '<(_outputs)' + ], + }, + ], + }, + ], +} diff --git a/third_party/python/gyp/test/rules/src/subdir2/file1.in b/third_party/python/gyp/test/rules/src/subdir2/file1.in new file mode 100644 index 0000000000..86ac3ad389 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir2/file1.in @@ -0,0 +1 @@ +Hello from file1.in diff --git a/third_party/python/gyp/test/rules/src/subdir2/file2.in b/third_party/python/gyp/test/rules/src/subdir2/file2.in new file mode 100644 index 0000000000..bf83d8ecec --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir2/file2.in @@ -0,0 +1 @@ +Hello from file2.in diff --git a/third_party/python/gyp/test/rules/src/subdir2/never_used.gyp b/third_party/python/gyp/test/rules/src/subdir2/never_used.gyp new file mode 100644 index 0000000000..17f6f55371 --- /dev/null +++ b/third_party/python/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/third_party/python/gyp/test/rules/src/subdir2/no_action.gyp b/third_party/python/gyp/test/rules/src/subdir2/no_action.gyp new file mode 100644 index 0000000000..ffa1cefe18 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir2/no_action.gyp @@ -0,0 +1,38 @@ +# Copyright (c) 2012 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 an action is only specified under a conditional is +# evaluated appropriately. +{ + 'targets': [ + { + 'target_name': 'extension_does_not_match_sources_and_no_action', + 'type': 'none', + 'msvs_cygwin_shell': 0, + 'sources': [ + 'file1.in', + 'file2.in', + ], + 'rules': [ + { + 'rule_name': 'assemble', + 'extension': 'asm', + 'outputs': [ + '<(RULE_INPUT_ROOT).fail', + ], + 'conditions': [ + # Always fails. + [ '"true"=="false"', { + 'action': [ + 'python', '../copy-file.py', '<(RULE_INPUT_PATH)', '<@(_outputs)', + ], + 'process_outputs_as_sources': 1, + 'message': 'test_rule', + }], + ], + }, + ], + }, + ], +} diff --git a/third_party/python/gyp/test/rules/src/subdir2/no_inputs.gyp b/third_party/python/gyp/test/rules/src/subdir2/no_inputs.gyp new file mode 100644 index 0000000000..e61a1a3ff6 --- /dev/null +++ b/third_party/python/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/third_party/python/gyp/test/rules/src/subdir2/none.gyp b/third_party/python/gyp/test/rules/src/subdir2/none.gyp new file mode 100644 index 0000000000..38bcdabdf6 --- /dev/null +++ b/third_party/python/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/third_party/python/gyp/test/rules/src/subdir2/program.c b/third_party/python/gyp/test/rules/src/subdir2/program.c new file mode 100644 index 0000000000..e5db175148 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir2/program.c @@ -0,0 +1,12 @@ +/* Copyright (c) 2014 Google Inc. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +int main(void) +{ + printf("Hello from program.c\n"); + return 0; +} diff --git a/third_party/python/gyp/test/rules/src/subdir3/executable2.gyp b/third_party/python/gyp/test/rules/src/subdir3/executable2.gyp new file mode 100644 index 0000000000..a2a528fc7b --- /dev/null +++ b/third_party/python/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/third_party/python/gyp/test/rules/src/subdir3/function3.in b/third_party/python/gyp/test/rules/src/subdir3/function3.in new file mode 100644 index 0000000000..99f46ab05e --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir3/function3.in @@ -0,0 +1,6 @@ +#include + +extern "C" void function3(void) +{ + printf("Hello from function3.in\n"); +} diff --git a/third_party/python/gyp/test/rules/src/subdir3/program.c b/third_party/python/gyp/test/rules/src/subdir3/program.c new file mode 100644 index 0000000000..c38eead50e --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir3/program.c @@ -0,0 +1,10 @@ +#include + +extern void function3(void); + +int main(void) +{ + printf("Hello from program.c\n"); + function3(); + return 0; +} diff --git a/third_party/python/gyp/test/rules/src/subdir4/asm-function.assem b/third_party/python/gyp/test/rules/src/subdir4/asm-function.assem new file mode 100644 index 0000000000..ed47cade95 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir4/asm-function.assem @@ -0,0 +1,10 @@ +#if PLATFORM_WINDOWS || PLATFORM_MAC +# define IDENTIFIER(n) _##n +#else /* Linux */ +# define IDENTIFIER(n) n +#endif + +.globl IDENTIFIER(asm_function) +IDENTIFIER(asm_function): + movl $41, %eax + ret diff --git a/third_party/python/gyp/test/rules/src/subdir4/build-asm.gyp b/third_party/python/gyp/test/rules/src/subdir4/build-asm.gyp new file mode 100644 index 0000000000..fe0fe93787 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir4/build-asm.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. + +# This one tests that assembly files ended as .s and .S are compiled. + +{ + 'target_defaults': { + 'conditions': [ + ['OS=="win"', { + 'defines': ['PLATFORM_WIN'], + }], + ['OS=="mac"', { + 'defines': ['PLATFORM_MAC'], + }], + ['OS=="linux"', { + 'defines': ['PLATFORM_LINUX'], + }], + ], + }, + 'targets': [ + { + 'target_name': 'program4', + 'type': 'executable', + 'sources': [ + 'asm-function.assem', + 'program.c', + ], + 'conditions': [ + ['OS=="linux" or OS=="mac"', { + 'rules': [ + { + 'rule_name': 'convert_assem', + 'extension': 'assem', + 'inputs': [], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).S', + ], + 'action': [ + 'bash', '-c', 'cp <(RULE_INPUT_PATH) <@(_outputs)', + ], + 'process_outputs_as_sources': 1, + }, + ], + }], + ], + }, + ], +} diff --git a/third_party/python/gyp/test/rules/src/subdir4/program.c b/third_party/python/gyp/test/rules/src/subdir4/program.c new file mode 100644 index 0000000000..ad647f4eb9 --- /dev/null +++ b/third_party/python/gyp/test/rules/src/subdir4/program.c @@ -0,0 +1,19 @@ +#include + +// Use the assembly function in linux and mac where it is built. +#if PLATFORM_LINUX || PLATFORM_MAC +extern int asm_function(void); +#else +int asm_function() { + return 41; +} +#endif + +int main(void) +{ + fprintf(stdout, "Hello from program.c\n"); + fflush(stdout); + fprintf(stdout, "Got %d.\n", asm_function()); + fflush(stdout); + return 0; +} -- cgit v1.2.3