Changeset - r28361:99a1cc03aea0
[Not reviewed]
master
0 6 1
Patric Stout - 11 months ago 2023-12-30 17:00:24
truebrain@openttd.org
Change: add vcpkg.json to instruct vcpkg what dependencies we require

This works on all OSes, making it far simpler for any developer
to jump in. Just install vcpkg, run "vcpkg install" in our root,
and you have all the dependencies.
7 files changed with 79 insertions and 85 deletions:
0 comments (0 inline, 0 general)
.github/workflows/ci-build.yml
Show inline comments
 
@@ -132,15 +132,21 @@ jobs:
 
          liblzma-dev \
 
          liblzo2-dev \
 
          ${{ matrix.libraries }} \
 
          zlib1g-dev \
 
          # EOF
 

	
 
        sudo vcpkg install \
 
          breakpad \
 
          # EOF
 
        echo "::group::Install vcpkg dependencies"
 

	
 
        # Disable vcpkg integration, as we mostly use system libraries.
 
        mv vcpkg.json vcpkg-disabled.json
 

	
 
        # We only use breakpad from vcpkg, as its CMake files
 
        # are a bit special. So the Ubuntu's variant doesn't work.
 
        vcpkg install breakpad
 

	
 
        echo "::endgroup::"
 
      env:
 
        DEBIAN_FRONTEND: noninteractive
 

	
 
    - name: Get OpenGFX
 
      run: |
 
@@ -173,16 +179,21 @@ jobs:
 
        echo "Running on $(nproc) cores"
 
        cmake --build . -j $(nproc)
 
        echo "::endgroup::"
 

	
 
    - name: Test
 
      run: |
 
        cd build
 
        ctest -j $(nproc) --timeout 120
 
        (
 
          cd build
 
          ctest -j $(nproc) --timeout 120
 
        )
 

	
 
        # Check no tracked files have been modified
 
        # Re-enable vcpkg.
 
        mv vcpkg-disabled.json vcpkg.json
 

	
 
        # Check no tracked files have been modified.
 
        git diff --exit-code
 

	
 
  macos:
 
    strategy:
 
      fail-fast: false
 
      matrix:
 
@@ -205,23 +216,12 @@ jobs:
 
      with:
 
        script: |
 
          core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
 
          core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
 
          core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
 

	
 
    - name: Prepare vcpkg
 
      run: |
 
        vcpkg install --triplet=${{ matrix.arch }}-osx \
 
          breakpad \
 
          curl \
 
          liblzma \
 
          libpng \
 
          lzo \
 
          zlib \
 
          # EOF
 

	
 
    - name: Install OpenGFX
 
      run: |
 
        mkdir -p ~/Documents/OpenTTD/baseset
 
        cd ~/Documents/OpenTTD/baseset
 

	
 
        echo "::group::Download OpenGFX"
 
@@ -280,23 +280,12 @@ jobs:
 
      with:
 
        script: |
 
          core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
 
          core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
 
          core.exportVariable('VCPKG_BINARY_SOURCES', 'clear;x-gha,readwrite')
 

	
 
    - name: Prepare vcpkg
 
      shell: bash
 
      run: |
 
        vcpkg install --triplet=${{ matrix.arch }}-windows-static \
 
          breakpad \
 
          liblzma \
 
          libpng \
 
          lzo \
 
          zlib \
 
          # EOF
 

	
 
    - name: Install OpenGFX
 
      shell: bash
 
      run: |
 
        mkdir -p "C:/Users/Public/Documents/OpenTTD/baseset"
 
        cd "C:/Users/Public/Documents/OpenTTD/baseset"
 

	
.github/workflows/release-linux.yml
Show inline comments
 
@@ -129,34 +129,18 @@ jobs:
 
          ./bootstrap-vcpkg.sh -disableMetrics
 
        )
 

	
 
        # Make Python3 available for other packages. This needs to be done
 
        # first, as otherwise dependencies fail to build because Python3 is
 
        # not available.
 
        /vcpkg/vcpkg install python3
 
        ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3
 

	
 
        # SDL2 needs dbus, but dbus default install comes with libsystemd
 
        # and some of libsystemd deps fail to build on our quite old linux.
 
        # So just install basic dbus without any extra deps.
 
        /vcpkg/vcpkg install dbus[core]
 
        (
 
          cd /
 

	
 
        # Now we can install OpenTTD dependencies
 
        /vcpkg/vcpkg install \
 
          breakpad \
 
          curl[http2] \
 
          fontconfig \
 
          freetype \
 
          harfbuzz \
 
          icu \
 
          liblzma \
 
          libpng \
 
          lzo \
 
          sdl2 \
 
          zlib \
 
          # EOF
 
          /vcpkg/vcpkg install python3
 
          ln -sf /vcpkg/installed/x64-linux/tools/python3/python3.[0-9][0-9] /usr/bin/python3
 
        )
 
        echo "::endgroup::"
 

	
 
        echo "::group::Install breakpad dependencies"
 
        cargo install dump_syms
 
        echo "::endgroup::"
 

	
