Bug 924615 - Move JarMaker.py into mozbuild; r=mshal
authorGregory Szorc <gps@mozilla.com>
Fri, 11 Oct 2013 13:19:11 -0700
changeset 164357 a83e068892bbef0dd6df474694fa8af5f917eb76
parent 164356 864f40ba0ae571b1d2ca13974199216e94823a16
child 164358 a6a1f08b5561c4ca3e561c30fd2a9eb3fbced4f8
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs924615
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 924615 - Move JarMaker.py into mozbuild; r=mshal
config/JarMaker.py
config/config.mk
config/rules.mk
config/tests/unit-JarMaker.py
js/src/config/config.mk
js/src/config/rules.mk
mobile/locales/Makefile.in
python/mozbuild/mozbuild/action/jar_maker.py
python/mozbuild/mozbuild/jar.py
python/mozbuild/mozbuild/test/test_jarmaker.py
--- a/config/config.mk
+++ b/config/config.mk
@@ -347,17 +347,16 @@ DEFINES += \
 	  -DIMPL_LIBXUL \
 		$(NULL)
 
 ifndef JS_SHARED_LIBRARY
 DEFINES += -DSTATIC_EXPORTABLE_JS_API
 endif
 endif
 
-# Flags passed to JarMaker.py
 MAKE_JARS_FLAGS = \
 	-t $(topsrcdir) \
 	-f $(MOZ_CHROME_FILE_FORMAT) \
 	$(NULL)
 
 ifdef USE_EXTENSION_MANIFEST
 MAKE_JARS_FLAGS += -e
 endif
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1446,20 +1446,20 @@ endif
 ifneq (,$(DIST_SUBDIR))
 ifndef XPI_ROOT_APPID
 $(error XPI_ROOT_APPID is not defined - langpacks will break.)
 endif
 endif
 endif
 
 libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
-	$(PYTHON) $(MOZILLA_DIR)/config/JarMaker.py \
+	$(call py_action,jar_maker,\
 	  $(QUIET) -j $(FINAL_TARGET)/chrome \
 	  $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
-	  $(JAR_MANIFEST)
+	  $(JAR_MANIFEST))
 
 endif
 endif
 
 ifneq ($(DIST_FILES),)
 DIST_FILES_PATH := $(FINAL_TARGET)
 DIST_FILES_FLAGS := $(XULAPP_DEFINES)
 PP_TARGETS += DIST_FILES
--- a/js/src/config/config.mk
+++ b/js/src/config/config.mk
@@ -347,17 +347,16 @@ DEFINES += \
 	  -DIMPL_LIBXUL \
 		$(NULL)
 
 ifndef JS_SHARED_LIBRARY
 DEFINES += -DSTATIC_EXPORTABLE_JS_API
 endif
 endif
 
-# Flags passed to JarMaker.py
 MAKE_JARS_FLAGS = \
 	-t $(topsrcdir) \
 	-f $(MOZ_CHROME_FILE_FORMAT) \
 	$(NULL)
 
 ifdef USE_EXTENSION_MANIFEST
 MAKE_JARS_FLAGS += -e
 endif
--- a/js/src/config/rules.mk
+++ b/js/src/config/rules.mk
@@ -1446,20 +1446,20 @@ endif
 ifneq (,$(DIST_SUBDIR))
 ifndef XPI_ROOT_APPID
 $(error XPI_ROOT_APPID is not defined - langpacks will break.)
 endif
 endif
 endif
 
 libs realchrome:: $(CHROME_DEPS) $(FINAL_TARGET)/chrome
-	$(PYTHON) $(MOZILLA_DIR)/config/JarMaker.py \
+	$(call py_action,jar_maker,\
 	  $(QUIET) -j $(FINAL_TARGET)/chrome \
 	  $(MAKE_JARS_FLAGS) $(XULPPFLAGS) $(DEFINES) $(ACDEFINES) \
-	  $(JAR_MANIFEST)
+	  $(JAR_MANIFEST))
 
 endif
 endif
 
 ifneq ($(DIST_FILES),)
 DIST_FILES_PATH := $(FINAL_TARGET)
 DIST_FILES_FLAGS := $(XULAPP_DEFINES)
 PP_TARGETS += DIST_FILES
--- a/mobile/locales/Makefile.in
+++ b/mobile/locales/Makefile.in
@@ -15,22 +15,16 @@
 include $(topsrcdir)/config/config.mk
 
 USE_AUTOTARGETS_MK=1
 include $(topsrcdir)/config/makefiles/makeutils.mk
 
 # Separate items of contention
 tgt-gendir = .deps/generated_$(AB_CD)
 
