summaryrefslogtreecommitdiff
path: root/deps/gyp/test/ninja/solibs_avoid_relinking
diff options
context:
space:
mode:
Diffstat (limited to 'deps/gyp/test/ninja/solibs_avoid_relinking')
-rwxr-xr-xdeps/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py46
-rw-r--r--deps/gyp/test/ninja/solibs_avoid_relinking/main.cc5
-rw-r--r--deps/gyp/test/ninja/solibs_avoid_relinking/solib.cc8
-rw-r--r--deps/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp38
4 files changed, 97 insertions, 0 deletions
diff --git a/deps/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py b/deps/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.py
new file mode 100755
index 0000000000..1b8e812eb2
--- /dev/null
+++ b/deps/gyp/test/ninja/solibs_avoid_relinking/gyptest-solibs-avoid-relinking.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.
+
+"""
+Verify that relinking a solib doesn't relink a dependent executable if the
+solib's public API hasn't changed.
+"""
+
+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/deps/gyp/test/ninja/solibs_avoid_relinking/main.cc b/deps/gyp/test/ninja/solibs_avoid_relinking/main.cc
new file mode 100644
index 0000000000..2cd74d3c77
--- /dev/null
+++ b/deps/gyp/test/ninja/solibs_avoid_relinking/main.cc
@@ -0,0 +1,5 @@
+extern int foo();
+
+int main() {
+ return foo();
+}
diff --git a/deps/gyp/test/ninja/solibs_avoid_relinking/solib.cc b/deps/gyp/test/ninja/solibs_avoid_relinking/solib.cc
new file mode 100644
index 0000000000..0856cd4e00
--- /dev/null
+++ b/deps/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/deps/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp b/deps/gyp/test/ninja/solibs_avoid_relinking/solibs_avoid_relinking.gyp
new file mode 100644
index 0000000000..e816351d68
--- /dev/null
+++ b/deps/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'],
+ },
+ }],
+ ],
+}