Bug 867089 - Validate the playbackRate before using it. r=ehsan
[gecko.git] / addon-sdk / copy_source.py
blob7f07764308c778190e69d56f759aaa7fd40d397e
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/.
5 import os
6 import posixpath
7 import sys
10 def normpath(path):
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
14 828317).
15 """
16 if os.environ.get('PYMAKE') or os.name not in ('nt', 'ce'):
17 return path
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>"
28 sys.exit(1)
30 topsrcdir = normpath(sys.argv[1])
31 source_dir = sys.argv[2]
32 target_dir = sys.argv[3]
34 print """
35 DEPTH = ..
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
46 sys.exit(1)
47 elif not os.path.isdir(real_source):
48 print >> sys.stderr, "Error: Source %s is not a directory" % real_source
49 sys.exit(1)
50 for dirpath, dirnames, filenames in os.walk(real_source):
51 if not filenames:
52 continue
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)
59 print " $(NULL)"
60 print "%s_DEST = %s%s" % (varname, target_dir, relative)
61 print "INSTALL_TARGETS += %s\n" % varname
63 print "include $(topsrcdir)/config/rules.mk"