Skip to content

Commit

Permalink
(#11614) zxing-cpp: add version 1.4.0
Browse files Browse the repository at this point in the history
* zxing-cpp: add version 1.4.0

* disable `__cpp_lib_string_view` checks for older gcc

* zxing-cpp/1.4.0 donesn't suppport Visual Studio <= 15.

* drop support for MT + Debug build (same as 1.3.0)

* require C++14 < 1.2.0, C++17 >= 1.2.0

* fix description
  • Loading branch information
toge authored Jul 18, 2022
1 parent ef91faa commit 33e52a6
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 14 deletions.
16 changes: 12 additions & 4 deletions recipes/zxing-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
sources:
"1.4.0":
url: "https://github.com/nu-book/zxing-cpp/archive/v1.4.0.tar.gz"
sha256: "126767bb56f8a1f25ae84d233db2e9b9be50d71f5776092d0e170ca0f0ed1862"
"1.3.0":
url: "https://github.com/nu-book/zxing-cpp/archive/v1.3.0.tar.gz"
sha256: "bfd8fc706def30e34f96088b5a7afdbe0917831e57a774d34e3ee864b01c6891"
"1.0.8":
url: "https://github.com/nu-book/zxing-cpp/archive/v1.0.8.tar.gz"
sha256: "9154b5456904e47bd4c38462d57e4b7897bfb20cb2bc2e8c958453e40e73c8b2"
patches:
"1.4.0":
# core/ByteArray checks `__cpp_lib_string_view` for using string_view.
# But some compilers(ex. gcc 7.2) don't support `__cpp_lib_string_view` but support string_view.
- patch_file: "patches/1.4.0-0001-fix-string-view.patch"
base_path: "source_subfolder"
"1.0.8":
- patch_file: "patches/0001-Fix-C2327-for-MSVC-2015.patch"
- patch_file: "patches/1.0.8-0001-Fix-C2327-for-MSVC-2015.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-include-limits.patch"
- patch_file: "patches/1.0.8-0002-include-limits.patch"
base_path: "source_subfolder"
- patch_file: "patches/0003-include-stdexcept.patch"
- patch_file: "patches/1.0.8-0003-include-stdexcept.patch"
base_path: "source_subfolder"
- patch_file: "patches/0004-include-cstddef.patch"
- patch_file: "patches/1.0.8-0004-include-cstddef.patch"
base_path: "source_subfolder"
32 changes: 22 additions & 10 deletions recipes/zxing-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ZXingCppConan(ConanFile):
name = "zxing-cpp"
description = "c++14 port of ZXing, a barcode scanning library"
description = "C++ port of ZXing, a barcode scanning library"
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/nu-book/zxing-cpp"
Expand Down Expand Up @@ -40,12 +40,20 @@ def _build_subfolder(self):
return "build_subfolder"

@property
def _compiler_cpp14_support(self):
def _compiler_cpp_support(self):
return {
"gcc": "5" if tools.Version(self.version) < "1.2" else "6",
"Visual Studio": "14",
"clang": "3.4",
"apple-clang": "3.4",
"14" : {
"gcc": "5",
"Visual Studio": "14",
"clang": "3.4",
"apple-clang": "3.4",
},
"17" : {
"gcc": "7",
"Visual Studio": "16",
"clang": "5",
"apple-clang": "5",
}
}

def export_sources(self):
Expand All @@ -62,15 +70,19 @@ def configure(self):
del self.options.fPIC

def validate(self):
cpp_version = 17 if tools.Version(self.version) >= "1.2.0" else 14

if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 14)
min_version = self._compiler_cpp14_support.get(str(self.settings.compiler))
tools.check_min_cppstd(self, cpp_version)
min_version = self._compiler_cpp_support.get(str(cpp_version)).get(str(self.settings.compiler))

if min_version and tools.Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
"This compiler is too old. {} needs a compiler with c++14 support".format(self.name)
"This compiler is too old. {} needs a compiler with c++{} support".format(self.name, cpp_version)
)

# FIXME: This is a workaround for "The system cannot execute the specified program."
if tools.Version(self.version) == "1.3.0" and is_msvc_static_runtime(self) and self.settings.build_type == "Debug":
if tools.Version(self.version) >= "1.3.0" and is_msvc_static_runtime(self) and self.settings.build_type == "Debug":
raise ConanInvalidConfiguration("{}/{} doesn't support MT + Debug.".format(self.name, self.version))

def source(self):
Expand Down
22 changes: 22 additions & 0 deletions recipes/zxing-cpp/all/patches/1.4.0-0001-fix-string-view.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/core/src/ByteArray.h b/core/src/ByteArray.h
index a31f42c..d5b102e 100644
--- a/core/src/ByteArray.h
+++ b/core/src/ByteArray.h
@@ -11,7 +11,7 @@
#include <string>
#include <vector>

-#ifdef __cpp_lib_string_view
+#if 1
#include <string_view>
#endif

@@ -30,7 +30,7 @@ public:

void append(const ByteArray& other) { insert(end(), other.begin(), other.end()); }

-#ifdef __cpp_lib_string_view
+#if 1
std::string_view asString(size_t pos = 0, size_t len = std::string_view::npos) const
{
return std::string_view(reinterpret_cast<const char*>(data()), size()).substr(pos, len);
2 changes: 2 additions & 0 deletions recipes/zxing-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"1.4.0":
folder: all
"1.3.0":
folder: all
"1.0.8":
Expand Down

0 comments on commit 33e52a6

Please sign in to comment.