Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/misc/scripts/install_perfetto.py
59209 views
1
#!/usr/bin/env python
2
3
import os
4
import sys
5
import tempfile
6
import urllib.request
7
from zipfile import ZipFile
8
9
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../"))
10
11
from misc.utility.color import Ansi, color_print
12
13
14
def get_latest_tag():
15
import json
16
17
url = "https://api.github.com/repos/google/perfetto/releases/latest"
18
with urllib.request.urlopen(url) as response:
19
data = json.load(response)
20
return data["tag_name"]
21
22
23
# Perfetto
24
# Check for latest version: https://github.com/google/perfetto/releases/latest
25
perfetto_tag = get_latest_tag()
26
perfetto_filename = "perfetto-cpp-sdk-src.zip"
27
perfetto_folder = "thirdparty/perfetto"
28
29
perfetto_archive_destination = os.path.join(tempfile.gettempdir(), perfetto_filename)
30
31
if os.path.isfile(perfetto_archive_destination):
32
os.remove(perfetto_archive_destination)
33
34
print(f"Downloading Perfetto {perfetto_tag} ...")
35
urllib.request.urlretrieve(
36
f"https://github.com/google/perfetto/releases/download/{perfetto_tag}/{perfetto_filename}",
37
perfetto_archive_destination,
38
)
39
40
print(f"Extracting Perfetto {perfetto_tag} to {perfetto_folder} ...")
41
with ZipFile(perfetto_archive_destination, "r") as zip_file:
42
zip_file.extractall(perfetto_folder)
43
os.remove(perfetto_archive_destination)
44
print("Perfetto installed successfully.\n")
45
46
# Complete message
47
color_print(f'{Ansi.GREEN}Perfetto was installed to "{perfetto_folder}" successfully!')
48
49