Skip to content

Commit

Permalink
Add upstream support for webview channels
Browse files Browse the repository at this point in the history
To enable downstream official build scripts to build channels for
standalone webview, upstream version code logic needs to generate
unique version codes for each channel.

Change-Id: Ic53d4c529416ded7bf32498c527d623f17b2f478
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1547757
Commit-Queue: Drew Stonebraker <stonebraker@chromium.org>
Reviewed-by: Tao Bai <michaelbai@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646941}
  • Loading branch information
Drew Stonebraker authored and Commit Bot committed Apr 2, 2019
1 parent e1a8ea6 commit 909e908
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 13 deletions.
6 changes: 5 additions & 1 deletion android_webview/system_webview_apk_tmpl.gni
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ template("system_webview_apk_tmpl") {
if (!defined(version_code)) {
if (_use_trichrome_library) {
version_code = trichrome_version_code
} else if (android_channel == "dev") {
version_code = webview_dev_version_code
} else if (android_channel == "beta") {
version_code = webview_beta_version_code
} else {
version_code = webview_version_code
version_code = webview_stable_version_code
}
}
if (!defined(version_name)) {
Expand Down
22 changes: 21 additions & 1 deletion build/util/android_chrome_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,34 @@
and will push the supported app with the highest version code to devices.
(note Play Store does not support hosting two different apps with same
version code and package name)
Each key in this dict represents a unique version code that will be used for
one or more android chrome apks.
Webview channels must have unique version codes for a couple reasons:
a) Play Store does not support having the same version code for different
versions of a package. Without unique codes, promoting a beta apk to stable
would require first removing the beta version.
b) Firebase project support (used by official builders) requires unique
[version code + package name].
We cannot add new webview package names for new channels because webview
packages are whitelisted by Android as webview providers.
WEBVIEW_STABLE, WEBVIEW_BETA, WEBVIEW_DEV are all used for standalone webview,
whereas the others are used for various chrome apks.
Note that a final digit of '3' for webview is reserved for Trichrome Webview.
The same versionCode is used for both Trichrome Chrome and Trichrome Webview.
"""
ANDROID_CHROME_APK_VERSION_CODE_DIFFS = {
'CHROME': 0,
'CHROME_MODERN': 1,
'MONOCHROME': 2,
'TRICHROME': 3,
'NOTOUCH_CHROME': 4,
'WEBVIEW': 0
'WEBVIEW_STABLE': 0,
'WEBVIEW_BETA': 1,
'WEBVIEW_DEV': 2,
}

"""The architecture preference is encoded into the version_code for devices
Expand Down
30 changes: 24 additions & 6 deletions build/util/android_chrome_version_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def testGenerateVersionCodesAndroidTrichrome(self):

self.assertEqual(trichrome_version_code, '372000003')


