Commit 5f3cbc9e authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

[Android WebAPK] Do not upload {{use_new_splash}} AndroidManifest.xml code to build bucket 6/X

https://chromium-review.googlesource.com/c/chromium/src/+/1253206 made WebApk.apk and
NewSplashWebApk.apk use the same AndroidManifest.xml template. In doing so, the CL
caused the NewSplashWebApk.apk-specific-code in AndroidManifest.xml to be uploaded to
the WebAPK server.

This CL changes the "webapk_tmpl" GN template to run pystache twice.
Pass #1 to generate AndroidManifest.xml to be uploaded to the WebAPK server. Fields
        which cannot be customized by the WebAPK server on a per-site basis are filled
        in.
Pass #2 fills in the remaining fields to generate AndroidManifest.xml for the test APK
        (WebApk.apk, NewSplahWebAPk.apk). These APKs are for local testing and are not
        uploaded to the WebAPK server.

BUG=817263

Change-Id: I3d4849d122195ba2e3d82bfb7bb5661dd765e3f7
Reviewed-on: https://chromium-review.googlesource.com/c/1279953
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602411}
parent f81c0531
......@@ -3,6 +3,18 @@
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!-- AndroidManifest.xml is generated in two mustache generation passes.
Pass #1 with square bracket delimiter to generate AndroidManifest.xml to
be uploaded to the WebAPK Minting Server. Fields which cannot be
customized by the WebAPK server on a per-site basis are filled in.
Pass #2 with curly bracket delimiter fills in the remaining fields. The
generated AndroidManifest.xml is for the test APK (WebApk.apk,
UnboundWebApk.apk ...). These APKs are for local testing and are
not uploaded to the WebAPK server.
-->
{{=[[ ]]=}}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="{{{manifest_package}}}"
......@@ -35,7 +47,7 @@
{{{raw_intent_filters}}}
</activity>
{{#use_new_splash}}
[[#use_new_splash]]
<activity android:name="org.chromium.webapk.shell_apk.h2o.SplashActivity"
android:theme="@style/SplashTheme"
android:enabled="false">
......@@ -52,8 +64,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
{{/use_new_splash}}
{{^use_new_splash}}
[[/use_new_splash]]
[[^use_new_splash]]
<activity android:name="org.chromium.webapk.shell_apk.MainActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:excludeFromRecents="true">
......@@ -62,7 +74,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
{{/use_new_splash}}
[[/use_new_splash]]
{{#share_template}}
<activity-alias android:name="org.chromium.webapk.shell_apk.ShareActivity{{{index}}}"
......@@ -97,7 +109,7 @@
{{/is_file_upload}}
</activity-alias>
{{/share_template}}
<meta-data android:name="org.chromium.webapk.shell_apk.shellApkVersion" android:value="{{{shell_apk_version}}}" />
<meta-data android:name="org.chromium.webapk.shell_apk.shellApkVersion" android:value="[[{shell_apk_version}]]" />
{{#bound_webapk}}
<meta-data android:name="org.chromium.webapk.shell_apk.runtimeHost" android:value="{{{runtime_host}}}" />
<meta-data android:name="org.chromium.webapk.shell_apk.runtimeHostApplicationName" android:value="{{{runtime_host_application_name}}}" />
......
......@@ -67,6 +67,9 @@ template("webapk_java") {
}
template("webapk_tmpl") {
_manifest_to_upload_target_name = "${target_name}_manifest_to_upload"
_manifest_to_upload_output =
"${target_gen_dir}/${_manifest_to_upload_target_name}/AndroidManifest.xml"
_manifest_target_name = "${target_name}_generate_manifest"
_manifest_output =
"${target_gen_dir}/${_manifest_target_name}/AndroidManifest.xml"
......@@ -78,18 +81,28 @@ template("webapk_tmpl") {
_use_new_splash = invoker.use_new_splash
}
manifest_processor_template(_manifest_target_name) {
forward_variables_from(invoker, [ "config_file" ])
# Generate manifest to upload to WebAPK server. Fills in all of the fields
# that the server cannot customize on a per-site basis.
manifest_processor_template(_manifest_to_upload_target_name) {
input = "AndroidManifest.xml"
output = _manifest_output
output = _manifest_to_upload_output
extra_variables = [
"shell_apk_version=$current_shell_apk_version",
"use_new_splash=$_use_new_splash",
]
}
# Generate manifest with test values.
manifest_processor_template(_manifest_target_name) {
forward_variables_from(invoker, [ "config_file" ])
input = _manifest_to_upload_output
output = _manifest_output
deps = [
":$_manifest_to_upload_target_name",
]
}
android_resources(_resources_target_name) {
custom_package = "org.chromium.webapk.shell_apk"
resource_dirs = [ "res" ]
......
......@@ -12,4 +12,4 @@
# //chrome/android/webapk/shell_apk:webapk is changed. This includes
# Java files, Android resource files and AndroidManifest.xml. Does not affect
# Chrome.apk
current_shell_apk_version = 67
current_shell_apk_version = 68
......@@ -18,9 +18,11 @@ template("manifest_processor_template") {
"deps",
])
sources = [
invoker.config_file,
invoker.input,
]
if (defined(invoker.config_file)) {
sources += [ invoker.config_file ]
}
script = "//chrome/android/webapk/shell_apk/manifest_processor.py"
outputs = [
......@@ -30,11 +32,15 @@ template("manifest_processor_template") {
args = [
"--template",
rebase_path(invoker.input, root_build_dir),
"--config_file",
rebase_path(invoker.config_file, root_build_dir),
"--output",
rebase_path(invoker.output, root_build_dir),
]
if (defined(invoker.config_file)) {
args += [
"--config_file",
rebase_path(invoker.config_file, root_build_dir),
]
}
if (defined(invoker.extra_variables)) {
extra_variables = invoker.extra_variables
args += [ "--extra_variables=${extra_variables}" ]
......
......@@ -36,10 +36,10 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('--template', required=True,
help='The template file to process.')
parser.add_argument('--config_file', required=True,
help='JSON file with values to put into template.')
parser.add_argument('--output', required=True,
help='The output file to generate.')
parser.add_argument('--config_file',
help='JSON file with values to put into template.')
parser.add_argument('--extra_variables', help='Variables to be made '
'available in the template processing environment (in '
'addition to those specified in config file), as a GN '
......@@ -48,8 +48,9 @@ def main():
options = parser.parse_args()
variables = {}
with open(options.config_file, 'r') as f:
variables = json.loads(f.read())
if options.config_file:
with open(options.config_file, 'r') as f:
variables = json.loads(f.read())
variables = _AppendParsedVariables(variables, options.extra_variables,
parser.error)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment