-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
libxls: add recipe #12152
Merged
Merged
libxls: add recipe #12152
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a6ae57e
libxls: add recipe
toge 0524b7d
fix KB of cci
toge 1664dfc
skip pylint in test_V1_package
toge e65f0b4
set HAVE_XLOCALE
toge b1baa1f
link libiconv
toge e90c838
don't link iconv on macos
toge 7499736
link iconv in CMakeLists.txt
toge cee4d69
fix package name
toge a119d5d
support ssize_t in MSVC
toge 145c4e2
follow conan v2
toge 6b8f856
fix self.options.shared wrong usage
toge c211c3a
replace restrict for msvc 15
toge 90c589a
use autotools
uilianries 84a725c
not autoreconf
uilianries 09672fc
Windows build
uilianries fb55723
license
uilianries 0b80d99
Merge pull request #3 from uilianries/libxls-add-recipe
toge 9c59a4a
update conan 1.52.0
toge 1a393d7
fix rpl_malloc undefined eerror
toge 4e122fe
drop support windows
toge 10cd02f
removed unused import
toge f74c299
remove replace_in_file
toge aa8b44e
remove unused import
toge 8c75cf4
improve validation error message
toge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sources: | ||
"1.6.2": | ||
url: "https://github.com/libxls/libxls/releases/download/v1.6.2/libxls-1.6.2.tar.gz" | ||
sha256: "5dacc34d94bf2115926c80c6fb69e4e7bd2ed6403d51cff49041a94172f5e371" | ||
patches: | ||
"1.6.2": | ||
- patch_file: "patches/1.6.2-0001-fix-ssize_t-msvc.patch" | ||
patch_description: "Solve ssize_t when building on Windows" | ||
patch_type: "conan" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,113 @@ | ||||||||||||
from conan import ConanFile | ||||||||||||
from conan.errors import ConanInvalidConfiguration | ||||||||||||
from conan.tools.gnu import Autotools, AutotoolsToolchain, AutotoolsDeps | ||||||||||||
from conan.tools.layout import basic_layout | ||||||||||||
from conan.tools.files import export_conandata_patches, apply_conandata_patches, rmdir, copy, save, get, rm | ||||||||||||
from conan.tools.apple import is_apple_os | ||||||||||||
from conan.tools.build import cross_building | ||||||||||||
|
||||||||||||
import os | ||||||||||||
|
||||||||||||
required_conan_version = ">=1.53.0" | ||||||||||||
|
||||||||||||
class LibxlsConan(ConanFile): | ||||||||||||
name = "libxls" | ||||||||||||
description = "a C library which can read Excel (xls) files." | ||||||||||||
license = "BSD-2-Clause" | ||||||||||||
url = "https://github.com/conan-io/conan-center-index" | ||||||||||||
homepage = "https://github.com/libxls/libxls/" | ||||||||||||
topics = ("excel", "xls") | ||||||||||||
settings = "os", "arch", "compiler", "build_type" | ||||||||||||
options = { | ||||||||||||
"shared": [True, False], | ||||||||||||
"fPIC": [True, False], | ||||||||||||
"with_cli": [True, False], | ||||||||||||
} | ||||||||||||
default_options = { | ||||||||||||
"shared": False, | ||||||||||||
"fPIC": True, | ||||||||||||
"with_cli": False, | ||||||||||||
} | ||||||||||||
|
||||||||||||
def export_sources(self): | ||||||||||||
export_conandata_patches(self) | ||||||||||||
|
||||||||||||
def config_options(self): | ||||||||||||
if self.settings.os == "Windows": | ||||||||||||
del self.options.fPIC | ||||||||||||
|
||||||||||||
def configure(self): | ||||||||||||
if self.options.shared: | ||||||||||||
self.options.rm_safe("fPIC") | ||||||||||||
self.settings.rm_safe("compiler.libcxx") | ||||||||||||
self.settings.rm_safe("compiler.cppstd") | ||||||||||||
|
||||||||||||
def layout(self): | ||||||||||||
basic_layout(self, src_folder='src') | ||||||||||||
|
||||||||||||
def requirements(self): | ||||||||||||
if not is_apple_os(self): | ||||||||||||
self.requires("libiconv/1.17") | ||||||||||||
|
||||||||||||
def validate(self): | ||||||||||||
if self.settings.os == "Windows": | ||||||||||||
raise ConanInvalidConfiguration(f"{self.ref} doesn't support Windows (yet). Contributions are always welcomed") | ||||||||||||
|
||||||||||||
def build_requirements(self): | ||||||||||||
if self.settings.os == "Windows": | ||||||||||||
self.tool_requires("msys2/cci.latest") | ||||||||||||
self.win_bash = True | ||||||||||||
|
||||||||||||
def source(self): | ||||||||||||
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) | ||||||||||||
|
||||||||||||
def generate(self): | ||||||||||||
toolchain = AutotoolsToolchain(self) | ||||||||||||
if cross_building(self): | ||||||||||||
toolchain.configure_args.append("ac_cv_func_malloc_0_nonnull=yes") | ||||||||||||
toolchain.configure_args.append("ac_cv_func_realloc_0_nonnull=yes") | ||||||||||||
toolchain.generate() | ||||||||||||
deps = AutotoolsDeps(self) | ||||||||||||
deps.generate() | ||||||||||||
|
||||||||||||
def _patch_sources(self): | ||||||||||||
config_h_content = """ | ||||||||||||
#define HAVE_ICONV 1 | ||||||||||||
#define ICONV_CONST | ||||||||||||
#define PACKAGE_VERSION "{}" | ||||||||||||
""".format(self.version) | ||||||||||||
if self.settings.os == "Macos": | ||||||||||||
config_h_content += "#define HAVE_XLOCALE_H 1\n" | ||||||||||||
save(self, os.path.join(self.source_folder, "include", "config.h"), config_h_content) | ||||||||||||
apply_conandata_patches(self) | ||||||||||||
|
||||||||||||
def build(self): | ||||||||||||
self._patch_sources() | ||||||||||||
autotools = Autotools(self) | ||||||||||||
autotools.configure() | ||||||||||||
autotools.make() | ||||||||||||
|
||||||||||||
def package(self): | ||||||||||||
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) | ||||||||||||
autotools = Autotools(self) | ||||||||||||
autotools.install() | ||||||||||||
rmdir(self, os.path.join(self.package_folder, "share")) | ||||||||||||
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) | ||||||||||||
rm(self, "*.la", os.path.join(self.package_folder, "lib")) | ||||||||||||
|
||||||||||||
def package_info(self): | ||||||||||||
self.cpp_info.libs = ["xlsreader"] | ||||||||||||
|
||||||||||||
if is_apple_os(self): | ||||||||||||
self.cpp_info.system_libs.append("iconv") | ||||||||||||
|
||||||||||||
self.cpp_info.set_property("cmake_file_name", "libxls") | ||||||||||||
self.cpp_info.set_property("cmake_target_name", "libxls::libxls") | ||||||||||||
self.cpp_info.set_property("pkg_config_name", "libxls") | ||||||||||||
|
||||||||||||
if not is_apple_os(self): | ||||||||||||
self.cpp_info.requires.append("libiconv::libiconv") | ||||||||||||
|
||||||||||||
# TODO: Remove in Conan 2.0 | ||||||||||||
Comment on lines
+108
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
self.cpp_info.names["cmake_find_package"] = "libxls" | ||||||||||||
self.cpp_info.names["cmake_find_package_multi"] = "libxls" |
14 changes: 14 additions & 0 deletions
14
recipes/libxls/all/patches/1.6.2-0001-fix-ssize_t-msvc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
diff --git a/include/libxls/xlstypes.h b/include/libxls/xlstypes.h | ||
index 52da772..3efba21 100644 | ||
--- a/include/libxls/xlstypes.h | ||
+++ b/include/libxls/xlstypes.h | ||
@@ -53,4 +53,9 @@ typedef unsigned __int64 unsigned64_t; | ||
typedef uint64_t unsigned64_t; | ||
#endif | ||
|
||
+#ifdef _MSC_VER | ||
+#include <BaseTsd.h> | ||
+typedef SSIZE_T ssize_t; | ||
+#endif | ||
+ | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package LANGUAGES C) | ||
|
||
find_package(libxls REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.c) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE libxls::libxls) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import CMake, cmake_layout | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
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 can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <stdio.h> | ||
|
||
#include "xls.h" | ||
|
||
int main() { | ||
struct xlsWorkBook* wb; | ||
struct xlsWorkSheet* ws; | ||
|
||
printf("libxls version : %s\n", xls_getVersion()); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
project(test_package) | ||
|
||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||
conan_basic_setup(TARGETS) | ||
|
||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ | ||
${CMAKE_CURRENT_BINARY_DIR}/test_package/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from conans import ConanFile, CMake, tools | ||
import os | ||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "cmake", "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") | ||
self.run(bin_path, run_environment=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"1.6.2": | ||
folder: "all" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised it's a system lib on Mac 🤔 not usually the case... care to share with me? I am not familar with this project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prince-chrismc
Sorry, I neglected it so much that I forgot some of it.
I will investigate again.