Consider adding a Mach Package Command for different Android Apps
Categories
(Fenix :: Tooling, enhancement)
Tracking
(Not tracked)
People
(Reporter: olivia, Unassigned)
References
(Blocks 1 open bug)
Details
./mach package
likely needs to have a refresh based on this conversation.
Historically, ./mach package
+ ./mach android archive-geckoview
could be used to generate an AAR. See docs. The command sequence was likely most relevant when we required dependency substitution and also appears to have historically earlier ties to Fennec.
Monorepo now makes it possible to use ./mach package
and we could make Fenix, Reference Browser, Focus, or GeckoView example. APKs or other redistributables.
Not sure if the command should be ./mach package <variant>
or if this should be a mozconfig option. Likely should go the same direction bug 1883086 goes.
Reporter | ||
Comment 1•8 months ago
|
||
(Tentatively put it under monorepo-enhancements
to help with triage. Please move if out of scope.)
Reporter | ||
Comment 2•8 months ago
•
|
||
More context and some additional conversation about some decisions this bug needs as well:
:jonalmeida mentioned we need to decide if we use ./mach package <variant>
or a mozconfig file.
:zmckenney mentioned we need to decide exactly which redistributable (APK? AAB?) we should produce produce on this command.
if the (new) intent of mach package is to create the packaged application similar to desktop that might make sense to output as AAB and then the person can extract the APK from that for the test device. This means that you more closely represent a Google Play Store install
:nalexander mentioned:
Under the hood, the bit of
mach package
that matters ismake stage-package
, which producesomni.ja
. That’s invoked by hand in the Gradle integration; see https://searchfox.org/mozilla-central/rev/fe2743c6c5c708061c7f6504b26958fcc815bb4a/build.gradle#329-354.
Probably will also need to check:
- Multi-locale packaging for GV
- Large AARs
(Please mention if I misrepresented anything in the conversation.)
Comment 3•8 months ago
|
||
Some context from bug 1854571.
./mach package
internally uses makefile rule, and internally it defines PACKAGE
variable for the generated package file.
def package(command_context, verbose=False):
"""Package the built product for distribution."""
ret = command_context._run_make(
directory=".", target="package", silent=not verbose, ensure_exit_code=False
PACKAGE = $(PKG_PATH)$(PKG_BASENAME)$(PKG_SUFFIX)
PKG_SUFFIX
variable is set for each package format. On android (APK
format) however, it's not set, given the actual command to make the package does nothing (true
command there).
ifeq ($(MOZ_PKG_FORMAT),APK)
INNER_MAKE_PACKAGE = true
INNER_UNMAKE_PACKAGE = true
endif
ifeq ($(MOZ_PKG_FORMAT),DMG)
PKG_SUFFIX = .dmg
Bug 1854571's patch adds logging for the generated package's path, using the PACKAGE
variable.
The variable is written to obj-*/dist/package_name.txt
file during the make
command. The file is read by Python script's side, and if the file exists, the path is printed at the end of the command.
For android build, given the PKG_SUFFIX
is empty and the file doesn't exist, right now it doesn't print anything (if not os.path.exists(package_path):
below).
When modifying the the makefile rule to generate package file, please set appropriate PKG_SUFFIX
variable, so that the code added by the patch will become work also for android build.
https://phabricator.services.mozilla.com/D207204#inline-1146911
toolkit/mozapps/installer/packager.mk
make-package-internal: prepare-package make-sourcestamp-file
@echo 'Compressing...'
$(call MAKE_PACKAGE,$(DIST))
echo $(PACKAGE) > $(ABS_DIST)/package_name.txt
python/mozbuild/mozbuild/mach_commands.py
def _print_package_name(command_context):
dist_path = mozpath.join(command_context.topobjdir, "dist")
package_name_path = mozpath.join(dist_path, "package_name.txt")
if not os.path.exists(package_name_path):
return
with open(package_name_path, "r") as f:
package_name = f.read().strip()
package_path = mozpath.join(dist_path, package_name)
if not os.path.exists(package_path):
return
command_context.log(
logging.INFO, "package", {}, "Created package: {}".format(package_path)
)
Reporter | ||
Comment 4•6 months ago
|
||
Multi-locale packaging for GV
I recently filed bug 1899856 for unrelated reasons, but I think it might be applicable worth mentioning here for context too.
Description
•