Skip to content

Commit

Permalink
Conan update (#344)
Browse files Browse the repository at this point in the history
Update conan recipe
  • Loading branch information
Alex-PLACET authored Feb 12, 2025
1 parent ad38206 commit 851a2df
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 38 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/conan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,31 @@ jobs:
runs-on: ubuntu-24.04

steps:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Conan Environment
uses: hankhsu1996/[email protected]
with:
cache-dependencies: true
cache-tool: true
cache-dependencies: false
cache-tool: false

- name: Install conan dependencies
run: |
conan profile detect --force
conan install . --output-folder=build --build=missing -s:a compiler.cppstd=20 -o:a generate_documentation=True
conan install . --output-folder=build --build=missing -s:a compiler.cppstd=20 -o:a use_date_polyfill=True -o:a build_tests=True
- name: CMake configuration
run: cmake --preset conan-release -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON
run: |
cmake --preset conan-release \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON \
-DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
- name: Build
working-directory: build/build/Release
Expand All @@ -49,4 +58,11 @@ jobs:
echo "version=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH" >> $GITHUB_OUTPUT
- name: Conan create package
run: conan create . --version=${{ steps.extract-version.outputs.version }} -s:a build_type=Release --build=missing -s:a compiler.cppstd=20 -o:a generate_documentation=True
run: conan create . --version=${{ steps.extract-version.outputs.version }} -s:a build_type=Release --build=missing -s:a compiler.cppstd=20 -o:a use_date_polyfill=True

- name: Conan test package
run: conan test ./conan_test_package sparrow/${{ steps.extract-version.outputs.version }} -s:a build_type=Release --build=missing -s:a compiler.cppstd=20 -o:a use_date_polyfill=True

- name: Run sccache stat for check
shell: bash
run: ${SCCACHE_PATH} --show-stats
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ CMakeUserPresets.json

# MacOS
.DS_Store
conan_test_package/build
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,20 @@ message(STATUS "sparrow binary version: v${SPARROW_BINARY_VERSION}")
# =============

OPTION(BUILD_TESTS "Build sparrow test suite" OFF)
MESSAGE(STATUS "🔧 Build tests: ${BUILD_TESTS}")
OPTION(BUILD_DOCS "Build sparrow documentation" OFF)
MESSAGE(STATUS "🔧 Build docs: ${BUILD_DOCS}")
OPTION(BUILD_EXAMPLES "Build sparrow examples" OFF)
MESSAGE(STATUS "🔧 Build examples: ${BUILD_EXAMPLES}")
OPTION(USE_DATE_POLYFILL "Use date polyfill implementation" ON)
MESSAGE(STATUS "🔧 Use date polyfill: ${USE_DATE_POLYFILL}")
OPTION(USE_LARGE_INT_PLACEHOLDERS "use types without api for big integers" OFF)
MESSAGE(STATUS "🔧 Use large int placeholders: ${USE_LARGE_INT_PLACEHOLDERS}")
OPTION(SPARROW_TARGET_32BIT "Test 32bit support" OFF)
MESSAGE(STATUS "🔧 Test 32bit support: ${SPARROW_TARGET_32BIT}")

OPTION(ENABLE_COVERAGE "Enable test coverage" OFF)
MESSAGE(STATUS "🔧 Enable coverage: ${ENABLE_COVERAGE}")

if(ENABLE_COVERAGE)
include(code_coverage)
Expand All @@ -118,6 +125,7 @@ endif()
# =============

OPTION(ACTIVATE_LINTER "Create targets to run clang-format" OFF)
MESSAGE(STATUS "🔧 Activate linter: ${ACTIVATE_LINTER}")
cmake_dependent_option(ACTIVATE_LINTER_DURING_COMPILATION "Run linter during the compilation" ON "ACTIVATE_LINTER" OFF)

if(ACTIVATE_LINTER)
Expand Down
9 changes: 9 additions & 0 deletions conan_test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.28)
project(test_package LANGUAGES CXX)

find_package(sparrow REQUIRED CONFIG)

add_executable(standalone main.cpp)

target_link_libraries(standalone PRIVATE sparrow::sparrow)
target_compile_features(standalone PRIVATE cxx_std_20)
30 changes: 30 additions & 0 deletions conan_test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.microsoft import is_msvc
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def generate(self):
tc = CMakeToolchain(self)
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
self.run(os.path.join(self.cpp.build.bindirs[0], "standalone"), env="conanrun")
36 changes: 36 additions & 0 deletions conan_test_package/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <cassert>
#include <list>

#include <sparrow/builder/builder.hpp>

