Skip to content

Commit 33e52a6

Browse files
authored
(#11614) zxing-cpp: add version 1.4.0
* 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
1 parent ef91faa commit 33e52a6

8 files changed

+58
-14
lines changed

recipes/zxing-cpp/all/conandata.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
sources:
2+
"1.4.0":
3+
url: "https://github.com/nu-book/zxing-cpp/archive/v1.4.0.tar.gz"
4+
sha256: "126767bb56f8a1f25ae84d233db2e9b9be50d71f5776092d0e170ca0f0ed1862"
25
"1.3.0":
36
url: "https://github.com/nu-book/zxing-cpp/archive/v1.3.0.tar.gz"
47
sha256: "bfd8fc706def30e34f96088b5a7afdbe0917831e57a774d34e3ee864b01c6891"
58
"1.0.8":
69
url: "https://github.com/nu-book/zxing-cpp/archive/v1.0.8.tar.gz"
710
sha256: "9154b5456904e47bd4c38462d57e4b7897bfb20cb2bc2e8c958453e40e73c8b2"
811
patches:
12+
"1.4.0":
13+
# core/ByteArray checks `__cpp_lib_string_view` for using string_view.
14+
# But some compilers(ex. gcc 7.2) don't support `__cpp_lib_string_view` but support string_view.
15+
- patch_file: "patches/1.4.0-0001-fix-string-view.patch"
16+
base_path: "source_subfolder"
917
"1.0.8":
10-
- patch_file: "patches/0001-Fix-C2327-for-MSVC-2015.patch"
18+
- patch_file: "patches/1.0.8-0001-Fix-C2327-for-MSVC-2015.patch"
1119
base_path: "source_subfolder"
12-
- patch_file: "patches/0002-include-limits.patch"
20+
- patch_file: "patches/1.0.8-0002-include-limits.patch"
1321
base_path: "source_subfolder"
14-
- patch_file: "patches/0003-include-stdexcept.patch"
22+
- patch_file: "patches/1.0.8-0003-include-stdexcept.patch"
1523
base_path: "source_subfolder"
16-
- patch_file: "patches/0004-include-cstddef.patch"
24+
- patch_file: "patches/1.0.8-0004-include-cstddef.patch"
1725
base_path: "source_subfolder"

recipes/zxing-cpp/all/conanfile.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

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

4242
@property
43-
def _compiler_cpp14_support(self):
43+
def _compiler_cpp_support(self):
4444
return {
45-
"gcc": "5" if tools.Version(self.version) < "1.2" else "6",
46-
"Visual Studio": "14",
47-
"clang": "3.4",
48-
"apple-clang": "3.4",
45+
"14" : {
46+
"gcc": "5",
47+
"Visual Studio": "14",
48+
"clang": "3.4",
49+
"apple-clang": "3.4",
50+
},
51+
"17" : {
52+
"gcc": "7",
53+
"Visual Studio": "16",
54+
"clang": "5",
55+
"apple-clang": "5",
56+
}
4957
}
5058

5159
def export_sources(self):
@@ -62,15 +70,19 @@ def configure(self):
6270
del self.options.fPIC
6371

6472
def validate(self):
73+
cpp_version = 17 if tools.Version(self.version) >= "1.2.0" else 14
74+
6575
if self.settings.compiler.get_safe("cppstd"):
66-
tools.check_min_cppstd(self, 14)
67-
min_version = self._compiler_cpp14_support.get(str(self.settings.compiler))
76+
tools.check_min_cppstd(self, cpp_version)
77+
min_version = self._compiler_cpp_support.get(str(cpp_version)).get(str(self.settings.compiler))
78+
6879
if min_version and tools.Version(self.settings.compiler.version) < min_version:
6980
raise ConanInvalidConfiguration(
70-
"This compiler is too old. {} needs a compiler with c++14 support".format(self.name)
81+
"This compiler is too old. {} needs a compiler with c++{} support".format(self.name, cpp_version)
7182
)
83+
7284
# FIXME: This is a workaround for "The system cannot execute the specified program."
73-
if tools.Version(self.version) == "1.3.0" and is_msvc_static_runtime(self) and self.settings.build_type == "Debug":
85+
if tools.Version(self.version) >= "1.3.0" and is_msvc_static_runtime(self) and self.settings.build_type == "Debug":
7486
raise ConanInvalidConfiguration("{}/{} doesn't support MT + Debug.".format(self.name, self.version))
7587

7688
def source(self):
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/core/src/ByteArray.h b/core/src/ByteArray.h
2+
index a31f42c..d5b102e 100644
3+
--- a/core/src/ByteArray.h
4+
+++ b/core/src/ByteArray.h
5+
@@ -11,7 +11,7 @@
6+
#include <string>
7+
#include <vector>
8+
9+
-#ifdef __cpp_lib_string_view
10+
+#if 1
11+
#include <string_view>
12+
#endif
13+
14+
@@ -30,7 +30,7 @@ public:
15+
16+
void append(const ByteArray& other) { insert(end(), other.begin(), other.end()); }
17+
18+
-#ifdef __cpp_lib_string_view
19+
+#if 1
20+
std::string_view asString(size_t pos = 0, size_t len = std::string_view::npos) const
21+
{
22+
return std::string_view(reinterpret_cast<const char*>(data()), size()).substr(pos, len);

recipes/zxing-cpp/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
versions:
2+
"1.4.0":
3+
folder: all
24
"1.3.0":
35
folder: all
46
"1.0.8":

0 commit comments

Comments
 (0)