def testGenerateVersionCodesAndroidNoTouch(self):
"""Assert it gives correct values for standard/example inputs"""
output = GenerateVersionCodes(
Expand All @@ -64,15 +63,32 @@ def testGenerateVersionCodesAndroidNoTouch(self):

self.assertEqual(notouch_chrome_version_code, '372000004')

def testGenerateVersionCodesAndroidWebviewStable(self):
"""Assert it gives correct values for standard/example inputs"""
output = GenerateVersionCodes(
self.EXAMPLE_VERSION_VALUES, arch='arm', is_next_build=False)

webview_stable_version_code = output['WEBVIEW_STABLE_VERSION_CODE']

self.assertEqual(webview_stable_version_code, '372000000')

def testGenerateVersionCodesAndroidWebviewBeta(self):
"""Assert it gives correct values for standard/example inputs"""
output = GenerateVersionCodes(
self.EXAMPLE_VERSION_VALUES, arch='arm', is_next_build=False)

webview_beta_version_code = output['WEBVIEW_BETA_VERSION_CODE']

self.assertEqual(webview_beta_version_code, '372000001')

def testGenerateVersionCodesAndroidWebview(self):
def testGenerateVersionCodesAndroidWebviewDev(self):
"""Assert it gives correct values for standard/example inputs"""
output = GenerateVersionCodes(
self.EXAMPLE_VERSION_VALUES, arch='arm', is_next_build=False)

webview_version_code = output['WEBVIEW_VERSION_CODE']
webview_dev_version_code = output['WEBVIEW_DEV_VERSION_CODE']

self.assertEqual(webview_version_code, '372000000')
self.assertEqual(webview_dev_version_code, '372000002')

def testGenerateVersionCodesAndroidNextBuild(self):
"""Assert it handles "next" builds correctly"""
Expand All @@ -82,11 +98,13 @@ def testGenerateVersionCodesAndroidNextBuild(self):
# Get just a sample of values
chrome_version_code = output['CHROME_VERSION_CODE']
monochrome_version_code = output['MONOCHROME_VERSION_CODE']
webview_version_code = output['WEBVIEW_VERSION_CODE']
webview_stable_version_code = output['WEBVIEW_STABLE_VERSION_CODE']
webview_beta_version_code = output['WEBVIEW_BETA_VERSION_CODE']

self.assertEqual(chrome_version_code, '372100005')
self.assertEqual(monochrome_version_code, '372100007')
self.assertEqual(webview_version_code, '372100005')
self.assertEqual(webview_stable_version_code, '372100005')
self.assertEqual(webview_beta_version_code, '372100006')

def testGenerateVersionCodesAndroidArchArm(self):
"""Assert it handles different architectures correctly.
Expand Down
12 changes: 9 additions & 3 deletions build/util/version.gni
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ if (target_os == "mac") {
"monochrome_version_code = \"@MONOCHROME_VERSION_CODE@\" " +
"trichrome_version_code = \"@TRICHROME_VERSION_CODE@\" " +
"notouch_chrome_version_code = \"@NOTOUCH_CHROME_VERSION_CODE@\" " +
"webview_version_code = \"@WEBVIEW_VERSION_CODE@\" "
"webview_stable_version_code = \"@WEBVIEW_STABLE_VERSION_CODE@\" " +
"webview_beta_version_code = \"@WEBVIEW_BETA_VERSION_CODE@\" " +
"webview_dev_version_code = \"@WEBVIEW_DEV_VERSION_CODE@\" "

if (target_cpu == "arm64" || target_cpu == "x64") {
_version_dictionary_template +=
Expand Down Expand Up @@ -99,7 +101,9 @@ if (target_os == "mac") {
"monochrome_version_code",
"trichrome_version_code",
"notouch_chrome_version_code",
"webview_version_code",
"webview_stable_version_code",
"webview_beta_version_code",
"webview_dev_version_code",
"monochrome_64_32_version_code",
"monochrome_64_version_code",
])
Expand All @@ -113,7 +117,9 @@ if (target_os == "mac") {
"Monochrome=$monochrome_version_code",
"TrichromeChrome=$trichrome_version_code",
"NoTouchChrome=$notouch_chrome_version_code",
"Webview=$webview_version_code",
"WebviewStable=$webview_stable_version_code",
"WebviewBeta=$webview_beta_version_code",
"WebviewDev=$webview_dev_version_code",
]

if (target_cpu == "arm64" || target_cpu == "x64") {
Expand Down
9 changes: 7 additions & 2 deletions build/util/version_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class _VersionTest(unittest.TestCase):
'chrome_modern_version_code',
'monochrome_version_code',
'trichrome_version_code',
'webview_version_code',
'webview_stable_version_code',
'webview_beta_version_code',
'webview_dev_version_code',
]

_EXAMPLE_ANDROID_TEMPLATE = (
Expand Down Expand Up @@ -108,7 +110,10 @@ def testBuildOutputAndroid(self):
r'\bchrome_modern_version_code = "\d+"\s')
self.assertRegexpMatches(contents, r'\bmonochrome_version_code = "\d+"\s')
self.assertRegexpMatches(contents, r'\btrichrome_version_code = "\d+"\s')
self.assertRegexpMatches(contents, r'\bwebview_version_code = "\d+"\s')
self.assertRegexpMatches(contents,
r'\bwebview_stable_version_code = "\d+"\s')
self.assertRegexpMatches(contents, r'\bwebview_beta_version_code = "\d+"\s')
self.assertRegexpMatches(contents, r'\bwebview_dev_version_code = "\d+"\s')

def testBuildOutputAndroidArchVariantsArm64(self):
"""Assert 64-bit-specific version codes"""
Expand Down

0 comments on commit 909e908

Please sign in to comment.