1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 """Ensure UNIX style paths are used with GNU make on Windows.
13 This can be removed once we no longer support GNU make on Windows (bug
16 if os
.environ
.get('PYMAKE') or os
.name
not in ('nt', 'ce'):
19 if len(path
) > 2 and path
[1] == ':':
20 path
= '/' + path
[0] + path
[2:]
22 return posixpath
.normpath(path
)
25 if len(sys
.argv
) != 4:
26 print >> sys
.stderr
, "Usage: copy_source.py " \
27 "<topsrcdir> <source directory> <target directory>"
30 topsrcdir
= normpath(sys
.argv
[1])
31 source_dir
= sys
.argv
[2]
32 target_dir
= sys
.argv
[3]
36 topsrcdir = %(topsrcdir)s
37 srcdir = %(topsrcdir)s/addon-sdk
38 VPATH = %(topsrcdir)s/addon-sdk
40 include $(topsrcdir)/config/config.mk
41 """ % {'topsrcdir': topsrcdir
}
43 real_source
= source_dir
.replace('/', os
.sep
)
44 if not os
.path
.exists(real_source
):
45 print >> sys
.stderr
, "Error: Missing source file %s" % real_source
47 elif not os
.path
.isdir(real_source
):
48 print >> sys
.stderr
, "Error: Source %s is not a directory" % real_source
50 for dirpath
, dirnames
, filenames
in os
.walk(real_source
):
53 dirpath
= dirpath
.replace(os
.sep
, '/')
54 relative
= dirpath
[len(source_dir
):]
55 varname
= "COMMONJS%s" % relative
.replace('/', '_')
56 print "%s_FILES = \\" % varname
57 for name
in filenames
:
58 print " %s/%s \\" % (dirpath
, name
)
60 print "%s_DEST = %s%s" % (varname
, target_dir
, relative
)
61 print "INSTALL_TARGETS += %s\n" % varname
63 print "include $(topsrcdir)/config/rules.mk"