Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 3b6138af6a84321fcd883e0ac1e9db2bcfc75698 1 parent 4105408
authored
0  gyp.bat 100644 → 100755
File mode changed
30  pylib/gyp/generator/msvs.py
@@ -5,6 +5,7 @@
5 5
 # found in the LICENSE file.
6 6
 
7 7
 import ntpath
  8
+import posixpath
8 9
 import os
9 10
 import re
10 11
 import subprocess
@@ -103,7 +104,10 @@ def _FixPath(path):
103 104
   """
104 105
   if fixpath_prefix and path and not os.path.isabs(path) and not path[0] == '$':
105 106
     path = os.path.join(fixpath_prefix, path)
106  
-  return path.replace('/', '\\')
  107
+  path = path.replace('/', '\\')
  108
+  if len(path) > 0 and path[-1] == '\\':
  109
+    path = path[:-1]
  110
+  return path
107 111
 
108 112
 
109 113
 def _SourceInFolders(sources, prefix=None, excluded=None):
@@ -976,12 +980,24 @@ def _GenerateProject(vcproj_filename, build_file, spec, options, version):
976 980
       dst = os.path.join(cpy['destination'], os.path.basename(src))
977 981
       # _AddCustomBuildTool() will call _FixPath() on the inputs and
978 982
       # outputs, so do the same for our generated command line.
979  
-      cmd = 'mkdir "%s" 2>nul & set ERRORLEVEL=0 & copy /Y "%s" "%s"' % (
980  
-          _FixPath(cpy['destination']), _FixPath(src), _FixPath(dst))
981  
-      _AddCustomBuildTool(p, spec,
982  
-                          inputs=[src], outputs=[dst],
983  
-                          description='Copying %s to %s' % (src, dst),
984  
-                          cmd=cmd)
  983
+      if src.endswith('/'):
  984
+        src_bare = src[:-1]
  985
+        base_dir = posixpath.split(src_bare)[0]
  986
+        outer_dir = posixpath.split(src_bare)[1]
  987
+        cmd = 'cd "%s" && xcopy /e /f /y "%s" "%s\\%s\\"' % (
  988
+            _FixPath(base_dir), outer_dir, _FixPath(dst), outer_dir)
  989
+        _AddCustomBuildTool(p, spec,
  990
+                            inputs=[src, build_file],
  991
+                            outputs=['dummy_copies', dst],
  992
+                            description='Copying %s to %s' % (src, dst),
  993
+                            cmd=cmd)
  994
+      else:
  995
+        cmd = 'mkdir "%s" 2>nul & set ERRORLEVEL=0 & copy /Y "%s" "%s"' % (
  996
+            _FixPath(cpy['destination']), _FixPath(src), _FixPath(dst))
  997
+        _AddCustomBuildTool(p, spec,
  998
+                            inputs=[src], outputs=[dst],
  999
+                            description='Copying %s to %s' % (src, dst),
  1000
+                            cmd=cmd)
985 1001
 
986 1002
   # Write it out.
987 1003
   p.Write()
26  test/copies/gyptest-all.py
@@ -24,19 +24,17 @@
24 24
                            'file2 contents\n',
25 25
                            chdir='relocate/src')
26 26
 
27  
-# TODO Not yet implemented on msvs
28  
-if test.format != 'msvs':
29  
-  test.built_file_must_match('copies-out/directory/file3',
30  
-                             'file3 contents\n',
31  
-                             chdir='relocate/src')
32  
-  test.built_file_must_match('copies-out/directory/file4',
33  
-                             'file4 contents\n',
34  
-                             chdir='relocate/src')
35  
-  test.built_file_must_match('copies-out/directory/subdir/file5',
36  
-                             'file5 contents\n',
37  
-                             chdir='relocate/src')
38  
-  test.built_file_must_match('copies-out/subdir/file6',
39  
-                             'file6 contents\n',
40  
-                             chdir='relocate/src')
  27
+test.built_file_must_match('copies-out/directory/file3',
  28
+                           'file3 contents\n',
  29
+                           chdir='relocate/src')
  30
+test.built_file_must_match('copies-out/directory/file4',
  31
+                           'file4 contents\n',
  32
+                           chdir='relocate/src')
  33
+test.built_file_must_match('copies-out/directory/subdir/file5',
  34
+                           'file5 contents\n',
  35
+                           chdir='relocate/src')
  36
+test.built_file_must_match('copies-out/subdir/file6',
  37
+                           'file6 contents\n',
  38
+                           chdir='relocate/src')
41 39
 
42 40
 test.pass_test()
26  test/copies/gyptest-default.py
@@ -24,19 +24,17 @@
24 24
                            'file2 contents\n',
25 25
                            chdir='relocate/src')
26 26
 
27  
-# TODO Not yet implemented on msvs
28  
-if test.format != 'msvs':
29  
-  test.built_file_must_match('copies-out/directory/file3',
30  
-                             'file3 contents\n',
31  
-                             chdir='relocate/src')
32  
-  test.built_file_must_match('copies-out/directory/file4',
33  
-                             'file4 contents\n',
34  
-                             chdir='relocate/src')
35  
-  test.built_file_must_match('copies-out/directory/subdir/file5',
36  
-                             'file5 contents\n',
37  
-                             chdir='relocate/src')
38  
-  test.built_file_must_match('copies-out/subdir/file6',
39  
-                             'file6 contents\n',
40  
-                             chdir='relocate/src')
  27
+test.built_file_must_match('copies-out/directory/file3',
  28
+                           'file3 contents\n',
  29
+                           chdir='relocate/src')
  30
+test.built_file_must_match('copies-out/directory/file4',
  31
+                           'file4 contents\n',
  32
+                           chdir='relocate/src')
  33
+test.built_file_must_match('copies-out/directory/subdir/file5',
  34
+                           'file5 contents\n',
  35
+                           chdir='relocate/src')
  36
+test.built_file_must_match('copies-out/subdir/file6',
  37
+                           'file6 contents\n',
  38
+                           chdir='relocate/src')
41 39
 
42 40
 test.pass_test()

0 notes on commit 3b6138a

Please sign in to comment.
Something went wrong with that request. Please try again.