diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 40d24fdf500..50074b0b3b6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -6,7 +6,13 @@ "ghcr.io/devcontainers/features/github-cli:1": {}, "ghcr.io/devcontainers-contrib/features/pre-commit:2": {}, "./features/ladybird": { - "llvm_version": 18, + "llvm_version": 18 + }, + "./features/vcpkg-cache": { + "release_triplet": true, + // FIXME: Figure out how to have the CI prebuilt version set both of these true + "debug_triplet": false, + "sanitizer_triplet": false }, "ghcr.io/devcontainers/features/desktop-lite": { "password": "vscode", @@ -44,17 +50,15 @@ "Toolchain/Local/**": true, "Toolchain/Tarballs/**": true, "Toolchain/Build/**": true, - "Build/**": true, + "Build/**": true }, "search.exclude": { "**/.git": true, "Toolchain/Local/**": true, "Toolchain/Tarballs/**": true, "Toolchain/Build/**": true, - "Build/**": true, + "Build/**": true }, - // Force clang-format to respect Ladybird's .clang-format style file. This is not necessary if you're not using the Microsoft C++ extension. - "C_Cpp.clang_format_style": "file", // Tab settings "editor.tabSize": 4, "editor.useTabStops": false, diff --git a/.devcontainer/features/vcpkg-cache/devcontainer-feature.json b/.devcontainer/features/vcpkg-cache/devcontainer-feature.json new file mode 100644 index 00000000000..80601215196 --- /dev/null +++ b/.devcontainer/features/vcpkg-cache/devcontainer-feature.json @@ -0,0 +1,27 @@ +{ + "name": "Caches Ladybird's vcpkg dependencies", + "id": "vcpkg-cache", + "version": "1.0.0", + "description": "Create a prebuilt vcpkg binary cache for Ladybird developer use", + "installsAfter": [ "./features/ladybird" ], + "containerEnv": { + "VCPKG_BINARY_SOURCES": ";files,/usr/local/share/vcpkg-binary-cache,read" + }, + "options": { + "release_triplet": { + "type": "boolean", + "default": true, + "description": "Build vcpkg dependencies with release configuration" + }, + "debug_triplet": { + "type": "boolean", + "default": false, + "description": "Build vcpkg dependencies with debug configuration" + }, + "sanitizer_triplet": { + "type": "boolean", + "default": false, + "description": "Build vcpkg dependencies with sanitizer configuration" + } + } +} diff --git a/.devcontainer/features/vcpkg-cache/install.sh b/.devcontainer/features/vcpkg-cache/install.sh new file mode 100644 index 00000000000..71bf8952344 --- /dev/null +++ b/.devcontainer/features/vcpkg-cache/install.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Prebuild ladybird's vcpkg dependencies +set -e + +# FIXME: Add some options to make this more flexible and usable by other projects +# FIXME: Find a way to do this without cloning ladybird + +cd /tmp + +CACHE_DIR=/usr/local/share/vcpkg-binary-cache +mkdir -p ${CACHE_DIR} + +# Clone ladybird to get access to vcpkg.json and vcpkg commit id +git clone https://github.com/LadybirdBrowser/ladybird.git --depth 1 +cd ladybird +# Grab and bootstrap the exact commit of vcpkg that trunk is using +python3 ./Toolchain/BuildVcpkg.py + +# Install the vcpkg.json in manifest mode from the root of the repo +# Set the binary cache directory to the one we intend to use at container runtime +export VCPKG_ROOT="${PWD}/Toolchain/Tarballs/vcpkg" +export VCPKG_BINARY_SOURCES="clear;files,${CACHE_DIR},readwrite" + +# Check options to see which versions we should build +if [ "${RELEASE_TRIPLET}" = "true" ]; then + ./Toolchain/Local/vcpkg/bin/vcpkg install --overlay-triplets="${PWD}/Meta/CMake/vcpkg/release-triplets" +fi + +if [ "${DEBUG_TRIPLET}" = "true" ]; then + ./Toolchain/Local/vcpkg/bin/vcpkg install --overlay-triplets="${PWD}/Meta/CMake/vcpkg/debug-triplets" +fi + +if [ "${SANITIZER_TRIPLET}" = "true" ]; then + ./Toolchain/Local/vcpkg/bin/vcpkg install --overlay-triplets="${PWD}/Meta/CMake/vcpkg/sanitizer-triplets" +fi + +# Clean up to reduce layer size +cd /tmp +rm -rf ladybird diff --git a/.github/workflows/dev-container.yml b/.github/workflows/dev-container.yml index 4dae7dc2f3f..41cf84f1e7f 100644 --- a/.github/workflows/dev-container.yml +++ b/.github/workflows/dev-container.yml @@ -6,6 +6,7 @@ on: push: paths: - '.devcontainer/**' + - 'vcpkg.json' schedule: # https://crontab.guru/#0_0_*_*_1 - cron: '0 0 * * 1'