Skip to content

Commit

Permalink
(#14291) jasper: Bump dependencies + update imports
Browse files Browse the repository at this point in the history
* jasper: Bump dependencies

Needed for #13988 and #14281

* block failing config + update imports

* fix extra del

* tix typo

* update save to new helper

* Update recipes/jasper/all/conanfile.py

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
  • Loading branch information
prince-chrismc and SpaceIm authored Dec 2, 2022
1 parent efd9d8e commit dfa430b
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions recipes/jasper/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from conans import ConanFile, CMake, tools
from conans import CMake
from conan import ConanFile
from conan.tools.files import get, save, rmdir, rm, replace_in_file, apply_conandata_patches, export_conandata_patches
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
import os
import textwrap

required_conan_version = ">=1.43.0"
required_conan_version = ">=1.53.0"


class JasperConan(ConanFile):
name = "jasper"
license = "JasPer License Version 2.0"
license = "JasPer-2.0"
homepage = "https://jasper-software.github.io/jasper"
url = "https://github.com/conan-io/conan-center-index"
topics = ("jasper", "tool-kit", "coding")
topics = ("tool-kit", "coding")
description = "JasPer Image Processing/Coding Tool Kit"

settings = "os", "arch", "compiler", "build_type"
Expand Down Expand Up @@ -38,27 +42,30 @@ def _build_subfolder(self):

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
del self.settings.compiler.cppstd
del self.settings.compiler.libcxx
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

def requirements(self):
if self.options.with_libjpeg == "libjpeg-turbo":
self.requires("libjpeg-turbo/2.1.2")
elif self.options.with_libjpeg == "libjpeg":
self.requires("libjpeg/9d")
self.requires("libjpeg/9e")

def validate(self):
if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version) == "16":
raise ConanInvalidConfiguration(f"{self.name} Current can not build in CCI due to windows SDK version. See https://github.com/conan-io/conan-center-index/pull/13285 for the solution hopefully")

def source(self):
tools.get(**self.conan_data["sources"][self.version],
get(self, **self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

def _configure_cmake(self):
Expand All @@ -74,8 +81,7 @@ def _configure_cmake(self):
return self._cmake

def _patch_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
apply_conandata_patches(self)
# Clean rpath in installed shared lib
cmakelists = os.path.join(self._source_subfolder, "CMakeLists.txt")
cmds_to_remove = [
Expand All @@ -84,7 +90,7 @@ def _patch_sources(self):
"set(CMAKE_INSTALL_RPATH\n \"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\")",
]
for cmd_to_remove in cmds_to_remove:
tools.replace_in_file(cmakelists, cmd_to_remove, "")
replace_in_file(self, cmakelists, cmd_to_remove, "")

def build(self):
self._patch_sources()
Expand All @@ -95,18 +101,16 @@ def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "share"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
if self.settings.os == "Windows":
for dll_prefix in ["concrt", "msvcp", "vcruntime"]:
tools.remove_files_by_mask(os.path.join(self.package_folder, "bin"),
"{}*.dll".format(dll_prefix))
rm(self, f"{dll_prefix}*.dll", os.path.join(self.package_folder, "bin"))
self._create_cmake_module_variables(
os.path.join(self.package_folder, self._module_file_rel_path)
)

@staticmethod
def _create_cmake_module_variables(module_file):
def _create_cmake_module_variables(self, module_file):
content = textwrap.dedent("""\
if(DEFINED Jasper_FOUND)
set(JASPER_FOUND ${Jasper_FOUND})
Expand All @@ -121,7 +125,7 @@ def _create_cmake_module_variables(module_file):
set(JASPER_VERSION_STRING ${Jasper_VERSION})
endif()
""")
tools.save(module_file, content)
save(self, module_file, content)

@property
def _module_file_rel_path(self):
Expand Down

0 comments on commit dfa430b

Please sign in to comment.