Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sail] Bump to 0.9.0-rc2, migrate to Conan V2 #14871

Merged
merged 47 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
174681e
Added libjpeg-turbo option
HappySeaFox May 9, 2022
52368da
Use SAIL_ENABLE_CODECS
HappySeaFox May 9, 2022
34f1bad
Merge branch 'conan-io:master' into master
HappySeaFox Sep 14, 2022
d6d97f8
[sail] Update to 0.9.0-rc1
HappySeaFox Sep 14, 2022
c51ac74
[sail] Fix linter errors
HappySeaFox Sep 14, 2022
e568f6d
[sail] Migrate to new CMake
HappySeaFox Sep 14, 2022
b67b8b8
[sail] Use apply_conandata_patches
HappySeaFox Sep 14, 2022
42daa05
[sail] Update libwebp 1.2.2 -> 1.2.3
HappySeaFox Sep 14, 2022
8b4a60b
[sail] Fix libjpeg-turbo target name
HappySeaFox Sep 14, 2022
6f803d3
[sail] Remove unused imports
HappySeaFox Sep 14, 2022
8253f0d
[sail] Refactor libjpeg-turbo usage
HappySeaFox Sep 14, 2022
0e17327
[sail] Added missing self
HappySeaFox Sep 14, 2022
2342849
[sail] Use copy from CMake tools
HappySeaFox Sep 14, 2022
6943c5f
[sail] Remove root CMakeLists and generators
HappySeaFox Sep 14, 2022
de8628c
[sail] Update avif rc1 patch
HappySeaFox Sep 15, 2022
fdf7e56
[sail] Remove CONFIG
HappySeaFox Sep 15, 2022
d1732e5
[sail] Disable pre23 for testing
HappySeaFox Sep 15, 2022
9828277
[sail] Disable AVIF for testing
HappySeaFox Sep 16, 2022
32e6dba
Merge branch 'conan-io:master' into master
HappySeaFox Sep 17, 2022
c0412d8
Merge branch 'conan-io:master' into master
HappySeaFox Sep 18, 2022
34c1c76
Merge branch 'conan-io:master' into master
HappySeaFox Sep 29, 2022
f3ca32f
Merge branch 'conan-io:master' into master
HappySeaFox Sep 30, 2022
5845240
Merge branch 'conan-io:master' into master
HappySeaFox Oct 25, 2022
6381acb
Merge branch 'conan-io:master' into master
HappySeaFox Dec 21, 2022
31238a6
Workaroud Windows SDK bug
HappySeaFox Dec 21, 2022
a3e5730
Update to RC2
HappySeaFox Dec 21, 2022
cfdc360
Bump versions
HappySeaFox Dec 21, 2022
a57aabd
Remove pre23 patch
HappySeaFox Dec 21, 2022
d7dd2ff
V1 test suite
HappySeaFox Dec 21, 2022
22b986f
Update RC1 to RC2 in config.yml
HappySeaFox Dec 21, 2022
ab21436
Added missing CMakeDeps
HappySeaFox Dec 21, 2022
aedc499
Enable AVIF
HappySeaFox Dec 21, 2022
4be1691
Update recipes/sail/all/conanfile.py
HappySeaFox Dec 22, 2022
54d618d
Update recipes/sail/all/conanfile.py
HappySeaFox Dec 22, 2022
54026de
Update recipes/sail/all/conanfile.py
HappySeaFox Dec 22, 2022
c8378ff
Update recipes/sail/all/test_v1_package/CMakeLists.txt
HappySeaFox Dec 22, 2022
b40dd8e
Use self.options.rm_safe("fPIC")
HappySeaFox Dec 22, 2022
a30971a
Fix typo
HappySeaFox Dec 22, 2022
bf7f479
Delete test_package.c
HappySeaFox Dec 24, 2022
f9bc2c9
Delete test_package.cpp
HappySeaFox Dec 24, 2022
f7dd4a3
Try workaround for check_c_source_compiles
HappySeaFox Jan 8, 2023
3256b14
Merge branch 'conan-io:master' into master
HappySeaFox Jan 8, 2023
0efcc6c
Test
HappySeaFox Jan 8, 2023
6bb710c
Try workaround for check_c_source_compiles for Windows only
HappySeaFox Jan 8, 2023
75681ff
Use str()
HappySeaFox Jan 9, 2023
986e7ca
Update libavif version
HappySeaFox Jan 9, 2023
c7bb959
Merge branch 'conan-io:master' into master
HappySeaFox Jan 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions recipes/sail/all/CMakeLists.txt

