Skip to content

Commit 37f3bd3

Browse files
committed
conan
1 parent 5d1bf0e commit 37f3bd3

File tree

7 files changed

+316
-0
lines changed

7 files changed

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

conan/conanfile.py

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

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