chromium 版本号定义在 src\chrome\VERSION
中。单纯的修改这里的版本号,一般是不能顺利编译通过的。比如68.0.3440.105要修改为主版本号大于 10的,比如:10.0.0.1,才能编译通过。
一般自己发布新版,都是从0.x.x.x或者1.x.x.x开始的。这就需要修改chromium的兼容说明文件。
chromium 为了版本兼容性,单独定义了一直json格式的版本支持说明文件。
src\components\policy\resources\policy_templates.json
大致格式如下
# Currently supported product names:
# 'chrome_frame', 'chrome_os', 'android', 'webview_android',
# 'chrome.win', 'chrome.linux', 'chrome.mac', 'chrome.*'
# For example if 'chrome.*:5-10' is specified for a policy, then it should
# be read as:
# 'chrome.linux:5-10', 'chrome.mac:5-10', 'chrome.win:5-10'
#
# The product name also affects in which templates the policy is included:
# chrome.*, chrome.win, chrome_frame -> ADM, ADMX, ADML, doc
# chrome.*, chrome.linux -> JSON, doc
# chrome.*, chrome.mac -> plist, plist_strings, doc
# everything else -> doc
#
# The default list of policies supported by Chrome is also generated based
# on the product names:
# chrome.* -> Chrome policy definition list
# chrome_os -> Chrome policy definition list, when building OS_CHROMEOS
#
比如编译windows版本,需要修改chrome.*
和chrome.win
对应的版本值
比如:68.0.3440.105版本。要把版本号修改位1.0.0.1。
就需要把policy_templates.json文件中所有chrome.*
和chrome.win
相关的值修改为:
A: 关闭类型的,位版本号小于编译代码的版本号,不需要处理,如下:65 < 68,所以不需要修改
'supported_on': ['chrome.*:58-65', 'chrome_os:58-65', 'android:58-65'],
B:起始版本号大约编译版本号的,不需要修改,如下: 69 > 68,不需要修改。
'supported_on': ['chrome.*:69-', 'chrome_os:69-'],
C:只有起始版本号,没有结束版本号的,且起始版本号小于编译版本号。如下:54 < 68。需要修改为1-
或者0-
.
'supported_on': ['chrome.*:1-', 'chrome_os:54-', 'android:54-'],
记得同时需要修改chrome.*
和chrome.win
对应的版本号兼容值。
[528/32355] ACTION //chrome/browser/metrics:expired_histograms_array(//build/toolchain/win:win_clang_x86)
FAILED: gen/chrome/browser/metrics/expired_histograms_array.h
D:/git/chromium/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe ../../tools/metrics/histograms/generate_expired_histograms_array.py -nchrome_metrics -ogen -Hchrome/browser/metrics/expired_histograms_array.h -d../../chrome/MAJOR_BRANCH_DATE -mD:/git/chromium/src/chrome/VERSION ../../tools/metrics/histograms/histograms.xml ../../tools/metrics/histograms/enums.xml
Traceback (most recent call last):
File "../../tools/metrics/histograms/generate_expired_histograms_array.py", line 262, in
sys.exit(main())
File "../../tools/metrics/histograms/generate_expired_histograms_array.py", line 258, in main
_GenerateFile(arguments)
File "../../tools/metrics/histograms/generate_expired_histograms_array.py", line 206, in _GenerateFile
current_milestone = _GetCurrentMilestone(file_content, _CURRENT_MILESTONE_RE)
File "../../tools/metrics/histograms/generate_expired_histograms_array.py", line 136, in _GetCurrentMilestone
return int(_FindMatch(content, regex, 1))
File "../../tools/metrics/histograms/generate_expired_histograms_array.py", line 93, in _FindMatch
format(pattern=regex.pattern, content=content))
__main__.Error: Unable to match MAJOR=([0-9]{2,3})\n with provided content: MAJOR=1
MINOR=0
BUILD=0
PATCH=7
需要修改匹配位置:
src\tools\metrics\histograms\generate_expired_histograms_array.py
_CURRENT_MILESTONE_RE = re.compile(r"MAJOR=([0-9]{2,3})\n")
_MILESTONE_EXPIRY_RE = re.compile(r"\AM([0-9]{2,3})")
改为:
_CURRENT_MILESTONE_RE = re.compile(r"MAJOR=([0-9]{1,3})\n")
_MILESTONE_EXPIRY_RE = re.compile(r"\AM([0-9]{1,3})")
修改号版本号,重新编译大约需要编译近2000个文件。
ninja -C out\Release chrome
ninja: Entering directory `out\Release'
[1/1] Regenerating ninja files
[1998/1998] STAMP obj/chrome/chrome.stamp
提示 gen\chrome\browser\unexpire_flags_gen.h
中的 base::Feature kUnexpireFlagsM-1
类似的错误。只需修改
src\tools\flags\generate_unexpire_flags.py
# 修改版本号后,主版本号为1时,会引入错误gen\chrome\browser\unexpire_flags_gen.h定义错误
if(mstone == 1):
mstone = 2
# 在下面这句话前面加入适当处理即可,比如当mstone=1时,令其为2
update_file_if_stale(sys.argv[1], gen_features_impl(progname, mstone - 1))