Skip to content

Commit

Permalink
Meta: Add a vcpkg cache to the devcontainer
Browse files Browse the repository at this point in the history
This also means that the prebuilt devcontainer will have a populated
vcpkg binary cache, speeding up the first build by a lot.
  • Loading branch information
ADKaster committed Oct 13, 2024
1 parent d890d64 commit c3eb9d1
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
27 changes: 27 additions & 0 deletions .devcontainer/features/vcpkg-cache/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
39 changes: 39 additions & 0 deletions .devcontainer/features/vcpkg-cache/install.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .github/workflows/dev-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
paths:
- '.devcontainer/**'
- '.vcpkg.json'
schedule:
# https://crontab.guru/#0_0_*_*_1
- cron: '0 0 * * 1'
Expand Down

0 comments on commit c3eb9d1

Please sign in to comment.