win: make msvs_shard work properly for static_library references
Before this, dependencies inside a static_library weren't updated to
reference the _N targets, necessitating workarounds like
https://src.chromium.org/viewvc/chrome?revision=254345&view=revision .
The 'refs_to_shard_external_lib' target fails before this change.
R=thakis@chromium.org
BUG=chromium:352495
Review URL: https://codereview.chromium.org/199413010
git-svn-id: http://gyp.googlecode.com/svn/trunk@1873 78cadc50-ecff-11dd-a971-7dbc132099af
diff --git a/pylib/gyp/MSVSUtil.py b/pylib/gyp/MSVSUtil.py
index 62e8d26..fbf3ed2 100644
--- a/pylib/gyp/MSVSUtil.py
+++ b/pylib/gyp/MSVSUtil.py
@@ -109,15 +109,16 @@
new_target_dicts[t] = target_dicts[t]
# Shard dependencies.
for t in new_target_dicts:
- dependencies = copy.copy(new_target_dicts[t].get('dependencies', []))
- new_dependencies = []
- for d in dependencies:
- if d in targets_to_shard:
- for i in range(targets_to_shard[d]):
- new_dependencies.append(_ShardName(d, i))
- else:
- new_dependencies.append(d)
- new_target_dicts[t]['dependencies'] = new_dependencies
+ for deptype in ('dependencies', 'dependencies_original'):
+ dependencies = copy.copy(new_target_dicts[t].get(deptype, []))
+ new_dependencies = []
+ for d in dependencies:
+ if d in targets_to_shard:
+ for i in range(targets_to_shard[d]):
+ new_dependencies.append(_ShardName(d, i))
+ else:
+ new_dependencies.append(d)
+ new_target_dicts[t][deptype] = new_dependencies
return (new_target_list, new_target_dicts)
@@ -264,4 +265,4 @@
# Update the original target to depend on the shim target.
target_dict.setdefault('dependencies', []).append(full_shim_target_name)
- return (target_list, target_dicts)
\ No newline at end of file
+ return (target_list, target_dicts)
diff --git a/test/win/gyptest-link-shard.py b/test/win/gyptest-link-shard.py
index fb9a3cd..9af9328 100644
--- a/test/win/gyptest-link-shard.py
+++ b/test/win/gyptest-link-shard.py
@@ -24,4 +24,7 @@
test.built_file_must_exist('shard_2.lib', chdir=CHDIR)
test.built_file_must_exist('shard_3.lib', chdir=CHDIR)
+ test.run_gyp('shard_ref.gyp', chdir=CHDIR)
+ test.build('shard_ref.gyp', test.ALL, chdir=CHDIR)
+
test.pass_test()
diff --git a/test/win/shard/hello.cc b/test/win/shard/hello.cc
new file mode 100644
index 0000000..a9dce62
--- /dev/null
+++ b/test/win/shard/hello.cc
@@ -0,0 +1,7 @@
+// Copyright 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.
+
+int main() {
+ return 0;
+}
diff --git a/test/win/shard/shard.gyp b/test/win/shard/shard.gyp
index 0635a75..eac45fc 100644
--- a/test/win/shard/shard.gyp
+++ b/test/win/shard/shard.gyp
@@ -16,5 +16,16 @@
],
'product_dir': '<(PRODUCT_DIR)',
},
+ {
+ 'target_name': 'refs_to_shard',
+ 'type': 'executable',
+ 'dependencies': [
+ # Make sure references are correctly updated.
+ 'shard',
+ ],
+ 'sources': [
+ 'hello.cc',
+ ],
+ },
]
}
diff --git a/test/win/shard/shard_ref.gyp b/test/win/shard/shard_ref.gyp
new file mode 100644
index 0000000..3ec8d76
--- /dev/null
+++ b/test/win/shard/shard_ref.gyp
@@ -0,0 +1,41 @@
+# Copyright 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': 'refs_to_shard_external_lib',
+ 'type': 'static_library',
+ 'dependencies': [
+ # Make sure references in other files are updated correctly.
+ 'shard.gyp:shard',
+ ],
+ 'sources': [
+ 'hello.cc',
+ ],
+ },
+ {
+ 'target_name': 'refs_to_shard_external_exe',
+ 'type': 'executable',
+ 'dependencies': [
+ # Make sure references in other files are updated correctly.
+ 'shard.gyp:shard',
+ ],
+ 'sources': [
+ 'hello.cc',
+ ],
+ },
+ {
+ 'target_name': 'refs_to_shard_external_dll',
+ 'type': 'shared_library',
+ 'dependencies': [
+ # Make sure references in other files are updated correctly.
+ 'shard.gyp:shard',
+ ],
+ 'sources': [
+ 'hello.cc',
+ ],
+ },
+ ]
+}