Permalink
Browse files

Adding support for copying directories to the 'copies' construct for …

…msvs.

BUG=gyp792
TEST=test/copies

Review URL: http://codereview.chromium.org/1120009

git-svn-id: http://gyp.googlecode.com/svn/trunk@801 78cadc50-ecff-11dd-a971-7dbc132099af
  • Loading branch information...
1 parent 4105408 commit 3b6138af6a84321fcd883e0ac1e9db2bcfc75698 bradnelson@google.com committed Mar 23, 2010
Showing with 47 additions and 35 deletions.
  1. 0 gyp.bat
  2. +23 −7 pylib/gyp/generator/msvs.py
  3. +12 −14 test/copies/gyptest-all.py
  4. +12 −14 test/copies/gyptest-default.py
View
0 gyp.bat 100644 → 100755
No changes.
@@ -5,6 +5,7 @@
# found in the LICENSE file.
import ntpath
+import posixpath
import os
import re
import subprocess
@@ -103,7 +104,10 @@ def _FixPath(path):
"""
if fixpath_prefix and path and not os.path.isabs(path) and not path[0] == '$':
path = os.path.join(fixpath_prefix, path)
- return path.replace('/', '\\')
+ path = path.replace('/', '\\')
+ if len(path) > 0 and path[-1] == '\\':
+ path = path[:-1]
+ return path
def _SourceInFolders(sources, prefix=None, excluded=None):
@@ -976,12 +980,24 @@ def _GenerateProject(vcproj_filename, build_file, spec, options, version):
dst = os.path.join(cpy['destination'], os.path.basename(src))
# _AddCustomBuildTool() will call _FixPath() on the inputs and
# outputs, so do the same for our generated command line.
- cmd = 'mkdir "%s" 2>nul & set ERRORLEVEL=0 & copy /Y "%s" "%s"' % (
- _FixPath(cpy['destination']), _FixPath(src), _FixPath(dst))
- _AddCustomBuildTool(p, spec,
- inputs=[src], outputs=[dst],
- description='Copying %s to %s' % (src, dst),
- cmd=cmd)
+ if src.endswith('/'):
+ src_bare = src[:-1]
+ base_dir = posixpath.split(src_bare)[0]
+ outer_dir = posixpath.split(src_bare)[1]
+ cmd = 'cd "%s" && xcopy /e /f /y "%s" "%s\\%s\\"' % (
+ _FixPath(base_dir), outer_dir, _FixPath(dst), outer_dir)
+ _AddCustomBuildTool(p, spec,
+ inputs=[src, build_file],
+ outputs=['dummy_copies', dst],
+ description='Copying %s to %s' % (src, dst),
+ cmd=cmd)
+ else:
+ cmd = 'mkdir "%s" 2>nul & set ERRORLEVEL=0 & copy /Y "%s" "%s"' % (
+ _FixPath(cpy['destination']), _FixPath(src), _FixPath(dst))
+ _AddCustomBuildTool(p, spec,
+ inputs=[src], outputs=[dst],
+ description='Copying %s to %s' % (src, dst),
+ cmd=cmd)
# Write it out.
p.Write()
View
@@ -24,19 +24,17 @@
'file2 contents\n',
chdir='relocate/src')
-# TODO Not yet implemented on msvs
-if test.format != 'msvs':
- test.built_file_must_match('copies-out/directory/file3',
- 'file3 contents\n',
- chdir='relocate/src')
- test.built_file_must_match('copies-out/directory/file4',
- 'file4 contents\n',
- chdir='relocate/src')
- test.built_file_must_match('copies-out/directory/subdir/file5',
- 'file5 contents\n',
- chdir='relocate/src')
- test.built_file_must_match('copies-out/subdir/file6',
- 'file6 contents\n',
- chdir='relocate/src')
+test.built_file_must_match('copies-out/directory/file3',
+ 'file3 contents\n',
+ chdir='relocate/src')
+test.built_file_must_match('copies-out/directory/file4',
+ 'file4 contents\n',
+ chdir='relocate/src')
+test.built_file_must_match('copies-out/directory/subdir/file5',
+ 'file5 contents\n',
+ chdir='relocate/src')
+test.built_file_must_match('copies-out/subdir/file6',
+ 'file6 contents\n',
+ chdir='relocate/src')
test.pass_test()
@@ -24,19 +24,17 @@
'file2 contents\n',
chdir='relocate/src')
-# TODO Not yet implemented on msvs
-if test.format != 'msvs':
- test.built_file_must_match('copies-out/directory/file3',
- 'file3 contents\n',
- chdir='relocate/src')
- test.built_file_must_match('copies-out/directory/file4',
- 'file4 contents\n',
- chdir='relocate/src')
- test.built_file_must_match('copies-out/directory/subdir/file5',
- 'file5 contents\n',
- chdir='relocate/src')
- test.built_file_must_match('copies-out/subdir/file6',
- 'file6 contents\n',
- chdir='relocate/src')
+test.built_file_must_match('copies-out/directory/file3',
+ 'file3 contents\n',
+ chdir='relocate/src')
+test.built_file_must_match('copies-out/directory/file4',
+ 'file4 contents\n',
+ chdir='relocate/src')
+test.built_file_must_match('copies-out/directory/subdir/file5',
+ 'file5 contents\n',
+ chdir='relocate/src')
+test.built_file_must_match('copies-out/subdir/file6',
+ 'file6 contents\n',
+ chdir='relocate/src')
test.pass_test()

0 comments on commit 3b6138a

Please sign in to comment.