.github/workflows/release-macos.yml
Show inline comments
 
@@ -52,29 +52,12 @@ jobs:
 
        echo "::endgroup::"
 

	
 
        echo "::group::Install breakpad dependencies"
 
        cargo install dump_syms
 
        echo "::endgroup::"
 

	
 
    - name: Prepare vcpkg
 
      run: |
 
        vcpkg install \
 
          breakpad:x64-osx \
 
          breakpad:arm64-osx \
 
          curl:x64-osx \
 
          curl:arm64-osx \
 
          liblzma:x64-osx \
 
          liblzma:arm64-osx \
 
          libpng:x64-osx \
 
          libpng:arm64-osx \
 
          lzo:x64-osx \
 
          lzo:arm64-osx \
 
          zlib:x64-osx \
 
          zlib:arm64-osx \
 
          # EOF
 

	
 
    - name: Install GCC problem matcher
 
      uses: ammaraskar/gcc-problem-matcher@master
 

	
 
    - name: Build tools
 
      run: |
 
        mkdir build-host
.github/workflows/release-windows.yml
Show inline comments
 
@@ -61,29 +61,12 @@ jobs:
 
        echo "::endgroup::"
 

	
 
        echo "::group::Install breakpad dependencies"
 
        cargo install dump_syms
 
        echo "::endgroup::"
 

	
 
    - name: Prepare vcpkg
 
      shell: bash
 
      run: |
 
        vcpkg install --triplet=${{ matrix.arch }}-windows-static \
 
          liblzma \
 
          libpng \
 
          lzo \
 
          zlib \
 
          # EOF
 

	
 
        # arm64-windows-static is not (yet) supported for breakpad.
 
        if [ "${{ matrix.arch }}" != "arm64" ]; then
 
          vcpkg install --triplet=${{ matrix.arch }}-windows-static \
 
            breakpad \
 
            # EOF
 
        fi
 

	
 
    - name: Install MSVC problem matcher
 
      uses: ammaraskar/msvc-problem-matcher@master
 

	
 
    - name: Configure developer command prompt for tools
 
      uses: ilammy/msvc-dev-cmd@v1
 
      with:
.gitignore
Show inline comments
 
@@ -2,6 +2,7 @@
 
/build*
 
CMakeSettings.json
 
docs/aidocs/*
 
docs/gamedocs/*
 
docs/source/*
 
/out
 
/vcpkg_installed
COMPILING.md
Show inline comments
 
@@ -56,14 +56,14 @@ the `static` versions, and OpenTTD curre
 
- lzo
 
- zlib
 

	
 
To install both the x64 (64bit) and x86 (32bit) variants (though only one is necessary), you can use:
 

	
 
```ps
 
.\vcpkg install breakpad:x64-windows-static liblzma:x64-windows-static libpng:x64-windows-static lzo:x64-windows-static zlib:x64-windows-static
 
.\vcpkg install breakpad:x86-windows-static liblzma:x86-windows-static libpng:x86-windows-static lzo:x86-windows-static zlib:x86-windows-static
 
.\vcpkg install --triplet=x64-windows-static
 
.\vcpkg install --triplet=x86-windows-static
 
```
 

	
 
You can open the folder (as a CMake project). CMake will be detected, and you can compile from there.
 
If libraries are installed but not found, you need to set VCPKG_TARGET_TRIPLET in CMake parameters.
 
For Visual Studio 2017 you also need to set CMAKE_TOOLCHAIN_FILE.
 
(Typical values are shown in the MSVC project file command line example)
vcpkg.json
Show inline comments
 
new file 100644
 
{
 
  "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
 
  "dependencies": [
 
    {
 
      "name": "breakpad",
 
      "platform": "!(windows & arm)"
 
    },
 
    {
 
      "name": "curl",
 
      "platform": "linux",
 
      "features": [
 
        "http2"
 
      ]
 
    },
 
    {
 
      "name": "dbus",
 
      "platform": "linux",
 
      "default-features": false
 
    },
 
    {
 
      "name": "fontconfig",
 
      "platform": "linux"
 
    },
 
    {
 
      "name": "freetype",
 
      "platform": "linux"
 
    },
 
    {
 
      "name": "harfbuzz",
 
      "platform": "linux"
 
    },
 
    {
 
      "name": "icu",
 
      "platform": "linux"
 
    },
 
    {
 
      "name": "liblzma"
 
    },
 
    {
 
      "name": "libpng"
 
    },
 
    {
 
      "name": "lzo"
 
    },
 
    {
 
      "name": "sdl2",
 
      "platform": "linux"
 
    },
 
    {
 
      "name": "zlib"
 
    }
 
  ],
 
  "builtin-baseline": "94cf042e6b7713913a3b3150f3ca3d0f4550f7c4"
 
}
0 comments (0 inline, 0 general)