Skip to content

Commit

Permalink
Merge pull request #17 from Ultimaker/CURA-11622_conan_v2
Browse files Browse the repository at this point in the history
Cura 11622 conan v2
  • Loading branch information
wawanbreton authored Dec 4, 2024
2 parents 554ca97 + a359441 commit 948c3da
Show file tree
Hide file tree
Showing 47 changed files with 231 additions and 4,372 deletions.
79 changes: 29 additions & 50 deletions .github/workflows/conan-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,79 +4,58 @@ on:
push:
paths:
- 'recipes/**'
- '.github/workflows/conan-package.yml'
branches:
- main
- 'CURA-*'
- 'PP-*'
- 'NP-*'

workflow_call:
inputs:
recipes:
description: 'Path to the recipes to be exported, e.g. "recipes/clipper/all/conanfile.py recipes/sentrylibrary/all/conanfile.py". Leave empty to export all the recipes.'
default: ''
required: true
type: string

permissions:
contents: read

env:
CONAN_LOGIN_USERNAME: ${{ secrets.CONAN_USER }}
CONAN_PASSWORD: ${{ secrets.CONAN_PASS }}

jobs:
conan-package-export:
name: Conan Package Export

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup the build environment
uses: ultimaker/cura-workflows/.github/actions/setup-build-environment@main
with:
fetch-depth: 1
conan_user: ${{ secrets.CONAN_USER }}
conan_password: ${{ secrets.CONAN_PASS }}

- uses: technote-space/get-diff-action@v6
- uses: greguintow/get-diff-action@v7
id: get-diff
if: ${{ github.event_name == 'push' }}
with:
PATTERNS: |
recipes/**/*.*
- name: Sync pip requirements
run: wget https://raw.githubusercontent.com/Ultimaker/cura-workflows/main/.github/workflows/requirements-runner.txt -O .github/workflows/requirements-runner.txt

- name: Setup Python and pip
uses: actions/setup-python@v4
with:
python-version: 3.11.x
cache: pip
cache-dependency-path: .github/workflows/requirements-runner.txt

- name: Install Python requirements and Create default Conan profile
run: pip install -r .github/workflows/requirements-runner.txt

- name: Setup pipeline caches
- name: Get recipes list
id: get-recipes-list
run: |
mkdir -p /home/runner/.conan/downloads
mkdir -p /home/runner/.conan/data
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
recipes_list="${{ inputs.recipes }}"
else
recipes_list="${{ env.GIT_DIFF_FILTERED }}"
fi
- name: Create default Conan profile
run: conan profile new default --detect
if [ -z "$recipes_list" ]; then
recipes_list=$(find . -mindepth 4 -maxdepth 4 -iname "conanfile.py" -print0 | xargs -0 echo)
fi
- name: Get Conan configuration
run: |
conan config install https://github.com/Ultimaker/conan-config.git
conan config install https://github.com/Ultimaker/conan-config.git -a "-b runner/${{ runner.os }}/${{ runner.arch }}"
- name: Cache Conan packages
uses: actions/cache@v3
with:
path: /home/runner/.conan/data
key: ${{ runner.os }}-conan-data-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-conan-data-
- name: Cache Conan downloads
uses: actions/cache@v3
with:
path: /home/runner/.conan/downloads
key: ${{ runner.os }}-conan-downloads-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-conan-downloads-
echo "recipes_list=$recipes_list" >> $GITHUB_OUTPUT
# TODO: Change NP-346 to main once merged
- name: Export changed recipes
run: |
mkdir runner_scripts
wget https://raw.githubusercontent.com/Ultimaker/cura-workflows/NP-346/runner_scripts/upload_conan_recipes.py -O runner_scripts/upload_conan_recipes.py
python runner_scripts/upload_conan_recipes.py --user ultimaker --branch ${{ github.ref_name }} --remote cura ${{ env.GIT_DIFF_FILTERED }}
python Cura-workflows/runner_scripts/upload_conan_recipes.py --user ultimaker --branch ${{ github.ref_name }} --remote cura-conan2 ${{ steps.get-recipes-list.outputs.recipes_list }}
37 changes: 17 additions & 20 deletions recipes/clipper/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os

from shutil import which

from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.errors import ConanInvalidConfiguration
import os

required_conan_version = ">=1.54.0"
required_conan_version = ">=2.7.0"


class ClipperConan(ConanFile):
Expand All @@ -17,25 +18,35 @@ class ClipperConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://www.angusj.com/delphi/clipper.php"
settings = "os", "arch", "compiler", "build_type"
package_type = "library"
python_requires = "sentrylibrary/1.0.0"
python_requires_extend = "sentrylibrary.SentryLibrary"

options = {
"shared": [True, False],
"fPIC": [True, False],
"enable_sentry": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"enable_sentry": False,
}

def init(self):
base = self.python_requires["sentrylibrary"].module.SentryLibrary
self.options.update(base.options, base.default_options)

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
super().config_options()

if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
super().configure()

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

Expand All @@ -51,6 +62,7 @@ def generate(self):
tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
# To install relocatable shared libs on Macos
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"
self.setup_cmake_toolchain_sentry(tc)
tc.generate()

def build(self):
Expand All @@ -59,22 +71,7 @@ def build(self):
cmake.configure(build_script_folder=os.path.join(self.source_folder, "cpp"))
cmake.build()

sentry_project = self.conf.get("user.curaengine:sentry_project", "", check_type=str)
sentry_org = self.conf.get("user.curaengine:sentry_org", "", check_type=str)
if self.options.get_safe("enable_sentry", False) and os.environ.get('SENTRY_TOKEN', None) and sentry_project != "" and sentry_org != "":
if which("sentry-cli") is None:
self.output.warn("sentry-cli is not installed, skipping uploading debug symbols")
else:
if self.settings.os == "Linux":
self.output.info("Stripping debug symbols from binary")
ext = ".so" if self.options.shared else ".a"
self.run(f"objcopy --only-keep-debug --compress-debug-sections=zlib libpolyclipping{ext} libpolyclipping.debug")
self.run(f"objcopy --strip-debug --strip-unneeded libpolyclipping{ext}")
self.run(f"objcopy --add-gnu-debuglink=libpolyclipping.debug libpolyclipping{ext}")

build_source_dir = self.build_path.parent.parent.as_posix()
self.output.info("Uploading debug symbols to sentry")
self.run(f"sentry-cli --auth-token {os.environ['SENTRY_TOKEN']} debug-files upload --include-sources -o {sentry_org} -p {sentry_project} {build_source_dir}")
self.send_sentry_debug_files(binary_basename = "libpolyclipping")

def package(self):
copy(self, "License.txt", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
Expand Down
2 changes: 2 additions & 0 deletions recipes/clipper/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"6.4.2":
folder: all
"4.10.0":
folder: all
86 changes: 0 additions & 86 deletions recipes/cpython/all/conandata.yml

This file was deleted.

Loading

0 comments on commit 948c3da

Please sign in to comment.