-
Notifications
You must be signed in to change notification settings - Fork 3
/
conanfile.py
66 lines (52 loc) · 2.65 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
from conans.model.conan_generator import Generator
from conans import ConanFile
class XmakeGenerator(ConanFile):
name = "xmake_generator"
version = "0.1.0"
url = "https://github.com/solvingj/conan-xmake_generator"
description = "Conan build generator for xmake build system"
topics = ("conan", "generator", "xmake", "tboox")
homepage = "https://github.com/tboox/xmake"
license = "MIT"
class xmake(Generator):
@property
def filename(self):
return "conanbuildinfo.xmake.lua"
@property
def content(self):
deps = XmakeDepsFormatter(self.deps_build_info)
# get plat
plat = str(self.settings.get_safe("os_build"))
# get mode
mode = str(self.settings.get_safe("build_type"))
# get arch
arch = str(self.settings.get_safe("arch_build"))
# make template
template = (' {plat}_{arch}_{mode} = \n'
' {{\n'
' includedirs = {{{deps.include_paths}}},\n'
' linkdirs = {{{deps.lib_paths}}},\n'
' links = {{{deps.libs}}},\n'
' defines = {{{deps.defines}}},\n'
' cxxflags = {{{deps.cppflags}}},\n'
' cflags = {{{deps.cflags}}},\n'
' shflags = {{{deps.sharedlinkflags}}},\n'
' ldflags = {{{deps.exelinkflags}}}\n'
' }}')
# make sections
sections = []
sections.append(template.format(plat = plat, arch = arch, mode = mode, deps = deps))
# make content
return "{\n" + ",\n".join(sections) + "\n}"
class XmakeDepsFormatter(object):
def __init__(self, deps_cpp_info):
self.include_paths = ",\n".join('"%s"' % p.replace("\\", "/") for p in deps_cpp_info.include_paths)
self.lib_paths = ",\n".join('"%s"' % p.replace("\\", "/") for p in deps_cpp_info.lib_paths)
self.bin_paths = ",\n".join('"%s"' % p.replace("\\", "/") for p in deps_cpp_info.bin_paths)
self.libs = ", ".join('"%s"' % p for p in deps_cpp_info.libs)
self.defines = ", ".join('"%s"' % p for p in deps_cpp_info.defines)
self.cppflags = ", ".join('"%s"' % p for p in deps_cpp_info.cppflags)
self.cflags = ", ".join('"%s"' % p for p in deps_cpp_info.cflags)
self.sharedlinkflags = ", ".join('"%s"' % p for p in deps_cpp_info.sharedlinkflags)
self.exelinkflags = ", ".join('"%s"' % p for p in deps_cpp_info.exelinkflags)
self.rootpath = "%s" % deps_cpp_info.rootpath.replace("\\", "/")