From bc1b8e06c07e5da5ba9a66d91811bf738c5f9ef1 Mon Sep 17 00:00:00 2001 From: trns1997 Date: Sun, 17 May 2026 17:26:43 +0200 Subject: [PATCH 1/2] fix and add conancreate packaging to ci --- .github/workflows/ci.yml | 17 ++++++++-- conan/all/conanfile.py | 69 +++++++++++++++++++++++++++++++++++++ conan/conanfile.py | 73 ++++++++++++++-------------------------- conanfile.py | 28 --------------- scripts/setup_build.sh | 2 +- 5 files changed, 110 insertions(+), 79 deletions(-) create mode 100644 conan/all/conanfile.py delete mode 100644 conanfile.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 242e2a1..b20e7b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Configure and build (Windows) if: runner.os == 'Windows' run: | - conan install conanfile.py -of=build/ \ + conan install conan/conanfile.py -of=build/ \ -pr:b conan/profile_windows_x86_64.txt \ -pr:h conan/profile_windows_x86_64.txt \ -o "&:unit_tests=True" \ @@ -75,6 +75,19 @@ jobs: run: ./kickmsg_microbench --benchmark_min_time=0.1s shell: bash + # Verify the Conan package recipe is well-formed and the package builds + # cleanly from the recipe (no local source leaking in). + conan-create: + name: Conan Create + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup-conan + + - name: conan create + run: conan create conan/all --version=0.0.0 --build=missing + shell: bash + # Cross-compile for ARM64 (no run — just verify it compiles) cross_arm64: name: Cross-compile (linux-aarch64) @@ -133,7 +146,7 @@ jobs: # PyPI project must list this repository + environment `maintainer` as # a trusted publisher). No API tokens stored in GitHub secrets. release: - needs: [build, cross_arm64, build-wheels] + needs: [build, conan-create, cross_arm64, build-wheels] if: startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-24.04 environment: diff --git a/conan/all/conanfile.py b/conan/all/conanfile.py new file mode 100644 index 0000000..fe39150 --- /dev/null +++ b/conan/all/conanfile.py @@ -0,0 +1,69 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMakeToolchain, CMakeDeps, CMake, cmake_layout +from conan.tools.files import copy +import os + +required_conan_version = ">=2.10.0" + + +class KickmsgRecipe(ConanFile): + name = "kickmsg" + license = "CeCILL-C" + url = "https://github.com/leducp/kickmsg" + description = "Lock-free shared-memory MPMC messaging library" + topics = ("ipc", "shared-memory", "lock-free", "pub-sub", "zero-copy") + package_type = "library" + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + def export_sources(self): + root = os.path.abspath(os.path.join(self.recipe_folder, "../..")) + copy(self, "CMakeLists.txt", src=root, dst=self.export_sources_folder) + copy(self, "include/*", src=root, dst=self.export_sources_folder) + copy(self, "src/*", src=root, dst=self.export_sources_folder) + copy(self, "cmake/*", src=root, dst=self.export_sources_folder) + copy(self, "LICENSE", src=root, dst=self.export_sources_folder) + + def configure(self): + if self.options.get_safe("shared"): + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, 17) + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["BUILD_UNIT_TESTS"] = "OFF" + tc.cache_variables["BUILD_BENCHMARKS"] = "OFF" + tc.cache_variables["BUILD_EXAMPLES"] = "OFF" + tc.cache_variables["ENABLE_TSAN"] = "OFF" + tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + copy(self, "LICENSE", src=self.source_folder, + dst=os.path.join(self.package_folder, "licenses")) + copy(self, "*.h", src=os.path.join(self.source_folder, "include"), + dst=os.path.join(self.package_folder, "include")) + copy(self, "*.a", src=self.build_folder, + dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "*.lib", src=self.build_folder, + dst=os.path.join(self.package_folder, "lib"), keep_path=False) + + def package_info(self): + self.cpp_info.libs = ["kickmsg"] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["rt", "pthread"] diff --git a/conan/conanfile.py b/conan/conanfile.py index e1b104b..6032f2a 100644 --- a/conan/conanfile.py +++ b/conan/conanfile.py @@ -1,55 +1,32 @@ from conan import ConanFile -from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -from conan.tools.files import copy -import os +class KickmsgDev(ConanFile): + """Local development conanfile — installs dependencies based on build options. -class KickmsgConan(ConanFile): - """Conan package recipe for kickmsg. - - For consumers: add kickmsg as a requirement in your conanfile: - self.requires("kickmsg/") + Options mirror those in scripts/configure.sh and CMakeLists.txt. + setup_build.sh passes them via -o when calling conan install. """ - name = "kickmsg" - license = "CeCILL-C" - url = "https://github.com/leducp/kickmsg" - description = "Lock-free shared-memory MPMC messaging library" - topics = ("ipc", "shared-memory", "lock-free", "pub-sub", "zero-copy") - settings = "os", "compiler", "build_type", "arch" - exports_sources = ( - "CMakeLists.txt", - "include/*", - "src/*", - "os/*", - "LICENSE", - ) - - def layout(self): - cmake_layout(self) - - def generate(self): - tc = CMakeToolchain(self) - tc.generate() - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def package(self): - copy(self, "LICENSE", src=self.source_folder, - dst=os.path.join(self.package_folder, "licenses")) - copy(self, "*.h", src=os.path.join(self.source_folder, "include"), - dst=os.path.join(self.package_folder, "include")) - copy(self, "*.a", src=self.build_folder, - dst=os.path.join(self.package_folder, "lib"), keep_path=False) - copy(self, "*.lib", src=self.build_folder, - dst=os.path.join(self.package_folder, "lib"), keep_path=False) - - def package_info(self): - self.cpp_info.libs = ["kickmsg"] - if self.settings.os == "Linux": - self.cpp_info.system_libs = ["rt", "pthread"] + options = { + "unit_tests": [True, False], + "benchmarks": [True, False], + } + default_options = { + "unit_tests": False, + "benchmarks": False, + } + + generators = "CMakeDeps" + + def requirements(self): + if self.options.unit_tests: + self.requires("gtest/1.15.0") + + if self.options.benchmarks: + self.requires("benchmark/1.9.1") + + def configure(self): + if self.options.unit_tests: + self.options["gtest"].build_gmock = True diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index f97c25a..0000000 --- a/conanfile.py +++ /dev/null @@ -1,28 +0,0 @@ -from conan import ConanFile - - -class KickmsgDev(ConanFile): - """Local development conanfile for kickmsg.""" - settings = "os", "compiler", "build_type", "arch" - - options = { - "unit_tests": [True, False], - "benchmarks": [True, False], - } - default_options = { - "unit_tests": False, - "benchmarks": False, - } - - generators = "CMakeDeps" - - def requirements(self): - if self.options.unit_tests: - self.requires("gtest/1.15.0") - - if self.options.benchmarks: - self.requires("benchmark/1.9.1") - - def configure(self): - if self.options.unit_tests: - self.options["gtest"].build_gmock = True diff --git a/scripts/setup_build.sh b/scripts/setup_build.sh index 5ad3380..1cb2287 100755 --- a/scripts/setup_build.sh +++ b/scripts/setup_build.sh @@ -259,7 +259,7 @@ fi # Conan install step "Installing Conan dependencies" info "Installing $BUILD_TYPE dependencies..." -conan install "$PROJECT_DIR/conanfile.py" -of="$build_dir" $CONAN_PROFILE_ARGS $CONAN_OPTIONS --build=missing -s build_type=$BUILD_TYPE +conan install "$PROJECT_DIR/conan/conanfile.py" -of="$build_dir" $CONAN_PROFILE_ARGS $CONAN_OPTIONS --build=missing -s build_type=$BUILD_TYPE # CMake configure step "Configuring CMake ($BUILD_TYPE)" From 208f36a2faafabe18314dccd209401346403d79b Mon Sep 17 00:00:00 2001 From: trns1997 Date: Sun, 17 May 2026 17:31:43 +0200 Subject: [PATCH 2/2] detect profile --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b20e7b3..b77e61b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,7 +85,9 @@ jobs: - uses: ./.github/actions/setup-conan - name: conan create - run: conan create conan/all --version=0.0.0 --build=missing + run: | + conan profile detect + conan create conan/all --version=0.0.0 --build=missing shell: bash # Cross-compile for ARM64 (no run — just verify it compiles)