diff --git a/build/mobile/robocop/Makefile.in b/build/mobile/robocop/Makefile.in index 20f820fdaeb..c0c4d089b2d 100644 --- a/build/mobile/robocop/Makefile.in +++ b/build/mobile/robocop/Makefile.in @@ -11,8 +11,6 @@ ANDROID_EXTRA_JARS += \ $(srcdir)/robotium-solo-4.3.1.jar \ $(NULL) -ANDROID_ASSETS_DIR := $(TESTPATH)/assets - _JAVA_HARNESS := \ Actions.java \ Assert.java \ diff --git a/build/mobile/robocop/moz.build b/build/mobile/robocop/moz.build index 5145e1219a4..75bf630534f 100644 --- a/build/mobile/robocop/moz.build +++ b/build/mobile/robocop/moz.build @@ -7,6 +7,9 @@ DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME'] base = '/mobile/android/tests/browser/robocop/' + +ANDROID_ASSETS_DIRS += [base + 'assets'] + TEST_HARNESS_FILES.testing.mochitest += [ base + 'robocop.ini', base + 'robocop_autophone.ini', diff --git a/config/makefiles/java-build.mk b/config/makefiles/java-build.mk index 06b11249d96..019745db58b 100644 --- a/config/makefiles/java-build.mk +++ b/config/makefiles/java-build.mk @@ -18,7 +18,7 @@ endif #} JAVAFILES ifdef ANDROID_APK_NAME #{ android_res_dirs := $(or $(ANDROID_RES_DIRS),$(srcdir)/res) _ANDROID_RES_FLAG := $(addprefix -S ,$(android_res_dirs)) -_ANDROID_ASSETS_FLAG := $(addprefix -A ,$(ANDROID_ASSETS_DIR)) +_ANDROID_ASSETS_FLAG := $(if $(ANDROID_ASSETS_DIRS),$(addprefix -A ,$(ANDROID_ASSETS_DIRS))) android_manifest := $(or $(ANDROID_MANIFEST_FILE),AndroidManifest.xml) GENERATED_DIRS += classes @@ -45,7 +45,7 @@ $(ANDROID_APK_NAME).ap_: .aapt.deps ; # resource files one subdirectory below the parent resource directory. android_res_files := $(wildcard $(addsuffix /*,$(wildcard $(addsuffix /*,$(android_res_dirs))))) -.aapt.deps: $(android_manifest) $(android_res_files) $(wildcard $(ANDROID_ASSETS_DIR)) +.aapt.deps: $(android_manifest) $(android_res_files) $(wildcard $(ANDROID_ASSETS_DIRS)) @$(TOUCH) $@ $(AAPT) package -f -M $< -I $(ANDROID_SDK)/android.jar $(_ANDROID_RES_FLAG) $(_ANDROID_ASSETS_FLAG) \ -J ${@D} \ diff --git a/mobile/android/app/assets/example_asset.txt b/mobile/android/app/assets/example_asset.txt new file mode 100644 index 00000000000..34338f983ea --- /dev/null +++ b/mobile/android/app/assets/example_asset.txt @@ -0,0 +1 @@ +This is an example asset. diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index 1826e129cdf..ce79d0af068 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -420,6 +420,7 @@ $(1): $$(call mkdir_deps,$(filter-out ./,$(dir $(3) $(4) $(5)))) $(2) $(if $(MOZ_ANDROID_MAX_SDK_VERSION),--max-res-version $(MOZ_ANDROID_MAX_SDK_VERSION),) \ --auto-add-overlay \ $$(addprefix -S ,$$(ANDROID_RES_DIRS)) \ + $$(addprefix -A ,$$(ANDROID_ASSETS_DIRS)) \ $(if $(extra_res_dirs),$$(addprefix -S ,$$(extra_res_dirs)),) \ $(if $(extra_packages),--extra-packages $$(extra_packages),) \ --custom-package org.mozilla.gecko \ diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index 60d1e4dd2c3..eff6bb5266f 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -764,6 +764,10 @@ ANDROID_GENERATED_RESFILES += [ 'res/values/strings.xml', ] +ANDROID_ASSETS_DIRS += [ + '/mobile/android/app/assets', +] + # We do not expose MOZ_INSTALL_TRACKING_ADJUST_SDK_APP_TOKEN here because that # would leak the value to build logs. Instead we expose the token quietly where # appropriate in Makefile.in. diff --git a/mobile/android/mach_commands.py b/mobile/android/mach_commands.py index d7a5b1fba5f..1a400328c1c 100644 --- a/mobile/android/mach_commands.py +++ b/mobile/android/mach_commands.py @@ -142,6 +142,7 @@ class MachCommands(MachCommandBase): srcdir('base/src/webrtc_video_capture/java', 'media/webrtc/trunk/webrtc/modules/video_capture/android/java/src') srcdir('base/src/webrtc_video_render/java', 'media/webrtc/trunk/webrtc/modules/video_render/android/java/src') srcdir('base/src/main/res', 'mobile/android/base/resources') + srcdir('base/src/main/assets', 'mobile/android/app/assets') srcdir('base/src/crashreporter/res', 'mobile/android/base/crashreporter/res') manifest_path = os.path.join(self.topobjdir, 'mobile', 'android', 'gradle.manifest') diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 7ec4e6b68a6..86de6351b35 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -26,6 +26,7 @@ import mozpack.path as mozpath from .common import CommonBackend from ..frontend.data import ( + AndroidAssetsDirs, AndroidResDirs, AndroidEclipseProjectData, BrandingFiles, @@ -71,6 +72,7 @@ from ..util import ( from ..makeutil import Makefile MOZBUILD_VARIABLES = [ + b'ANDROID_ASSETS_DIRS', b'ANDROID_GENERATED_RESFILES', b'ANDROID_RES_DIRS', b'ASFLAGS', @@ -603,6 +605,10 @@ class RecursiveMakeBackend(CommonBackend): for p in obj.paths: backend_file.write('ANDROID_RES_DIRS += %s\n' % p.full_path) + elif isinstance(obj, AndroidAssetsDirs): + for p in obj.paths: + backend_file.write('ANDROID_ASSETS_DIRS += %s\n' % p.full_path) + else: return obj.ack() diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index ab7a5c61dde..906f075e21c 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -699,6 +699,14 @@ VARIABLES = { file. """, 'export'), + 'ANDROID_ASSETS_DIRS': (ContextDerivedTypedListWithItems(Path, List), list, + """Android assets directories. + + This variable contains a list of directories containing static + files to package into an 'assets' directory and merge into an + APK file. + """, 'export'), + 'ANDROID_ECLIPSE_PROJECT_TARGETS': (dict, dict, """Defines Android Eclipse project targets. diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index 63150bffe43..c08c85233e5 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -975,3 +975,14 @@ class AndroidResDirs(ContextDerived): def __init__(self, context, paths): ContextDerived.__init__(self, context) self.paths = paths + +class AndroidAssetsDirs(ContextDerived): + """Represents Android assets directories.""" + + __slots__ = ( + 'paths', + ) + + def __init__(self, context, paths): + ContextDerived.__init__(self, context) + self.paths = paths diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index ddc0d28e783..f8ccf02ca20 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -24,6 +24,7 @@ import reftest import mozinfo from .data import ( + AndroidAssetsDirs, AndroidResDirs, BrandingFiles, ConfigFileSubstitution, @@ -700,14 +701,18 @@ class TreeMetadataEmitter(LoggingMixin): for name, data in context.get('ANDROID_ECLIPSE_PROJECT_TARGETS', {}).items(): yield ContextWrapped(context, data) - paths = context.get('ANDROID_RES_DIRS') - if paths: + for (symbol, cls) in [ + ('ANDROID_RES_DIRS', AndroidResDirs), + ('ANDROID_ASSETS_DIRS', AndroidAssetsDirs)]: + paths = context.get(symbol) + if not paths: + continue for p in paths: if isinstance(p, SourcePath) and not os.path.isdir(p.full_path): raise SandboxValidationError('Directory listed in ' - 'ANDROID_RES_DIRS is not a directory: \'%s\'' % - p.full_path, context) - yield AndroidResDirs(context, paths) + '%s is not a directory: \'%s\'' % + (symbol, p.full_path), context) + yield cls(context, paths) if passthru.variables: yield passthru diff --git a/toolkit/mozapps/installer/upload-files.mk b/toolkit/mozapps/installer/upload-files.mk index 34402f501aa..1804f9b0795 100644 --- a/toolkit/mozapps/installer/upload-files.mk +++ b/toolkit/mozapps/installer/upload-files.mk @@ -470,6 +470,7 @@ INNER_MAKE_PACKAGE = \ ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \ unzip -o $(_ABS_DIST)/gecko.ap_ && \ rm $(_ABS_DIST)/gecko.ap_ && \ + $(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ assets && \ $(ZIP) $(if $(ALREADY_SZIPPED),-0 ,$(if $(MOZ_ENABLE_SZIP),-0 ))$(_ABS_DIST)/gecko.ap_ $(ASSET_SO_LIBRARIES) && \ $(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) $(SZIP_LIBRARIES) && \ $(if $(filter-out ./,$(OMNIJAR_DIR)), \