-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
71 lines (63 loc) · 2.42 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.files import load, copy
from conan.tools.scm import Git
import re
import os
class ImGuiImplD2DConan(ConanFile):
name = "ImGuiImplD2D"
description = "ImGUI Direct2D backend"
license = "MIT"
author = "Boguslaw Rymut ([email protected])"
topics = ("gui", "graphical", "bloat-free", "backend")
generators = "CMakeDeps"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
def set_version(self):
git = Git(self, self.recipe_folder)
try:
if git.is_dirty():
self.version = "cci_%s" % datetime.datetime.utcnow().strftime('%Y%m%dT%H%M%S')
except:
pass
try:
tag = git.run("describe --tags").strip()
if tag.startswith("v"):
tag = tag[1:].strip()
if re.match("^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", tag):
self.version = tag
return
except:
pass
try:
self.version = load(self, "version.semver").strip()
return
except:
pass
try:
self.version = "rev_%s" % git.get_commit().strip()
return
except:
pass
return None
def requirements(self):
self.requires("imgui/1.89.9")
def configure(self):
if self.settings.os == "Windows":
del self.options.fPIC
def layout(self):
cmake_layout(self)
def generate(self):
backends = os.path.join(self.export_sources_folder, "backends")
copy(self, "imgui_impl_sdlrenderer2.*", self.dependencies["imgui"].cpp_info.srcdirs[0], os.path.join(self.build_folder, "backends"))
copy(self, "imgui_impl_sdl2.*", self.dependencies["imgui"].cpp_info.srcdirs[0], os.path.join(self.build_folder, "backends"))
copy(self, "imgui_impl_win32.*", self.dependencies["imgui"].cpp_info.srcdirs[0], os.path.join(self.build_folder, "backends"))
tc = CMakeToolchain(self)
tc.generate()