int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
{
// using initializer_list
auto arr = sparrow::build({1, 2, 3, 4, 5});
/////////////////////
// using vector
std::vector<int> v{1, 2, 3, 4, 5};
auto arr2 = sparrow::build(v);
/////////////////////
// using list
std::list<int> l{1, 2, 3, 4, 5};
auto arr3 = sparrow::build(l);
/////////////////////
// using any range
auto iota = std::views::iota(1, 6)
| std::views::transform(
[](int i)
{
return static_cast<int>(i);
}
);
auto arr4 = sparrow::build(iota);
/////////////////////
// all of the arrays above are equivalent to the manually built array
auto arr5 = sparrow::primitive_array<int>({1, 2, 3, 4, 5});
assert(arr == arr2);
assert(arr == arr3);
assert(arr == arr4);
assert(arr == arr5);
return EXIT_SUCCESS;
}
63 changes: 42 additions & 21 deletions conanfile.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import copy
from conan.tools.build.cppstd import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy
from conan.tools.microsoft import is_msvc
from conan.tools.scm import Version
import os

required_conan_version = ">=2.0"

class SparrowRecipe(ConanFile):
name = "sparrow"
Expand All @@ -14,26 +16,32 @@ class SparrowRecipe(ConanFile):
author = "Man Group"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/man-group/sparrow"
topics = ("arrow", "header-only")
topics = ("arrow", "apache arrow", "columnar format", "dataframe")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
package_type = "header-library"
no_copy_source = True
exports_sources = "include/*", "LICENSE"
generators = "CMakeDeps"
exports_sources = "include/*", "LICENSE", "src/*", "cmake/*", "docs/*", "CMakeLists.txt", "sparrowConfig.cmake.in"
options = {
"shared": [True, False],
"fPIC": [True, False],
"use_date_polyfill": [True, False],
"build_tests": [True, False],
"generate_documentation": [True, False],
}
default_options = {
"use_date_polyfill": True,
"shared": False,
"fPIC": True,
"use_date_polyfill": False,
"build_tests": False,
"generate_documentation": False,
}

def requirements(self):
if self.options.get_safe("use_date_polyfill"):
self.requires("date/3.0.1#032e24ad8bd1fd136dd33c932563d3d1")
self.test_requires("doctest/2.4.11")
self.test_requires("catch2/3.7.0")
self.requires("date/3.0.3")
if self.options.get_safe("build_tests"):
self.test_requires("doctest/2.4.11")
self.test_requires("catch2/3.7.0")

def build_requirements(self):
if self.options.get_safe("generate_documentation"):
Expand All @@ -46,10 +54,10 @@ def _min_cppstd(self):
@property
def _compilers_minimum_version(self):
return {
"apple-clang": "13",
"clang": "16",
"apple-clang": "16",
"clang": "18",
"gcc": "12",
"msvc": "193"
"msvc": "194"
}

def validate(self):
Expand All @@ -63,26 +71,39 @@ def validate(self):
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self)
cmake_layout(self, src_folder=".")

def generate(self):
tc = CMakeToolchain(self)
tc.variables["USE_DATE_POLYFILL"] = self.options.get_safe(
"use_date_polyfill", False)
tc.variables["BUILD_DOCS"] = self.options.get_safe(
"generate_documentation", False)
tc.variables["BUILD_TESTS"] = self.options.get_safe("build_tests", False)
if is_msvc(self):
tc.variables["USE_LARGE_INT_PLACEHOLDERS"] = True
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "LICENSE",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder)
copy(self, "*.hpp", self.source_folder, self.package_folder)
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []

def package_id(self):
self.info.clear()
self.cpp_info.libs = ["sparrow"]
self.cpp_info.set_property("cmake_file_name", "sparrow")
self.cpp_info.set_property("cmake_target_name", "sparrow::sparrow")
25 changes: 14 additions & 11 deletions sparrowConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
############################################################################
# Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht #
# Copyright (c) QuantStack
# #
# Distributed under the terms of the BSD 3-Clause License. #
# #
# The full license is in the file LICENSE, distributed with this software. #
# Copyright 2024 Man Group Operations Limited #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# http://www.apache.org/licenses/LICENSE-2.0 #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
############################################################################

# xparrow cmake module
# sparrow cmake module
# This module sets the following variables in your project::
#
# xparrow_FOUND - true if xparrow found on the system
# xparrow_INCLUDE_DIRS - the directory containing xparrow headers
# xparrow_LIBRARY - empty
# sparrow_FOUND - true if sparrow found on the system
# sparrow_INCLUDE_DIRS - the directory containing sparrow headers
# sparrow_LIBRARY - empty

@PACKAGE_INIT@

Expand All @@ -23,4 +27,3 @@ if(NOT TARGET sparrow::sparrow)
get_target_property(@PROJECT_NAME@_INCLUDE_DIRS sparrow::sparrow INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(@PROJECT_NAME@_LIBRARY sparrow::sparrow LOCATION)
endif()

2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
cmake_minimum_required(VERSION 3.28)

OPTION(FETCH_DEPENDENCIES_WITH_CMAKE "Fetch dependencies with CMake: Can be OFF, ON, or MISSING, in this case CMake download only dependencies which are not previously found." OFF)

MESSAGE(STATUS "🔧 FETCH_DEPENDENCIES_WITH_CMAKE: ${FETCH_DEPENDENCIES_WITH_CMAKE}")
enable_testing()

if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
Expand Down

0 comments on commit 851a2df

Please sign in to comment.