Bug 837915: Updates to the add-on SDK APIs don't propagate to the build. r=gps
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 14 Feb 2013 09:38:38 -0800
changeset 121939 3b817e00e439958ad966c6a47daaf813e97023f7
parent 121938 c326960b40bc5aa85fed8665d9fd7dd970fb36e2
child 121940 265796431ef9ac259e54ee4d7460090e8d49bcfc
push idunknown
push userunknown
push dateunknown
reviewersgps
bugs837915
milestone21.0a1
Bug 837915: Updates to the add-on SDK APIs don't propagate to the build. r=gps
addon-sdk/Makefile.in
addon-sdk/copy_source.py
--- a/addon-sdk/Makefile.in
+++ b/addon-sdk/Makefile.in
@@ -6,23 +6,19 @@ DEPTH     = @DEPTH@
 topsrcdir = @top_srcdir@
 srcdir    = @srcdir@
 VPATH     = @srcdir@
 
 include $(topsrcdir)/config/config.mk
 
 TEST_DIRS += test
 
-COMMONJS_FILES = \
-  source/lib/toolkit \
-  source/lib/sdk \
-  $(NULL)
-
-COMMONJS_DEST = $(FINAL_TARGET)/modules/commonjs
-INSTALL_TARGETS += COMMONJS
+libs::
+	$(PYTHON) $(srcdir)/copy_source.py $(topsrcdir) $(srcdir)/source/lib $(FINAL_TARGET)/modules/commonjs >copy_source.mk
+	$(MAKE) -f copy_source.mk libs
 
 include $(topsrcdir)/config/rules.mk
 
 TEST_FILES = \
   source/app-extension \
   source/bin \
   source/data \
   source/python-lib \
new file mode 100644
--- /dev/null
+++ b/addon-sdk/copy_source.py
@@ -0,0 +1,46 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import os
+import sys
+
+if len(sys.argv) != 4:
+    print >> sys.stderr, "Usage: copy_source.py " \
+                         "<topsrcdir> <source directory> <target directory>"
+    sys.exit(1)
+
+topsrcdir = sys.argv[1]
+source_dir = sys.argv[2]
+target_dir = sys.argv[3]
+
+print """
+DEPTH     = ..
+topsrcdir = %(topsrcdir)s
+srcdir    = %(topsrcdir)s/addon-sdk
+VPATH     = %(topsrcdir)s/addon-sdk
+
+include $(topsrcdir)/config/config.mk
+""" % {'topsrcdir': topsrcdir}
+
+real_source = source_dir.replace('/', os.sep)
+if not os.path.exists(real_source):
+    print >> sys.stderr, "Error: Missing source file %s" % real_source
+    sys.exit(1)
+elif not os.path.isdir(real_source):
+    print >> sys.stderr, "Error: Source %s is not a directory" % real_source
+    sys.exit(1)
+for dirpath, dirnames, filenames in os.walk(real_source):
+    if not filenames:
+        continue
+    dirpath = dirpath.replace(os.sep, '/')
+    relative = dirpath[len(source_dir):]
+    varname = "COMMONJS%s" % relative.replace('/', '_')
+    print "%s_FILES = \\" % varname
+    for name in filenames:
+        print "  %s/%s \\" % (dirpath, name)
+    print "  $(NULL)"
+    print "%s_DEST = %s%s" % (varname, target_dir, relative)
+    print "INSTALL_TARGETS += %s\n" % varname
+
+print "include $(topsrcdir)/config/rules.mk"