This repository has been archived by the owner on Jul 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
63 lines (55 loc) · 2.75 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
from conans import ConanFile, AutoToolsBuildEnvironment, tools
from conans.tools import SystemPackageTool
from conans.errors import ConanInvalidConfiguration
import os
class TinyMidiConan(ConanFile):
name = "tinymidi"
description = "A small C library for doing MIDI on GNU/Linux"
topics = ("conan", "tinymidi", "MIDI")
url = "https://github.com/bincrafters/conan-tinymidi"
homepage = "https://github.com/krgn/tinymidi"
license = "LGPL-3.0-only"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.settings.os != "Linux":
raise ConanInvalidConfiguration("Only Linux is supported")
def system_requirements(self):
if tools.os_info.with_apt:
if not tools.which("libtool"):
installer = SystemPackageTool()
installer.install("libtool-bin")
def source(self):
commit = os.path.splitext(os.path.basename(self.conan_data["sources"][self.version]["url"]))[0]
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + commit
os.rename(extracted_dir, self._source_subfolder)
def build(self):
with tools.chdir(self._source_subfolder):
tools.replace_in_file("Makefile",
"INSTALL_PREFIX=/usr",
"INSTALL_PREFIX=%s" % self.package_folder)
tools.replace_in_file("Makefile", "COMPILE_FLAGS = ", "COMPILE_FLAGS = $(CFLAGS) ")
tools.replace_in_file("Makefile", "LINKING_FLAGS = ", "LINKING_FLAGS = $(CFLAGS) ")
tools.mkdir(os.path.join(self.package_folder, 'include'))
tools.mkdir(os.path.join(self.package_folder, 'lib'))
env_build = AutoToolsBuildEnvironment(self)
env_build.make()
def package(self):
with tools.chdir(self._source_subfolder):
env_build = AutoToolsBuildEnvironment(self)
env_build.install()
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
if self.options.shared:
os.unlink(os.path.join(self.package_folder, "lib", "libtinymidi.a"))
else:
os.unlink(os.path.join(self.package_folder, "lib", "libtinymidi.so"))
os.unlink(os.path.join(self.package_folder, "lib", "libtinymidi.so.1"))
os.unlink(os.path.join(self.package_folder, "lib", "libtinymidi.so.1.0.0"))
def package_info(self):
self.cpp_info.libs = ["tinymidi"]