Skip to content

Commit a79a00d

Browse files
Merge pull request #1 from Our-OpenLab/develop
Develop
2 parents 939e07e + d0cdcb0 commit a79a00d

File tree

122 files changed

+16660
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+16660
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This starter workflow is for a CMake project running on a single platform. There is a different starter workflow if you need cross-platform coverage.
2+
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
3+
name: CMake on a single platform
4+
5+
on:
6+
push:
7+
branches: [ "main" ]
8+
pull_request:
9+
branches: [ "main" ]
10+
11+
env:
12+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
13+
BUILD_TYPE: Release
14+
BUILD_TESTS: ON
15+
16+
jobs:
17+
build:
18+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
19+
# You can convert this to a matrix build if you need cross-platform coverage.
20+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
21+
runs-on: ubuntu-latest
22+
container:
23+
image: guillaumemichel1026/cvector:latest
24+
options: --privileged
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
29+
- name: Install Conan dependencies
30+
if: env.BUILD_TESTS == 'ON'
31+
run: |
32+
conan install . --output-folder=build --build=missing -s build_type=${{env.BUILD_TYPE}}
33+
34+
- name: Configure CMake
35+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
36+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
37+
run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
38+
-DBUILD_TESTS=${{env.BUILD_TESTS}} \
39+
-DCMAKE_TOOLCHAIN_FILE=build/Debug/generators/conan_toolchain.cmake
40+
41+
- name: Build
42+
# Build your program with the given configuration
43+
run: cmake --build build --config ${{env.BUILD_TYPE}}
44+
45+
- name: Test
46+
if: env.BUILD_TESTS == 'ON'
47+
run: ctest --test-dir build --output-on-failure
48+

.idea/material_theme_project_new.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CMakeLists.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_minimum_required(VERSION 3.30)
2+
project(cvector LANGUAGES C CXX)
3+
4+
option(BUILD_TESTS "Build tests" ON)
5+
6+
include_directories(include)
7+
8+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
9+
add_compile_options(-g -fprofile-arcs -ftest-coverage)
10+
add_link_options(-fprofile-arcs -ftest-coverage)
11+
endif()
12+
13+
add_library(cvector STATIC
14+
src/cvector_core.c
15+
src/cvector_insert_erase.c
16+
src/cvector_resize.c
17+
)
18+
19+
# Exemple d'utilisation
20+
add_executable(example examples/example_usage.c)
21+
target_link_libraries(example cvector)
22+
23+
# Tests
24+
if(BUILD_TESTS)
25+
enable_testing()
26+
find_package(GTest REQUIRED)
27+
28+
add_executable(test_cvector tests/test_cvector.cpp)
29+
target_link_libraries(test_cvector PRIVATE cvector gtest::gtest)
30+
add_test(NAME cvector_tests COMMAND test_cvector)
31+
endif()
32+
33+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
34+
find_program(GCOVR_EXECUTABLE gcovr REQUIRED)
35+
add_custom_target(coverage
36+
COMMAND ${GCOVR_EXECUTABLE} --root ${CMAKE_SOURCE_DIR} --filter ${CMAKE_SOURCE_DIR}/src/ --html --html-details --output coverage.html
37+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
38+
COMMENT "Generating code coverage report"
39+
)
40+
endif()

build.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
# Colors for output
4+
GREEN='\033[0;32m'
5+
RED='\033[0;31m'
6+
NC='\033[0m' # No color
7+
8+
# Directories
9+
BUILD_DIR="build"
10+
11+
# CMake options
12+
CMAKE_BUILD_TYPE="Debug" # Change to "Release" if needed
13+
BUILD_TESTS=ON # Enable or disable tests
14+
15+
echo -e "${GREEN}--- Configuring and building with CMake ---${NC}"
16+
17+
# Install Conan dependencies if tests are enabled
18+
if [ "$BUILD_TESTS" = "ON" ]; then
19+
echo -e "${GREEN}--- Installing dependencies with Conan ---${NC}"
20+
if ! conan install . --output-folder="$BUILD_DIR" --build=missing -s build_type="$CMAKE_BUILD_TYPE"; then
21+
echo -e "${RED}Conan dependency installation failed.${NC}"
22+
exit 1
23+
fi
24+
fi
25+
26+
# Configure and generate build files using CMake
27+
if ! cmake -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" -DBUILD_TESTS="$BUILD_TESTS" -DCMAKE_TOOLCHAIN_FILE="$BUILD_DIR/build/Debug/generators/conan_toolchain.cmake" .; then
28+
echo -e "${RED}CMake configuration failed.${NC}"
29+
exit 1
30+
fi
31+
32+
# Build the project
33+
if ! cmake --build "$BUILD_DIR" --config "$CMAKE_BUILD_TYPE"; then
34+
echo -e "${RED}Build failed.${NC}"
35+
exit 1
36+
fi
37+
38+
echo -e "${GREEN}--- Build completed successfully ---${NC}"
39+
40+
# Run tests if enabled
41+
if [ "$BUILD_TESTS" = "ON" ]; then
42+
echo -e "${GREEN}--- Running tests ---${NC}"
43+
if ! ctest --test-dir "$BUILD_DIR" --output-on-failure; then
44+
echo -e "${RED}Some tests failed.${NC}"
45+
exit 1
46+
fi
47+
echo -e "${GREEN}All tests passed successfully.${NC}"
48+
fi
49+
50+
echo -e "${GREEN}Script completed successfully.${NC}"

0 commit comments

Comments
 (0)