michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import os michael@0: import sys michael@0: michael@0: if len(sys.argv) != 5: michael@0: print >> sys.stderr, "Usage: copy_source.py " \ michael@0: " " michael@0: sys.exit(1) michael@0: michael@0: topsrcdir = sys.argv[1] michael@0: source_dir = sys.argv[2] michael@0: target_dir = sys.argv[3] michael@0: isB2G = int(sys.argv[4]) michael@0: michael@0: print """ michael@0: DEPTH = .. michael@0: topsrcdir = %(topsrcdir)s michael@0: srcdir = %(topsrcdir)s/addon-sdk michael@0: VPATH = %(topsrcdir)s/addon-sdk michael@0: michael@0: include $(topsrcdir)/config/config.mk michael@0: """ % {'topsrcdir': topsrcdir} michael@0: michael@0: real_source = source_dir.replace('/', os.sep) michael@0: if not os.path.exists(real_source): michael@0: print >> sys.stderr, "Error: Missing source file %s" % real_source michael@0: sys.exit(1) michael@0: elif not os.path.isdir(real_source): michael@0: print >> sys.stderr, "Error: Source %s is not a directory" % real_source michael@0: sys.exit(1) michael@0: for dirpath, dirnames, filenames in os.walk(real_source): michael@0: if not filenames: michael@0: continue michael@0: dirpath = dirpath.replace(os.sep, '/') michael@0: relative = dirpath[len(source_dir):] michael@0: if isB2G and relative in [ michael@0: '/method/test', michael@0: '/sdk/ui', michael@0: '/sdk/ui/button', michael@0: '/sdk/ui/sidebar', michael@0: '/sdk/places', michael@0: '/sdk/places/host', michael@0: '/sdk/tabs', michael@0: '/sdk/panel', michael@0: '/sdk/frame', michael@0: '/sdk/test', michael@0: '/sdk/window', michael@0: '/sdk/windows', michael@0: '/sdk/deprecated', michael@0: ]: michael@0: continue michael@0: varname = "COMMONJS%s" % relative.replace('/', '_') michael@0: print "%s_FILES = \\" % varname michael@0: for name in filenames: michael@0: print " %s/%s \\" % (dirpath, name) michael@0: print " $(NULL)" michael@0: print "%s_DEST = %s%s" % (varname, target_dir, relative) michael@0: print "INSTALL_TARGETS += %s\n" % varname michael@0: michael@0: print "include $(topsrcdir)/config/rules.mk"