chromium/remoting/remoting_version.gni

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/chrome_build.gni")
import("//chrome/version.gni")

remoting_version_file = "//remoting/VERSION"

_version_py_abspath = "//build/util/version.py"
if (is_chrome_branded) {
  _remoting_branding_abspath = "//remoting/branding_Chrome"
} else {
  _remoting_branding_abspath = "//remoting/branding_Chromium"
}

# Set these files as being input dependencies to the scripts, so the build will
# be re-run if the files change.
remoting_version_files = [
  remoting_version_file,
  _remoting_branding_abspath,
]

_remoting_version_path = rebase_path(remoting_version_file, root_build_dir)
_remoting_branding_path =
    rebase_path(_remoting_branding_abspath, root_build_dir)

_template =
    "mac_native_messaging_bundle = \"@MAC_NATIVE_MESSAGING_HOST_BUNDLE_NAME@\" "
_template += "mac_remote_assistance_bundle = \"@MAC_REMOTE_ASSISTANCE_HOST_BUNDLE_NAME@\" "
_template += "host_bundle_name = \"@MAC_HOST_BUNDLE_NAME@\" "
_template += "host_legacy_bundle_name = \"@MAC_HOST_LEGACY_BUNDLE_NAME@\" "
_template += "host_name= \"@MAC_HOST_PACKAGE_NAME@\" "
_template += "host_service_name = \"@DAEMON_FILE_NAME@\" "
_template += "bundle_prefix = \"@MAC_UNINSTALLER_BUNDLE_PREFIX@\" "
_template += "host_uninstaller_name = \"@MAC_UNINSTALLER_NAME@\" "
_template += "version_patch = \"@REMOTING_PATCH@\" "

if (is_mac) {
  _template += "host_bundle_id = \"@MAC_HOST_BUNDLE_ID@\" "
  _template += "native_messaging_host_bundle_id = \"@MAC_NATIVE_MESSAGING_HOST_BUNDLE_ID@\""
  _template += "remote_assistance_host_bundle_id = \"@MAC_REMOTE_ASSISTANCE_HOST_BUNDLE_ID@\" "
  _template += "uninstaller_bundle_id = \"@MAC_UNINSTALLER_BUNDLE_ID@\""
}

if (is_ios) {
  _template += "ios_bundle_id = \"@IOS_BUNDLE_ID@\""
  _template += "ios_display_name = \"@IOS_DISPLAY_NAME@\""
  _template += "ios_exec_name = \"@IOS_EXEC_NAME@\""
  _template += "ios_product_name = \"@IOS_PRODUCT_NAME@\""
}

_result = exec_script(_version_py_abspath,
                      [
                        "-f",
                        _remoting_branding_path,
                        "-f",
                        _remoting_version_path,
                        "-t",
                        _template,
                      ],
                      "scope",
                      remoting_version_files)

host_name = _result.host_name
host_service_name = _result.host_service_name
bundle_prefix = _result.bundle_prefix
host_uninstaller_name = _result.host_uninstaller_name
me2me_host_bundle_name = _result.host_bundle_name
me2me_host_legacy_bundle_name = _result.host_legacy_bundle_name
native_messaging_host_bundle_name = _result.mac_native_messaging_bundle
remote_assistance_host_bundle_name = _result.mac_remote_assistance_bundle
remoting_version_patch = _result.version_patch
remoting_version_short =
    "$chrome_version_major.$remoting_version_patch.$chrome_version_build"
remoting_version_full = "$remoting_version_short.$chrome_version_patch"

if (is_mac) {
  host_bundle_id = _result.host_bundle_id
  native_messaging_host_bundle_id = _result.native_messaging_host_bundle_id
  remote_assistance_host_bundle_id = _result.remote_assistance_host_bundle_id
  uninstaller_bundle_id = _result.uninstaller_bundle_id

  host_name_nospace = exec_script("//remoting/tools/remove_spaces.py",
                                  [ "$host_name" ],
                                  "trim string")
  host_service_name_nospace = exec_script("//remoting/tools/remove_spaces.py",
                                          [ "$host_service_name" ],
                                          "trim string")
  host_uninstaller_name_nospace =
      exec_script("//remoting/tools/remove_spaces.py",
                  [ "$host_uninstaller_name" ],
                  "trim string")
}

if (is_ios) {
  remoting_ios_bundle_id = _result.ios_bundle_id
  remoting_ios_display_name = _result.ios_display_name
  remoting_ios_executable_name = _result.ios_exec_name
  remoting_ios_product_name = _result.ios_product_name
}