Skip to content

Commit 4fa1abd

Browse files
committed
conan
1 parent 0538fa7 commit 4fa1abd

File tree

7 files changed

+316
-0
lines changed

7 files changed

+316
-0
lines changed

.github/workflows/ci.yml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,158 @@ jobs:
363363
api-key: ${{ secrets.NUGET_DOT_ORG_API_KEY }}
364364
if: startsWith(github.ref, 'refs/tags/')
365365

366+
##### conan - linux #####
367+
conan-linux:
368+
strategy:
369+
fail-fast: false
370+
matrix:
371+
include:
372+
- {os: debian, codename: bookworm, image_owner: }
373+
# - {os: debian, codename: bookworm, image_owner: i386/, labels: [i386,docker]}
374+
- {os: debian, codename: bookworm, image_owner: , labels: [arm32,docker]}
375+
- {os: debian, codename: bookworm, image_owner: , labels: [arm64,docker]}
376+
runs-on: ${{ (matrix.labels == '' && 'ubuntu-latest') || matrix.labels }}
377+
container: ${{ matrix.image_owner }}${{ matrix.os }}:${{ matrix.codename }}
378+
name: conan - linux | ${{ matrix.labels[0] }}
379+
steps:
380+
- name: add llvm repo (for clang-format)
381+
uses: myci-actions/add-deb-repo@main
382+
with:
383+
repo: deb http://apt.llvm.org/${{ matrix.codename }} llvm-toolchain-${{ matrix.codename }} main
384+
repo-name: llvm
385+
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
386+
install: clang-format clang-tidy
387+
- name: add cppfw deb repo
388+
uses: myci-actions/add-deb-repo@main
389+
with:
390+
repo: deb https://gagis.hopto.org/repo/cppfw/${{ matrix.os }} ${{ matrix.codename }} main
391+
repo-name: cppfw
392+
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
393+
install: devscripts equivs myci pipx cmake git
394+
- name: add ~/.local/bin to PATH
395+
uses: myci-actions/export-env-var@main
396+
with: {name: PATH, value: "$PATH:$HOME/.local/bin"}
397+
- name: install conan
398+
run: pipx install conan
399+
- name: create default conan profile
400+
run: |
401+
conan profile detect --name default
402+
sed -i -E "s/compiler.cppstd=.*$/compiler.cppstd=17/g" ~/.conan2/profiles/default
403+
- name: git clone
404+
uses: myci-actions/checkout@main
405+
- name: set PACKAGE_VERSION
406+
uses: myci-actions/export-env-var@main
407+
with: {name: PACKAGE_VERSION, value: $(myci-deb-version.sh debian/changelog)}
408+
if: startsWith(github.ref, 'refs/tags/')
409+
- name: build
410+
run: |
411+
conan remote add cppfw $MYCI_CONAN_REMOTE
412+
conan create conan --build=missing --user $MYCI_CONAN_USER --channel main --version $PACKAGE_VERSION
413+
- name: deploy conan package
414+
run: |
415+
conan remote login --password $MYCI_CONAN_PASSWORD cppfw $MYCI_CONAN_USER
416+
conan upload --check --remote cppfw $PACKAGE_NAME/$PACKAGE_VERSION@$MYCI_CONAN_USER/main
417+
if: startsWith(github.ref, 'refs/tags/')
418+
##### conan - macosx #####
419+
conan-macosx:
420+
strategy:
421+
fail-fast: false
422+
matrix:
423+
os:
424+
# - macos-10.15
425+
# - macos-11
426+
# - macos-12
427+
- macos-latest
428+
name: conan - ${{ matrix.os }}
429+
runs-on: ${{ matrix.os }}
430+
steps:
431+
- name: workaround python2 and python3 issue when upgrading python
432+
run : |
433+
rm -rf /usr/local/bin/2to3*
434+
rm -rf /usr/local/bin/idle3*
435+
rm -rf /usr/local/bin/pydoc3*
436+
rm -rf /usr/local/bin/python3
437+
rm -rf /usr/local/bin/python3-config
438+
rm -rf /usr/local/bin/python3*
439+
rm -rf /usr/local/bin/python3*-config
440+
- name: install clang-tidy and clang-format
441+
run: |
442+
brew install llvm
443+
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
444+
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
445+
ln -s "$(brew --prefix llvm)/bin/clang-apply-replacements" "/usr/local/bin/clang-apply-replacements"
446+
- name: git clone
447+
uses: myci-actions/checkout@main
448+
- name: add cppfw tap
449+
run: |
450+
brew tap cppfw/tap
451+
brew update
452+
- name: install ci tools
453+
run: brew install myci conan
454+
- name: create default conan profile
455+
run: |
456+
conan profile detect --name default
457+
sed -i -E "s/compiler.cppstd=.*$/compiler.cppstd=17/g" ~/.conan2/profiles/default
458+
- name: set PACKAGE_VERSION
459+
uses: myci-actions/export-env-var@main
460+
with: {name: PACKAGE_VERSION, value: $(myci-deb-version.sh debian/changelog)}
461+
if: startsWith(github.ref, 'refs/tags/')
462+
- name: build
463+
run: |
464+
conan remote add cppfw $MYCI_CONAN_REMOTE
465+
conan create conan --build=missing --user $MYCI_CONAN_USER --channel main --version $PACKAGE_VERSION
466+
- name: deploy conan package
467+
run: |
468+
conan remote login --password $MYCI_CONAN_PASSWORD cppfw $MYCI_CONAN_USER
469+
conan upload --check --remote cppfw $PACKAGE_NAME/$PACKAGE_VERSION@$MYCI_CONAN_USER/main
470+
if: startsWith(github.ref, 'refs/tags/')
471+
472+
##### conan - emscripten #####
473+
conan-emscripten:
474+
strategy:
475+
fail-fast: false
476+
matrix:
477+
include:
478+
# - {os: ubuntu, codename: noble, image_owner: }
479+
- {os: debian, codename: bookworm, image_owner: }
480+
# - {os: debian, codename: bookworm, image_owner: i386/, labels: [i386,docker]}
481+
# - {os: debian, codename: bookworm, image_owner: , labels: [arm32,docker]}
482+
# - {os: debian, codename: bookworm, image_owner: , labels: [arm64,docker]}
483+
runs-on: ${{ (matrix.labels == '' && 'ubuntu-latest') || matrix.labels }}
484+
container: ${{ matrix.image_owner }}${{ matrix.os }}:${{ matrix.codename }}
485+
name: conan - emscripten | ${{ matrix.labels[0] }}
486+
steps:
487+
- name: add cppfw deb repo
488+
uses: myci-actions/add-deb-repo@main
489+
with:
490+
repo: deb https://gagis.hopto.org/repo/cppfw/${{ matrix.os }} ${{ matrix.codename }} main
491+
repo-name: cppfw
492+
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
493+
install: devscripts equivs myci pipx cmake git nodejs
494+
- name: add ~/.local/bin to PATH
495+
uses: myci-actions/export-env-var@main
496+
with: {name: PATH, value: "$PATH:$HOME/.local/bin"}
497+
- name: install conan
498+
run: pipx install conan
499+
- name: create default conan profile
500+
run: |
501+
conan profile detect --name default
502+
sed -i -E "s/compiler.cppstd=.*$/compiler.cppstd=17/g" ~/.conan2/profiles/default
503+
- name: git clone
504+
uses: myci-actions/checkout@main
505+
with:
506+
submodules: false
507+
- name: set PACKAGE_VERSION
508+
uses: myci-actions/export-env-var@main
509+
with: {name: PACKAGE_VERSION, value: $(myci-deb-version.sh debian/changelog)}
510+
if: startsWith(github.ref, 'refs/tags/')
511+
- name: build
512+
run: |
513+
conan remote add cppfw $MYCI_CONAN_REMOTE
514+
# NOTE: specifying empty test folder to skip the test stage
515+
conan create conan --profile:build default --profile:host emscripten/conan.profile --build=missing --user $MYCI_CONAN_USER --channel main --version $PACKAGE_VERSION --test-folder ""
516+
- name: deploy conan package
517+
run: |
518+
conan remote login --password $MYCI_CONAN_PASSWORD cppfw $MYCI_CONAN_USER
519+
conan upload --check --remote cppfw $PACKAGE_NAME/$PACKAGE_VERSION@$MYCI_CONAN_USER/main
520+
if: startsWith(github.ref, 'refs/tags/')

