summaryrefslogtreecommitdiffstats
path: root/third_party/python/gyp/test/ninja
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/python/gyp/test/ninja')
-rw-r--r--third_party/python/gyp/test/ninja/action-rule-hash/gyptest-action-rule-hash.py32
-rw-r--r--third_party/python/gyp/test/ninja/action-rule-hash/subdir/action-rule-hash.gyp29
-rw-r--r--third_party/python/gyp/test/ninja/action-rule-hash/subdir/emit.py13
-rwxr-xr-xthird_party/python/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py64
-rw-r--r--third_party/python/gyp/test/ninja/action_dependencies/src/a.c10
-rw-r--r--third_party/python/gyp/test/ninja/action_dependencies/src/a.h13
-rw-r--r--third_party/python/gyp/test/ninja/action_dependencies/src/action_dependencies.gyp88
-rw-r--r--third_party/python/gyp/test/ninja/action_dependencies/src/b.c18
-rw-r--r--third_party/python/gyp/test/ninja/action_dependencies/src/b.h13
-rw-r--r--third_party/python/gyp/test/ninja/action_dependencies/src/c.c10
-rw-r--r--third_party/python/gyp/test/ninja/action_dependencies/src/c.h13
-rwxr-xr-xthird_party/python/gyp/test/ninja/action_dependencies/src/emit.py11
-rw-r--r--third_party/python/gyp/test/ninja/chained-dependency/chained-dependency.gyp53
-rw-r--r--third_party/python/gyp/test/ninja/chained-dependency/chained.c5
-rwxr-xr-xthird_party/python/gyp/test/ninja/chained-dependency/gyptest-chained-dependency.py30
-rw-r--r--third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/gyptest-empty-and-non-empty-duplicate-name.py23
-rw-r--r--third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/subdir/included.gyp19
-rw-r--r--third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/test.gyp19
-rw-r--r--third_party/python/gyp/test/ninja/normalize-paths-win/gyptest-normalize-paths.py46
-rw-r--r--third_party/python/gyp/test/ninja/normalize-paths-win/hello.cc7
-rw-r--r--third_party/python/gyp/test/ninja/normalize-paths-win/normalize-paths.gyp68
-rw-r--r--third_party/python/gyp/test/ninja/s-needs-no-depfiles/empty.s1
-rwxr-xr-xthird_party/python/gyp/test/ninja/s-needs-no-depfiles/gyptest-s-needs-no-depfiles.py42
-rw-r--r--third_party/python/gyp/test/ninja/s-needs-no-depfiles/s-needs-no-depfiles.gyp13
-rwxr-xr-xthird_party/python/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py48
-rw-r--r--third_party/python/gyp/test/ninja/solibs_avoid_relinking/main.cc5
-rw-r--r--third_party/python/gyp/test/ninja/solibs_avoid_relinking/solib.cc8
-rw-r--r--third_party/python/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp38
-rw-r--r--third_party/python/gyp/test/ninja/use-console/foo.bar5
-rw-r--r--third_party/python/gyp/test/ninja/use-console/gyptest-use-console.py29
-rw-r--r--third_party/python/gyp/test/ninja/use-console/use-console.gyp60
-rw-r--r--third_party/python/gyp/test/ninja/use-custom-environment-files/gyptest-use-custom-environment-files.py28
-rw-r--r--third_party/python/gyp/test/ninja/use-custom-environment-files/use-custom-environment-files.cc7
-rw-r--r--third_party/python/gyp/test/ninja/use-custom-environment-files/use-custom-environment-files.gyp15
34 files changed, 883 insertions, 0 deletions
diff --git a/third_party/python/gyp/test/ninja/action-rule-hash/gyptest-action-rule-hash.py b/third_party/python/gyp/test/ninja/action-rule-hash/gyptest-action-rule-hash.py
new file mode 100644
index 0000000000..7147fd2fc3
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action-rule-hash/gyptest-action-rule-hash.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Verify that running gyp in a different directory does not cause actions and
+rules to rerun.
+"""
+
+import os
+import sys
+import TestGyp
+
+test = TestGyp.TestGyp(formats=['ninja'])
+# The xcode-ninja generator handles gypfiles which are not at the
+# project root incorrectly.
+# cf. https://code.google.com/p/gyp/issues/detail?id=460
+if test.format == 'xcode-ninja':
+ test.skip_test()
+
+test.run_gyp('subdir/action-rule-hash.gyp')
+test.build('subdir/action-rule-hash.gyp', test.ALL)
+test.up_to_date('subdir/action-rule-hash.gyp')
+
+# Verify that everything is still up-to-date when we re-invoke gyp from a
+# different directory.
+test.run_gyp('action-rule-hash.gyp', '--depth=../', chdir='subdir')
+test.up_to_date('subdir/action-rule-hash.gyp')
+
+test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/action-rule-hash/subdir/action-rule-hash.gyp b/third_party/python/gyp/test/ninja/action-rule-hash/subdir/action-rule-hash.gyp
new file mode 100644
index 0000000000..0e88a3019f
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action-rule-hash/subdir/action-rule-hash.gyp
@@ -0,0 +1,29 @@
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'program',
+ 'type': 'executable',
+ 'sources': [
+ '<(INTERMEDIATE_DIR)/main.cc',
+ ],
+ 'actions': [
+ {
+ 'action_name': 'emit_main_cc',
+ 'inputs': ['emit.py'],
+ 'outputs': ['<(INTERMEDIATE_DIR)/main.cc'],
+ 'action': [
+ 'python',
+ 'emit.py',
+ '<(INTERMEDIATE_DIR)/main.cc',
+ ],
+ # Allows the test to run without hermetic cygwin on windows.
+ 'msvs_cygwin_shell': 0,
+ },
+ ],
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/action-rule-hash/subdir/emit.py b/third_party/python/gyp/test/ninja/action-rule-hash/subdir/emit.py
new file mode 100644
index 0000000000..6b17125574
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action-rule-hash/subdir/emit.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import sys
+
+f = open(sys.argv[1], 'w')
+f.write('int main() {\n')
+f.write(' return 0;\n')
+f.write('}\n')
+f.close()
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py b/third_party/python/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py
new file mode 100755
index 0000000000..89813bab17
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py
@@ -0,0 +1,64 @@
+#!/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.
+
+"""
+Verify that building an object file correctly depends on running actions in
+dependent targets, but not the targets themselves.
+"""
+
+from __future__ import print_function
+
+import os
+import sys
+
+if sys.platform == 'win32':
+ print("This test is currently disabled: https://crbug.com/483696.")
+ sys.exit(0)
+
+
+import TestGyp
+
+# NOTE(piman): This test will not work with other generators because:
+# - it explicitly tests the optimization, which is not implemented (yet?) on
+# other generators
+# - it relies on the exact path to output object files, which is generator
+# dependent, and actually, relies on the ability to build only that object file,
+# which I don't think is available on all generators.
+# TODO(piman): Extend to other generators when possible.
+test = TestGyp.TestGyp(formats=['ninja'])
+# xcode-ninja doesn't support building single object files by design.
+if test.format == 'xcode-ninja':
+ test.skip_test()
+
+test.run_gyp('action_dependencies.gyp', chdir='src')
+
+chdir = 'relocate/src'
+test.relocate('src', chdir)
+
+objext = '.obj' if sys.platform == 'win32' else '.o'
+
+test.build('action_dependencies.gyp',
+ os.path.join('obj', 'b.b' + objext),
+ chdir=chdir)
+
+# The 'a' actions should be run (letting b.c compile), but the a static library
+# should not be built.
+test.built_file_must_not_exist('a', type=test.STATIC_LIB, chdir=chdir)
+test.built_file_must_not_exist('b', type=test.STATIC_LIB, chdir=chdir)
+test.built_file_must_exist(os.path.join('obj', 'b.b' + objext), chdir=chdir)
+
+test.build('action_dependencies.gyp',
+ os.path.join('obj', 'c.c' + objext),
+ chdir=chdir)
+
+# 'a' and 'b' should be built, so that the 'c' action succeeds, letting c.c
+# compile
+test.built_file_must_exist('a', type=test.STATIC_LIB, chdir=chdir)
+test.built_file_must_exist('b', type=test.EXECUTABLE, chdir=chdir)
+test.built_file_must_exist(os.path.join('obj', 'c.c' + objext), chdir=chdir)
+
+
+test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/src/a.c b/third_party/python/gyp/test/ninja/action_dependencies/src/a.c
new file mode 100644
index 0000000000..4d7af9b26c
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/src/a.c
@@ -0,0 +1,10 @@
+/* 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 "a.h"
+
+int funcA() {
+ return 42;
+}
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/src/a.h b/third_party/python/gyp/test/ninja/action_dependencies/src/a.h
new file mode 100644
index 0000000000..335db56739
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/src/a.h
@@ -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.
+ */
+
+#ifndef A_H_
+#define A_H_
+
+#include "a/generated.h"
+
+int funcA();
+
+#endif // A_H_
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/src/action_dependencies.gyp b/third_party/python/gyp/test/ninja/action_dependencies/src/action_dependencies.gyp
new file mode 100644
index 0000000000..5baa7a7d47
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/src/action_dependencies.gyp
@@ -0,0 +1,88 @@
+# 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': 'a',
+ 'type': 'static_library',
+ 'sources': [
+ 'a.c',
+ 'a.h',
+ ],
+ 'actions': [
+ {
+ 'action_name': 'generate_headers',
+ 'inputs': [
+ 'emit.py'
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/a/generated.h'
+ ],
+ 'action': [
+ 'python',
+ 'emit.py',
+ '<(SHARED_INTERMEDIATE_DIR)/a/generated.h',
+ ],
+ # Allows the test to run without hermetic cygwin on windows.
+ 'msvs_cygwin_shell': 0,
+ },
+ ],
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ],
+ },
+ },
+ {
+ 'target_name': 'b',
+ 'type': 'executable',
+ 'sources': [
+ 'b.c',
+ 'b.h',
+ ],
+ 'dependencies': [
+ 'a',
+ ],
+ },
+ {
+ 'target_name': 'c',
+ 'type': 'static_library',
+ 'sources': [
+ 'c.c',
+ 'c.h',
+ ],
+ 'dependencies': [
+ 'b',
+ ],
+ 'actions': [
+ {
+ 'action_name': 'generate_headers',
+ 'inputs': [
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/c/generated.h'
+ ],
+ 'action': [
+ '<(PRODUCT_DIR)/b',
+ '<(SHARED_INTERMEDIATE_DIR)/c/generated.h',
+ ],
+ # Allows the test to run without hermetic cygwin on windows.
+ 'msvs_cygwin_shell': 0,
+ },
+ ],
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ],
+ },
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/src/b.c b/third_party/python/gyp/test/ninja/action_dependencies/src/b.c
new file mode 100644
index 0000000000..824464695a
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/src/b.c
@@ -0,0 +1,18 @@
+/* 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.
+ */
+
+#include <stdio.h>
+
+#include "b.h"
+
+int main(int argc, char** argv) {
+ FILE* f;
+ if (argc < 2)
+ return 1;
+ f = fopen(argv[1], "wt");
+ fprintf(f, "#define VALUE %d\n", funcA());
+ fclose(f);
+ return 0;
+}
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/src/b.h b/third_party/python/gyp/test/ninja/action_dependencies/src/b.h
new file mode 100644
index 0000000000..91362cd899
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/src/b.h
@@ -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.
+ */
+
+#ifndef B_H_
+#define B_H_
+
+#include "a.h"
+
+int funcB();
+
+#endif // B_H_
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/src/c.c b/third_party/python/gyp/test/ninja/action_dependencies/src/c.c
new file mode 100644
index 0000000000..b412087ec8
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/src/c.c
@@ -0,0 +1,10 @@
+/* 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 "c.h"
+
+int funcC() {
+ return VALUE;
+}
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/src/c.h b/third_party/python/gyp/test/ninja/action_dependencies/src/c.h
new file mode 100644
index 0000000000..c81a45bbe7
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/src/c.h
@@ -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.
+ */
+
+#ifndef C_H_
+#define C_H_
+
+#include "c/generated.h"
+
+int funcC();
+
+#endif // C_H_
diff --git a/third_party/python/gyp/test/ninja/action_dependencies/src/emit.py b/third_party/python/gyp/test/ninja/action_dependencies/src/emit.py
new file mode 100755
index 0000000000..8ed12f7393
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/action_dependencies/src/emit.py
@@ -0,0 +1,11 @@
+#!/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], 'w')
+f.write('/* Hello World */\n')
+f.close()
diff --git a/third_party/python/gyp/test/ninja/chained-dependency/chained-dependency.gyp b/third_party/python/gyp/test/ninja/chained-dependency/chained-dependency.gyp
new file mode 100644
index 0000000000..3fe68ae85a
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/chained-dependency/chained-dependency.gyp
@@ -0,0 +1,53 @@
+# 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': [
+ # This first target generates a header.
+ {
+ 'target_name': 'generate_header',
+ 'type': 'none',
+ 'msvs_cygwin_shell': '0',
+ 'actions': [
+ {
+ 'action_name': 'generate header',
+ 'inputs': [],
+ 'outputs': ['<(SHARED_INTERMEDIATE_DIR)/generated/header.h'],
+ 'action': [
+ 'python', '-c', 'open(<(_outputs), "w")'
+ ]
+ },
+ ],
+ 'all_dependent_settings': {
+ 'include_dirs': [
+ '<(SHARED_INTERMEDIATE_DIR)',
+ ],
+ },
+ },
+
+ # This intermediate target does nothing other than pull in a
+ # dependency on the above generated target.
+ {
+ 'target_name': 'chain',
+ 'type': 'none',
+ 'dependencies': [
+ 'generate_header',
+ ],
+ },
+
+ # This final target is:
+ # - a static library (so gyp doesn't transitively pull in dependencies);
+ # - that relies on the generated file two dependencies away.
+ {
+ 'target_name': 'chained',
+ 'type': 'static_library',
+ 'dependencies': [
+ 'chain',
+ ],
+ 'sources': [
+ 'chained.c',
+ ],
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/chained-dependency/chained.c b/third_party/python/gyp/test/ninja/chained-dependency/chained.c
new file mode 100644
index 0000000000..c1ff1a7b12
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/chained-dependency/chained.c
@@ -0,0 +1,5 @@
+#include "generated/header.h"
+
+int main(void) {
+ return 0;
+}
diff --git a/third_party/python/gyp/test/ninja/chained-dependency/gyptest-chained-dependency.py b/third_party/python/gyp/test/ninja/chained-dependency/gyptest-chained-dependency.py
new file mode 100755
index 0000000000..d8763f1d3d
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/chained-dependency/gyptest-chained-dependency.py
@@ -0,0 +1,30 @@
+#!/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 files generated by two-steps-removed actions are built before
+dependent compile steps.
+"""
+
+import os
+import sys
+import TestGyp
+
+# This test is Ninja-specific in that:
+# - the bug only showed nondeterministically in parallel builds;
+# - it relies on a ninja-specific output file path.
+
+test = TestGyp.TestGyp(formats=['ninja'])
+# xcode-ninja doesn't support building single object files by design.
+if test.format == 'xcode-ninja':
+ test.skip_test()
+
+test.run_gyp('chained-dependency.gyp')
+objext = '.obj' if sys.platform == 'win32' else '.o'
+test.build('chained-dependency.gyp',
+ os.path.join('obj', 'chained.chained' + objext))
+# The test passes if the .o file builds successfully.
+test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/gyptest-empty-and-non-empty-duplicate-name.py b/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/gyptest-empty-and-non-empty-duplicate-name.py
new file mode 100644
index 0000000000..0bdca66cdc
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/gyptest-empty-and-non-empty-duplicate-name.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Verifies a phony target isn't output if a target exists with the same name that
+was output.
+"""
+
+import TestGyp
+
+test = TestGyp.TestGyp(formats=['ninja'])
+
+# Reset xcode_ninja_target_pattern to its default for this test.
+test.run_gyp('test.gyp', '-G', 'xcode_ninja_target_pattern=^$')
+
+# Check for both \r and \n to cover both windows and linux.
+test.must_not_contain('out/Default/build.ninja', 'build empty_target: phony\r')
+test.must_not_contain('out/Default/build.ninja', 'build empty_target: phony\n')
+
+test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/subdir/included.gyp b/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/subdir/included.gyp
new file mode 100644
index 0000000000..1b9fc42f3f
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/subdir/included.gyp
@@ -0,0 +1,19 @@
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'empty_target',
+ 'type': 'executable',
+ 'sources': [
+ 'test.cc',
+ ],
+ },
+ {
+ 'target_name': 'included_empty_target',
+ 'type': 'none',
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/test.gyp b/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/test.gyp
new file mode 100644
index 0000000000..9aa6287c7c
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/empty-and-non-empty-duplicate-name/test.gyp
@@ -0,0 +1,19 @@
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'All',
+ 'type': 'none',
+ 'dependencies': [
+ 'subdir/included.gyp:included_empty_target'
+ ]
+ },
+ {
+ 'target_name': 'empty_target',
+ 'type': 'none',
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/normalize-paths-win/gyptest-normalize-paths.py b/third_party/python/gyp/test/ninja/normalize-paths-win/gyptest-normalize-paths.py
new file mode 100644
index 0000000000..f56dbe5921
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/normalize-paths-win/gyptest-normalize-paths.py
@@ -0,0 +1,46 @@
+#!/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.
+
+"""
+Make sure paths are normalized with VS macros properly expanded on Windows.
+"""
+
+import TestGyp
+
+import sys
+
+if sys.platform == 'win32':
+ test = TestGyp.TestGyp(formats=['ninja'])
+
+ test.run_gyp('normalize-paths.gyp')
+
+ # We can't use existence tests because any case will pass, so we check the
+ # contents of ninja files directly since that's what we're most concerned
+ # with anyway.
+ subninja = open(test.built_file_path('obj/some_target.ninja')).read()
+ if '$!product_dir' in subninja:
+ test.fail_test()
+ if 'out\\Default' in subninja:
+ test.fail_test()
+
+ second = open(test.built_file_path('obj/second.ninja')).read()
+ if ('..\\..\\things\\AnotherName.exe' in second or
+ 'AnotherName.exe' not in second):
+ test.fail_test()
+
+ copytarget = open(test.built_file_path('obj/copy_target.ninja')).read()
+ if '$(VSInstallDir)' in copytarget:
+ test.fail_test()
+
+ action = open(test.built_file_path('obj/action.ninja')).read()
+ if '..\\..\\out\\Default' in action:
+ test.fail_test()
+ if '..\\..\\SomethingElse' in action or 'SomethingElse' not in action:
+ test.fail_test()
+ if '..\\..\\SomeOtherInput' in action or 'SomeOtherInput' not in action:
+ test.fail_test()
+
+ test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/normalize-paths-win/hello.cc b/third_party/python/gyp/test/ninja/normalize-paths-win/hello.cc
new file mode 100644
index 0000000000..1711567ef5
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/normalize-paths-win/hello.cc
@@ -0,0 +1,7 @@
+// 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.
+
+int main() {
+ return 0;
+}
diff --git a/third_party/python/gyp/test/ninja/normalize-paths-win/normalize-paths.gyp b/third_party/python/gyp/test/ninja/normalize-paths-win/normalize-paths.gyp
new file mode 100644
index 0000000000..544d06456d
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/normalize-paths-win/normalize-paths.gyp
@@ -0,0 +1,68 @@
+# 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': 'Some_Target',
+ 'type': 'executable',
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'OutputFile': '<(PRODUCT_DIR)/stuff/AnotherName.exe',
+ },
+ },
+ 'sources': [
+ 'HeLLo.cc',
+ 'blOrP.idl',
+ ],
+ },
+ {
+ 'target_name': 'second',
+ 'type': 'executable',
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'OutputFile': '$(OutDir)\\things\\AnotherName.exe',
+ },
+ },
+ 'sources': [
+ 'HeLLo.cc',
+ ],
+ },
+ {
+ 'target_name': 'Copy_Target',
+ 'type': 'none',
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)',
+ 'files': [
+ '$(VSInstallDir)\\bin\\cl.exe',
+ ],
+ },
+ ],
+ },
+ {
+ 'target_name': 'action',
+ 'type': 'none',
+ 'msvs_cygwin_shell': '0',
+ 'actions': [
+ {
+ 'inputs': [
+ '$(IntDir)\\SomeInput',
+ '$(OutDir)\\SomeOtherInput',
+ ],
+ 'outputs': [
+ '<(PRODUCT_DIR)/ReSuLt',
+ '<(SHARED_INTERMEDIATE_DIR)/TempFile',
+ '$(OutDir)\SomethingElse',
+ ],
+ 'action_name': 'Test action',
+ # Unfortunately, we can't normalize this field because it's
+ # free-form. Fortunately, ninja doesn't inspect it at all (only the
+ # inputs and outputs) so it's not mandatory.
+ 'action': [],
+ },
+ ],
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/s-needs-no-depfiles/empty.s b/third_party/python/gyp/test/ninja/s-needs-no-depfiles/empty.s
new file mode 100644
index 0000000000..218d8921e5
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/s-needs-no-depfiles/empty.s
@@ -0,0 +1 @@
+# This file intentionally left blank.
diff --git a/third_party/python/gyp/test/ninja/s-needs-no-depfiles/gyptest-s-needs-no-depfiles.py b/third_party/python/gyp/test/ninja/s-needs-no-depfiles/gyptest-s-needs-no-depfiles.py
new file mode 100755
index 0000000000..77a3245d46
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/s-needs-no-depfiles/gyptest-s-needs-no-depfiles.py
@@ -0,0 +1,42 @@
+#!/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.
+
+"""
+Verify that .s files don't always trigger a rebuild, as would happen if depfiles
+were used for them (since clang & gcc ignore -MMD when building .s->.o on
+linux).
+"""
+
+import os
+import sys
+import TestCommon
+import TestGyp
+
+# NOTE(fischman): Each generator uses depfiles (or not) differently, so this is
+# a ninja-specific test.
+test = TestGyp.TestGyp(formats=['ninja'])
+
+if sys.platform == 'win32' or sys.platform == 'win64':
+ # This test is about clang/gcc vs. depfiles; VS gets a pass.
+ test.pass_test()
+ sys.exit(0)
+
+test.run_gyp('s-needs-no-depfiles.gyp')
+
+# Build the library, grab its timestamp, rebuild the library, ensure timestamp
+# hasn't changed.
+test.build('s-needs-no-depfiles.gyp', 'empty')
+empty_dll = test.built_file_path('empty', test.SHARED_LIB)
+test.built_file_must_exist(empty_dll)
+pre_stat = os.stat(test.built_file_path(empty_dll))
+test.sleep()
+test.build('s-needs-no-depfiles.gyp', 'empty')
+post_stat = os.stat(test.built_file_path(empty_dll))
+
+if pre_stat.st_mtime != post_stat.st_mtime:
+ test.fail_test()
+else:
+ test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/s-needs-no-depfiles/s-needs-no-depfiles.gyp b/third_party/python/gyp/test/ninja/s-needs-no-depfiles/s-needs-no-depfiles.gyp
new file mode 100644
index 0000000000..bd66b1a70a
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/s-needs-no-depfiles/s-needs-no-depfiles.gyp
@@ -0,0 +1,13 @@
+# 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': [
+ {
+ 'target_name': 'empty',
+ 'type': 'shared_library',
+ 'sources': [ 'empty.s' ],
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py
new file mode 100755
index 0000000000..fd4470ac23
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py
@@ -0,0 +1,48 @@
+#!/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.
+
+"""
+Verify that relinking a solib doesn't relink a dependent executable if the
+solib's public API hasn't changed.
+"""
+
+from __future__ import print_function
+
+import os
+import sys
+import TestCommon
+import TestGyp
+
+# NOTE(fischman): This test will not work with other generators because the
+# API-hash-based-mtime-preservation optimization is only implemented in
+# ninja.py. It could be extended to the make.py generator as well pretty
+# easily, probably.
+# (also, it tests ninja-specific out paths, which would have to be generalized
+# if this was extended to other generators).
+test = TestGyp.TestGyp(formats=['ninja'])
+
+if not os.environ.get('ProgramFiles(x86)'):
+ # TODO(scottmg)
+ print('Skipping test on x86, http://crbug.com/365833')
+ test.pass_test()
+
+test.run_gyp('solibs_avoid_relinking.gyp')
+
+# Build the executable, grab its timestamp, touch the solib's source, rebuild
+# executable, ensure timestamp hasn't changed.
+test.build('solibs_avoid_relinking.gyp', 'b')
+test.built_file_must_exist('b' + TestCommon.exe_suffix)
+pre_stat = os.stat(test.built_file_path('b' + TestCommon.exe_suffix))
+os.utime(os.path.join(test.workdir, 'solib.cc'),
+ (pre_stat.st_atime, pre_stat.st_mtime + 100))
+test.sleep()
+test.build('solibs_avoid_relinking.gyp', 'b')
+post_stat = os.stat(test.built_file_path('b' + TestCommon.exe_suffix))
+
+if pre_stat.st_mtime != post_stat.st_mtime:
+ test.fail_test()
+else:
+ test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/solibs_avoid_relinking/main.cc b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/main.cc
new file mode 100644
index 0000000000..2cd74d3c77
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/main.cc
@@ -0,0 +1,5 @@
+extern int foo();
+
+int main() {
+ return foo();
+}
diff --git a/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solib.cc b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solib.cc
new file mode 100644
index 0000000000..0856cd4e00
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solib.cc
@@ -0,0 +1,8 @@
+#ifdef _MSC_VER
+__declspec(dllexport)
+#else
+__attribute__((visibility("default")))
+#endif
+int foo() {
+ return 42;
+}
diff --git a/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp
new file mode 100644
index 0000000000..e816351d68
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.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.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'a',
+ 'type': 'shared_library',
+ 'sources': [ 'solib.cc' ],
+ # Incremental linking enabled so that .lib timestamp is maintained when
+ # exports are unchanged.
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'LinkIncremental': '2',
+ }
+ },
+ },
+ {
+ 'target_name': 'b',
+ 'type': 'executable',
+ 'sources': [ 'main.cc' ],
+ 'dependencies': [ 'a' ],
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'LinkIncremental': '2',
+ }
+ },
+ },
+ ],
+ 'conditions': [
+ ['OS=="linux"', {
+ 'target_defaults': {
+ 'cflags': ['-fPIC'],
+ },
+ }],
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/use-console/foo.bar b/third_party/python/gyp/test/ninja/use-console/foo.bar
new file mode 100644
index 0000000000..07c476a866
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/use-console/foo.bar
@@ -0,0 +1,5 @@
+# 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.
+
+This is a dummy file for rule/action input.
diff --git a/third_party/python/gyp/test/ninja/use-console/gyptest-use-console.py b/third_party/python/gyp/test/ninja/use-console/gyptest-use-console.py
new file mode 100644
index 0000000000..f76fcd9829
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/use-console/gyptest-use-console.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Make sure 'ninja_use_console' is supported in actions and rules.
+"""
+
+import TestGyp
+
+test = TestGyp.TestGyp(formats=['ninja'])
+
+test.run_gyp('use-console.gyp')
+
+no_pool = open(test.built_file_path('obj/no_pool.ninja')).read()
+if 'pool =' in no_pool:
+ test.fail_test()
+
+action_pool = open(test.built_file_path('obj/action_pool.ninja')).read()
+if 'pool = console' not in action_pool:
+ test.fail_test()
+
+rule_pool = open(test.built_file_path('obj/rule_pool.ninja')).read()
+if 'pool = console' not in rule_pool:
+ test.fail_test()
+
+test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/use-console/use-console.gyp b/third_party/python/gyp/test/ninja/use-console/use-console.gyp
new file mode 100644
index 0000000000..84e63184c6
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/use-console/use-console.gyp
@@ -0,0 +1,60 @@
+# Copyright (c) 2014 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'no_pool',
+ 'type': 'none',
+ 'actions': [
+ {
+ 'action_name': 'some_action',
+ 'action': ['echo', 'hello'],
+ 'inputs': ['foo.bar'],
+ 'outputs': ['dummy'],
+ },
+ ],
+ 'rules': [
+ {
+ 'rule_name': 'some_rule',
+ 'extension': 'bar',
+ 'action': ['echo', 'hello'],
+ 'outputs': ['dummy'],
+ },
+ ],
+ 'sources': [
+ 'foo.bar',
+ ],
+ },
+ {
+ 'target_name': 'action_pool',
+ 'type': 'none',
+ 'actions': [
+ {
+ 'action_name': 'some_action',
+ 'action': ['echo', 'hello'],
+ 'inputs': ['foo.bar'],
+ 'outputs': ['dummy'],
+ 'ninja_use_console': 1,
+ },
+ ],
+ },
+ {
+ 'target_name': 'rule_pool',
+ 'type': 'none',
+ 'rules': [
+ {
+ 'rule_name': 'some_rule',
+ 'extension': 'bar',
+ 'action': ['echo', 'hello'],
+ 'outputs': ['dummy'],
+ 'ninja_use_console': 1,
+ },
+ ],
+ 'sources': [
+ 'foo.bar',
+ ],
+ },
+ ],
+}
diff --git a/third_party/python/gyp/test/ninja/use-custom-environment-files/gyptest-use-custom-environment-files.py b/third_party/python/gyp/test/ninja/use-custom-environment-files/gyptest-use-custom-environment-files.py
new file mode 100644
index 0000000000..0c44b1d1c9
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/use-custom-environment-files/gyptest-use-custom-environment-files.py
@@ -0,0 +1,28 @@
+#!/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.
+
+"""
+Make sure environment files can be suppressed.
+"""
+
+import TestGyp
+
+import os
+import sys
+
+if sys.platform == 'win32':
+ test = TestGyp.TestGyp(formats=['ninja'])
+
+ test.run_gyp('use-custom-environment-files.gyp',
+ '-G', 'ninja_use_custom_environment_files')
+
+ # Make sure environment files do not exist.
+ if os.path.exists(test.built_file_path('environment.x86')):
+ test.fail_test()
+ if os.path.exists(test.built_file_path('environment.x64')):
+ test.fail_test()
+
+ test.pass_test()
diff --git a/third_party/python/gyp/test/ninja/use-custom-environment-files/use-custom-environment-files.cc b/third_party/python/gyp/test/ninja/use-custom-environment-files/use-custom-environment-files.cc
new file mode 100644
index 0000000000..1711567ef5
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/use-custom-environment-files/use-custom-environment-files.cc
@@ -0,0 +1,7 @@
+// 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.
+
+int main() {
+ return 0;
+}
diff --git a/third_party/python/gyp/test/ninja/use-custom-environment-files/use-custom-environment-files.gyp b/third_party/python/gyp/test/ninja/use-custom-environment-files/use-custom-environment-files.gyp
new file mode 100644
index 0000000000..dbc95a9439
--- /dev/null
+++ b/third_party/python/gyp/test/ninja/use-custom-environment-files/use-custom-environment-files.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': 'test_use_custom_environment_files',
+ 'type': 'executable',
+ 'sources': [
+ 'use-custom-environment-files.cc',
+ ],
+ },
+ ],
+}