summaryrefslogtreecommitdiff
path: root/deps/gyp/test/ninja/action_dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'deps/gyp/test/ninja/action_dependencies')
-rwxr-xr-xdeps/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py62
-rw-r--r--deps/gyp/test/ninja/action_dependencies/src/a.c10
-rw-r--r--deps/gyp/test/ninja/action_dependencies/src/a.h13
-rw-r--r--deps/gyp/test/ninja/action_dependencies/src/action_dependencies.gyp88
-rw-r--r--deps/gyp/test/ninja/action_dependencies/src/b.c18
-rw-r--r--deps/gyp/test/ninja/action_dependencies/src/b.h13
-rw-r--r--deps/gyp/test/ninja/action_dependencies/src/c.c10
-rw-r--r--deps/gyp/test/ninja/action_dependencies/src/c.h13
-rwxr-xr-xdeps/gyp/test/ninja/action_dependencies/src/emit.py11
9 files changed, 238 insertions, 0 deletions
diff --git a/deps/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py b/deps/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py
new file mode 100755
index 0000000000..cb59d7e3c1
--- /dev/null
+++ b/deps/gyp/test/ninja/action_dependencies/gyptest-action-dependencies.py
@@ -0,0 +1,62 @@
+#!/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.
+"""
+
+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/deps/gyp/test/ninja/action_dependencies/src/a.c b/deps/gyp/test/ninja/action_dependencies/src/a.c
new file mode 100644
index 0000000000..4d7af9b26c
--- /dev/null
+++ b/deps/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/deps/gyp/test/ninja/action_dependencies/src/a.h b/deps/gyp/test/ninja/action_dependencies/src/a.h
new file mode 100644
index 0000000000..335db56739
--- /dev/null
+++ b/deps/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/deps/gyp/test/ninja/action_dependencies/src/action_dependencies.gyp b/deps/gyp/test/ninja/action_dependencies/src/action_dependencies.gyp
new file mode 100644
index 0000000000..5baa7a7d47
--- /dev/null
+++ b/deps/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/deps/gyp/test/ninja/action_dependencies/src/b.c b/deps/gyp/test/ninja/action_dependencies/src/b.c
new file mode 100644
index 0000000000..824464695a
--- /dev/null
+++ b/deps/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/deps/gyp/test/ninja/action_dependencies/src/b.h b/deps/gyp/test/ninja/action_dependencies/src/b.h
new file mode 100644
index 0000000000..91362cd899
--- /dev/null
+++ b/deps/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/deps/gyp/test/ninja/action_dependencies/src/c.c b/deps/gyp/test/ninja/action_dependencies/src/c.c
new file mode 100644
index 0000000000..b412087ec8
--- /dev/null
+++ b/deps/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/deps/gyp/test/ninja/action_dependencies/src/c.h b/deps/gyp/test/ninja/action_dependencies/src/c.h
new file mode 100644
index 0000000000..c81a45bbe7
--- /dev/null
+++ b/deps/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/deps/gyp/test/ninja/action_dependencies/src/emit.py b/deps/gyp/test/ninja/action_dependencies/src/emit.py
new file mode 100755
index 0000000000..2df74b79a1
--- /dev/null
+++ b/deps/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], 'wb')
+f.write('/* Hello World */\n')
+f.close()