From 49db7bbe081f9f103df04fd0d30b8ffd31508a2b Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sat, 30 Dec 2023 18:00:24 +0100 Subject: [PATCH] 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. --- .github/workflows/ci-build.yml | 45 +++++++++------------- .github/workflows/release-linux.yml | 26 +++---------- .github/workflows/release-macos.yml | 17 --------- .github/workflows/release-windows.yml | 17 --------- .gitignore | 1 + COMPILING.md | 4 +- vcpkg.json | 54 +++++++++++++++++++++++++++ 7 files changed, 79 insertions(+), 85 deletions(-) create mode 100644 vcpkg.json diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index d646a3a7bf..e5e6e6e5a4 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -135,9 +135,15 @@ jobs: 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 @@ -176,10 +182,15 @@ jobs: - 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: @@ -208,17 +219,6 @@ jobs: 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 @@ -283,17 +283,6 @@ jobs: 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: | diff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.yml index 8a3fec19b5..e7151347dc 100644 --- a/.github/workflows/release-linux.yml +++ b/.github/workflows/release-linux.yml @@ -132,28 +132,12 @@ jobs: # 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 + ( + cd / - # 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] - - # 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" diff --git a/.github/workflows/release-macos.yml b/.github/workflows/release-macos.yml index 631584bc98..ca4d1ac412 100644 --- a/.github/workflows/release-macos.yml +++ b/.github/workflows/release-macos.yml @@ -55,23 +55,6 @@ jobs: 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 diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml index 3f7658083d..602c6050a0 100644 --- a/.github/workflows/release-windows.yml +++ b/.github/workflows/release-windows.yml @@ -64,23 +64,6 @@ jobs: 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 diff --git a/.gitignore b/.gitignore index 4eed0f0e47..3d0376aa94 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ docs/aidocs/* docs/gamedocs/* docs/source/* /out +/vcpkg_installed diff --git a/COMPILING.md b/COMPILING.md index 5ed519553e..578b5e4568 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -59,8 +59,8 @@ the `static` versions, and OpenTTD currently needs the following dependencies: 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. diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000000..15079f7a31 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,54 @@ +{ + "$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" +}