mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
Toolchain: Rewrite BuildVcpkg.sh in python
Co-Authored-By: Andrew Kaster <andrew@ladybird.org>
This commit is contained in:
parent
83bfba79b6
commit
c92d9cce42
Notes:
github-actions[bot]
2024-10-11 03:49:57 +00:00
Author: https://github.com/pheonixfirewingz Commit: https://github.com/LadybirdBrowser/ladybird/commit/c92d9cce420 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1695 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/nico Reviewed-by: https://github.com/vitalyster
3 changed files with 49 additions and 48 deletions
|
@ -137,7 +137,7 @@ delete_target() {
|
|||
}
|
||||
|
||||
build_vcpkg() {
|
||||
( cd "$LADYBIRD_SOURCE_DIR/Toolchain" && ./BuildVcpkg.sh )
|
||||
( cd "$LADYBIRD_SOURCE_DIR/Toolchain" && python3 ./BuildVcpkg.py )
|
||||
}
|
||||
|
||||
ensure_toolchain() {
|
||||
|
|
47
Toolchain/BuildVcpkg.py
Executable file
47
Toolchain/BuildVcpkg.py
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import pathlib
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
|
||||
def main() -> int:
|
||||
script_dir = pathlib.Path(__file__).parent.resolve()
|
||||
|
||||
git_repo = "https://github.com/microsoft/vcpkg.git"
|
||||
git_rev = "2960d7d80e8d09c84ae8abf15c12196c2ca7d39a" # 2024.09.30
|
||||
|
||||
tarball_dir = script_dir / "Tarballs"
|
||||
tarball_dir.mkdir(parents=True, exist_ok=True)
|
||||
vcpkg_checkout = tarball_dir / "vcpkg"
|
||||
|
||||
if not vcpkg_checkout.is_dir():
|
||||
subprocess.check_call(args=["git", "clone", git_repo], cwd=tarball_dir)
|
||||
else:
|
||||
bootstrapped_vcpkg_version = subprocess.check_output(
|
||||
["git", "-C", vcpkg_checkout, "rev-parse", "HEAD"]).strip().decode()
|
||||
|
||||
if bootstrapped_vcpkg_version == git_rev:
|
||||
return 0
|
||||
|
||||
print(f"Building vcpkg@{git_rev}")
|
||||
|
||||
subprocess.check_call(args=["git", "fetch", "origin"], cwd=vcpkg_checkout)
|
||||
subprocess.check_call(args=["git", "checkout", git_rev], cwd=vcpkg_checkout)
|
||||
|
||||
bootstrap_script = "bootstrap-vcpkg.bat" if os.name == 'nt' else "bootstrap-vcpkg.sh"
|
||||
subprocess.check_call(args=[vcpkg_checkout / bootstrap_script, "-disableMetrics"], cwd=vcpkg_checkout, shell=True)
|
||||
|
||||
install_dir = script_dir / "Local" / "vcpkg" / "bin"
|
||||
install_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
vcpkg_name = "vcpkg.exe" if os.name == 'nt' else "vcpkg"
|
||||
shutil.copy(vcpkg_checkout / vcpkg_name, install_dir / vcpkg_name)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -1,49 +1,3 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# This script builds the vcpkg dependency management system
|
||||
set -e
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
. "${DIR}/../Meta/shell_include.sh"
|
||||
|
||||
# FIXME: Make the test262-runner CI use a non-root user
|
||||
ci=0
|
||||
if [[ "$1" == "--ci" ]]; then
|
||||
echo "Running in CI mode, will not check for root user"
|
||||
ci=1
|
||||
shift
|
||||
fi
|
||||
|
||||
if [ "$ci" -eq 0 ]; then
|
||||
exit_if_running_as_root "Do not run BuildVcpkg.sh as root, parts of your Toolchain directory will become root-owned"
|
||||
fi
|
||||
|
||||
GIT_REPO="https://github.com/microsoft/vcpkg.git"
|
||||
GIT_REV="2960d7d80e8d09c84ae8abf15c12196c2ca7d39a" # 2024.09.30
|
||||
PREFIX_DIR="$DIR/Local/vcpkg"
|
||||
|
||||
mkdir -p "$DIR/Tarballs"
|
||||
pushd "$DIR/Tarballs"
|
||||
if [[ ! -d vcpkg ]]; then
|
||||
git clone "${GIT_REPO}"
|
||||
else
|
||||
bootstrapped_vcpkg_version=$(git -C vcpkg rev-parse HEAD)
|
||||
|
||||
if [[ "${bootstrapped_vcpkg_version}" == "${GIT_REV}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Building vcpkg"
|
||||
|
||||
cd vcpkg
|
||||
git fetch origin
|
||||
git checkout $GIT_REV
|
||||
|
||||
./bootstrap-vcpkg.sh -disableMetrics
|
||||
|
||||
mkdir -p "$PREFIX_DIR/bin"
|
||||
cp vcpkg "$PREFIX_DIR/bin"
|
||||
popd
|
||||
python3 ./Toolchain/BuildVcpkg.py
|
||||
|
|
Loading…
Reference in a new issue