Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from Conan 1.x to 2.x #4417

Merged
merged 21 commits into from
Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,18 @@ jobs:
version: ${{ matrix.qt-version }}

# WINDOWS
- name: Cache conan packages part 1
if: startsWith(matrix.os, 'windows')
uses: actions/cache@v3
with:
key: ${{ runner.os }}-${{ matrix.crashpad }}-conan-user-${{ hashFiles('**/conanfile.txt') }}
path: ~/.conan/
- name: Setup conan variables (Windows)
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')
Expand All @@ -129,7 +128,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')
Expand All @@ -138,15 +137,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 `
Expand Down Expand Up @@ -192,9 +197,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
Expand Down
12 changes: 6 additions & 6 deletions BUILDING_ON_WINDOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,27 @@ 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

Open up your terminal with the Visual Studio environment variables (e.g. `x64 Native Tools Command Prompt for VS 2022`), cd to the cloned c2 directory and run the following commands:

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:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
52 changes: 52 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -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,
)
15 changes: 0 additions & 15 deletions conanfile.txt

This file was deleted.