From de8e0e234fc86da8330c552ecd2a03fbdf503ef9 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Fri, 11 Oct 2013 13:19:11 -0700 Subject: [PATCH] Bug 924615 - Move JarMaker.py into mozbuild; r=mshal --- config/config.mk | 1 - config/rules.mk | 4 ++-- js/src/config/config.mk | 1 - js/src/config/rules.mk | 4 ++-- mobile/locales/Makefile.in | 11 ++--------- python/mozbuild/mozbuild/action/jar_maker.py | 15 +++++++++++++++ .../mozbuild/mozbuild/jar.py | 9 +++------ .../mozbuild/mozbuild/test/test_jarmaker.py | 8 +++++++- 8 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 python/mozbuild/mozbuild/action/jar_maker.py rename config/JarMaker.py => python/mozbuild/mozbuild/jar.py (99%) rename config/tests/unit-JarMaker.py => python/mozbuild/mozbuild/test/test_jarmaker.py (98%) diff --git a/config/config.mk b/config/config.mk index e72058d238ada..ac943e90a3835 100644 --- a/config/config.mk +++ b/config/config.mk @@ -352,7 +352,6 @@ DEFINES += -DSTATIC_EXPORTABLE_JS_API endif endif -# Flags passed to JarMaker.py MAKE_JARS_FLAGS = \ -t $(topsrcdir) \ -f $(MOZ_CHROME_FILE_FORMAT) \ diff --git a/config/rules.mk b/config/rules.mk index 01a65c975f727..a5ad85c1972c9 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -1451,10 +1451,10 @@ 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 diff --git a/js/src/config/config.mk b/js/src/config/config.mk index e72058d238ada..ac943e90a3835 100644 --- a/js/src/config/config.mk +++ b/js/src/config/config.mk @@ -352,7 +352,6 @@ DEFINES += -DSTATIC_EXPORTABLE_JS_API endif endif -# Flags passed to JarMaker.py MAKE_JARS_FLAGS = \ -t $(topsrcdir) \ -f $(MOZ_CHROME_FILE_FORMAT) \ diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index 01a65c975f727..a5ad85c1972c9 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -1451,10 +1451,10 @@ 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 diff --git a/mobile/locales/Makefile.in b/mobile/locales/Makefile.in index 18505c6ffd943..f928917e1d55d 100644 --- a/mobile/locales/Makefile.in +++ b/mobile/locales/Makefile.in @@ -20,12 +20,6 @@ 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 @@ -130,18 +124,17 @@ search-preqs =\ $(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 diff --git a/python/mozbuild/mozbuild/action/jar_maker.py b/python/mozbuild/mozbuild/action/jar_maker.py new file mode 100644 index 0000000000000..544fb8768f2da --- /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:])) diff --git a/config/JarMaker.py b/python/mozbuild/mozbuild/jar.py similarity index 99% rename from config/JarMaker.py rename to python/mozbuild/mozbuild/jar.py index 5ad8b21b6acc3..ecabec5f9cc33 100644 --- a/config/JarMaker.py +++ b/python/mozbuild/mozbuild/jar.py @@ -9,7 +9,6 @@ ''' import sys import os -import os.path import errno import re import logging @@ -439,10 +438,11 @@ def symlink(self, src, dest): 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 @@ -484,6 +484,3 @@ def main(): else: infile, = args jm.makeJar(infile, options.j) - -if __name__ == "__main__": - main() diff --git a/config/tests/unit-JarMaker.py b/python/mozbuild/mozbuild/test/test_jarmaker.py similarity index 98% rename from config/tests/unit-JarMaker.py rename to python/mozbuild/mozbuild/test/test_jarmaker.py index 51d97462be5a4..04acad0b5a4df 100644 --- a/config/tests/unit-JarMaker.py +++ b/python/mozbuild/mozbuild/test/test_jarmaker.py @@ -1,3 +1,7 @@ +# 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 @@ -8,7 +12,9 @@ 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