conan/conanfile.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import os
2+
from conan import ConanFile
3+
from conan.tools.scm import Git
4+
from conan.tools.files import load, update_conandata, copy
5+
from conan.tools.layout import basic_layout
6+
7+
class RuisConan(ConanFile):
8+
name = "ruis"
9+
license = "MIT"
10+
author = "Ivan Gagis <[email protected]>"
11+
url = "http://github.com/cppfw/" + name
12+
description = "cross-platform GUI C++ library"
13+
topics = ("C++", "cross-platform")
14+
settings = "os", "compiler", "build_type", "arch"
15+
package_type = "library"
16+
options = {"shared": [True, False], "fPIC": [True, False]}
17+
default_options = {"shared": False, "fPIC": True}
18+
generators = "AutotoolsDeps" # this will set CXXFLAGS etc. env vars
19+
20+
def requirements(self):
21+
self.requires("utki/[>=1.1.202]@cppfw/main", transitive_headers=True, transitive_libs=True)
22+
self.requires("papki/[>=0.0.0]@cppfw/main", transitive_headers=True, transitive_libs=True)
23+
self.requires("svgren/[>=0.0.0]@cppfw/main", transitive_headers=False, transitive_libs=True)
24+
self.requires("rasterimage/[>=0.1.3]@cppfw/main", transitive_headers=True, transitive_libs=True)
25+
self.requires("tml/[>=0.0.0]@cppfw/main", transitive_headers=True, transitive_libs=True)
26+
self.requires("freetype/[>=0.0.0]", transitive_headers=False, transitive_libs=True)
27+
28+
def build_requirements(self):
29+
if self.settings.os != "Emscripten":
30+
self.requires("tst/[>=0.3.29]@cppfw/main", visible=False)
31+
self.tool_requires("prorab/[>=2.0.27]@cppfw/main")
32+
self.tool_requires("prorab-extra/[>=0.2.57]@cppfw/main")
33+
34+
def config_options(self):
35+
if self.settings.os == "Windows":
36+
del self.options.fPIC
37+
38+
# save commit and remote URL to conandata.yml for packaging
39+
def export(self):
40+
git = Git(self)
41+
scm_url = git.get_remote_url()
42+
# NOTE: Git.get_commit() doesn't work properly,
43+
# it gets latest commit of the folder in which conanfile.py resides.
44+
# So, we use "git rev-parse HEAD" instead as it gets the actual HEAD
45+
# commit regardless of the current working directory within the repo.
46+
scm_commit = git.run("rev-parse HEAD") # get current commit
47+
update_conandata(self, {"sources": {"commit": scm_commit, "url": scm_url}})
48+
49+
def source(self):
50+
git = Git(self)
51+
sources = self.conan_data["sources"]
52+
# shallow fetch commit
53+
git.fetch_commit(url=sources["url"], commit=sources['commit'])
54+
# shallow clone submodules
55+
git.run("submodule update --init --remote --depth 1")
56+
57+
def build(self):
58+
if self.settings.os == "Emscripten":
59+
self.run("make $MAKE_INCLUDE_DIRS_ARG config=wasm --directory=src")
60+
else:
61+
self.run("make $MAKE_INCLUDE_DIRS_ARG lint=off")
62+
self.run("make $MAKE_INCLUDE_DIRS_ARG lint=off test")
63+
64+
def package(self):
65+
if self.settings.os == "Emscripten":
66+
src_rel_dir = os.path.join(self.build_folder, "src/out/wasm")
67+
else:
68+
src_rel_dir = os.path.join(self.build_folder, "src/out/rel")
69+
70+
src_dir = os.path.join(self.build_folder, "src")
71+
dst_include_dir = os.path.join(self.package_folder, "include")
72+
dst_lib_dir = os.path.join(self.package_folder, "lib")
73+
dst_bin_dir = os.path.join(self.package_folder, "bin")
74+
copy(conanfile=self, pattern="*.h", dst=dst_include_dir, src=src_dir, keep_path=True)
75+
copy(conanfile=self, pattern="*.hpp", dst=dst_include_dir, src=src_dir, keep_path=True)
76+
77+
if self.options.shared:
78+
copy(conanfile=self, pattern="*" + self.name + ".lib", dst=dst_lib_dir, src="", keep_path=False)
79+
copy(conanfile=self, pattern="*.dll", dst=dst_bin_dir, src=src_rel_dir, keep_path=False)
80+
copy(conanfile=self, pattern="*.so", dst=dst_lib_dir, src=src_rel_dir, keep_path=False)
81+
copy(conanfile=self, pattern="*.so.*", dst=dst_lib_dir, src=src_rel_dir, keep_path=False)
82+
copy(conanfile=self, pattern="*.dylib", dst=dst_lib_dir, src=src_rel_dir, keep_path=False)
83+
else:
84+
copy(conanfile=self, pattern="*" + self.name + ".lib", dst=dst_lib_dir, src="", keep_path=False)
85+
copy(conanfile=self, pattern="*.a", dst=dst_lib_dir, src=src_rel_dir, keep_path=False)
86+
87+
def package_info(self):
88+
self.cpp_info.libs = [self.name]
89+
90+
def package_id(self):
91+
# change package id only when minor or major version changes, i.e. when ABI breaks
92+
self.info.requires.minor_mode()

