Skip to content

Commit

Permalink
add ubuntu 24 and gcc14/g++14
Browse files Browse the repository at this point in the history
  • Loading branch information
beats-dh committed Oct 13, 2024
1 parent c4786c4 commit b3faca3
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 18 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
os: [ubuntu-22.04, ubuntu-24.04]
buildtype: [linux-release, linux-debug]
include:
- os: ubuntu-22.04
triplet: x64-linux
- os: ubuntu-24.04
triplet: x64-linux

steps:
- name: Checkout repository
Expand All @@ -50,12 +52,21 @@ jobs:
run: >
sudo apt-get update && sudo apt-get install ccache linux-headers-$(uname -r)
- name: Switch to gcc-11
if: matrix.os == 'ubuntu-20.04'
- name: Switch to gcc-12 on Ubuntu 22.04
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt install gcc-12 g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 100 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12
sudo update-alternatives --set gcc /usr/bin/gcc-12
- name: Switch to gcc-14 on Ubuntu 24.04
if: matrix.os == 'ubuntu-24.04'
run: |
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update
sudo apt-get install gcc-14 g++-14 -y
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 --slave /usr/bin/g++ g++ /usr/bin/g++-14 --slave /usr/bin/gcov gcov /usr/bin/gcov-14
sudo update-alternatives --set gcc /usr/bin/gcc-14
- name: CCache
uses: hendrikmuhs/ccache-action@main
Expand Down
1 change: 0 additions & 1 deletion cmake/modules/CanaryLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ target_link_libraries(${PROJECT_NAME}_lib
spdlog::spdlog
unofficial::argon2::libargon2
unofficial::libmariadb
unofficial::mariadbclient
protobuf
)

Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/FindMySQL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ IF (WIN32)
ADD_DEFINITIONS(-DDBUG_OFF)
ENDIF (CMAKE_BUILD_TYPE STREQUAL Debug)

FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient libmariadb
FIND_LIBRARY(MYSQL_LIB NAMES mariadbclient libmariadb
PATHS
$ENV{MYSQL_DIR}/lib/${libsuffixDist}
$ENV{MYSQL_DIR}/libmysql
Expand Down
19 changes: 19 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,26 @@

#include "canary_server.hpp"
#include "lib/di/container.hpp"
// Define um conceito para garantir que a função só aceite contêineres de números
template<typename T>
concept NumberContainer = requires(T a) {
typename T::value_type;
requires std::integral<typename T::value_type> || std::floating_point<typename T::value_type>;
};

// Função que calcula a média de um contêiner de números
auto calculateAverage(const NumberContainer auto& container) {
// Utiliza ranges e std::views para processar o contêiner
return std::accumulate(container.begin(), container.end(), 0.0) / std::ranges::distance(container);
}

int main() {
std::vector<int> numbers = {1, 2, 3, 4, 5};

// Calcula a média usando a função com suporte a C++23
double average = calculateAverage(numbers);

std::cout << "Average: " << average << std::endl;

return inject<CanaryServer>().run();
}
7 changes: 4 additions & 3 deletions src/pch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@
#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/args.h>
#include <fmt/ranges.h>

// FMT Custom Formatter for Enums
template <typename E>
struct fmt::formatter<E, std::enable_if_t<std::is_enum_v<E>, char>> : formatter<std::underlying_type_t<E>> {
struct fmt::formatter<E, std::enable_if_t<std::is_enum_v<E>, char>> : fmt::formatter<std::underlying_type_t<E>> {
template <typename FormatContext>
auto format(E e, FormatContext &ctx) {
return formatter<std::underlying_type_t<E>>::format(
auto format(E e, FormatContext &ctx) const {
return fmt::formatter<std::underlying_type_t<E>>::format(
static_cast<std::underlying_type_t<E>>(e), ctx
);
}
Expand Down
9 changes: 2 additions & 7 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"bext-ut",
"curl",
"eventpp",
"libmariadb",
"luajit",
"magic-enum",
"mio",
Expand All @@ -23,12 +24,6 @@
"default-features": true,
"features": ["otlp-http", "prometheus"]
},
{
"name": "libmariadb",
"features": [
"mariadbclient"
]
},
{
"name": "gmp",
"platform": "linux"
Expand All @@ -38,5 +33,5 @@
"platform": "windows"
}
],
"builtin-baseline": "095ee06e7f60dceef7d713e3f8b1c2eb10d650d7"
"builtin-baseline": "9558037875497b9db8cf38fcd7db68ec661bffe7"
}

0 comments on commit b3faca3

Please sign in to comment.