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

feat: Add libbasisu package 1.15.0 #6468

Merged

Conversation

mmatisko
Copy link
Contributor

@mmatisko mmatisko commented Jul 23, 2021

Specify library name and version: libbasisu/1.15.0

This is also a good place to share with all of us why you are submitting this PR (specially if it is a new addition to ConanCenter): is it a dependency of other libraries you want to package? Are you the author of the library? Thanks!

I'm not the author of this library, but it's is a dependency of for library we use and we would like to provide a Conan package for the simple use of anyone in the community.


  • I've read the guidelines for contributing.
  • I've followed the PEP8 style guides for Python code in the recipes.
  • I've used the latest Conan client version.
  • I've tried at least one configuration locally with the
    conan-center hook activated.

@CLAassistant
Copy link

CLAassistant commented Jul 23, 2021

CLA assistant check
All committers have signed the CLA.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

"sse": [True, False],
"x64": [True, False],
"zstd": [True, False],
"no_iterator_debug_level": [True, False]
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename this option such no double negations are possible. e.g. iterator_debug_level (and negate all tests, depending on it).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to custom_iterator_debug_level, I believe it's more readable and understandable now.

"sse": [True, False],
"x64": [True, False],
"zstd": [True, False],
"no_iterator_debug_level": [True, False]
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this option sets _ITERATOR_DEBUG_LEVEL.
This means that this option is only relevant for Visual Studio.
So please remove this option in config_options when self.settings.compiler != "Visual Studio".

self._cmake.definitions["BUILD_X64"] = self.options.x64
self._cmake.definitions["SSE"] = self.options.sse
self._cmake.definitions["ZSTD"] = self.options.zstd
self._cmake.definitions["BASISU_NO_ITERATOR_DEBUG_LEVEL"] = self.options.no_iterator_debug_level
Copy link
Contributor

@madebr madebr Jul 23, 2021

Choose a reason for hiding this comment

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

When you apply https://github.com/conan-io/conan-center-index/pull/6468/files#r675570927, you need to use self.options.get_safe("no_iterator_debug_level").

Suggested change
self._cmake.definitions["BASISU_NO_ITERATOR_DEBUG_LEVEL"] = self.options.no_iterator_debug_level
self._cmake.definitions["BASISU_NO_ITERATOR_DEBUG_LEVEL"] = self.options.no_iterator_debug_level

options = {
"fPIC": [True, False],
"shared": [True, False],
"sse": [True, False],
Copy link
Contributor

Choose a reason for hiding this comment

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

What level of sse support is this?
x86_64 demands a minimum level of sse support.
Is this for x86 support? Or is this for x86_64 with extra sse? e.g. SSE4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's support for SSE4.1, I renamed it to use_sse4.

"fPIC": [True, False],
"shared": [True, False],
"sse": [True, False],
"x64": [True, False],
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't create an option for a settings.
You should remove this option and use self.settings.arch == "x86_64" instead.

"shared": [True, False],
"sse": [True, False],
"x64": [True, False],
"zstd": [True, False],
Copy link
Contributor

Choose a reason for hiding this comment

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

When it means that an option will add support for an extra dependency, we usually add the with_ prefix.

Suggested change
"zstd": [True, False],
"with_zstd": [True, False],

"zstd": True,
"no_iterator_debug_level": True
}
short_paths = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking, is this really required?

Comment on lines 58 to 59
if not self._minimal_compiler_version():
raise ConanInvalidConfiguration("{} {} does not support Visual Studio <= 14 with shared:True".format(self.name, self.version))
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this to a validate method.

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

Choose a reason for hiding this comment

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

Is this clearing necessary? Does it bother the cmake build system?
If not, why remove it? I'ld just keep it.

