Commit 8cc90522 authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Remove old-style version

All ChromeDriver builds will be using Chrome version numbers, instead of
having its own version.

Bug: chromedriver:2080
Change-Id: I845289296c21329ba5e6e8d2adc44eb234981bd8
Reviewed-on: https://chromium-review.googlesource.com/c/1459921Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Commit-Queue: John Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630211}
parent 72c44a02
...@@ -205,33 +205,6 @@ source_set("automation_client_lib") { ...@@ -205,33 +205,6 @@ source_set("automation_client_lib") {
] ]
} }
action("embed_version_in_cpp") {
script = "embed_version_in_cpp.py"
inputs = [
"cpp_source.py",
"VERSION",
"//chrome/VERSION",
# We don't actually use LASTCHANGE as an input file. It is updated
# whenever a different Git revision is checked out, at which point
# version.cc needs to be updated with the new revision info.
lastchange_file,
]
outputs = [
"$target_gen_dir/version.cc",
"$target_gen_dir/version.h",
]
args = [
"--chromedriver-version-file",
rebase_path("VERSION", root_build_dir),
"--chrome-version-file",
rebase_path("//chrome/VERSION", root_build_dir),
"--directory",
rebase_path(target_gen_dir, root_build_dir),
]
}
source_set("lib") { source_set("lib") {
sources = [ sources = [
"//third_party/webdriver/atoms.cc", "//third_party/webdriver/atoms.cc",
...@@ -278,6 +251,8 @@ source_set("lib") { ...@@ -278,6 +251,8 @@ source_set("lib") {
"session_thread_map.h", "session_thread_map.h",
"util.cc", "util.cc",
"util.h", "util.h",
"version.cc",
"version.h",
"window_commands.cc", "window_commands.cc",
"window_commands.h", "window_commands.h",
] ]
...@@ -285,9 +260,6 @@ source_set("lib") { ...@@ -285,9 +260,6 @@ source_set("lib") {
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations. # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
configs += [ "//build/config/compiler:no_size_t_to_int_warning" ] configs += [ "//build/config/compiler:no_size_t_to_int_warning" ]
# Also compile the generated version files.
sources += get_target_outputs(":embed_version_in_cpp")
if (use_x11) { if (use_x11) {
sources += [ "keycode_text_conversion_x.cc" ] sources += [ "keycode_text_conversion_x.cc" ]
} }
...@@ -299,11 +271,11 @@ source_set("lib") { ...@@ -299,11 +271,11 @@ source_set("lib") {
deps = [ deps = [
":automation_client_lib", ":automation_client_lib",
":embed_version_in_cpp",
"//base", "//base",
"//base/third_party/dynamic_annotations", "//base/third_party/dynamic_annotations",
"//chrome/common:constants", "//chrome/common:constants",
"//chrome/common:version_header", "//chrome/common:version_header",
"//components/version_info:generate_version_info",
"//crypto", "//crypto",
"//net", "//net",
"//net/server:http_server", "//net/server:http_server",
......
#!/usr/bin/env python
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Embeds version string in C++ code for ChromeDriver."""
import optparse
import os
import re
import sys
import chrome_paths
import cpp_source
sys.path.insert(0, os.path.join(chrome_paths.GetSrc(), 'build', 'util'))
import lastchange
def get_release_version(chrome_version_file, version_info):
"""Return version string appropriate for a release branch.
Args:
chrome_version_file: name of Chrome's version file, e.g., chrome/VERSION.
version_info: VersionInfo object returned from lastchange.FetchVersionInfo.
"""
# Parse Chrome version file, which should have four lines of key=value,
# giving the major, minor, build, and patch number.
version = {}
for line in open(chrome_version_file, 'r').readlines():
key, val = line.rstrip('\r\n').split('=', 1)
version[key] = val
if version_info is not None:
# Release branch revision has the format
# '26c10db8bff36a8b6fc073c0f38b1e9493cabb04-refs/branch-heads/3515@{#5}'.
match = re.match('[0-9a-fA-F]+-refs/branch-heads/\d+@{#\d+}',
version_info.revision)
if not match:
# revision is not the expected format, probably not in a release branch.
return None
# Result is based on Chrome version number, e.g.,
# '70.0.3516.0 (26c10db8bff36a8b6fc073c0f38b1e9493cabb04)'.
return '%s.%s.%s.%s (%s)' % (
version['MAJOR'], version['MINOR'], version['BUILD'], version['PATCH'],
version_info.revision_id)
else:
# No version_info from Git. Assume we are in a release branch if Chrome
# patch number is not 0.
if version['PATCH'] == '0':
return None
return '%s.%s.%s.%s' % (
version['MAJOR'], version['MINOR'], version['BUILD'], version['PATCH'])
def get_master_version(chromedriver_version, version_info):
"""Return version string appropriate for the master branch.
Args:
chromedriver_version: ChromeDriver version, e.g., '2.41'.
version_info: VersionInfo object returned from lastchange.FetchVersionInfo.
"""
if version_info is None:
return None
# Master branch revision has the format
# 'cc009559c91323445dec7e2f545298bf10726eaf-refs/heads/master@{#581331}'.
# We need to grab the commit position (e.g., '581331') near the end.
match = re.match('[0-9a-fA-F]+-refs/heads/master@{#(\d+)}',
version_info.revision)
if not match:
# revision is not the expected format, probably not in the master branch.
return None
# result is based on legacy style ChromeDriver version number, e.g.,
# '2.41.581331 (cc009559c91323445dec7e2f545298bf10726eaf)'.
commit_position = match.group(1)
return '%s.%s (%s)' % (
chromedriver_version, commit_position, version_info.revision_id)
def main():
parser = optparse.OptionParser()
parser.add_option('', '--chromedriver-version-file')
parser.add_option('', '--chrome-version-file')
parser.add_option(
'', '--directory', type='string', default='.',
help='Path to directory where the cc/h file should be created')
options, _ = parser.parse_args()
chromedriver_version = open(
options.chromedriver_version_file, 'r').read().strip()
# Get a VersionInfo object corresponding to the Git commit we are at,
# using the same filter used by main function of build/util/lastchange.py.
# On success, version_info.revision_id is a 40-digit Git hash,
# and version_info.revision is a longer string with more information.
# On failure, version_info is None.
version_info = lastchange.FetchGitRevision(None, '^Change-Id:')
version = get_release_version(options.chrome_version_file, version_info)
if version is None:
version = get_master_version(chromedriver_version, version_info)
if version is None:
if version_info is not None:
# Not in a known branch, but has Git revision.
version = '%s (%s)' % (chromedriver_version, version_info.revision_id)
else:
# Git command failed. Just use ChromeDriver version string.
version = chromedriver_version
global_string_map = {
'kChromeDriverVersion': version
}
cpp_source.WriteSource('version',
'chrome/test/chromedriver',
options.directory, global_string_map)
if __name__ == '__main__':
sys.exit(main())
...@@ -130,12 +130,6 @@ def _UpdateTestResultsLog(platform, commit_position, passed): ...@@ -130,12 +130,6 @@ def _UpdateTestResultsLog(platform, commit_position, passed):
_PutTestResultsLog(platform, log) _PutTestResultsLog(platform, log)
def _GetVersion():
"""Get the current chromedriver version."""
with open(os.path.join(_THIS_DIR, 'VERSION'), 'r') as f:
return f.read().strip()
def _GetSupportedChromeVersions(): def _GetSupportedChromeVersions():
"""Get the minimum and maximum supported Chrome versions. """Get the minimum and maximum supported Chrome versions.
...@@ -165,8 +159,8 @@ def _ArchiveGoodBuild(platform, commit_position): ...@@ -165,8 +159,8 @@ def _ArchiveGoodBuild(platform, commit_position):
zip_path = util.Zip(os.path.join(chrome_paths.GetBuildDir([server_name]), zip_path = util.Zip(os.path.join(chrome_paths.GetBuildDir([server_name]),
server_name)) server_name))
build_name = 'chromedriver_%s_%s.%s.zip' % ( build_name = 'chromedriver_%s_%s.zip' % (
platform, _GetVersion(), commit_position) platform, commit_position)
build_url = '%s/%s' % (GS_CONTINUOUS_URL, build_name) build_url = '%s/%s' % (GS_CONTINUOUS_URL, build_name)
if slave_utils.GSUtilCopy(zip_path, build_url): if slave_utils.GSUtilCopy(zip_path, build_url):
util.MarkBuildStepError() util.MarkBuildStepError()
...@@ -174,8 +168,8 @@ def _ArchiveGoodBuild(platform, commit_position): ...@@ -174,8 +168,8 @@ def _ArchiveGoodBuild(platform, commit_position):
if util.IsWindows(): if util.IsWindows():
zip_path = util.Zip(os.path.join( zip_path = util.Zip(os.path.join(
chrome_paths.GetBuildDir([server_name + '.pdb']), server_name + '.pdb')) chrome_paths.GetBuildDir([server_name + '.pdb']), server_name + '.pdb'))
pdb_name = 'chromedriver_%s_pdb_%s.%s.zip' % ( pdb_name = 'chromedriver_%s_pdb_%s.zip' % (
platform, _GetVersion(), commit_position) platform, commit_position)
pdb_url = '%s/%s' % (GS_CONTINUOUS_URL, pdb_name) pdb_url = '%s/%s' % (GS_CONTINUOUS_URL, pdb_name)
if slave_utils.GSUtilCopy(zip_path, pdb_url): if slave_utils.GSUtilCopy(zip_path, pdb_url):
util.MarkBuildStepError() util.MarkBuildStepError()
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/test/chromedriver/version.h"
#include "components/version_info/version_info_values.h"
const char kChromeDriverVersion[] = PRODUCT_VERSION " (" LAST_CHANGE ")";
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_TEST_CHROMEDRIVER_VERSION_H_
#define CHROME_TEST_CHROMEDRIVER_VERSION_H_
extern const char kChromeDriverVersion[];
#endif // CHROME_TEST_CHROMEDRIVER_VERSION_H_
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