Skip to content

Commit c0d4736

Browse files
committed
Add CI
1 parent 22f64d0 commit c0d4736

2 files changed

Lines changed: 292 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: DualViewPlugin
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
env:
9+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
10+
BUILD_TYPE: Release
11+
12+
# for matrix check https://docs.github.com/en/actions/reference/specifications-for-github-hosted-runners
13+
jobs:
14+
prepare_matrix:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
matrix: ${{ steps.matrix_setup.outputs.matrix }}
18+
steps:
19+
- name: Get matrix from file
20+
id: matrix_setup
21+
uses: ManiVaultStudio/github-actions/matrix_setup@main
22+
23+
cross-platform-build:
24+
name: Cross platform build
25+
needs: prepare_matrix
26+
# The CMake configure and build commands are platform agnostic and should work equally
27+
# well on Windows or Mac. You can convert this to a matrix build if you need
28+
# cross-platform coverage.
29+
# See: https://docs.github.com/en/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
matrix:
33+
include: ${{ fromJson(needs.prepare_matrix.outputs.matrix) }}
34+
35+
steps:
36+
- name: Checkout the source
37+
if: github.event_name != 'pull_request'
38+
uses: actions/checkout@v4
39+
with:
40+
submodules: recursive
41+
fetch-depth: 0
42+
43+
- name: Checkout the source - pull request
44+
if: github.event_name == 'pull_request'
45+
uses: actions/checkout@v4
46+
with:
47+
submodules: recursive
48+
fetch-depth: 0
49+
ref: ${{ github.event.pull_request.head.ref }}
50+
51+
- name: Select Xcode for Mac only
52+
if: startsWith(runner.os, 'macOS')
53+
run: |
54+
sudo xcode-select -switch /Applications/Xcode_${{matrix.build-xcode-version}}.app
55+
56+
- name: Setup python version
57+
uses: actions/setup-python@v5
58+
with:
59+
python-version: "3.11"
60+
61+
- name: Start ssh key agent
62+
uses: webfactory/ssh-agent@v0.9.0
63+
with:
64+
ssh-private-key: ${{ secrets.RULESSUPPORT_DEPLOY_KEY }}
65+
66+
- name: Install SSH deploy key for rulessupport
67+
uses: shimataro/ssh-key-action@v2
68+
with:
69+
key: ${{ secrets.RULESSUPPORT_DEPLOY_KEY }}
70+
known_hosts: github.com AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
71+
72+
- name: Windows build
73+
if: startsWith(runner.os, 'Windows')
74+
uses: ManiVaultStudio/github-actions/conan_windows_build@main
75+
with:
76+
conan-visual-version: ${{matrix.build-cversion}}
77+
conan-visual-runtime: ${{matrix.build-runtime}}
78+
conan-build-type: ${{matrix.build-config}}
79+
conan-user: ${{secrets.LKEB_UPLOAD_USER}}
80+
conan-password: ${{secrets.LKEB_UPLOAD_USER_PASSWORD}}
81+
conan-pem: ${{secrets.LKEB_UPLOAD_CERT_CHAIN}}
82+
rs_ssh_key: ${{ secrets.RULESSUPPORT_DEPLOY_KEY }}
83+
84+
- name: Linux build
85+
if: startsWith(matrix.os, 'ubuntu')
86+
uses: ManiVaultStudio/github-actions/conan_linuxmac_build@main
87+
with:
88+
conan-compiler: ${{matrix.build-compiler}}
89+
conan-compiler-version: ${{matrix.build-cversion}}
90+
conan-libcxx-version: ${{matrix.build-libcxx}}
91+
conan-build-type: ${{matrix.build-config}}
92+
conan-build-os: ${{matrix.build-os}}
93+
build-arch: ${{matrix.build-arch}}
94+
conan-user: ${{secrets.LKEB_UPLOAD_USER}}
95+
conan-password: ${{secrets.LKEB_UPLOAD_USER_PASSWORD}}
96+
conan-pem: ${{secrets.LKEB_UPLOAD_CERT_CHAIN}}
97+
conan-cc: gcc-${{matrix.build-cversion}}
98+
conan-cxx: g++-${{matrix.build-cversion}}
99+
100+
- name: Mac build
101+
if: startsWith(matrix.os, 'macos')
102+
uses: ManiVaultStudio/github-actions/conan_linuxmac_build@main
103+
with:
104+
conan-compiler: ${{matrix.build-compiler}}
105+
conan-compiler-version: ${{matrix.build-cversion}}
106+
conan-libcxx-version: ${{matrix.build-libcxx}}
107+
conan-build-type: ${{matrix.build-config}}
108+
conan-build-os: ${{matrix.build-os}}
109+
build-arch: ${{matrix.build-arch}}
110+
conan-user: ${{secrets.LKEB_UPLOAD_USER}}
111+
conan-password: ${{secrets.LKEB_UPLOAD_USER_PASSWORD}}
112+
conan-pem: ${{secrets.LKEB_UPLOAD_CERT_CHAIN}}

