mirror of
https://github.com/Alex313031/thorium.git
synced 2025-01-08 10:47:44 -03:00
[infra] Refactored some sh files with python
1.Move *.bat files to //win_scripts/old. These files have not been updated for a long time and are not convenient to use. 2.Rewrite some sh files with python, currently only for the parts applicable to Windows. 3.Some other related changes.
This commit is contained in:
parent
4e7fbbe02a
commit
ce732accf6
25 changed files with 1015 additions and 4 deletions
|
@ -2,3 +2,7 @@
|
|||
|
||||
- This directory contains files and scripts to make portable *.zip* packages of Thorium for Linux and Windows.
|
||||
- Run a script with `--help` to see usage.
|
||||
- For `make_portable_win.py`, make sure
|
||||
[7-zip](https://www.7-zip.org/download.html) is installed on the device and
|
||||
the installation directory of 7-zip needs to be placed in the environment
|
||||
variable.
|
||||
|
|
100
infra/portable/make_portable_win.py
Normal file
100
infra/portable/make_portable_win.py
Normal file
|
@ -0,0 +1,100 @@
|
|||
# Copyright (c) 2024 Alex313031 and gz83.
|
||||
|
||||
# This file is the equivalent of make_portable_win.py.
|
||||
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import zipfile
|
||||
|
||||
|
||||
def fail(msg):
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
result = subprocess.run(command, shell=True)
|
||||
if result.returncode != 0:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
def display_help():
|
||||
print("\nScript to make a portable Thorium .zip for Windows.\n")
|
||||
print("\nPlease place the thorium_mini_installer.exe file in this directory before running.\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def copy_installer():
|
||||
cr_src_dir = os.getenv('CR_DIR', r'C:/src/chromium/src')
|
||||
src_path = os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium', 'thorium_mini_installer.exe'))
|
||||
dest_path = os.path.normpath(os.path.join(os.getcwd(), 'thorium_mini_installer.exe'))
|
||||
|
||||
if not os.path.exists(src_path):
|
||||
fail(f"thorium_mini_installer.exe not found at {src_path}")
|
||||
|
||||
print(f"Copying thorium_mini_installer.exe from {src_path} to {dest_path}...\n")
|
||||
shutil.copy(src_path, dest_path)
|
||||
|
||||
|
||||
def extract_and_copy_files():
|
||||
# Extract and copy files
|
||||
os.makedirs('./temp/USER_DATA', exist_ok=True)
|
||||
try_run('7z x thorium_mini_installer.exe')
|
||||
try_run('7z x chrome.7z')
|
||||
shutil.move('Chrome-bin', './temp/BIN')
|
||||
shutil.copy('./README.win', './temp/README.txt')
|
||||
shutil.copy('./THORIUM.BAT', './temp/')
|
||||
shutil.copy('./THORIUM_SHELL.BAT', './temp/')
|
||||
|
||||
def zip_files():
|
||||
# Create zip archive
|
||||
with zipfile.ZipFile('thorium_portable.zip', 'w', zipfile.ZIP_DEFLATED) as zf:
|
||||
for root, _, files in os.walk('./temp'):
|
||||
for file in files:
|
||||
file_path = os.path.join(root, file)
|
||||
zf.write(file_path, os.path.relpath(file_path, './temp'))
|
||||
|
||||
def clean_up():
|
||||
# Cleanup extracted files
|
||||
try:
|
||||
os.remove('chrome.7z')
|
||||
shutil.rmtree('temp')
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
def main():
|
||||
|
||||
print("\nNOTE: You must place the thorium .exe file in this directory before running.")
|
||||
print(" AND you must have 7-Zip installed and in your PATH.")
|
||||
print(" Make sure to rename the .zip properly as per the release instructions.")
|
||||
print(" AND make sure to edit the THORIUM_SHELL.BAT to match the version number of this release.\n")
|
||||
|
||||
copy_installer()
|
||||
|
||||
input("Press Enter to continue or Ctrl + C to abort.")
|
||||
|
||||
print("Extracting & Copying files from thorium .exe file...\n")
|
||||
time.sleep(2)
|
||||
|
||||
extract_and_copy_files()
|
||||
|
||||
print("\nZipping up...\n")
|
||||
zip_files()
|
||||
|
||||
print("\nCleaning up...\n")
|
||||
time.sleep(2)
|
||||
|
||||
clean_up()
|
||||
|
||||
print("\nDone! Zip is at ./thorium_portable.zip")
|
||||
print("Remember to rename it with the version before distributing it.\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
<img src="https://github.com/Alex313031/thorium/blob/main/logos/NEW/win/mini_installer/thorium_mini_installer_86.png">
|
||||
|
||||
This directory contains batch files for building Thorium natively on Windows.
|
||||
This directory contains python files for building Thorium natively on Windows.
|
||||
|
||||
The "bin" subdirectory contains useful "aliases" for cmd.exe. One can copy this folder somewhere or leave it where it is and then add it to your PATH.
|
||||
|
||||
Also recommended is Clink > https://mridgers.github.io/clink/
|
||||
Before running the Python files in this directory, please strictly follow the instructions in [BUILDING_WIN](https://github.com/Alex313031/thorium/blob/main/docs/BUILDING_WIN.md).
|
||||
|
|
48
win_scripts/build_win.py
Normal file
48
win_scripts/build_win.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
# Copyright (c) 2024 Alex313031 and gz83.
|
||||
|
||||
# This file is the equivalent of build_win.sh in the parent directory.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Error handling functions
|
||||
def fail(msg):
|
||||
# Print error message and exit
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
if subprocess.call(command, shell=True) != 0:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
# Help function
|
||||
def display_help():
|
||||
print("\nScript to build Thorium for Windows.\n")
|
||||
print("Usage: python win_scripts\build_win.py # (where # is number of jobs)\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# Set chromium/src dir from Windows environment variable
|
||||
cr_src_dir = os.getenv('CR_DIR', r'C:/src/chromium/src')
|
||||
|
||||
print("\nBuilding Thorium for Windows\n")
|
||||
|
||||
# Change directory and run build commands
|
||||
os.chdir(cr_src_dir)
|
||||
# Determine the number of threads to use
|
||||
jobs = sys.argv[1] if len(sys.argv) > 1 else str(os.cpu_count())
|
||||
|
||||
try_run(f'autoninja -C out/thorium thorium_all -j{jobs}')
|
||||
|
||||
# Move the installer
|
||||
installer_src = os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium', 'mini_installer.exe'))
|
||||
installer_dest = os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium', 'thorium_mini_installer.exe'))
|
||||
os.rename(installer_src, installer_dest)
|
||||
|
||||
print(f"Build Completed. Installer at '{installer_dest}'")
|
64
win_scripts/clean.py
Normal file
64
win_scripts/clean.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
# Copyright (c) 2024 Alex313031 and gz83.
|
||||
|
||||
"""
|
||||
This file is the equivalent of clean.sh in the parent directory, but it directly
|
||||
deletes //out/thorium and unneeded PGO files.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
def fail(msg):
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
try:
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
def clean_files(directory):
|
||||
for filename in os.listdir(directory):
|
||||
file_path = os.path.join(directory, filename)
|
||||
if os.path.isfile(file_path):
|
||||
try:
|
||||
os.remove(file_path)
|
||||
print(f"Removed: {file_path}")
|
||||
except Exception as e:
|
||||
fail(f"Failed to remove {file_path}: {e}")
|
||||
|
||||
|
||||
def delete_directory(directory):
|
||||
if os.path.exists(directory):
|
||||
try:
|
||||
shutil.rmtree(directory)
|
||||
print(f"Removed directory: {directory}")
|
||||
except Exception as e:
|
||||
fail(f"Failed to remove directory {directory}: {e}")
|
||||
|
||||
|
||||
def display_help():
|
||||
print("\nScript to remove unneeded artifacts\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# Set chromium/src dir from Windows environment variable
|
||||
cr_src_dir = os.getenv('CR_DIR', r'C:/src/chromium/src')
|
||||
|
||||
print("\nCleaning up unneeded artifacts\n")
|
||||
|
||||
profiles_dir = os.path.normpath(os.path.join(cr_src_dir, "chrome", "build", "pgo_profiles"))
|
||||
clean_files(profiles_dir)
|
||||
|
||||
thorium_dir = os.path.normpath(os.path.join(cr_src_dir, "out", "thorium"))
|
||||
delete_directory(thorium_dir)
|
||||
|
||||
print("\nDone cleaning artifacts\n")
|
88
win_scripts/reset_depot_tools.py
Normal file
88
win_scripts/reset_depot_tools.py
Normal file
|
@ -0,0 +1,88 @@
|
|||
# Copyright (c) 2024 Alex313031, midzer and gz83.
|
||||
|
||||
"""
|
||||
This file is the equivalent of reset_depot_tools.py in the parent folder, but we
|
||||
do not need to deal with the .vpython_cipd_cache.
|
||||
This file may prompt "Access denied" and other prompts during the operation, but
|
||||
in fact it seems that the files we need to delete have been deleted.
|
||||
"""
|
||||
|
||||
# TODO(gz83): Suppress false positives during operation?
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def fail(msg):
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
try:
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
def remove(item_path):
|
||||
if os.path.exists(item_path):
|
||||
if os.path.isdir(item_path):
|
||||
try:
|
||||
# Try to unlock and delete the directory
|
||||
unlock_and_delete(item_path)
|
||||
print(f"removed '{item_path}'")
|
||||
except PermissionError as e:
|
||||
print(f"Failed to remove '{item_path}': {e}")
|
||||
else:
|
||||
os.remove(item_path)
|
||||
print(f"removed '{item_path}'")
|
||||
|
||||
|
||||
def unlock_and_delete(path):
|
||||
"""Attempts to unlock and delete a directory using cmd commands."""
|
||||
if sys.platform == "win32":
|
||||
# Use the Windows command line tools to unlock the directory
|
||||
try:
|
||||
# Use the command 'del' to delete all files recursively
|
||||
subprocess.run(f'del /S /Q "{path}\\*"', shell=True, check=True)
|
||||
# Use the command 'rmdir' to delete the directory
|
||||
subprocess.run(f'rmdir /S /Q "{path}"', shell=True, check=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Failed to unlock and delete directory '{path}' via CMD: {e}")
|
||||
raise PermissionError(f"Failed to unlock and delete directory '{path}' via CMD: {e}")
|
||||
else:
|
||||
# For other platforms, just use shutil.rmtree
|
||||
shutil.rmtree(path)
|
||||
|
||||
|
||||
def display_help():
|
||||
print("\nScript to reset depot_tools on Windows.\n")
|
||||
print("This will remove depot_tools, .gsutil, and .vpython-root")
|
||||
print("from your disk, and then re-clone depot_tools.")
|
||||
print("\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
depot_tools_dir = os.getenv('DEPOT_TOOLS_DIR', r"C:\src\depot_tools")
|
||||
gsutil_dir = os.path.expandvars(os.getenv('GSUTIL_DIR', r'%USERPROFILE%\.gsutil'))
|
||||
vpython_root_dir = os.path.expandvars(os.getenv('VPYTHON_ROOT_DIR', r'%LOCALAPPDATA%\.vpython-root'))
|
||||
|
||||
print("\nRemoving depot_tools, etc\n")
|
||||
|
||||
remove(depot_tools_dir)
|
||||
remove(gsutil_dir)
|
||||
remove(vpython_root_dir)
|
||||
|
||||
print("\nRe-clone depot_tools\n")
|
||||
|
||||
os.chdir(os.path.dirname(depot_tools_dir))
|
||||
try_run(f"git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git")
|
||||
|
||||
print(f"\nCompleted. You can now use the depot_tools installed at: {depot_tools_dir}\n")
|
||||
print("\nYou can now run trunk.py\n")
|
386
win_scripts/setup.py
Normal file
386
win_scripts/setup.py
Normal file
|
@ -0,0 +1,386 @@
|
|||
# Copyright (c) 2024 Alex313031 and gz83.
|
||||
|
||||
"""
|
||||
This file is the equivalent of setup.sh in the parent folder, but only for
|
||||
Windows builds.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def fail(msg):
|
||||
# Print error message and exit
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
# Execute a command and die on failure
|
||||
try:
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
def copy(src, dst):
|
||||
# Copy a file and print verbose output like cp -v
|
||||
try:
|
||||
print(f"Copying {src} to {dst}")
|
||||
shutil.copy(src, dst)
|
||||
except FileNotFoundError as e:
|
||||
fail(f"File copy failed: {e}")
|
||||
|
||||
|
||||
def copy_directory(source_dir, destination_dir):
|
||||
if not os.path.exists(destination_dir):
|
||||
os.makedirs(destination_dir)
|
||||
print(f"Created directory {destination_dir}")
|
||||
for item in os.listdir(source_dir):
|
||||
s = os.path.join(source_dir, item)
|
||||
d = os.path.join(destination_dir, item)
|
||||
if os.path.isdir(s):
|
||||
print(f"Copying directory {s} to {d}")
|
||||
shutil.copytree(s, d, dirs_exist_ok=True)
|
||||
else:
|
||||
copy(s, d)
|
||||
|
||||
|
||||
# --help
|
||||
def display_help():
|
||||
print("\nScript to copy Thorium source files over the Chromium source tree\n")
|
||||
print("\nThis should be done AFTER running this setup.py\n")
|
||||
print("Use the --woa flag for Windows on ARM builds.")
|
||||
print("Use the --avx512 flag for AVX-512 Builds.")
|
||||
print("Use the --avx2 flag for AVX2 Builds.")
|
||||
print("Use the --sse4 flag for SSE4.1 Builds.")
|
||||
print("Use the --sse3 flag for SSE3 Builds.")
|
||||
print("Use the --sse2 flag for 32-bit SSE2 Builds.")
|
||||
print("\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
# Set chromium/src dir from Windows environment variable
|
||||
cr_src_dir = os.getenv('CR_DIR', r'C:/src/chromium/src')
|
||||
# Set Thorium dir from Windows environment variable
|
||||
thor_src_dir = os.path.expandvars(os.getenv('THOR_DIR', r'%USERPROFILE%/thorium'))
|
||||
|
||||
|
||||
print("\nCreating build output directory...\n")
|
||||
os.makedirs(f"{cr_src_dir}/out/thorium/", exist_ok=True)
|
||||
|
||||
print("\nCopying Thorium source files over the Chromium tree\n")
|
||||
|
||||
# Copy libjxl src
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'thorium-libjxl/src/')),
|
||||
os.path.normpath(os.path.join(cr_src_dir))
|
||||
)
|
||||
|
||||
# Copy src/BUILD.gn
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'src', 'BUILD.gn')),
|
||||
os.path.normpath(os.path.join(cr_src_dir))
|
||||
)
|
||||
|
||||
# Copy Thorium sources
|
||||
thorium_sources = [
|
||||
'src/ash',
|
||||
'src/build',
|
||||
'src/chrome',
|
||||
'src/chromeos',
|
||||
'src/components',
|
||||
'src/content',
|
||||
'src/extensions',
|
||||
'src/google_apis',
|
||||
'src/media',
|
||||
'src/net',
|
||||
'src/sandbox',
|
||||
'src/services',
|
||||
'src/third_party',
|
||||
'src/tools',
|
||||
'src/ui',
|
||||
'src/v8'
|
||||
]
|
||||
|
||||
for source in thorium_sources:
|
||||
relative_path = source.replace('src/', '', 1)
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, source)),
|
||||
os.path.normpath(os.path.join(cr_src_dir, relative_path))
|
||||
)
|
||||
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'thorium_shell')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'pak_src', 'binaries', 'pak')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'pak_src', 'binaries', 'pak-win')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
|
||||
|
||||
patches = [
|
||||
'other/fix-policy-templates.patch',
|
||||
'other/ftp-support-thorium.patch',
|
||||
'other/thorium-2024-ui.patch',
|
||||
]
|
||||
for patch in patches:
|
||||
relative_path = patch.replace('other/', '', 1)
|
||||
os.path.normpath(os.path.join(cr_src_dir, os.path.dirname(relative_path)))
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, patch)),
|
||||
os.path.normpath(os.path.join(cr_src_dir, relative_path))
|
||||
)
|
||||
|
||||
|
||||
print( "\nPatching FFMPEG for HEVC\n")
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'add-hevc-ffmpeg-decoder-parser.patch')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'third_party', 'ffmpeg'))
|
||||
)
|
||||
# Change directory to ffmpeg_dir and run commands
|
||||
ffmpeg_dir = os.path.join(cr_src_dir, 'third_party', 'ffmpeg')
|
||||
os.chdir(ffmpeg_dir)
|
||||
try_run(f'git apply --reject add-hevc-ffmpeg-decoder-parser.patch')
|
||||
|
||||
|
||||
print( "\nPatching policy templates\n")
|
||||
# Change directory to cr_src_dir and run commands
|
||||
os.chdir(cr_src_dir)
|
||||
try_run(f'git apply --reject fix-policy-templates.patch')
|
||||
|
||||
|
||||
print( "\nPatching FTP support\n")
|
||||
# Change directory to cr_src_dir and run commands
|
||||
os.chdir(cr_src_dir)
|
||||
try_run(f'git apply --reject ftp-support-thorium.patch')
|
||||
|
||||
|
||||
print( "\nPatching for Thorium 2024 UI\n")
|
||||
# Change directory to cr_src_dir and run commands
|
||||
os.chdir(cr_src_dir)
|
||||
try_run(f'git apply --reject thorium-2024-ui.patch')
|
||||
|
||||
|
||||
if '--woa' not in sys.argv:
|
||||
print("\nPatching FFMPEG for AC3 & E-AC3\n")
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'ffmpeg_hevc_ac3.patch')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'third_party', 'ffmpeg'))
|
||||
)
|
||||
# Change directory to ffmpeg_dir and run commands
|
||||
ffmpeg_dir = os.path.join(cr_src_dir, 'third_party', 'ffmpeg')
|
||||
os.chdir(ffmpeg_dir)
|
||||
try_run(f'git apply --reject ffmpeg_hevc_ac3.patch')
|
||||
else:
|
||||
print("\nSkipping patching FFMPEG for AC3 & E-AC3 due to --woa option.\n")
|
||||
|
||||
|
||||
print("\nCopying other files to out/thorium\n")
|
||||
# Copying additional files
|
||||
os.makedirs(f"{cr_src_dir}/out/thorium/default_apps", exist_ok=True)
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'infra', 'default_apps')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium', 'default_apps'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'infra', 'initial_preferences')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'infra', 'thor_ver')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
|
||||
# Copy Windows on Arm files
|
||||
def copy_woa():
|
||||
print("\nCopying Windows on Arm build files\n")
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'arm', 'build')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'build'))
|
||||
)
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'arm', 'third_party')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'third_party'))
|
||||
)
|
||||
os.chdir(cr_src_dir)
|
||||
print("\nDownloading PGO Profiles for Windows on Arm\n")
|
||||
try_run(
|
||||
'python3 tools/update_pgo_profiles.py --target=win-arm64 '
|
||||
'update --gs-url-base=chromium-optimization-profiles/pgo_profiles'
|
||||
)
|
||||
print("\nDownloading PGO Profile for V8\n")
|
||||
try_run(
|
||||
'python3 v8/tools/builtins-pgo/download_profiles.py '
|
||||
'--depot-tools=third_party/depot_tools --force download'
|
||||
)
|
||||
|
||||
|
||||
if '--woa' in sys.argv:
|
||||
copy_woa()
|
||||
|
||||
|
||||
# Copy AVX512 build files
|
||||
def copy_avx512():
|
||||
print("\nCopying AVX-512 build files\n")
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'AVX512', 'build')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'build'))
|
||||
)
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'AVX512', 'third_party')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'third_party'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'AVX512', 'thor_ver')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
os.chdir(cr_src_dir)
|
||||
print("\nDownloading PGO Profiles for Windows x64\n")
|
||||
try_run(
|
||||
'python3 tools/update_pgo_profiles.py --target=win64 '
|
||||
'update --gs-url-base=chromium-optimization-profiles/pgo_profiles'
|
||||
)
|
||||
print("\nDownloading PGO Profile for V8\n")
|
||||
try_run(
|
||||
'python3 v8/tools/builtins-pgo/download_profiles.py '
|
||||
'--depot-tools=third_party/depot_tools --force download'
|
||||
)
|
||||
|
||||
|
||||
if '--avx512' in sys.argv:
|
||||
copy_avx512()
|
||||
|
||||
|
||||
# Copy AVX2 build files
|
||||
def copy_avx2():
|
||||
print("\nCopying AVX2 build files\n")
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'AVX2', 'build')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'build'))
|
||||
)
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'AVX2', 'third_party')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'third_party'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'AVX2', 'thor_ver')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
os.chdir(cr_src_dir)
|
||||
print("\nDownloading PGO Profiles for Windows x64\n")
|
||||
try_run(
|
||||
'python3 tools/update_pgo_profiles.py --target=win64 '
|
||||
'update --gs-url-base=chromium-optimization-profiles/pgo_profiles'
|
||||
)
|
||||
print("\nDownloading PGO Profile for V8\n")
|
||||
try_run(
|
||||
'python3 v8/tools/builtins-pgo/download_profiles.py '
|
||||
'--depot-tools=third_party/depot_tools --force download'
|
||||
)
|
||||
|
||||
|
||||
if '--avx2' in sys.argv:
|
||||
copy_avx2()
|
||||
|
||||
|
||||
# Copy SSE4.1 build files
|
||||
def copy_sse4():
|
||||
print("\nCopying SSE4.1 build files\n")
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'SSE4.1', 'build')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'build'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'SSE4.1', 'thor_ver')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
os.chdir(cr_src_dir)
|
||||
print("\nDownloading PGO Profiles for Windows x64\n")
|
||||
try_run(
|
||||
'python3 tools/update_pgo_profiles.py --target=win64 '
|
||||
'update --gs-url-base=chromium-optimization-profiles/pgo_profiles'
|
||||
)
|
||||
print("\nDownloading PGO Profile for V8\n")
|
||||
try_run(
|
||||
'python3 v8/tools/builtins-pgo/download_profiles.py '
|
||||
'--depot-tools=third_party/depot_tools --force download'
|
||||
)
|
||||
|
||||
|
||||
if '--sse4' in sys.argv:
|
||||
copy_sse4()
|
||||
|
||||
|
||||
# Copy SSE3 build files
|
||||
def copy_sse3():
|
||||
print("\nCopying SSE3 build files\n")
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'SSE3', 'build')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'build'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'SSE3', 'thor_ver')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
os.chdir(cr_src_dir)
|
||||
print("\nDownloading PGO Profiles for Windows x64\n")
|
||||
try_run(
|
||||
'python3 tools/update_pgo_profiles.py --target=win64 '
|
||||
'update --gs-url-base=chromium-optimization-profiles/pgo_profiles'
|
||||
)
|
||||
print("\nDownloading PGO Profiles for Windows x86\n")
|
||||
try_run(
|
||||
'python3 tools/update_pgo_profiles.py --target=win32 '
|
||||
'update --gs-url-base=chromium-optimization-profiles/pgo_profiles'
|
||||
)
|
||||
print("\nDownloading PGO Profile for V8\n")
|
||||
try_run(
|
||||
'python3 v8/tools/builtins-pgo/download_profiles.py '
|
||||
'--depot-tools=third_party/depot_tools --force download'
|
||||
)
|
||||
|
||||
|
||||
if '--sse3' in sys.argv:
|
||||
copy_sse3()
|
||||
|
||||
|
||||
# Copy SSE2 build files
|
||||
def copy_sse2():
|
||||
print("\nCopying SSE2 build files\n")
|
||||
copy_directory(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'SSE2', 'build')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'build'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'other', 'SSE2', 'thor_ver')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'out', 'thorium'))
|
||||
)
|
||||
os.chdir(cr_src_dir)
|
||||
print("\nDownloading PGO Profiles for Windows x86\n")
|
||||
try_run(
|
||||
'python3 tools/update_pgo_profiles.py --target=win32 '
|
||||
'update --gs-url-base=chromium-optimization-profiles/pgo_profiles'
|
||||
)
|
||||
print("\nDownloading PGO Profile for V8\n")
|
||||
try_run(
|
||||
'python3 v8/tools/builtins-pgo/download_profiles.py '
|
||||
'--depot-tools=third_party/depot_tools --force download'
|
||||
)
|
||||
|
||||
|
||||
if '--sse2' in sys.argv:
|
||||
copy_sse2()
|
||||
|
||||
|
||||
print("\nDone!\n")
|
||||
print("\nEnjoy Thorium!\n")
|
74
win_scripts/tot.py
Normal file
74
win_scripts/tot.py
Normal file
|
@ -0,0 +1,74 @@
|
|||
# Copyright (c) 2024 Alex313031 and gz83.
|
||||
|
||||
"""
|
||||
This file is used to sync commits in Chromium's Tip-of-tree branch and does not
|
||||
contain any Thorium-specific files.
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
# Error handling function
|
||||
def fail(msg):
|
||||
# Print error message and exit
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
# Execute a command and die on failure
|
||||
try:
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
# --help
|
||||
def display_help():
|
||||
print(f"\nScript to Rebase/Sync Chromium repo to Tip of Tree.\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# Set chromium/src dir from Windows environment variable
|
||||
cr_src_dir = os.getenv('CR_DIR', r'C:/src/chromium/src')
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
print("\nScript to Rebase/Sync Chromium repo to Tip of Tree.\n")
|
||||
print(
|
||||
f"Rebasing/Syncing to `origin/main` and running hooks in {cr_src_dir}\n"
|
||||
)
|
||||
|
||||
# Change directory to cr_src_dir and run commands
|
||||
os.chdir(cr_src_dir)
|
||||
|
||||
# Commands to run
|
||||
commands = [
|
||||
'cd v8 && git restore . && git clean -ffd',
|
||||
'cd third_party/devtools-frontend/src && git restore . && git clean -ffd',
|
||||
'cd third_party/ffmpeg && git restore . && git clean -ffd',
|
||||
'git checkout -f origin/main',
|
||||
'git clean -ffd',
|
||||
'git rebase-update',
|
||||
'git fetch --tags',
|
||||
'gclient sync --with_branch_heads --with_tags -f -R -D',
|
||||
'git clean -ffd',
|
||||
'gclient runhooks'
|
||||
]
|
||||
|
||||
# Run each command with error handling
|
||||
for cmd in commands:
|
||||
try_run(cmd)
|
||||
|
||||
print("\nDone!\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
85
win_scripts/trunk.py
Normal file
85
win_scripts/trunk.py
Normal file
|
@ -0,0 +1,85 @@
|
|||
# Copyright (c) 2024 Alex313031, midzer and gz83.
|
||||
|
||||
"""
|
||||
This file is the equivalent of trunk.sh in the parent folder, but for native
|
||||
builds on Windows, we do not need to deal with the vs artifacts hash.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def fail(msg):
|
||||
# Print error message and exit
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
# Execute a command and exit on failure
|
||||
try:
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
def safe_rmtree(path):
|
||||
# Remove a directory if it exists
|
||||
path = os.path.normpath(path)
|
||||
if os.path.exists(path):
|
||||
print(f"Removing: {path}")
|
||||
shutil.rmtree(path)
|
||||
|
||||
|
||||
# --help
|
||||
def display_help():
|
||||
print(f"\nScript to Rebase/Sync the Chromium repo.\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# Set chromium/src dir from Windows environment variable
|
||||
cr_src_dir = os.getenv('CR_DIR', r'C:/src/chromium/src')
|
||||
# Thorium-specific directory that need to be deleted
|
||||
pak_dir = os.path.normpath(os.path.join(cr_src_dir, "third_party", "pak"))
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
print("\nScript to Rebase/Sync the Chromium repo.\n")
|
||||
print(f"Rebasing/Syncing and running hooks in {cr_src_dir}\n")
|
||||
|
||||
# Change directory to cr_src_dir and run commands
|
||||
os.chdir(cr_src_dir)
|
||||
|
||||
# Remove Thorium-specific directory if it exists
|
||||
safe_rmtree(pak_dir)
|
||||
|
||||
# Commands to run
|
||||
commands = [
|
||||
'cd v8 && git restore . && git clean -ffd',
|
||||
'cd third_party/devtools-frontend/src && git restore . && git clean -ffd',
|
||||
'cd third_party/ffmpeg && git restore . && git clean -ffd',
|
||||
'git checkout -f origin/main',
|
||||
'git clean -ffd',
|
||||
'git clean -ffd',
|
||||
'git rebase-update',
|
||||
'git fetch --tags',
|
||||
'gclient sync --with_branch_heads --with_tags -f -R -D',
|
||||
'git clean -ffd',
|
||||
'gclient runhooks'
|
||||
]
|
||||
|
||||
# Run each command with error handling
|
||||
for cmd in commands:
|
||||
try_run(cmd)
|
||||
|
||||
print("\nDone! You can now run version.py.\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
70
win_scripts/upstream_version.py
Normal file
70
win_scripts/upstream_version.py
Normal file
|
@ -0,0 +1,70 @@
|
|||
# Copyright (c) 2024 Alex313031 and gz83.
|
||||
|
||||
"""
|
||||
This file is the equivalent of upstream_version.sh in the parent folder, but for native
|
||||
builds on Windows, we do not need to deal with the vs artifacts hash and linux
|
||||
sysroot. At the same time, download only the PGO file for win64.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def fail(msg):
|
||||
# Print error message and exit
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
# Execute a command and die on failure
|
||||
try:
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
# --help
|
||||
def display_help():
|
||||
print(f"\nScript to check out Chromium tag of current Thorium version.\n")
|
||||
print(f"\nNOTE: You may need to run trunk.py before using this script\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# Set chromium/src dir from Windows environment variable
|
||||
cr_src_dir = os.getenv('CR_DIR', r'C:/src/chromium/src')
|
||||
|
||||
|
||||
# Set cr_ver
|
||||
cr_ver = "128.0.6613.194"
|
||||
|
||||
|
||||
print(f"\nCurrent Chromium version is: {cr_ver}\n")
|
||||
print(f"\nNOTE: Checking out tags/{cr_ver} in {cr_src_dir}\n")
|
||||
|
||||
# Change directory to cr_src_dir and run commands
|
||||
os.chdir(cr_src_dir)
|
||||
|
||||
try_run(f'git checkout -f tags/{cr_ver}')
|
||||
|
||||
# Commands to run
|
||||
commands = [
|
||||
'git clean -ffd',
|
||||
'git clean -ffd',
|
||||
'gclient sync --with_branch_heads --with_tags -f -R -D',
|
||||
'gclient runhooks',
|
||||
]
|
||||
|
||||
# Run each command with error handling
|
||||
for cmd in commands:
|
||||
try_run(cmd)
|
||||
|
||||
|
||||
print(f"\nChromium tree is checked out at tag: {cr_ver}\n")
|
||||
|
||||
print("\nDone!\n")
|
94
win_scripts/version.py
Normal file
94
win_scripts/version.py
Normal file
|
@ -0,0 +1,94 @@
|
|||
# Copyright (c) 2024 Alex313031 and gz83.
|
||||
|
||||
"""
|
||||
This file is the equivalent of version.sh in the parent folder, but for native
|
||||
builds on Windows, we do not need to deal with the vs artifacts hash and linux
|
||||
sysroot. At the same time, download only the PGO file for win64.
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def fail(msg):
|
||||
# Print error message and exit
|
||||
print(f"{sys.argv[0]}: {msg}", file=sys.stderr)
|
||||
sys.exit(111)
|
||||
|
||||
|
||||
def try_run(command):
|
||||
# Execute a command and die on failure
|
||||
try:
|
||||
subprocess.run(command, shell=True, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
fail(f"Failed {command}")
|
||||
|
||||
|
||||
def copy(src, dst):
|
||||
# Copy a file and print verbose output like cp -v
|
||||
try:
|
||||
print(f"Copying {src} to {dst}")
|
||||
shutil.copy(src, dst)
|
||||
except FileNotFoundError as e:
|
||||
fail(f"File copy failed: {e}")
|
||||
|
||||
|
||||
# --help
|
||||
def display_help():
|
||||
print(f"\nScript to check out Chromium tag of current Thorium version.\n")
|
||||
print(f"\nNOTE: You may need to run trunk.py before using this script\n")
|
||||
|
||||
if '--help' in sys.argv:
|
||||
display_help()
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
# Set chromium/src dir from Windows environment variable
|
||||
cr_src_dir = os.getenv('CR_DIR', r'C:/src/chromium/src')
|
||||
# Set Thorium dir from Windows environment variable
|
||||
thor_src_dir = os.path.expandvars(os.getenv('THOR_DIR', r'%USERPROFILE%/thorium'))
|
||||
|
||||
|
||||
# Set thor_ver
|
||||
thor_ver = "128.0.6613.194"
|
||||
|
||||
|
||||
print(f"\nCurrent Thorium version is: {thor_ver}\n")
|
||||
print(f"\nNOTE: Checking out tags/{thor_ver} in {cr_src_dir}\n")
|
||||
|
||||
# Change directory to cr_src_dir and run commands
|
||||
os.chdir(cr_src_dir)
|
||||
|
||||
try_run(f'git checkout -f tags/{thor_ver}')
|
||||
|
||||
# Copy files using shutil
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'thorium-libjxl/src/DEPS')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'DEPS'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'thorium-libjxl/src/.gitmodules')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, '.gitmodules'))
|
||||
)
|
||||
copy(
|
||||
os.path.normpath(os.path.join(thor_src_dir, 'thorium-libjxl/src/third_party/.gitignore')),
|
||||
os.path.normpath(os.path.join(cr_src_dir, 'third_party/.gitignore'))
|
||||
)
|
||||
|
||||
# Commands to run
|
||||
commands = [
|
||||
'git clean -ffd',
|
||||
'git clean -ffd',
|
||||
'gclient sync --with_branch_heads --with_tags -f -R -D',
|
||||
'gclient runhooks',
|
||||
]
|
||||
|
||||
# Run each command with error handling
|
||||
for cmd in commands:
|
||||
try_run(cmd)
|
||||
|
||||
print(f"\nChromium tree is checked out at tag: {thor_ver}\n")
|
||||
|
||||
print("\nDone! You can now run setup.py\n")
|
Loading…
Reference in a new issue