#!/usr/bin/env python3
# Copyright (C) 2021 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# DO NOT EDIT. Auto-generated by tools/gen_amalgamated_python_tools
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# This file should do the same thing when being invoked in any of these ways:
# ./traceconv
# python traceconv
# bash traceconv
# cat ./traceconv | bash
# cat ./traceconv | python -

BASH_FALLBACK=""" "
exec python3 - "$@" <<'#'EOF
#"""  # yapf: disable


# ----- Amalgamator: begin of python/perfetto/prebuilts/manifests/traceconv.py
# This file has been generated by: tools/roll-prebuilts v45.0
TRACECONV_MANIFEST = [{
    'arch':
        'mac-amd64',
    'file_name':
        'traceconv',
    'file_size':
        8299680,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/mac-amd64/traceconv',
    'sha256':
        '80291c46aea5bf3b1007a385fc6442a99865bfdd70ea627b3e9a2e19d6d62de1',
    'platform':
        'darwin',
    'machine': ['x86_64']
}, {
    'arch':
        'mac-arm64',
    'file_name':
        'traceconv',
    'file_size':
        7761304,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/mac-arm64/traceconv',
    'sha256':
        '53b78c7f9ee26a766b2d8f28e8033367f697d669b133383dfb116fd44f7ffa8a',
    'platform':
        'darwin',
    'machine': ['arm64']
}, {
    'arch':
        'linux-amd64',
    'file_name':
        'traceconv',
    'file_size':
        8353608,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/linux-amd64/traceconv',
    'sha256':
        '57e1cf04dc25fa6a6f7ae3482158f2dfb363269baeab1673343974312551a753',
    'platform':
        'linux',
    'machine': ['x86_64']
}, {
    'arch':
        'linux-arm',
    'file_name':
        'traceconv',
    'file_size':
        6317844,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/linux-arm/traceconv',
    'sha256':
        'e361944a78b55b83bc072043dd983b8f5debcf5a875b79accfcb02d864f97a85',
    'platform':
        'linux',
    'machine': ['armv6l', 'armv7l', 'armv8l']
}, {
    'arch':
        'linux-arm64',
    'file_name':
        'traceconv',
    'file_size':
        8061520,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/linux-arm64/traceconv',
    'sha256':
        '80e8842b22e9c92b4d44f0e16d6b65b0d013d7c769e853961a0f222287898850',
    'platform':
        'linux',
    'machine': ['aarch64']
}, {
    'arch':
        'android-arm',
    'file_name':
        'traceconv',
    'file_size':
        6320968,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/android-arm/traceconv',
    'sha256':
        '4d17f00e48f256cc9a725db1e4ba7eddd1fc4ab96e7e67cade07338ac74eab88'
}, {
    'arch':
        'android-arm64',
    'file_name':
        'traceconv',
    'file_size':
        7998792,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/android-arm64/traceconv',
    'sha256':
        '230e91c8bfa59094d69b0dad0fb3328b9c2134a3d34653d6d4fa2a05ed2db4b2'
}, {
    'arch':
        'android-x86',
    'file_name':
        'traceconv',
    'file_size':
        8670248,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/android-x86/traceconv',
    'sha256':
        'e59e7a34fd0af9cd0db84ae104bdb79cbf7efb5d71ab11f3b31f6045c1621c5b'
}, {
    'arch':
        'android-x64',
    'file_name':
        'traceconv',
    'file_size':
        8229048,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/android-x64/traceconv',
    'sha256':
        '277eab28583824c02159b4b0611d4cb4480305da477f607a90b161c834a21e6b'
}, {
    'arch':
        'windows-amd64',
    'file_name':
        'traceconv.exe',
    'file_size':
        8119296,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v45.0/windows-amd64/traceconv.exe',
    'sha256':
        '3fffac0a1d3bea94924e219a8390c96aef729cd0dfa9f216a2c20eb56ece9e86',
    'platform':
        'win32',
    'machine': ['amd64']
}]

# ----- Amalgamator: end of python/perfetto/prebuilts/manifests/traceconv.py

# ----- Amalgamator: begin of python/perfetto/prebuilts/perfetto_prebuilts.py
# Copyright (C) 2021 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Functions to fetch pre-pinned Perfetto prebuilts.

This function is used in different places:
- Into the //tools/{trace_processor, traceconv} scripts, which are just plain
  wrappers around executables.