Comment on lines +94 to +95
self.copy("*.h", dst=os.path.join("include", self.name, "transcoder"), src=os.path.join(self._source_subfolder, "transcoder"))
self.copy("*.h", dst=os.path.join("include", self.name, "encoder"), src=os.path.join(self._source_subfolder, "encoder"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you're already patching the cmake script,
consider adding this instead of the call to self.copy("*.h").

install(DIRECTORY transcoder DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libbasisu" FILES_MATCHING "*.h")
install(DIRECTORY encoder DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libbasisu" FILES_MATCHING "*.h")

or the following, if I screwed up the folders.

install(DIRECTORY transcoder DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libbasisu/transcoder" FILES_MATCHING "*.h")
install(DIRECTORY encoder DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libbasisu/encoder" FILES_MATCHING "*.h")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I only wanted to make necessary changes in the cmake script, I have moved all of the installation steps to the package method in conanfile.py. But the second proposal would be ok as well.


-if (NOT MSVC)
- target_link_libraries(basisu m pthread)
+if (MSVC)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can change this to WIN32. mingw also needs to export the symbols.


def _minimal_compiler_version(self) -> bool:
version = tools.Version(self.settings.compiler.version.value)
return (self.settings.compiler == "Visual Studio" and version >= "15") \
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a dict for this, it makes cleaner code. See other recipes on cci on how this can be done.
Also, unknown compiler should be allowed. A warning message can be printed then.

@conan-center-bot

This comment has been minimized.

@conan-center-bot

This comment has been minimized.

@mmatisko mmatisko force-pushed the feature/add-libbasisu-package branch from a4ad4aa to 2396c31 Compare July 27, 2021 18:15
@conan-center-bot

This comment has been minimized.

@SSE4 SSE4 requested a review from uilianries July 28, 2021 06:21
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,14 @@
-project(basisu)
Copy link
Contributor

Choose a reason for hiding this comment

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

As a general note, when you see a poor cmake script that needs to be patched (heavily).
It's always nice to also send the changes to the project itself. That way, upstream benefits too from your work.

madebr
madebr previously approved these changes Jul 28, 2021
Comment on lines 68 to 69
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)

Move it to validate() method, because it's validating the cppstd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not going to argue, but in official documentation is check_min_cppstd used in configure.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for pointing it. Indeed check_min_cppstd is older than validate and the documentation is outdated now. I'll open an PR updating it.

Comment on lines 80 to 81
custom_iterator_debug_level = self.options.get_safe("custom_iterator_debug_level", default="False")
self._cmake.definitions["BASISU_NO_ITERATOR_DEBUG_LEVEL"] = not custom_iterator_debug_level
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
custom_iterator_debug_level = self.options.get_safe("custom_iterator_debug_level", default="False")
self._cmake.definitions["BASISU_NO_ITERATOR_DEBUG_LEVEL"] = not custom_iterator_debug_level
self._cmake.definitions["BASISU_NO_ITERATOR_DEBUG_LEVEL"] = not self.options.get_safe("custom_iterator_debug_level", False)

Default won't be converted from String to Boolean.

Copy link
Contributor Author

@mmatisko mmatisko Jul 28, 2021

Choose a reason for hiding this comment

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

May I ask you for any possible and correct solution for this? As I can see it's quite common in other recipes, e.g. self._autotools.fpic = self.options.get_safe("fPIC", True) in the libpcap recipe and little bit lower in the documentation as well:

def build(self):
    # Will return None if doesn't exist
    fpic = self.options.get_safe("fPIC")
    # Will return the default value if the return is None
    shared = self.options.get_safe("shared", default=False)

Copy link
Contributor

Choose a reason for hiding this comment

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

uilian suggested to change the argument of the default argument from the string "False" to the boolean False.
.get_safe tries to convert a value to the type of the default value.

Related to your question, I would do:

fpic = self.options.get_safe("fPIC", True)  # Return True when fPIC is not available (it is often removed when built as a shared library)

Copy link
Member

Choose a reason for hiding this comment

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

Correct. Thanks!

Use default value of custom_iterator_debug_level in get_safe
@conan-center-bot
Copy link
Collaborator

All green in build 6 (b8c077018b2793d5f9a91db4d3fa0dae0ece9b49):

  • libbasisu/1.15.0@:
    All packages built successfully! (All logs)

Copy link
Contributor

@Croydon Croydon left a comment

Choose a reason for hiding this comment

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

Why was this package named libbasisu instead of basis_universal?

This looks wrong to me. There is also a command line tool which we might want to add at some point to this package

https://github.com/BinomialLLC/basis_universal#command-line-compression-tool

@madebr
Copy link
Contributor

madebr commented Jul 31, 2021

This library has vendored some libraries, which are available in cci.
See its README:

The encoder uses lodepng for loading and saving PNG images, which is Copyright (c) 2005-2019 Lode Vandevenne. It uses the zlib license. It also uses apg_bmp for loading BMP images, which is Copyright 2019 Anton Gerdelan. It uses the Apache 2.0 license.
The encoder optionally uses Zstandard's single source file compressor (in zstd/zstd.c) to support compressing supercompressed KTX2 files.

So in theory, lodepng and zstd should become requirements + libbasisu's build system modified to use these.

@conan-center-bot conan-center-bot merged commit 800cfb0 into conan-io:master Jul 31, 2021
@SpaceIm
Copy link
Contributor

SpaceIm commented Jul 31, 2021

I Agree with @Croydon, basis_univeral or basisu would have been more appropriate. Though, AFAIR, this project doesn't officially provide a lib anyway.

-option(STATIC "static linking" FALSE)
-option(SSE "SSE 4.1 support" FALSE)
+
+project(libbasisu VERSION 1.15.0 LANGUAGES CXX)
Copy link
Contributor

@SpaceIm SpaceIm Jul 31, 2021

Choose a reason for hiding this comment

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

Not a good idea to prefix project name with lib, then rely on it for library target.

Then you end up with ugly liblib file name:

libbasisu/1.15.0 package(): Packaged 1 '.a' file: liblibbasisu.a

@mmatisko
Copy link
Contributor Author

mmatisko commented Aug 2, 2021

Why was this package named libbasisu instead of basis_universal?

This looks wrong to me. There is also a command line tool which we might want to add at some point to this package

https://github.com/BinomialLLC/basis_universal#command-line-compression-tool

We named this package as libbasisu as we were inspired by the package names libcurl which is only a library, but curl itself is a standalone tool. We use this library (as a library, not with a tool) in our projects, so we chose a package name that is prefixed with "lib" so that it can be distinguished as a library-only package. We also wanted to do as little changes as possible to have a fully functional Conan package with a library. That is also the reason why we used bundled versions of zlib and lodepng libraries in this package. With the next version of the library, we could also provide an option for building a cmd tool (probably with a renamed package name basisu), if you insist. In the future, the suggested improvements might be added (e.g. utilization of the zlib and lodepng packages).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants