Skip to content

Commit c585267

Browse files
committed
conan
1 parent 636384c commit c585267

File tree

8 files changed

+316
-2
lines changed

8 files changed

+316
-2
lines changed

.github/workflows/ci.yml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ env:
99
MYCI_NEXUS_PASSWORD: ${{ secrets.MYCI_NEXUS_PASSWORD }}
1010
MYCI_GIT_USERNAME: igagis
1111
MYCI_GIT_PASSWORD: ${{ secrets.MYCI_GIT_ACCESS_TOKEN }}
12+
MYCI_CONAN_REMOTE: https://gagis.hopto.org/conan
13+
MYCI_CONAN_USER: cppfw
14+
MYCI_CONAN_PASSWORD: ${{ secrets.MYCI_CONAN_PASSWORD }}
1215
jobs:
1316
##### deb linux #####
1417
deb:
@@ -197,3 +200,159 @@ jobs:
197200
# filename: '.\nuget\*.nupkg'
198201
# api-key: ${{ secrets.NUGET_DOT_ORG_API_KEY }}
199202
# if: startsWith(github.ref, 'refs/tags/')
203+
204+
##### conan - linux #####
205+
conan-linux:
206+
strategy:
207+
fail-fast: false
208+
matrix:
209+
include:
210+
- {os: debian, codename: bookworm, image_owner: }
211+
# - {os: debian, codename: bookworm, image_owner: i386/, labels: [i386,docker]}
212+
- {os: debian, codename: bookworm, image_owner: , labels: [arm32,docker]}
213+
- {os: debian, codename: bookworm, image_owner: , labels: [arm64,docker]}
214+
runs-on: ${{ (matrix.labels == '' && 'ubuntu-latest') || matrix.labels }}
215+
container: ${{ matrix.image_owner }}${{ matrix.os }}:${{ matrix.codename }}
216+
name: conan - linux | ${{ matrix.labels[0] }}
217+
steps:
218+
- name: add llvm repo (for clang-format)
219+
uses: myci-actions/add-deb-repo@main
220+
with:
221+
repo: deb http://apt.llvm.org/${{ matrix.codename }} llvm-toolchain-${{ matrix.codename }} main
222+
repo-name: llvm
223+
keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
224+
install: clang-format clang-tidy
225+
- name: add cppfw deb repo
226+
uses: myci-actions/add-deb-repo@main
227+
with:
228+
repo: deb https://gagis.hopto.org/repo/cppfw/${{ matrix.os }} ${{ matrix.codename }} main
229+
repo-name: cppfw
230+
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
231+
install: devscripts equivs myci pipx cmake git
232+
- name: add ~/.local/bin to PATH
233+
uses: myci-actions/export-env-var@main
234+
with: {name: PATH, value: "$PATH:$HOME/.local/bin"}
235+
- name: install conan
236+
run: pipx install conan
237+
- name: create default conan profile
238+
run: |
239+
conan profile detect --name default
240+
sed -i -E "s/compiler.cppstd=.*$/compiler.cppstd=17/g" ~/.conan2/profiles/default
241+
- name: git clone
242+
uses: myci-actions/checkout@main
243+
- name: set PACKAGE_VERSION
244+
uses: myci-actions/export-env-var@main
245+
with: {name: PACKAGE_VERSION, value: $(myci-deb-version.sh debian/changelog)}
246+
if: startsWith(github.ref, 'refs/tags/')
247+
- name: build
248+
run: |
249+
conan remote add cppfw $MYCI_CONAN_REMOTE
250+
conan create conan --build=missing --user $MYCI_CONAN_USER --channel main --version $PACKAGE_VERSION
251+
- name: deploy conan package
252+
run: |
253+
conan remote login --password $MYCI_CONAN_PASSWORD cppfw $MYCI_CONAN_USER
254+
conan upload --check --remote cppfw $PACKAGE_NAME/$PACKAGE_VERSION@$MYCI_CONAN_USER/main
255+
if: startsWith(github.ref, 'refs/tags/')
256+
##### conan - macosx #####
257+
conan-macosx:
258+
strategy:
259+
fail-fast: false
260+
matrix:
261+
os:
262+
# - macos-10.15
263+
# - macos-11
264+
# - macos-12
265+
- macos-latest
266+
name: conan - ${{ matrix.os }}
267+
runs-on: ${{ matrix.os }}
268+
steps:
269+
- name: workaround python2 and python3 issue when upgrading python
270+
run : |
271+
rm -rf /usr/local/bin/2to3*
272+
rm -rf /usr/local/bin/idle3*
273+
rm -rf /usr/local/bin/pydoc3*
274+
rm -rf /usr/local/bin/python3
275+
rm -rf /usr/local/bin/python3-config
276+
rm -rf /usr/local/bin/python3*
277+
rm -rf /usr/local/bin/python3*-config
278+
- name: install clang-tidy and clang-format
279+
run: |
280+
brew install llvm
281+
ln -s "$(brew --prefix llvm)/bin/clang-format" "/usr/local/bin/clang-format"
282+
ln -s "$(brew --prefix llvm)/bin/clang-tidy" "/usr/local/bin/clang-tidy"
283+
ln -s "$(brew --prefix llvm)/bin/clang-apply-replacements" "/usr/local/bin/clang-apply-replacements"
284+
- name: git clone
285+
uses: myci-actions/checkout@main
286+
- name: add cppfw tap
287+
run: |
288+
brew tap cppfw/tap
289+
brew update
290+
- name: install ci tools
291+
run: brew install myci conan
292+
- name: create default conan profile
293+
run: |
294+
conan profile detect --name default
295+
sed -i -E "s/compiler.cppstd=.*$/compiler.cppstd=17/g" ~/.conan2/profiles/default
296+
- name: set PACKAGE_VERSION
297+
uses: myci-actions/export-env-var@main
298+
with: {name: PACKAGE_VERSION, value: $(myci-deb-version.sh debian/changelog)}
299+
if: startsWith(github.ref, 'refs/tags/')
300+
- name: build
301+
run: |
302+
conan remote add cppfw $MYCI_CONAN_REMOTE
303+
conan create conan --build=missing --user $MYCI_CONAN_USER --channel main --version $PACKAGE_VERSION
304+
- name: deploy conan package
305+
run: |
306+
conan remote login --password $MYCI_CONAN_PASSWORD cppfw $MYCI_CONAN_USER
307+
conan upload --check --remote cppfw $PACKAGE_NAME/$PACKAGE_VERSION@$MYCI_CONAN_USER/main
308+
if: startsWith(github.ref, 'refs/tags/')
309+
310+
##### conan - emscripten #####
311+
conan-emscripten:
312+
strategy:
313+
fail-fast: false
314+
matrix:
315+
include:
316+
# - {os: ubuntu, codename: noble, image_owner: }
317+
- {os: debian, codename: bookworm, image_owner: }
318+
# - {os: debian, codename: bookworm, image_owner: i386/, labels: [i386,docker]}
319+
# - {os: debian, codename: bookworm, image_owner: , labels: [arm32,docker]}
320+
# - {os: debian, codename: bookworm, image_owner: , labels: [arm64,docker]}
321+
runs-on: ${{ (matrix.labels == '' && 'ubuntu-latest') || matrix.labels }}
322+
container: ${{ matrix.image_owner }}${{ matrix.os }}:${{ matrix.codename }}
323+
name: conan - emscripten | ${{ matrix.labels[0] }}
324+
steps:
325+
- name: add cppfw deb repo
326+
uses: myci-actions/add-deb-repo@main
327+
with:
328+
repo: deb https://gagis.hopto.org/repo/cppfw/${{ matrix.os }} ${{ matrix.codename }} main
329+
repo-name: cppfw
330+
keys-asc: https://gagis.hopto.org/repo/cppfw/pubkey.gpg
331+
install: devscripts equivs myci pipx cmake git nodejs
332+
- name: add ~/.local/bin to PATH
333+
uses: myci-actions/export-env-var@main
334+
with: {name: PATH, value: "$PATH:$HOME/.local/bin"}
335+
- name: install conan
336+
run: pipx install conan
337+
- name: create default conan profile
338+
run: |
339+
conan profile detect --name default
340+
sed -i -E "s/compiler.cppstd=.*$/compiler.cppstd=17/g" ~/.conan2/profiles/default
341+
- name: git clone
342+
uses: myci-actions/checkout@main
343+
with:
344+
submodules: false
345+
- name: set PACKAGE_VERSION
346+
uses: myci-actions/export-env-var@main
347+
with: {name: PACKAGE_VERSION, value: $(myci-deb-version.sh debian/changelog)}
348+
if: startsWith(github.ref, 'refs/tags/')
349+
- name: build
350+
run: |
351+
conan remote add cppfw $MYCI_CONAN_REMOTE
352+
# NOTE: specifying empty test folder to skip the test stage
353+
conan create conan --profile:build default --profile:host emscripten/conan.profile --build=missing --user $MYCI_CONAN_USER --channel main --version $PACKAGE_VERSION --test-folder ""
354+
- name: deploy conan package
355+
run: |
356+
conan remote login --password $MYCI_CONAN_PASSWORD cppfw $MYCI_CONAN_USER
357+
conan upload --check --remote cppfw $PACKAGE_NAME/$PACKAGE_VERSION@$MYCI_CONAN_USER/main
358+
if: startsWith(github.ref, 'refs/tags/')