- Into the //tools/{heap_profiler, record_android_trace} scripts, which contain
  some other hand-written python code.

The manifest argument looks as follows:
TRACECONV_MANIFEST = [
  {
    'arch': 'mac-amd64',
    'file_name': 'traceconv',
    'file_size': 7087080,
    'url': https://commondatastorage.googleapis.com/.../trace_to_text',
    'sha256': 7d957c005b0dc130f5bd855d6cec27e060d38841b320d04840afc569f9087490',
    'platform': 'darwin',
    'machine': 'x86_64'
  },
  ...
]

The intended usage is:

  from perfetto.prebuilts.manifests.traceconv import TRACECONV_MANIFEST
  bin_path = get_perfetto_prebuilt(TRACECONV_MANIFEST)
  subprocess.call(bin_path, ...)
"""

import hashlib
import os
import platform
import random
import subprocess
import sys


def download_or_get_cached(file_name, url, sha256):
  """ Downloads a prebuilt or returns a cached version

  The first time this is invoked, it downloads the |url| and caches it into
  ~/.local/share/perfetto/prebuilts/$tool_name. On subsequent invocations it
  just runs the cached version.
  """
  dir = os.path.join(
      os.path.expanduser('~'), '.local', 'share', 'perfetto', 'prebuilts')
  os.makedirs(dir, exist_ok=True)
  bin_path = os.path.join(dir, file_name)
  sha256_path = os.path.join(dir, file_name + '.sha256')
  needs_download = True

  # Avoid recomputing the SHA-256 on each invocation. The SHA-256 of the last
  # download is cached into file_name.sha256, just check if that matches.
  if os.path.exists(bin_path) and os.path.exists(sha256_path):
    with open(sha256_path, 'rb') as f:
      digest = f.read().decode()
      if digest == sha256:
        needs_download = False

  if needs_download:  # The file doesn't exist or the SHA256 doesn't match.
    # Use a unique random file to guard against concurrent executions.
    # See https://github.com/google/perfetto/issues/786 .
    tmp_path = '%s.%d.tmp' % (bin_path, random.randint(0, 100000))
    print('Downloading ' + url)
    subprocess.check_call(['curl', '-f', '-L', '-#', '-o', tmp_path, url])
    with open(tmp_path, 'rb') as fd:
      actual_sha256 = hashlib.sha256(fd.read()).hexdigest()
    if actual_sha256 != sha256:
      raise Exception('Checksum mismatch for %s (actual: %s, expected: %s)' %
                      (url, actual_sha256, sha256))
    os.chmod(tmp_path, 0o755)
    os.replace(tmp_path, bin_path)
    with open(tmp_path, 'w') as f:
      f.write(sha256)
    os.replace(tmp_path, sha256_path)
  return bin_path


def get_perfetto_prebuilt(manifest, soft_fail=False, arch=None):
  """ Downloads the prebuilt, if necessary, and returns its path on disk. """
  plat = sys.platform.lower()
  machine = platform.machine().lower()
  manifest_entry = None
  for entry in manifest:
    # If the caller overrides the arch, just match that (for Android prebuilts).
    if arch:
      if entry.get('arch') == arch:
        manifest_entry = entry
        break
      continue
    # Otherwise guess the local machine arch.
    if entry.get('platform') == plat and machine in entry.get('machine', []):
      manifest_entry = entry
      break
  if manifest_entry is None:
    if soft_fail:
      return None
    raise Exception(
        ('No prebuilts available for %s-%s\n' % (plat, machine)) +
        'See https://perfetto.dev/docs/contributing/build-instructions')

  return download_or_get_cached(
      file_name=manifest_entry['file_name'],
      url=manifest_entry['url'],
      sha256=manifest_entry['sha256'])


def run_perfetto_prebuilt(manifest):
  bin_path = get_perfetto_prebuilt(manifest)
  if sys.platform.lower() == 'win32':
    sys.exit(subprocess.check_call([bin_path, *sys.argv[1:]]))
  os.execv(bin_path, [bin_path] + sys.argv[1:])

# ----- Amalgamator: end of python/perfetto/prebuilts/perfetto_prebuilts.py

if __name__ == '__main__':
  run_perfetto_prebuilt(TRACECONV_MANIFEST)

#EOF