This file was deleted.

13 changes: 7 additions & 6 deletions recipes/sail/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
sources:
"0.9.0-pre23":
url: "https://github.com/smoked-herring/sail/archive/v0.9.0-pre23.tar.gz"
sha256: "6c5314561fda3d388b4653e7424cdf2ae2c65767e79203576804ca41fc930a6b"
"0.9.0-rc2":
url: "https://github.com/smoked-herring/sail/archive/v0.9.0-rc2.tar.gz"
sha256: "988d318fd4cfbc77ccbda49f4ac751d1998b990db157aef32b0dbd32d11f8fd6"
patches:
"0.9.0-pre23":
- patch_file: "patches/0.9.0-pre23-avif-find-package.patch"
base_path: "src"
"0.9.0-rc2":
- patch_file: "patches/0.9.0-rc2-avif-find-package.patch"
patch_type: "conan"
patch_description: "Make the AVIF codec use find_package()"
139 changes: 72 additions & 67 deletions recipes/sail/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from conan.tools.files import rename
from conans import ConanFile, CMake, tools
import functools
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, rename, rmdir
from conan.tools.microsoft import is_msvc
import os

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

class SAILConan(ConanFile):
name = "sail"
Expand All @@ -20,7 +21,7 @@ class SAILConan(ConanFile):
"with_avif": [True, False],
"with_gif": [True, False],
"with_jpeg2000": [True, False],
"with_jpeg": [True, False],
"with_jpeg": ["libjpeg", "libjpeg-turbo", False],
"with_png": [True, False],
"with_tiff": [True, False],
"with_webp": [True, False],
Expand All @@ -32,101 +33,105 @@ class SAILConan(ConanFile):
"with_avif": True,
"with_gif": True,
"with_jpeg2000": True,
"with_jpeg": True,
"with_jpeg": "libjpeg",
"with_png": True,
"with_tiff": True,
"with_webp": True,
}
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"

@property
def _source_subfolder(self):
return "src"

@property
def _build_subfolder(self):
return "build"

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
self.options.rm_safe("fPIC")

def configure(self):
if self.options.shared:
del self.options.fPIC
self.options.rm_safe("fPIC")

def requirements(self):
if self.options.with_avif:
self.requires("libavif/0.9.3")
self.requires("libavif/0.11.1")
if self.options.with_gif:
self.requires("giflib/5.2.1")
if self.options.with_jpeg2000:
self.requires("jasper/2.0.33")
HappySeaFox marked this conversation as resolved.
Show resolved Hide resolved
if self.options.with_jpeg:
self.requires("libjpeg/9d")
if self.options.with_jpeg == "libjpeg-turbo":
self.requires("libjpeg-turbo/2.1.4")
elif self.options.with_jpeg == "libjpeg":
self.requires("libjpeg/9e")
if self.options.with_png:
self.requires("libpng/1.6.37")
self.requires("libpng/1.6.39")
if self.options.with_tiff:
self.requires("libtiff/4.3.0")
self.requires("libtiff/4.4.0")
if self.options.with_webp:
self.requires("libwebp/1.2.2")
self.requires("libwebp/1.2.4")

def layout(self):
cmake_layout(self, src_folder="src")

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

@functools.lru_cache(1)
def _configure_cmake(self):
except_codecs = []