conan/conanfile.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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 RuisRenderNullConan(ConanFile):
8+
name = "ruis-render-null"
9+
license = "MIT"
10+
author = "Ivan Gagis <igagis@gmail.com>"
11+
url = "http://github.com/cppfw/" + name
12+
description = "null renderer for ruis 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("ruis/[>=0.0.0]@cppfw/main", transitive_headers=True, transitive_libs=True)
22+
23+
def build_requirements(self):
24+
if self.settings.os != "Emscripten":
25+
self.requires("tst/[>=0.3.29]@cppfw/main", visible=False)
26+
self.tool_requires("prorab/[>=2.0.27]@cppfw/main")
27+
self.tool_requires("prorab-extra/[>=0.2.57]@cppfw/main")
28+
29+
def config_options(self):
30+
if self.settings.os == "Windows":
31+
del self.options.fPIC
32+
33+
# save commit and remote URL to conandata.yml for packaging
34+
def export(self):
35+
git = Git(self)
36+
scm_url = git.get_remote_url()
37+
# NOTE: Git.get_commit() doesn't work properly,
38+
# it gets latest commit of the folder in which conanfile.py resides.
39+
# So, we use "git rev-parse HEAD" instead as it gets the actual HEAD
40+
# commit regardless of the current working directory within the repo.
41+
scm_commit = git.run("rev-parse HEAD") # get current commit
42+
update_conandata(self, {"sources": {"commit": scm_commit, "url": scm_url}})
43+
44+
def source(self):
45+
git = Git(self)
46+
sources = self.conan_data["sources"]
47+
# shallow fetch commit
48+
git.fetch_commit(url=sources["url"], commit=sources['commit'])
49+
# shallow clone submodules
50+
git.run("submodule update --init --remote --depth 1")
51+
52+
def build(self):
53+
if self.settings.os == "Emscripten":
54+
self.run("make $MAKE_INCLUDE_DIRS_ARG config=wasm --directory=src")
55+
else:
56+
self.run("make $MAKE_INCLUDE_DIRS_ARG lint=off --directory=src")
57+
# self.run("make $MAKE_INCLUDE_DIRS_ARG lint=off test")
58+
59+
def package(self):
60+
if self.settings.os == "Emscripten":
61+
src_rel_dir = os.path.join(self.build_folder, "src/out/wasm")
62+
else:
63+
src_rel_dir = os.path.join(self.build_folder, "src/out/rel")
64+
65+
src_dir = os.path.join(self.build_folder, "src")
66+
dst_include_dir = os.path.join(self.package_folder, "include")
67+
dst_lib_dir = os.path.join(self.package_folder, "lib")
68+
dst_bin_dir = os.path.join(self.package_folder, "bin")
69+
copy(conanfile=self, pattern="*.h", dst=dst_include_dir, src=src_dir, keep_path=True)
70+
copy(conanfile=self, pattern="*.hpp", dst=dst_include_dir, src=src_dir, keep_path=True)
71+
72+
if self.options.shared:
73+
copy(conanfile=self, pattern="*" + self.name + ".lib", dst=dst_lib_dir, src="", keep_path=False)
74+
copy(conanfile=self, pattern="*.dll", dst=dst_bin_dir, src=src_rel_dir, keep_path=False)
75+
copy(conanfile=self, pattern="*.so", dst=dst_lib_dir, src=src_rel_dir, keep_path=False)
76+
copy(conanfile=self, pattern="*.so.*", dst=dst_lib_dir, src=src_rel_dir, keep_path=False)
77+
copy(conanfile=self, pattern="*.dylib", dst=dst_lib_dir, src=src_rel_dir, keep_path=False)
78+
else:
79+
copy(conanfile=self, pattern="*" + self.name + ".lib", dst=dst_lib_dir, src="", keep_path=False)
80+
copy(conanfile=self, pattern="*.a", dst=dst_lib_dir, src=src_rel_dir, keep_path=False)
81+
82+
def package_info(self):
83+
self.cpp_info.libs = [self.name]
84+
85+
def package_id(self):
86+
# change package id only when minor or major version changes, i.e. when ABI breaks
87+
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-render-null::ruis-render-null)

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/render/null/renderer.hpp>
2+
3+
int main(int argc, const char** argv){
4+
auto r = utki::make_shared<ruis::render::null::renderer>();
5+
6+
std::cout << "hello ruis-render-null! viewport = " << r.get().get_viewport() << 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

debian/control.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Build-Depends:
88
prorab-extra,
99
clang-format,
1010
clang-tidy,
11-
libruis-dev (>= 0.5.210),
12-
libglew-dev
11+
libruis-dev (>= 0.5.210)
1312
Build-Depends-Indep: doxygen
1413
Standards-Version: 3.9.2
1514

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)