diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c03dc20f92..cbb2d3045c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -108,19 +108,19 @@ jobs: version: ${{ matrix.qt-version }} # WINDOWS - - name: Cache conan packages part 1 + - name: Setup conan variables (Windows) if: startsWith(matrix.os, 'windows') - uses: actions/cache@v3 - with: - key: ${{ runner.os }}-${{ matrix.crashpad }}-conan-user-${{ hashFiles('**/conanfile.txt') }} - path: ~/.conan/ + run: | + "C2_USE_OPENSSL3=$(if ($Env:C2_BUILD_WITH_QT6 -eq "on") { "True" } else { "False" })" >> "$Env:GITHUB_ENV" + "C2_CONAN_CACHE_SUFFIX=$(if ($Env:C2_BUILD_WITH_QT6 -eq "on") { "-QT6" } else { "`" })" >> "$Env:GITHUB_ENV" + shell: powershell - - name: Cache conan packages part 2 + - name: Cache conan packages if: startsWith(matrix.os, 'windows') uses: actions/cache@v3 with: - key: ${{ runner.os }}-${{ matrix.crashpad }}-conan-root-${{ hashFiles('**/conanfile.txt') }} - path: C:/.conan/ + key: ${{ runner.os }}-conan-user-${{ hashFiles('**/conanfile.py') }}${{ env.C2_CONAN_CACHE_SUFFIX }} + path: ~/.conan2/ - name: Add Conan to path if: startsWith(matrix.os, 'windows') @@ -129,7 +129,7 @@ jobs: - name: Install dependencies (Windows) if: startsWith(matrix.os, 'windows') run: | - choco install conan -y --version 1.58.0 + choco install conan -y - name: Enable Developer Command Prompt if: startsWith(matrix.os, 'windows') @@ -138,15 +138,21 @@ jobs: - name: Setup Conan (Windows) if: startsWith(matrix.os, 'windows') run: | - conan profile new --detect --force default - conan profile update conf.tools.cmake.cmaketoolchain:generator="NMake Makefiles" default + conan --version + conan profile detect -f + shell: powershell - name: Build (Windows) if: startsWith(matrix.os, 'windows') run: | mkdir build cd build - conan install .. -s build_type=RelWithDebInfo -b missing -pr:b=default + conan install .. ` + -s build_type=RelWithDebInfo ` + -c tools.cmake.cmaketoolchain:generator="NMake Makefiles" ` + -b missing ` + --output-folder=. ` + -o with_openssl3="$Env:C2_USE_OPENSSL3" cmake ` -G"NMake Makefiles" ` -DCMAKE_BUILD_TYPE=RelWithDebInfo ` @@ -192,9 +198,9 @@ jobs: name: chatterino-windows-x86-64-${{ matrix.qt-version }}-symbols.pdb.7z path: build/bin/chatterino.pdb.7z - - name: Clean Conan pkgs + - name: Clean Conan cache if: startsWith(matrix.os, 'windows') - run: conan remove "*" -fsb + run: conan cache clean --source --build --download "*" shell: bash # LINUX diff --git a/BUILDING_ON_WINDOWS.md b/BUILDING_ON_WINDOWS.md index 027e0f23c89..29e3cc54a1f 100644 --- a/BUILDING_ON_WINDOWS.md +++ b/BUILDING_ON_WINDOWS.md @@ -79,16 +79,14 @@ Note: This installation will take about 200 MB of disk space. ### Using CMake -#### Install conan +#### Install conan 2 -Install [conan](https://conan.io/downloads.html) and make sure it's in your `PATH` (default setting). +Install [conan 2](https://conan.io/downloads.html) and make sure it's in your `PATH` (default setting). Then in a terminal, configure conan to use `NMake Makefiles` as its generator: 1. Generate a new profile - `conan profile new --detect --force default` -1. Configure the profile to use `NMake Makefiles` as its generator - `conan profile update conf.tools.cmake.cmaketoolchain:generator="NMake Makefiles" default` + `conan profile detect` #### Build @@ -96,10 +94,12 @@ Open up your terminal with the Visual Studio environment variables (e.g. `x64 Na 1. `mkdir build` 1. `cd build` -1. `conan install .. -s build_type=Release --build=missing` +1. `conan install .. -s build_type=Release -c tools.cmake.cmaketoolchain:generator="NMake Makefiles" --build=missing --output-folder=.` 1. `cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_PREFIX_PATH="C:\Qt\5.15.2\msvc2019_64" ..` 1. `nmake` +To build a debug build, you'll also need to add the `-s compiler.runtime_type=Debug` flag to the `conan install` invocation. See [this StackOverflow post](https://stackoverflow.com/questions/59828611/windeployqt-doesnt-deploy-qwindowsd-dll-for-a-debug-application/75607313#75607313) + #### Ensure DLLs are available Once Chatterino has finished building, to ensure all .dll's are available you can run this from the build directory: diff --git a/CHANGELOG.md b/CHANGELOG.md index 965ea6236b0..f3c0478bd4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Dev: Only log debug messages when NDEBUG is not defined. (#4442) - Dev: Cleaned up theme related code. (#4450) - Dev: Ensure tests have default-initialized settings. (#4498) +- Dev: Conan 2.0 is now used instead of Conan 1.0. (#4417) ## 2.4.2 diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 00000000000..7db329b8ba7 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,52 @@ +from conan import ConanFile +from conan.tools.files import copy +from os import path + + +class Chatterino(ConanFile): + name = "Chatterino" + requires = "boost/1.81.0" + settings = "os", "compiler", "build_type", "arch" + default_options = { + "with_benchmark": False, + "with_openssl3": False, + "openssl*:shared": True, + } + options = { + "with_benchmark": [True, False], + # Qt is built with OpenSSL 3 from version 6.5.0 onwards + "with_openssl3": [True, False], + } + generators = "CMakeDeps", "CMakeToolchain" + + def requirements(self): + if self.options.get_safe("with_benchmark", False): + self.requires("benchmark/1.7.1") + + if self.options.get_safe("with_openssl3", False): + self.requires("openssl/3.1.0") + else: + self.requires("openssl/1.1.1t") + + def generate(self): + copy_bin = lambda dep, selector, subdir: copy( + self, + selector, + dep.cpp_info.bindirs[0], + path.join(self.build_folder, subdir), + keep_path=False, + ) + for dep in self.dependencies.values(): + # macOS + copy_bin(dep, "*.dylib", "bin") + # Windows + copy_bin(dep, "*.dll", "bin") + copy_bin(dep, "*.dll", "Chatterino2") # used in CI + # Linux + copy( + self, + "*.so*", + dep.cpp_info.libdirs[0], + path.join(self.build_folder, "bin"), + keep_path=False, + ) diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index 52f1d9109aa..00000000000 --- a/conanfile.txt +++ /dev/null @@ -1,15 +0,0 @@ -[requires] -openssl/1.1.1s -boost/1.80.0 - -[generators] -CMakeDeps -CMakeToolchain - -[options] -openssl:shared=True - -[imports] -bin, *.dll -> ./bin @ keep_path=False -bin, *.dll -> ./Chatterino2 @ keep_path=False -lib, *.so* -> ./bin @ keep_path=False