зеркало из https://github.com/mozilla/gecko-dev.git
Bug 925185 - Part 1: Add add_java_jar to moz.build. r=gps
--HG-- extra : rebase_source : 3e637b09ccf908b77ecd65f3b598796514d42eed
This commit is contained in:
Родитель
6fcae33467
Коммит
3fc94c4a5c
|
@ -30,11 +30,13 @@ from ..frontend.data import (
|
|||
GeneratedWebIDLFile,
|
||||
InstallationTarget,
|
||||
IPDLFile,
|
||||
JavaJarData,
|
||||
LocalInclude,
|
||||
PreprocessedTestWebIDLFile,
|
||||
PreprocessedWebIDLFile,
|
||||
Program,
|
||||
SandboxDerived,
|
||||
SandboxWrapped,
|
||||
TestWebIDLFile,
|
||||
VariablePassthru,
|
||||
XPIDLFile,
|
||||
|
@ -413,6 +415,15 @@ class RecursiveMakeBackend(CommonBackend):
|
|||
elif isinstance(obj, InstallationTarget):
|
||||
self._process_installation_target(obj, backend_file)
|
||||
|
||||
elif isinstance(obj, SandboxWrapped):
|
||||
# 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)
|
||||
|
||||
self._backend_files[obj.srcdir] = backend_file
|
||||
|
||||
def _fill_root_mk(self):
|
||||
|
@ -993,6 +1004,23 @@ class RecursiveMakeBackend(CommonBackend):
|
|||
path = '$(srcdir)/'
|
||||
backend_file.write('LOCAL_INCLUDES += -I%s%s\n' % (path, local_include))
|
||||
|
||||
def _process_java_jar_data(self, jar, backend_file):
|
||||
target = jar.name
|
||||
backend_file.write('JAVA_JAR_TARGETS += %s\n' % target)
|
||||
backend_file.write('%s_DEST := %s.jar\n' % (target, jar.name))
|
||||
if jar.sources:
|
||||
backend_file.write('%s_JAVAFILES := %s\n' %
|
||||
(target, ' '.join(jar.sources)))
|
||||
if jar.generated_sources:
|
||||
backend_file.write('%s_PP_JAVAFILES := %s\n' %
|
||||
(target, ' '.join(jar.generated_sources)))
|
||||
if jar.extra_jars:
|
||||
backend_file.write('%s_EXTRA_JARS := %s\n' %
|
||||
(target, ' '.join(jar.extra_jars)))
|
||||
if jar.javac_flags:
|
||||
backend_file.write('%s_JAVAC_FLAGS := %s\n' %
|
||||
(target, jar.javac_flags))
|
||||
|
||||
def _write_manifests(self, dest, manifests):
|
||||
man_dir = os.path.join(self.environment.topobjdir, '_build_manifests',
|
||||
dest)
|
||||
|
|
|
@ -359,6 +359,54 @@ class LocalInclude(SandboxDerived):
|
|||
|
||||
self.path = path
|
||||
|
||||
|
||||
class SandboxWrapped(SandboxDerived):
|
||||
"""Generic sandbox 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, sandbox, wrapped):
|
||||
SandboxDerived.__init__(self, sandbox)
|
||||
|
||||
self.wrapped = wrapped
|
||||
|
||||
|
||||
class JavaJarData(object):
|
||||
"""Represents a Java JAR file.
|
||||
|
||||
A Java JAR has the following members:
|
||||
* sources - list of input java sources
|
||||
* generated_sources - list of generated input java sources
|
||||
* extra_jars - list of JAR file dependencies to include on the
|
||||
javac compiler classpath
|
||||
* javac_flags - string 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=None):
|
||||
self.name = name
|
||||
self.sources = list(sources)
|
||||
self.generated_sources = list(generated_sources)
|
||||
self.extra_jars = list(extra_jars)
|
||||
self.javac_flags = javac_flags
|
||||
|
||||
|
||||
class InstallationTarget(SandboxDerived):
|
||||
"""Describes the rules that affect where files get installed to."""
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ from .data import (
|
|||
PreprocessedWebIDLFile,
|
||||
Program,
|
||||
ReaderSummary,
|
||||
SandboxWrapped,
|
||||
TestWebIDLFile,
|
||||
TestManifest,
|
||||
VariablePassthru,
|
||||
|
@ -248,6 +249,9 @@ class TreeMetadataEmitter(LoggingMixin):
|
|||
for obj in self._process_test_manifest(sandbox, info, path):
|
||||
yield obj
|
||||
|
||||
for name, jar in sandbox.get('JAVA_JAR_TARGETS', {}).items():
|
||||
yield SandboxWrapped(sandbox, jar)
|
||||
|
||||
def _process_test_manifest(self, sandbox, info, manifest_path):
|
||||
flavor, install_prefix, filter_inactive = info
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@ from mozbuild.util import (
|
|||
|
||||
from mozbuild.backend.configenvironment import ConfigEnvironment
|
||||
|
||||
from .data import (
|
||||
JavaJarData,
|
||||
)
|
||||
|
||||
from .sandbox import (
|
||||
SandboxError,
|
||||
SandboxExecutionError,
|
||||
|
@ -222,6 +226,22 @@ class MozbuildSandbox(Sandbox):
|
|||
|
||||
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 self['JAVA_JAR_TARGETS'].has_key(name):
|
||||
raise Exception('Java JAR has already been registered: %s' % name)
|
||||
|
||||
jar = JavaJarData(name)
|
||||
self['JAVA_JAR_TARGETS'][name] = jar
|
||||
return jar
|
||||
|
||||
def _add_tier_directory(self, tier, reldir, static=False, external=False):
|
||||
"""Register a tier directory with the build."""
|
||||
if isinstance(reldir, text_type):
|
||||
|
|
|
@ -235,6 +235,13 @@ VARIABLES = {
|
|||
"""Name of target library generated when cross compiling.
|
||||
""", 'binaries'),
|
||||
|
||||
'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().
|
||||
""", 'binaries'),
|
||||
|
||||
'JS_MODULES_PATH': (unicode, unicode, "",
|
||||
"""Sub-directory of ``$(FINAL_TARGET)`` to install
|
||||
``EXTRA_JS_MODULES``.
|
||||
|
@ -574,6 +581,19 @@ FUNCTIONS = {
|
|||
include('/elsewhere/foo.build')
|
||||
"""),
|
||||
|
||||
'add_java_jar': ('_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`.
|
||||
"""),
|
||||
|
||||
'add_tier_dir': ('_add_tier_directory', (str, [str, list], bool, bool),
|
||||
"""Register a directory for tier traversal.
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче