Bug 1444546 - Post: Remove add_java_jar and support. r=Build draft
authorNick Alexander <nalexander@mozilla.com>
Tue, 06 Mar 2018 14:48:20 -0800
changeset 787984 88abda604f7b3f8523bdb3dcc46b77932bf13af0
parent 787983 fe7b2f4f549d52f6554a7f09b90342eca6369038
child 787985 170735bbe59f488b9c78f57ac11ae12fd2fa430e
child 788074 be92a7ab0f36563e7b3af69f42095dc2b244bdd2
push id107864
push usernalexander@mozilla.com
push dateWed, 25 Apr 2018 19:17:46 +0000
reviewersBuild
bugs1444546
milestone61.0a1
Bug 1444546 - Post: Remove add_java_jar and support. r=Build MozReview-Commit-ID: J6E2ZOs9r3P
config/makefiles/java-build.mk
config/rules.mk
python/mozbuild/mozbuild/backend/recursivemake.py
python/mozbuild/mozbuild/frontend/context.py
python/mozbuild/mozbuild/frontend/data.py
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/frontend/reader.py
deleted file mode 100644
--- a/config/makefiles/java-build.mk
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- makefile -*-
-# vim:set ts=8 sw=8 sts=8 noet:
-#
-# 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/.
-
-ifndef INCLUDED_JAVA_BUILD_MK #{
-
-default_bootclasspath_jars := \
-  $(ANDROID_SDK)/android.jar \
-  $(NULL)
-
-default_classpath_jars := \
-  $(NULL)
-
-# Turn a possibly empty list of JAR files into a Java classpath, like a.jar:b.jar.
-# Arg 1: Possibly empty list of JAR files.
-define classpath_template
-$(subst $(NULL) ,:,$(strip $(1)))
-endef
-
-ifdef JAVA_JAR_TARGETS #{
-# Arg 1: Output target name with .jar suffix, like jars/jarfile.jar.
-#        Intermediate class files are generated in jars/jarfile-classes.
-# Arg 2: Java sources list.  We use VPATH and $^ so sources can be
-#        relative to $(srcdir) or $(CURDIR).
-# Arg 3: List of extra jars to link against.  We do not use VPATH so
-#        jars must be relative to $(CURDIR).
-# Arg 4: Additional JAVAC_FLAGS.
-
-# Note: Proguard fails when stale .class files corresponding to
-# removed inner classes are present in the object directory.  These
-# stale class files get packaged into the .jar file, which then gets
-# processed by Proguard.  To work around this, we always delete any
-# existing jarfile-classes directory and start fresh.
-
-define java_jar_template
-$(1): $(2) $(3) $(default_bootclasspath_jars) $(default_classpath_jars)
-	$$(REPORT_BUILD)
-	@$$(RM) -rf $(1:.jar=)-classes
-	@$$(NSINSTALL) -D $(1:.jar=)-classes
-	@$$(if $$(filter-out .,$$(@D)),$$(NSINSTALL) -D $$(@D))
-	$$(JAVAC) $$(JAVAC_FLAGS)\
-		$(4)\
-		-d $(1:.jar=)-classes\
-		$(addprefix -bootclasspath ,$(call classpath_template,$(default_bootclasspath_jars)))\
-		$(addprefix -classpath ,$(call classpath_template,$(default_classpath_jars) $(3)))\
-		$$(filter %.java,$$^)
-	$$(JAR) cMf $$@ -C $(1:.jar=)-classes .
-
-GARBAGE += $(1)
-
-GARBAGE_DIRS += $(1:.jar=)-classes
-endef
-
-$(foreach jar,$(JAVA_JAR_TARGETS),\
-  $(if $($(jar)_DEST),,$(error Missing $(jar)_DEST))\
-  $(if $($(jar)_JAVAFILES) $($(jar)_PP_JAVAFILES),,$(error Must provide at least one of $(jar)_JAVAFILES and $(jar)_PP_JAVAFILES))\
-  $(eval $(call java_jar_template,$($(jar)_DEST),$($(jar)_JAVAFILES) $($(jar)_PP_JAVAFILES),$($(jar)_EXTRA_JARS),$($(jar)_JAVAC_FLAGS)))\
-)
-endif #} JAVA_JAR_TARGETS
-
-
-INCLUDED_JAVA_BUILD_MK := 1
-
-endif #} INCLUDED_JAVA_BUILD_MK
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -1168,23 +1168,16 @@ ifeq ($(HOST_OS_ARCH),WINNT)
 root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\1|')
 non-root-path = $(shell echo $(1) | sed -e 's|\(/[^/]*\)/\?\(.*\)|\2|')
 normalizepath = $(foreach p,$(1),$(if $(filter /%,$(1)),$(patsubst %/,%,$(shell cd $(call root-path,$(1)) && pwd -W))/$(call non-root-path,$(1)),$(1)))
 else
 normalizepath = $(1)
 endif
 
 ###############################################################################