conan/test_package/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(PackageTest CXX)
3+
4+
# set(CMAKE_VERBOSE_MAKEFILE on)
5+
6+
find_package(ruis CONFIG REQUIRED)
7+
8+
add_executable(example example.cpp)
9+
target_link_libraries(example ruis::ruis)

conan/test_package/conanfile.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
3+
from conan import ConanFile, tools
4+
from conan.tools.cmake import CMake, cmake_layout
5+
6+
class TestConan(ConanFile):
7+
settings = "os", "compiler", "build_type", "arch"
8+
generators = "CMakeToolchain", "CMakeDeps"
9+
10+
def requirements(self):
11+
self.requires(self.tested_reference_str)
12+
13+
def build(self):
14+
cmake = CMake(self)
15+
cmake.configure()
16+
cmake.build()
17+
18+
def layout(self):
19+
cmake_layout(self)
20+
21+
def test(self):
22+
self.run(".%sexample" % os.sep, env="conanrun") # env sets LD_LIBRARY_PATH etc. to find dependency libs

conan/test_package/example.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <ruis/util/length.hpp>
2+
3+
int main(int argc, const char** argv){
4+
ruis::length len(13);
5+
6+
std::cout << "hello ruis! len.is_undefined() = " << (len.is_undefined() ? "true" : "false") << std::endl;
7+
8+
return 0;
9+
}

config/wasm.mk

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
include $(config_dir)base/base.mk
2+
3+
this_cxxflags += -O3
4+
5+
this_cxx := em++
6+
this_cc := emcc
7+
this_ar := emar
8+
9+
this_static_lib_only = : true
10+
11+
# TODO: remove the warning suppression when the PR is merged
12+
# Suppress version-check warning due to https://github.com/conan-io/conan-center-index/pull/26247
13+
this_cxxflags += -Wno-version-check
14+
15+
this_cxxflags += -fwasm-exceptions
16+
this_ldflags += -fwasm-exceptions
17+
18+
this_cxxflags += -pthread
19+
this_ldflags += -pthread

emscripten/conan.profile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[settings]
2+
os=Emscripten
3+
arch=wasm
4+
compiler=clang
5+
compiler.version=15
6+
compiler.libcxx=libc++
7+
build_type=Release
8+
9+
[tool_requires]
10+
emsdk/[>=3.1.72]

0 commit comments

Comments
 (0)