-jar-maker = \
-  $(firstword \
-    $(wildcard $(MOZILLA_DIR)/config/JarMaker.py) \
-    $(topsrcdir)/config/JarMaker.py \
-  )
-
 GENERATED_DIRS += .deps
 
 ifdef LOCALE_MERGEDIR
 vpath book%.inc $(LOCALE_MERGEDIR)/mobile/profile
 endif
 vpath book%.inc $(LOCALE_SRCDIR)/profile
 ifdef LOCALE_MERGEDIR
 vpath book%.inc @srcdir@/en-US/profile
@@ -125,28 +119,27 @@ search-dir-deps = \
   $(dir-chrome) \
   $(NULL)
 
 search-preqs =\
   $(call mkdir_deps,$(dir $(search-jar-ts))) \
   $(call mkdir_deps,$(FINAL_TARGET)/chrome) \
   $(search-jar) \
   $(search-dir-deps) \
-  $(jar-maker) \
   $(if $(IS_LANGUAGE_REPACK),FORCE) \
   $(GLOBAL_DEPS) \
   $(NULL)
 
 .PHONY: searchplugins
 searchplugins: $(search-preqs)
-	$(PYTHON) $(jar-maker) \
+	$(call py_action,jar_maker,\
           $(QUIET) -j $(FINAL_TARGET)/chrome \
           -s $(topsrcdir)/$(relativesrcdir)/en-US/searchplugins \
           -s $(LOCALE_SRCDIR)/searchplugins \
-          $(MAKE_JARS_FLAGS) $(search-jar)
+          $(MAKE_JARS_FLAGS) $(search-jar))
 	$(TOUCH) $@
 
 include $(topsrcdir)/config/rules.mk
 
 
 #############
 libs-preqs =\
   $(call mkdir-deps,$(DIST)/install) \
new file mode 100644
--- /dev/null
+++ b/python/mozbuild/mozbuild/action/jar_maker.py
@@ -0,0 +1,15 @@
+# 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 sys
+
+import mozbuild.jar
+
+
+def main(args):
+    return mozbuild.jar.main(args)
+
+
+if __name__ == '__main__':
+    sys.exit(main(sys.argv[1:]))
rename from config/JarMaker.py
rename to python/mozbuild/mozbuild/jar.py
--- a/config/JarMaker.py
+++ b/python/mozbuild/mozbuild/jar.py
@@ -4,17 +4,16 @@
 
 '''jarmaker.py provides a python class to package up chrome content by
 processing jar.mn files.
 
 See the documentation for jar.mn on MDC for further details on the format.
 '''
 import sys
 import os
-import os.path
 import errno
 import re
 import logging
 from time import localtime
 from MozZipFile import ZipFile
 from cStringIO import StringIO
 
 from mozbuild.util import (
@@ -434,20 +433,21 @@ class JarMaker(object):
       if sys.platform != "win32":
         os.symlink(src, out)
       else:
         # On Win32, use ctypes to create a hardlink
         rv = CreateHardLink(out, src, None)
         if rv == 0:
           raise WinError()
 
-def main():
+def main(args=None):
+  args = args or sys.argv
   jm = JarMaker()
   p = jm.getCommandLineParser()
-  (options, args) = p.parse_args()
+  (options, args) = p.parse_args(args)
   jm.processIncludes(options.I)
   jm.outputFormat = options.f
   jm.sourcedirs = options.s
   jm.topsourcedir = options.t
   if options.e:
     jm.useChromeManifest = True
     jm.useJarfileManifest = False
   if options.bothManifests:
@@ -479,11 +479,8 @@ def main():
   logging.getLogger().setLevel(noise)
   topsrc = options.t
   topsrc = os.path.normpath(os.path.abspath(topsrc))
   if not args:
     infile = sys.stdin
   else:
     infile,  = args
   jm.makeJar(infile, options.j)
-
-if __name__ == "__main__":
-  main()
rename from config/tests/unit-JarMaker.py
rename to python/mozbuild/mozbuild/test/test_jarmaker.py
--- a/config/tests/unit-JarMaker.py
+++ b/python/mozbuild/mozbuild/test/test_jarmaker.py
@@ -1,19 +1,25 @@
+# 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/.
+
 from __future__ import print_function
 import unittest
 
 import os, sys, os.path, time, inspect
 from filecmp import dircmp
 from tempfile import mkdtemp
 from shutil import rmtree, copy2
 from StringIO import StringIO
 from zipfile import ZipFile
 import mozunit
-from JarMaker import JarMaker
+
+from mozbuild.jar import JarMaker
+
 
 if sys.platform == "win32":
     import ctypes
     from ctypes import POINTER, WinError
     DWORD = ctypes.c_ulong
     LPDWORD = POINTER(DWORD)
     HANDLE = ctypes.c_void_p
     GENERIC_READ = 0x80000000