conanfile.py

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
from conans import ConanFile
2+
from conan.tools.cmake import CMakeDeps, CMake, CMakeToolchain
3+
from conans.tools import save, load
4+
from conans.tools import os_info, SystemPackageTool
5+
import os
6+
import shutil
7+
import pathlib
8+
import subprocess
9+
from rules_support import PluginBranchInfo
10+
11+
12+
class DualViewPluginConan(ConanFile):
13+
"""Class to package the plugin using conan
14+
15+
Packages both RELEASE and RELWITHDEBINFO.
16+
Uses rules_support (github.com/hdps/rulessupport) to derive
17+
versioninfo based on the branch naming convention
18+
as described in https://github.com/ManiVaultStudio/core/wiki/Branch-naming-rules
19+
"""
20+
21+
name = "DualViewPlugin"
22+
description = """Viewer for exploring cell-gene embeddings"""
23+
topics = ("manivault", "plugin", "viewer")
24+
url = "https://github.com/ManiVaultStudio/DualViewPlugin"
25+
author = "B. van Lew b.van_lew@lumc.nl" # conan recipe author
26+
license = "LGPL 3.0"
27+
28+
short_paths = True
29+
generators = "CMakeDeps"
30+
31+
# Options may need to change depending on the packaged library
32+
settings = {"os": None, "build_type": None, "compiler": None, "arch": None}
33+
options = {"shared": [True, False], "fPIC": [True, False]}
34+
default_options = {"shared": True, "fPIC": True}
35+
36+
37+
# Qt requirement is inherited from mv-core
38+
39+
scm = {
40+
"type": "git",
41+
"subfolder": "hdps/DualViewPlugin",
42+
"url": "auto",
43+
"revision": "auto",
44+
}
45+
46+
def __get_git_path(self):
47+
path = load(
48+
pathlib.Path(pathlib.Path(__file__).parent.resolve(), "__gitpath.txt")
49+
)
50+
print(f"git info from {path}")
51+
return path
52+
53+
def export(self):
54+
print("In export")
55+
# save the original source path to the directory used to build the package
56+
save(
57+
pathlib.Path(self.export_folder, "__gitpath.txt"),
58+
str(pathlib.Path(__file__).parent.resolve()),
59+
)
60+
61+
def set_version(self):
62+
# Assign a version from the branch name
63+
branch_info = PluginBranchInfo(self.recipe_folder)
64+
self.version = branch_info.version
65+
# print(f"Got version: {self.version}")
66+
67+
def requirements(self):
68+
branch_info = PluginBranchInfo(self.__get_git_path())
69+
print(f"Core requirement {branch_info.core_requirement}")
70+
self.requires(branch_info.core_requirement)
71+
72+
def configure(self):
73+
pass
74+
75+
def system_requirements(self):
76+
# if os_info.is_macos:
77+
# installer = SystemPackageTool()
78+
# installer.install("libomp")
79+
# proc = subprocess.run("brew --prefix libomp", shell=True, capture_output=True)
80+
# subprocess.run(f"ln {proc.stdout.decode('UTF-8').strip()}/lib/libomp.dylib /usr/local/lib/libomp.dylib", shell=True)
81+
# if os_info.is_linux:
82+
# self.run("sudo apt update && sudo apt install -y libtbb-dev")
83+
# cwd = pathlib.Path().resolve()
84+
# self.run("sudo apt update && sudo apt install -y libtbb-dev")
85+
# print(f"current working directory: {cwd}")
86+
# self.run("sudo ls cmake/")
87+
# self.run("sudo cp cmake/lkeb-artifactory-lumc-nl-chain.crt /usr/local/share/ca-certificates/")
88+
# self.run("sudo update-ca-certificates")
89+
# May be needed for macOS or Linux
90+
pass
91+
92+
def config_options(self):
93+
if self.settings.os == "Windows":
94+
del self.options.fPIC
95+
96+
def generate(self):
97+
generator = None
98+
if self.settings.os == "Macos":
99+
generator = "Xcode"
100+
if self.settings.os == "Linux":
101+
generator = "Ninja Multi-Config"
102+
103+
tc = CMakeToolchain(self, generator=generator)
104+
105+
tc.variables["CMAKE_CXX_STANDARD_REQUIRED"] = "ON"
106+
107+
# Use the Qt provided .cmake files
108+
qt_path = pathlib.Path(self.deps_cpp_info["qt"].rootpath)
109+
qt_cfg = list(qt_path.glob("**/Qt6Config.cmake"))[0]
110+
qt_dir = qt_cfg.parents[0].as_posix()
111+
112+
tc.variables["Qt6_DIR"] = qt_dir
113+
114+
# Use the ManiVault .cmake file to find ManiVault with find_package
115+
mv_core_root = self.deps_cpp_info["hdps-core"].rootpath
116+
manivault_dir = pathlib.Path(mv_core_root, "cmake", "mv").as_posix()
117+
print("ManiVault_DIR: ", manivault_dir)
118+
tc.variables["ManiVault_DIR"] = manivault_dir
119+
120+
# if os_info.is_macos:
121+
# proc = subprocess.run("brew --prefix libomp", shell=True, capture_output=True)
122+
# prefix_path = f"{proc.stdout.decode('UTF-8').strip()}"
123+
# tc.variables["OpenMP_ROOT"] = prefix_path
124+
125+
# Set some build options
126+
tc.variables["MV_UNITY_BUILD"] = "ON"
127+
128+
tc.generate()
129+
130+
131+
def _configure_cmake(self):
132+
cmake = CMake(self)
133+
cmake.configure(build_script_folder="hdps/DualViewPlugin")
134+
cmake.verbose = True
135+
return cmake
136+
137+
def build(self):
138+
print("Build OS is : ", self.settings.os)
139+
140+
cmake = self._configure_cmake()
141+
cmake.build(build_type="RelWithDebInfo")
142+
cmake.build(build_type="Release")
143+
144+
def package(self):
145+
package_dir = pathlib.Path(self.build_folder, "package")
146+
relWithDebInfo_dir = package_dir / "RelWithDebInfo"
147+
release_dir = package_dir / "Release"
148+
print("Packaging install dir: ", package_dir)
149+
subprocess.run(
150+
[
151+
"cmake",
152+
"--install",
153+
self.build_folder,
154+
"--config",
155+
"RelWithDebInfo",
156+
"--prefix",
157+
relWithDebInfo_dir,
158+
]
159+
)
160+
subprocess.run(
161+
[
162+
"cmake",
163+
"--install",
164+
self.build_folder,
165+
"--config",
166+
"Release",
167+
"--prefix",
168+
release_dir,
169+
]
170+
)
171+
self.copy(pattern="*", src=package_dir)
172+
173+
174+
def package_info(self):
175+
self.cpp_info.relwithdebinfo.libdirs = ["RelWithDebInfo/lib"]
176+
self.cpp_info.relwithdebinfo.bindirs = ["RelWithDebInfo/Plugins", "RelWithDebInfo"]
177+
self.cpp_info.relwithdebinfo.includedirs = ["RelWithDebInfo/include", "RelWithDebInfo"]
178+
self.cpp_info.release.libdirs = ["Release/lib"]
179+
self.cpp_info.release.bindirs = ["Release/Plugins", "Release"]
180+
self.cpp_info.release.includedirs = ["Release/include", "Release"]

0 commit comments

Comments
 (0)