-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconanfile.py
More file actions
96 lines (83 loc) · 3.68 KB
/
conanfile.py
File metadata and controls
96 lines (83 loc) · 3.68 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import copy as conan_copy
import os
import sys
import time
class DreamPicoPortConan(ConanFile):
name = "dream_pico_port_api"
version = "1.0.5"
package_type = "library"
license = "MIT"
author = "James M Smith"
url = "https://github.com/OrangeFox86/DreamPicoPort-API"
description = "USB-host-side API for host-mode DreamPicoPort"
topics = ["Maple Bus", "Sega", "Dreamcast", "retro", "gaming"]
settings = ["os", "compiler", "build_type", "arch"]
options = {
"shared": [True, False],
"fPIC": [True, False],
"tests": [True, False],
"with_libusb": [True, False]
}
default_options = {
"shared": False,
"libusb/*:shared": False,
"fPIC": True,
"tests": False,
"with_libusb": False
}
exports_sources = [
"CMakeLists.txt",
"src/*",
"test/*"
]
def requirements(self):
if self.options.get_safe("with_libusb", True):
self.requires("libusb/[>=1.0.26 <2.0.0]")
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
else:
# libusb is required for all other OSes
self.options.rm_safe("with_libusb")
def configure(self):
if self.options.get_safe("shared"):
self.options.rm_safe("fPIC")
def generate(self):
# This generates "conan_toolchain.cmake" in self.generators_folder
tc = CMakeToolchain(self)
tc.variables["DREAMPICOPORT_API_BUILD_SHARED_LIBS"] = bool(self.options.get_safe("shared", False))
tc.variables["DREAMPICOPORT_TESTS"] = bool(self.options.get_safe("tests", False))
if self.options.get_safe("with_libusb", True):
tc.variables["DREAMPICOPORT_WITH_LIBUSB"] = True
tc.variables["DREAMPICOPORT_USE_EXTERNAL_LIBUSB"] = True
tc.variables["DREAMPICOPORT_EXTERNAL_LIBUSB_PROJECT_NAME"] = "libusb"
tc.variables["DREAMPICOPORT_LIBUSB_LIBRARIES"] = "libusb::libusb"
else:
tc.variables["DREAMPICOPORT_WITH_LIBUSB"] = False
tc.generate()
# This generates "foo-config.cmake" and "bar-config.cmake" in self.generators_folder
deps = CMakeDeps(self)
deps.generate()
def build(self):
if self.options.get_safe("with_libusb", True) and self.settings.os == "Windows":
print("***\n*** WARNING: using libusb from conancenter is currently problematic for Windows builds\n***", file=sys.stderr)
time.sleep(3)
cmake = CMake(self)
cmake.configure(cli_args=["--no-warn-unused-cli"])
cmake.build()
def package(self):
cmake = CMake(self)
cmake.configure(cli_args=["--no-warn-unused-cli"])
cmake.install()
def package_info(self):
self.cpp_info.set_property("cmake_find_mode", "none")
self.cpp_info.builddirs.append("cmake")
def deploy(self):
conan_copy(self, "*", src=os.path.join(self.package_folder, "bin"), dst=os.path.join(self.deploy_folder, "bin"))
conan_copy(self, "*.so*", src=os.path.join(self.package_folder, "lib"), dst=os.path.join(self.deploy_folder, "lib"))
conan_copy(self, "*.dll", src=os.path.join(self.package_folder, "bin"), dst=os.path.join(self.deploy_folder, "bin"))
# .a and .lib files not are not needed for deployment
#conan_copy(self, "*.a*", src=os.path.join(self.package_folder, "lib"), dst=os.path.join(self.deploy_folder, "lib"))
#conan_copy(self, "*.lib*", src=os.path.join(self.package_folder, "lib"), dst=os.path.join(self.deploy_folder, "lib"))