-# Java rules
-###############################################################################
-ifneq (,$(JAVA_JAR_TARGETS))
-  include $(MOZILLA_DIR)/config/makefiles/java-build.mk
-endif
-
-###############################################################################
 # Bunch of things that extend the 'export' rule (in order):
 ###############################################################################
 
 ifneq ($(XPI_NAME),)
 $(FINAL_TARGET):
 	$(NSINSTALL) -D $@
 
 export:: $(FINAL_TARGET)
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -30,33 +30,31 @@ from mozbuild.frontend.context import (
 from .common import CommonBackend
 from ..frontend.data import (
     BaseLibrary,
     BaseProgram,
     ChromeManifestEntry,
     ComputedFlags,
     ConfigFileSubstitution,
     ContextDerived,
-    ContextWrapped,
     Defines,
     DirectoryTraversal,
     ExternalLibrary,
     FinalTargetFiles,
     FinalTargetPreprocessedFiles,
     GeneratedFile,
     GeneratedSources,
     HostDefines,
     HostLibrary,
     HostProgram,
     HostRustProgram,
     HostSimpleProgram,
     HostSources,
     InstallationTarget,
     JARManifest,
-    JavaJarData,
     Library,
     Linkable,
     LocalInclude,
     LocalizedFiles,
     LocalizedPreprocessedFiles,
     ObjdirFiles,
     ObjdirPreprocessedFiles,
     PerSourceFlag,
@@ -648,27 +646,16 @@ class RecursiveMakeBackend(CommonBackend
             self._process_per_source_flag(obj, backend_file)
 
         elif isinstance(obj, ComputedFlags):
             self._process_computed_flags(obj, backend_file)
 
         elif isinstance(obj, InstallationTarget):
             self._process_installation_target(obj, backend_file)
 
-        elif isinstance(obj, ContextWrapped):
-            # Process a rich build system object from the front-end
-            # as-is.  Please follow precedent and handle CamelCaseData
-            # in a function named _process_camel_case_data.  At some
-            # point in the future, this unwrapping process may be
-            # automated.
-            if isinstance(obj.wrapped, JavaJarData):
-                self._process_java_jar_data(obj.wrapped, backend_file)
-            else:
-                return False
-
         elif isinstance(obj, RustLibrary):
             self.backend_input_files.add(obj.cargo_file)
             self._process_rust_library(obj, backend_file)
             # No need to call _process_linked_libraries, because Rust
             # libraries are self-contained objects at this point.
 
             # Hook the library into the compile graph.
             build_target = self._build_target_for_obj(obj)
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -1533,23 +1533,16 @@ VARIABLES = {
         This variable contains a list of source code files to compile.
         with the host compiler.
         """),
 
     'HOST_LIBRARY_NAME': (unicode, unicode,
         """Name of target library generated when cross compiling.
         """),
 
-    'JAVA_JAR_TARGETS': (dict, dict,
-        """Defines Java JAR targets to be built.
-
-        This variable should not be populated directly. Instead, it should
-        populated by calling add_java_jar().
-        """),
-
     'LIBRARY_DEFINES': (OrderedDict, dict,
         """Dictionary of compiler defines to declare for the entire library.
 
         This variable works like DEFINES, except that declarations apply to all
         libraries that link into this library via FINAL_LIBRARY.
         """),
 
     'LIBRARY_NAME': (unicode, unicode,
@@ -2252,29 +2245,16 @@ FUNCTIONS = {
 
            include('sibling.build')
 
         Include ``foo.build`` from a path within the top source directory::
 
            include('/elsewhere/foo.build')
         """),
 
-    'add_java_jar': (lambda self: self._add_java_jar, (str,),
-        """Declare a Java JAR target to be built.
-
-        This is the supported way to populate the JAVA_JAR_TARGETS
-        variable.
-
-        The parameters are:
-        * dest - target name, without the trailing .jar. (required)
-
-        This returns a rich Java JAR type, described at
-        :py:class:`mozbuild.frontend.data.JavaJarData`.
-        """),
-
     'export': (lambda self: self._export, (str,),
         """Make the specified variable available to all child directories.
 
         The variable specified by the argument string is added to the
         environment of all directories specified in the DIRS and TEST_DIRS
         variables. If those directories themselves have child directories,
         the variable will be exported to all of them.
 
@@ -2430,17 +2410,17 @@ SPECIAL_VARIABLES = {
     'EXTRA_PP_COMPONENTS': (lambda context: context['FINAL_TARGET_PP_FILES'].components._strings, list,
         """Javascript XPCOM files.
 
        This variable contains a list of files to preprocess.  Generated
        files will be installed in the ``/components`` directory of the distribution.
         """),
 
     'JS_PREFERENCE_FILES': (lambda context: context['FINAL_TARGET_FILES'].defaults.pref._strings, list,
-        """Exported javascript files.
+        """Exported JavaScript files.
 
         A list of files copied into the dist directory for packaging and installation.
         Path will be defined for gre or application prefs dir based on what is building.
         """),
 
     'JS_PREFERENCE_PP_FILES': (lambda context: context['FINAL_TARGET_PP_FILES'].defaults.pref._strings, list,
         """Like JS_PREFERENCE_FILES, preprocessed..
         """),
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -896,64 +896,16 @@ class JARManifest(ContextDerived):
     )
 
     def __init__(self, context, path):
         ContextDerived.__init__(self, context)
 
         self.path = path
 
 
-class ContextWrapped(ContextDerived):
-    """Generic context derived container object for a wrapped rich object.
-
-    Use this wrapper class to shuttle a rich build system object
-    completely defined in moz.build files through the tree metadata
-    emitter to the build backend for processing as-is.
-    """
-
-    __slots__ = (
-        'wrapped',
-    )
-
-    def __init__(self, context, wrapped):
-        ContextDerived.__init__(self, context)
-
-        self.wrapped = wrapped
-
-
-class JavaJarData(object):
-    """Represents a Java JAR file.
-
-    A Java JAR has the following members:
-        * sources - strictly ordered list of input java sources
-        * generated_sources - strictly ordered list of generated input
-          java sources
-        * extra_jars - list of JAR file dependencies to include on the
-          javac compiler classpath
-        * javac_flags - list containing extra flags passed to the
-          javac compiler
-    """
-
-    __slots__ = (
-        'name',
-        'sources',
-        'generated_sources',
-        'extra_jars',
-        'javac_flags',
-    )
-
-    def __init__(self, name, sources=[], generated_sources=[],
-            extra_jars=[], javac_flags=[]):
-        self.name = name
-        self.sources = StrictOrderingOnAppendList(sources)
-        self.generated_sources = StrictOrderingOnAppendList(generated_sources)
-        self.extra_jars = list(extra_jars)
-        self.javac_flags = list(javac_flags)
-
-
 class BaseSources(ContextDerived):
     """Base class for files to be compiled during the build."""
 
     __slots__ = (
         'files',
         'canonical_suffix',
     )
 
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -23,17 +23,16 @@ import mozinfo
 import pytoml
 
 from .data import (
     BaseRustProgram,
     BaseSources,
     ChromeManifestEntry,
     ComputedFlags,
     ConfigFileSubstitution,
-    ContextWrapped,
     Defines,
     DirectoryTraversal,
     Exports,
     FinalTargetFiles,
     FinalTargetPreprocessedFiles,
     GeneratedFile,
     GeneratedSources,
     GnProjectData,
@@ -1277,19 +1276,16 @@ class TreeMetadataEmitter(LoggingMixin):
                 yield RustTest(context, rust_test, features)
 
         for obj in self._process_test_manifests(context):
             yield obj
 
         for obj in self._process_jar_manifests(context):
             yield obj
 
-        for name, jar in context.get('JAVA_JAR_TARGETS', {}).items():
-            yield ContextWrapped(context, jar)
-
         computed_as_flags.resolve_flags('MOZBUILD',
                                         context.get('ASFLAGS'))
 
         if context.get('USE_YASM') is True:
             yasm = context.config.substs.get('YASM')
             if not yasm:
                 raise SandboxValidationError('yasm is not available', context)
             passthru.variables['AS'] = yasm
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -48,20 +48,16 @@ from mozbuild.testing import (
     WEB_PLATFORM_TESTS_FLAVORS,
 )
 
 from mozbuild.backend.configenvironment import ConfigEnvironment
 
 from mozpack.files import FileFinder
 import mozpack.path as mozpath
 
-from .data import (
-    JavaJarData,
-)
-
 from .sandbox import (
     default_finder,
     SandboxError,
     SandboxExecutionError,
     SandboxLoadError,
     Sandbox,
 )
 
@@ -243,32 +239,16 @@ class MozbuildSandbox(Sandbox):
         # realpath() is needed for true security. But, this isn't for security
         # protection, so it is omitted.
         if not is_read_allowed(path, self._context.config):
             raise SandboxLoadError(self._context.source_stack,
                 sys.exc_info()[2], illegal_path=path)
 
         Sandbox.exec_file(self, path)
 
-    def _add_java_jar(self, name):
-        """Add a Java JAR build target."""
-        if not name:
-            raise Exception('Java JAR cannot be registered without a name')
-
-        if '/' in name or '\\' in name or '.jar' in name:
-            raise Exception('Java JAR names must not include slashes or'
-                ' .jar: %s' % name)
-
-        if name in self['JAVA_JAR_TARGETS']:
-            raise Exception('Java JAR has already been registered: %s' % name)
-
-        jar = JavaJarData(name)
-        self['JAVA_JAR_TARGETS'][name] = jar
-        return jar
-
     def _export(self, varname):
         """Export the variable to all subdirectories of the current path."""
 
         exports = self.metadata.setdefault('exports', dict())
         if varname in exports:
             raise Exception('Variable has already been exported: %s' % varname)
 
         try: