Skip to content

Commit 91e8248

Browse files
committed
Updated OpenSSL version, fixed cppformat, added local docker environment for tests
1 parent 54a3e1e commit 91e8248

File tree

5 files changed

+57
-9
lines changed

5 files changed

+57
-9
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Language: Cpp
33
BasedOnStyle: Google
44
ColumnLimit: 80
55
IndentWidth: 2
6-
Standard: Cpp11
6+
Standard: c++17

.dev/Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM ubuntu:24.04
2+
3+
# Define Conan and CMake versions
4+
ARG CONAN_VERSION=2.6.0
5+
ARG CMAKE_VERSION=3.30.1
6+
7+
# Define User ID and Group ID
8+
ARG USER_ID=1000
9+
ARG GROUP_ID=1000
10+
11+
WORKDIR /project
12+
13+
# Define Labels
14+
LABEL maintainer="Michele Adduci <adduci@tutanota.com>" \
15+
description="Docker image for C++ development with Conan and CMake" \
16+
cmake.version="${CMAKE_VERSION}" \
17+
conan.version="${CONAN_VERSION}"
18+
19+
# Install basic tooling
20+
RUN apt-get update && \
21+
apt-get install -y \
22+
build-essential \
23+
curl \
24+
gcc \
25+
cppcheck \
26+
clang-format && \
27+
apt-get clean && \
28+
rm -rf /var/lib/apt/lists/*
29+
30+
# Install Conan and CMake from GitHub Releases
31+
RUN curl -fsSL https://github.com/conan-io/conan/releases/download/${CONAN_VERSION}/conan-${CONAN_VERSION}-amd64.deb -o /tmp/conan.deb && \
32+
dpkg -i /tmp/conan.deb && \
33+
curl -fsSL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz -o /tmp/cmake.tar.gz && \
34+
mkdir -p /opt/cmake && \
35+
tar -xzf /tmp/cmake.tar.gz -C /opt/cmake/ --strip-components=1 && \
36+
chmod +x /opt/cmake/bin/* && \
37+
ln -sf /opt/cmake/bin/cmake /usr/bin/cmake && \
38+
ln -sf /opt/cmake/bin/ctest /usr/bin/ctest && \
39+
ln -sf /opt/cmake/bin/cpack /usr/bin/cpack && \
40+
ln -sf /opt/cmake/bin/ccmake /usr/bin/ccmake && \
41+
rm -rf /tmp/*
42+
43+
# Create non-root user to run container with less privileges
44+
USER ${USER_ID}
45+
46+
# Run Conan profile detection as non-root user
47+
RUN conan profile detect

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ project(moderncpp-project LANGUAGES CXX DESCRIPTION "moderncpp-project is a star
1717

1818
# Set Project version (used for library versioning and for CPack)
1919
set(CMAKE_PROJECT_VERSION_MAJOR 1)
20-
set(CMAKE_PROJECT_VERSION_MINOR 0)
21-
set(CMAKE_PROJECT_VERSION_PATCH 0)
20+
set(CMAKE_PROJECT_VERSION_MINOR 1)
21+
set(CMAKE_PROJECT_VERSION_PATCH 2)
2222
set(CMAKE_PROJECT_VERSION ${CMAKE_PROJECT_VERSION_MAJOR}.${CMAKE_PROJECT_VERSION_MINOR}.${CMAKE_PROJECT_VERSION_PATCH})
2323

2424
# Set required C++ Standard

conanfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[requires]
2-
openssl/3.2.1
2+
openssl/3.2.2
33
doctest/2.4.11
44

55
[generators]

project/hellolib/src/hellolib.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,25 @@ int32_t hellolib::saySomethingHashed(
3030
return 1;
3131
}
3232

33-
EVP_MD_CTX *context = EVP_MD_CTX_new();
34-
if(context == NULL) {
33+
EVP_MD_CTX *context = EVP_MD_CTX_new();
34+
if (context == NULL) {
3535
std::cerr << "Failed to create context\n";
3636
return 2;
3737
}
3838

39-
if(1 != EVP_DigestInit_ex(context, EVP_sha256(), NULL)) {
39+
if (1 != EVP_DigestInit_ex(context, EVP_sha256(), NULL)) {
4040
std::cerr << "Failed to initialize context\n";
4141
return 3;
4242
}
4343

44-
if(1 != EVP_DigestUpdate(context, (unsigned char *)something.c_str(), something.size())) {
44+
if (1 != EVP_DigestUpdate(context, (unsigned char *)something.c_str(),
45+
something.size())) {
4546
std::cerr << "Failed to create hash value\n";
4647
return 4;
4748
}
4849

4950
std::array<unsigned char, 32> buffer{};
50-
if(1 != EVP_DigestFinal_ex(context, buffer.data(), NULL)) {
51+
if (1 != EVP_DigestFinal_ex(context, buffer.data(), NULL)) {
5152
std::cerr << "Failed to finalize hash result\n";
5253
return 5;
5354
}

0 commit comments

Comments
 (0)