12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- from conans import ConanFile, tools
- from conans.errors import ConanInvalidConfiguration
- from conans.tools import os_info
- import os
- class ZlibConan(ConanFile):
- name = "zlib"
- version = "1.2.11"
- license = "Zlib"
- author = "Shawn Morford <DarkMorford@Gmail.com>"
- url = "https://code.darkmorford.net/conan-pkg/zlib"
- description = "A Massively Spiffy Yet Delicately Unobtrusive Compression Library"
- homepage = "http://zlib.net/"
- topics = ("compression", "utility")
- exports_sources = ["patches/*"]
- settings = "os", "compiler", "build_type", "arch"
- options = {"shared": [True, False]}
- default_options = {"shared": False}
- @property
- def subfolder(self):
- return os.path.join(self.source_folder, f"zlib-{self.version}")
- def configure(self):
- del self.settings.compiler.cppstd
- del self.settings.compiler.libcxx
- def source(self):
- tools.get(**self.conan_data["sources"][self.version])
- for patch in self.conan_data["patches"][self.version]:
- tools.patch(base_path=self.subfolder, **patch)
- def _build_nmake(self):
- flags = [f"-{self.settings.compiler.runtime}"]
- if self.settings.build_type == "Debug":
- flags.append("-Od")
- else:
- flags.append("-O2")
- with tools.vcvars(self.settings), tools.chdir(self.subfolder):
- makefile = os.path.join("win32", "Makefile.msc")
- flags = " ".join(flags)
- self.run(f'nmake -f "{makefile}" LOC="{flags}"')
- def build(self):
- if self.settings.compiler == "Visual Studio" and os_info.is_windows:
- self._build_nmake()
- else:
- raise ConanInvalidConfiguration("This configuration is not yet supported.")
- def build_id(self):
- if self.settings.compiler == "Visual Studio":
- self.info_build.options.shared = "Both"
- def package(self):
- self.copy("*.h", dst="include", src="hello")
- self.copy("*hello.lib", dst="lib", keep_path=False)
- self.copy("*.dll", dst="bin", keep_path=False)
- self.copy("*.so", dst="lib", keep_path=False)
- self.copy("*.dylib", dst="lib", keep_path=False)
- self.copy("*.a", dst="lib", keep_path=False)
- def package_info(self):
- self.cpp_info.libs = ["hello"]
|