if not self.options.with_avif:
except_codecs.append("AVIF")
if not self.options.with_gif:
except_codecs.append("GIF")
if not self.options.with_jpeg2000:
except_codecs.append("JPEG2000")
if not self.options.with_jpeg:
except_codecs.append("JPEG")
if not self.options.with_png:
except_codecs.append("PNG")
if not self.options.with_tiff:
except_codecs.append("TIFF")
if not self.options.with_webp:
except_codecs.append("WEBP")
get(self, **self.conan_data["sources"][self.version],
strip_root=True, destination=self.source_folder)

cmake = CMake(self)
cmake.definitions["SAIL_BUILD_APPS"] = False
cmake.definitions["SAIL_BUILD_EXAMPLES"] = False
cmake.definitions["SAIL_BUILD_TESTS"] = False
cmake.definitions["SAIL_COMBINE_CODECS"] = True
cmake.definitions["SAIL_EXCEPT_CODECS"] = ";".join(except_codecs)
cmake.definitions["SAIL_INSTALL_PDB"] = False
cmake.definitions["SAIL_THREAD_SAFE"] = self.options.thread_safe
cmake.configure(build_folder=self._build_subfolder)
def generate(self):
enable_codecs = []

return cmake
if self.options.with_avif:
enable_codecs.append("avif")
if self.options.with_gif:
enable_codecs.append("gif")
if self.options.with_jpeg2000:
enable_codecs.append("jpeg2000")
if self.options.with_jpeg:
enable_codecs.append("jpeg")
if self.options.with_png:
enable_codecs.append("png")
if self.options.with_tiff:
enable_codecs.append("tiff")
if self.options.with_webp:
enable_codecs.append("webp")

tc = CMakeToolchain(self)
tc.variables["SAIL_BUILD_APPS"] = False
tc.variables["SAIL_BUILD_EXAMPLES"] = False
tc.variables["SAIL_BUILD_TESTS"] = False
tc.variables["SAIL_COMBINE_CODECS"] = True
tc.variables["SAIL_ENABLE_CODECS"] = ";".join(enable_codecs)
tc.variables["SAIL_INSTALL_PDB"] = False
tc.variables["SAIL_THREAD_SAFE"] = self.options.thread_safe
# TODO: Remove after fixing https://github.com/conan-io/conan/issues/12012
if is_msvc(self):
tc.cache_variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type)
# TODO: Remove after fixing https://github.com/conan-io/conan-center-index/issues/13159
# C3I workaround to force CMake to choose the highest version of
# the windows SDK available in the system
if is_msvc(self) and not self.conf.get("tools.cmake.cmaketoolchain:system_version"):
Comment on lines +107 to +110
Copy link
Contributor

@jwillikers jwillikers Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to avoid doing this outside of C3I? I know the Qt 6 recipe implements some special validation logic with if os.getenv('NOT_ON_C3I', '0') == '0': to only evaluate in C3I. This allows local devs to set the variable and override this behavior.

Not sure if this should be done, but I wanted to ask. @prince-chrismc Any thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Environment should be totally avoided on Conan 2.0, so conan config will be the best and safest approach. About Qt, that variable should be replace by a configuration too. As you should know, env vars are fragile, they can be easily replace, also, depending the user/profile they may change too, so it's not safe using them.

tc.variables["CMAKE_SYSTEM_VERSION"] = "10.0"
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
apply_conandata_patches(self)

cmake = self._configure_cmake()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
self.copy("LICENSE.txt", src=self._source_subfolder, dst="licenses")
self.copy("LICENSE.INIH.txt", src=self._source_subfolder, dst="licenses")
self.copy("LICENSE.MUNIT.txt", src=self._source_subfolder, dst="licenses")
cmake = self._configure_cmake()
copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "LICENSE.INIH.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "LICENSE.MUNIT.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))

cmake = CMake(self)
cmake.install()

