Skip to content

Commit

Permalink
Merge pull request #2 from uilianries/tinycbor
Browse files Browse the repository at this point in the history
Fix Windows build for tinycbor
  • Loading branch information
ericriff authored Dec 20, 2019
2 parents 796fcd8 + 774eceb commit 30f2075
Showing 1 changed file with 40 additions and 15 deletions.
55 changes: 40 additions & 15 deletions recipes/tinycbor/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ class tinycborConan(ConanFile):
_env_build = None
_env_vars = []

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
# INFO: shared options does not work on Windows
del self.options.shared

def configure(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_autotools(self):
if not self._env_build:
self._env_build = AutoToolsBuildEnvironment(self)
Expand All @@ -31,33 +46,43 @@ def _configure_autotools(self):
self._env_build.fpic = self.options.fPIC
return self._env_build, self._env_vars

def configure(self):
if self.settings.os == "Windows":
self.options.remove("fPIC")
self.options.remove("shared") # Shared lib only supported on unix systems
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
def _build_nmake(self):
with tools.chdir(self._source_subfolder):
vcvars_command = tools.vcvars_command(self.settings)
self.run("%s && nmake -f Makefile.nmake" % vcvars_command)

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
def _build_make(self):
with tools.chdir(self._source_subfolder):
env_build, env_vars = self._configure_autotools()
env_build.make(vars=env_vars)

def build(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)
with tools.chdir(self._source_subfolder):
env_build, env_vars = self._configure_autotools()
env_build.make(vars=env_vars)
if self.settings.compiler == "Visual Studio":
self._build_nmake()
else:
self._build_make()

def package(self):
def _package_unix(self):
with tools.chdir(self._source_subfolder):
env_build, env_vars = self._configure_autotools()
env_build.install(vars=env_vars)
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "bin"))

def _package_visual(self):
self.copy("tinycbor.lib", src=os.path.join(self._source_subfolder, "lib"), dst="lib")
for header in ["cbor.h", "cborjson.h", "tinycbor-version.h"]:
self.copy(header, src=os.path.join(self._source_subfolder, "src"), dst="include")

def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
if self.settings.compiler == "Visual Studio":
self._package_visual()
else:
self._package_unix()

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Linux":
Expand Down

0 comments on commit 30f2075

Please sign in to comment.