#!/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:
# ./trace_processor
# python trace_processor
# bash trace_processor
# cat ./trace_processor | bash
# cat ./trace_processor | python -

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


# ----- Amalgamator: begin of python/perfetto/prebuilts/manifests/trace_processor_shell.py
# This file has been generated by: tools/roll-prebuilts v48.1
TRACE_PROCESSOR_SHELL_MANIFEST = [{
    'arch':
        'mac-amd64',
    'file_name':
        'trace_processor_shell',
    'file_size':
        9949656,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/mac-amd64/trace_processor_shell',
    'sha256':
        'e9dcf95aaa02f8c00a724f0ff34ba3a454c717beb9900cf9fd97ab142b362452',
    'platform':
        'darwin',
    'machine': ['x86_64']
}, {
    'arch':
        'mac-arm64',
    'file_name':
        'trace_processor_shell',
    'file_size':
        9223224,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/mac-arm64/trace_processor_shell',
    'sha256':
        '9a0541a0f52f95bfcb8dc88d94bc4494c660d95eefc40fc946ab43d995051ff7',
    'platform':
        'darwin',
    'machine': ['arm64']
}, {
    'arch':
        'linux-amd64',
    'file_name':
        'trace_processor_shell',
    'file_size':
        10142800,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/linux-amd64/trace_processor_shell',
    'sha256':
        '18c8730b52f8ee1d9e202031527435b6b2e3149fbd9b1046b2e77d18f06aa337',
    'platform':
        'linux',
    'machine': ['x86_64']
}, {
    'arch':
        'linux-arm',
    'file_name':
        'trace_processor_shell',
    'file_size':
        7329432,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/linux-arm/trace_processor_shell',
    'sha256':
        '0558040998666576e1063d6d626b8aa9e354f18d73d225240f043b3c9236befa',
    'platform':
        'linux',
    'machine': ['armv6l', 'armv7l', 'armv8l']
}, {
    'arch':
        'linux-arm64',
    'file_name':
        'trace_processor_shell',
    'file_size':
        9703384,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/linux-arm64/trace_processor_shell',
    'sha256':
        'eeb95cc54358df08375ffae4862c043a6737902179ce8e0408984004c32cf93c',
    'platform':
        'linux',
    'machine': ['aarch64']
}, {
    'arch':
        'android-arm',
    'file_name':
        'trace_processor_shell',
    'file_size':
        7367412,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/android-arm/trace_processor_shell',
    'sha256':
        'd29b1e6aee52ceff24c072f56c7be7795d0fa29f3596e2633fafa60782384718'
}, {
    'arch':
        'android-arm64',
    'file_name':
        'trace_processor_shell',
    'file_size':
        9598784,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/android-arm64/trace_processor_shell',
    'sha256':
        '06e80c562c0043cca9225ade3c961a081bcc7435660117d5a6db26b815d0b9ca'
}, {
    'arch':
        'android-x86',
    'file_name':
        'trace_processor_shell',
    'file_size':
        10625488,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/android-x86/trace_processor_shell',
    'sha256':
        '2a576fb397da14d0dabcfa97f5eeec15b4dc55df009308f75a5fdf9de8a9b0dd'
}, {
    'arch':
        'android-x64',
    'file_name':
        'trace_processor_shell',
    'file_size':
        9915664,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/android-x64/trace_processor_shell',
    'sha256':
        'a30be9f09b53110394e87af4d6b41ae24cd74d9a3f97ac1cc4d6ae2057ac6977'
}, {
    'arch':
        'windows-amd64',
    'file_name':
        'trace_processor_shell.exe',
    'file_size':
        9922560,
    'url':
        'https://commondatastorage.googleapis.com/perfetto-luci-artifacts/v48.1/windows-amd64/trace_processor_shell.exe',
    'sha256':
        'd41639844a6c36dbaa195d91e9c356f2172d924c70a1bfed5432c407f857f009',
    'platform':
        'win32',
    'machine': ['amd64']
}]

# ----- Amalgamator: end of python/perfetto/prebuilts/manifests/trace_processor_shell.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(TRACE_PROCESSOR_SHELL_MANIFEST)

#EOF
