-
Notifications
You must be signed in to change notification settings - Fork 4
/
conanfile.py
66 lines (54 loc) · 2.69 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 import Generator
from conans import ConanFile
class PremakeDeps(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("\\", "/")
class Premake(Generator):
@property
def filename(self):
return "conanpremake.lua"
@property
def content(self):
deps = PremakeDeps(self.deps_build_info)
template = ('conan_includedirs{dep} = {{{deps.include_paths}}}\n'
'conan_libdirs{dep} = {{{deps.lib_paths}}}\n'
'conan_bindirs{dep} = {{{deps.bin_paths}}}\n'
'conan_libs{dep} = {{{deps.libs}}}\n'
'conan_cppdefines{dep} = {{{deps.defines}}}\n'
'conan_cppflags{dep} = {{{deps.cppflags}}}\n'
'conan_cflags{dep} = {{{deps.cflags}}}\n'
'conan_sharedlinkflags{dep} = {{{deps.sharedlinkflags}}}\n'
'conan_exelinkflags{dep} = {{{deps.exelinkflags}}}\n')
sections = ["#!lua"]
all_flags = template.format(dep="", deps=deps)
sections.append(all_flags)
template_deps = template + 'conan_rootpath{dep} = "{deps.rootpath}"\n'
for dep_name, dep_cpp_info in self.deps_build_info.dependencies:
deps = PremakeDeps(dep_cpp_info)
dep_name = dep_name.replace("-", "_")
dep_flags = template_deps.format(dep="_" + dep_name, deps=deps)
sections.append(dep_flags)
return "\n".join(sections)
class MyCustomGeneratorPackage(ConanFile):
name = "PremakeGen"
version = "0.1"
url = "https://github.com/memsharded/conan-premake"
license = "MIT"
def build(self):
pass
def package_info(self):
self.cpp_info.includedirs = []
self.cpp_info.libdirs = []
self.cpp_info.bindirs = []