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/.
9 print >> sys
.stderr
, "Usage: copy_source.py " \
10 "<topsrcdir> <source directory> <target directory> <isb2g>"
13 topsrcdir
= sys
.argv
[1]
14 source_dir
= sys
.argv
[2]
15 target_dir
= sys
.argv
[3]
16 isB2G
= int(sys
.argv
[4])
20 topsrcdir = %(topsrcdir)s
21 srcdir = %(topsrcdir)s/addon-sdk
22 VPATH = %(topsrcdir)s/addon-sdk
24 include $(topsrcdir)/config/config.mk
25 """ % {'topsrcdir': topsrcdir
}
27 real_source
= source_dir
.replace('/', os
.sep
)
28 if not os
.path
.exists(real_source
):
29 print >> sys
.stderr
, "Error: Missing source file %s" % real_source
31 elif not os
.path
.isdir(real_source
):
32 print >> sys
.stderr
, "Error: Source %s is not a directory" % real_source
34 for dirpath
, dirnames
, filenames
in os
.walk(real_source
):
37 dirpath
= dirpath
.replace(os
.sep
, '/')
38 relative
= dirpath
[len(source_dir
):]
39 if isB2G
and relative
in [
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 "%s_TARGET = copy_source" % varname
62 print "INSTALL_TARGETS += %s\n" % varname
64 print "include $(topsrcdir)/config/rules.mk"