| # Copyright 2015 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. |
| |
| # This exposes the Chrome version as GN variables for use in build files. |
| # This also generates the various version codes used for builds of chrome for |
| # android. |
| # |
| # PREFER NOT TO USE THESE. The GYP build uses this kind of thing extensively. |
| # However, it is far better to write an action (or use the process_version |
| # wrapper in build/util/version.gni) to generate a file at build-time with the |
| # information you need. This allows better dependency checking and GN will |
| # run faster. |
| # |
| # These values should only be used if you REALLY need to depend on them at |
| # build-time, for example, in the computation of output file names. |
| |
| # Give version.py a pattern that will expand to a GN scope consisting of |
| # all values we need at once. |
| _version_dictionary_template = "full = \"@MAJOR@.@MINOR@.@BUILD@.@PATCH@\" " + |
| "major = \"@MAJOR@\" minor = \"@MINOR@\" " + |
| "build = \"@BUILD@\" patch = \"@PATCH@\" " |
| |
| # The file containing the Chrome version number. |
| chrome_version_file = "//chrome/VERSION" |
| |
| _script_arguments = [] |
| |
| if (target_os == "mac") { |
| _version_dictionary_template += "patch_hi = @PATCH_HI@ patch_lo = @PATCH_LO@ " |
| |
| _script_arguments += [ |
| "-e", |
| "PATCH_HI=int(PATCH)//256", |
| "-e", |
| "PATCH_LO=int(PATCH)%256", |
| ] |
| } else if (target_os == "android") { |
| import("//build/config/android/config.gni") |
| |
| _version_dictionary_template += |
| "chrome_version_code = " + "\"@CHROME_VERSION_CODE@\" " + |
| "chrome_modern_version_code = \"@CHROME_MODERN_VERSION_CODE@\" " + |
| "monochrome_version_code = \"@MONOCHROME_VERSION_CODE@\" " + |
| "trichrome_version_code = \"@TRICHROME_VERSION_CODE@\" " + |
| "notouch_chrome_version_code = \"@NOTOUCH_CHROME_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 += |
| "monochrome_64_32_version_code = \"@MONOCHROME_64_32_VERSION_CODE@\" " + |
| "monochrome_64_version_code = \"@MONOCHROME_64_VERSION_CODE@\" " + |
| "trichrome_64_32_version_code = \"@TRICHROME_64_32_VERSION_CODE@\" " + |
| "trichrome_64_version_code = \"@TRICHROME_64_VERSION_CODE@\" " |
| } |
| |
| _script_arguments += [ |
| "-a", |
| target_cpu, |
| ] |
| |
| if (!public_android_sdk) { |
| _script_arguments += [ "--next" ] |
| } |
| } |
| |
| _script_arguments += [ |
| "-f", |
| rebase_path(chrome_version_file, root_build_dir), |
| "-t", |
| _version_dictionary_template, |
| "--os", |
| target_os, |
| ] |
| |
| _result = exec_script("version.py", |
| _script_arguments, |
| "scope", |
| [ chrome_version_file ]) |
| |
| # Full version. For example "45.0.12321.0" |
| chrome_version_full = _result.full |
| |
| # The consituent parts of the full version. |
| chrome_version_major = _result.major |
| chrome_version_minor = _result.minor |
| chrome_version_build = _result.build |
| chrome_version_patch = _result.patch |
| |
| if (target_os == "mac") { |
| chrome_version_patch_hi = _result.patch_hi |
| chrome_version_patch_lo = _result.patch_lo |
| |
| chrome_dylib_version = "$chrome_version_build.$chrome_version_patch_hi" + |
| ".$chrome_version_patch_lo" |
| } else if (target_os == "android") { |
| forward_variables_from(_result, |
| [ |
| "chrome_modern_version_code", |
| "chrome_version_code", |
| "monochrome_64_32_version_code", |
| "monochrome_64_version_code", |
| "monochrome_version_code", |
| "notouch_chrome_version_code", |
| "trichrome_64_32_version_code", |
| "trichrome_64_version_code", |
| "trichrome_version_code", |
| "webview_beta_version_code", |
| "webview_dev_version_code", |
| "webview_stable_version_code", |
| ]) |
| |
| chrome_version_name = chrome_version_full |
| |
| lines_to_write = [ |
| "VersionName: $chrome_version_name", |
| "Chrome: $chrome_version_code", |
| "ChromeModern: $chrome_modern_version_code", |
| "Monochrome: $monochrome_version_code", |
| "TrichromeChrome: $trichrome_version_code", |
| "MonochromeFP: $notouch_chrome_version_code", |
| "AndroidWebviewStable: $webview_stable_version_code", |
| "AndroidWebviewBeta: $webview_beta_version_code", |
| "AndroidWebviewDev: $webview_dev_version_code", |
| ] |
| |
| if (target_cpu == "arm64" || target_cpu == "x64") { |
| lines_to_write += [ |
| "Monochrome6432: $monochrome_64_32_version_code", |
| "Monochrome64: $monochrome_64_version_code", |
| "TrichromeChrome6432: $trichrome_64_32_version_code", |
| "TrichromeChrome64: $trichrome_64_version_code", |
| ] |
| } |
| |
| write_file("$root_out_dir/android_chrome_versions.txt", lines_to_write) |
| } |