# Remove CMake and pkg-config rules
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
# Move icons
rename(self, os.path.join(self.package_folder, "share"),
os.path.join(self.package_folder, "res"))
Expand Down Expand Up @@ -158,7 +163,7 @@ def package_info(self):
if self.options.with_jpeg2000:
self.cpp_info.components["sail-codecs"].requires.append("jasper::jasper")
if self.options.with_jpeg:
self.cpp_info.components["sail-codecs"].requires.append("libjpeg::libjpeg")
self.cpp_info.components["sail-codecs"].requires.append("{0}::{0}".format(self.options.with_jpeg))
if self.options.with_png:
self.cpp_info.components["sail-codecs"].requires.append("libpng::libpng")
if self.options.with_tiff:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
diff --git a/src/sail-codecs/avif/CMakeLists.txt b/src/sail-codecs/avif/CMakeLists.txt
index 870de541..1fe5a7e7 100644
index 3f36e0c8..1e31be83 100644
--- a/src/sail-codecs/avif/CMakeLists.txt
+++ b/src/sail-codecs/avif/CMakeLists.txt
@@ -1,7 +1,6 @@
-find_library(AVIF_LIBRARY avif)
-find_path(AVIF_INCLUDE_DIRS avif/avif.h)
+find_package(libavif CONFIG)
-find_library(AVIF_LIBRARY avif ${SAIL_CODEC_AVIF_REQUIRED_OPTION})
-find_path(AVIF_INCLUDE_DIRS avif/avif.h ${SAIL_CODEC_AVIF_REQUIRED_OPTION})
+find_package(libavif ${SAIL_CODEC_AVIF_REQUIRED_OPTION})

-if (NOT AVIF_LIBRARY OR NOT AVIF_INCLUDE_DIRS)
+if (NOT libavif_FOUND)
Expand Down
7 changes: 2 additions & 5 deletions recipes/sail/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(Sail REQUIRED CONFIG)

# C API
add_executable(test_package_c test_package.c)
target_compile_definitions(test_package_c PRIVATE SAIL_DEMO_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/png.png")
target_compile_definitions(test_package_c PRIVATE SAIL_DEMO_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/bmp.bmp")
target_link_libraries(test_package_c PRIVATE SAIL::Sail)

# C++ API
add_executable(test_package_cxx test_package.cpp)
target_compile_definitions(test_package_cxx PRIVATE SAIL_DEMO_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/png.png")
target_compile_definitions(test_package_cxx PRIVATE SAIL_DEMO_FILE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/bmp.bmp")
target_link_libraries(test_package_cxx PRIVATE SAIL::SailC++)
Binary file added recipes/sail/all/test_package/bmp.bmp
Binary file not shown.
24 changes: 16 additions & 8 deletions recipes/sail/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package_c")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package_c")
self.run(bin_path, env="conanrun")

bin_path = os.path.join("bin", "test_package_cxx")
self.run(bin_path, run_environment=True)
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package_cxx")
self.run(bin_path, env="conanrun")
Binary file removed recipes/sail/all/test_package/png.png
Binary file not shown.
2 changes: 1 addition & 1 deletion recipes/sail/all/test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, char *argv[])

struct sail_image *image;

SAIL_TRY_OR_EXECUTE(sail_load_image_from_file(SAIL_DEMO_FILE_PATH, &image),
SAIL_TRY_OR_EXECUTE(sail_load_from_file(SAIL_DEMO_FILE_PATH, &image),
/* on error */ return 1);

printf("Size: %ux%u, bytes per line: %u, "
Expand Down
8 changes: 8 additions & 0 deletions recipes/sail/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
Binary file added recipes/sail/all/test_v1_package/bmp.bmp
Binary file not shown.
20 changes: 20 additions & 0 deletions recipes/sail/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package_c")
self.run(bin_path, run_environment=True)

bin_path = os.path.join("bin", "test_package_cxx")
self.run(bin_path, run_environment=True)
2 changes: 1 addition & 1 deletion recipes/sail/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"0.9.0-pre23":
"0.9.0-rc2":
folder: all