summaryrefslogtreecommitdiff
path: root/zxing-cpp.spec
blob: d49a9ac834579bfd00c9dbecee1e7590e175557e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Name: zxing-cpp
Version: 1.2.0
Release: 1
Summary: C++ port of the ZXing ("Zebra Crossing") barcode scanning library

License: LGPLv2 with exceptions or LGPLv3 with exceptions
Url: https://github.com/nu-book/zxing-cpp
Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz

BuildRequires: gcc-c++ cmake cmake(fmt)
BuildRequires: stb_image-devel >= 2.27^20210910gitaf1a5bc-0.2
BuildRequires: stb_image-static stb_image_write-devel stb_image_write-static
# https://github.com/nu-book/zxing-cpp/issues/248
Patch0: 0001-Add-a-mode-to-build-against-system-versions-of-depen.patch
# Update stb_image/stb_image_write
# https://github.com/nu-book/zxing-cpp/pull/269
Patch1: %{url}/pull/269.patch
# Use the system copy of pybind11 rather than trying to download a copy. This
# patch is unconditional, so it is not, as-is, suitable for sending upstream.
Patch2: zxing-cpp-1.2.0-system-pybind11.patch
# fix for recent libfmt
Patch3: 0001-test-update-to-libfmt-v9.0.0.patch
# fix for gcc 13
Patch4: 0001-include-cstdint.patch

%description
ZXing-C++ ("zebra crossing") is an open-source, multi-format 1D/2D barcode
image processing library implemented in C++.

%package devel
License: ASL 2.0 and (LGPLv2 with exceptions or LGPLv3 with exceptions)
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}

%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.

%package -n python3-%{name}
Summary:        Python bindings for the %{name} barcode library

BuildRequires: python3-devel python3-pip python3-hatchling python3-hatch-vcs python3-wheel
BuildRequires: pybind11-devel cmake chrpath 

Requires: %{name}%{?_isa} = %{version}-%{release}

%description -n python3-%{name}
%{summary}.

%prep
%autosetup -p1
# remove bundled stb libraries:
rm -v thirdparty/stb/stb_image_write.h thirdparty/stb/stb_image.h
# stb_image.h is trivially forked: reconstruct the changes with the latest
# unbundled copy
cp -p /usr/include/stb/stb_image.h thirdparty/stb/
pushd thirdparty/stb
patch -p1 < stb_image.patch
popd

# don’t use unversioned “python” interpreter in tests
sed -r -i 's@(COMMAND )python@\1%{python3}@' wrappers/python/CMakeLists.txt

%build
%cmake -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON_MODULE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
%make_build
pushd wrappers/python
export VERBOSE=1
%pyproject_build
popd

%install
%make_install
pushd wrappers/python
%pyproject_install
popd
install -t '%{buildroot}%{python3_sitearch}' -p \
    wrappers/python/zxingcpp.*.so
chrpath --delete %{buildroot}%{python3_sitearch}/zxingcpp.*.so

%check

%files
%license LICENSE LICENSE.ZXing LICENSE.Qt LGPL_EXCEPTION.Qt NOTICE
%{_libdir}/libZXing.so.1
%{_libdir}/libZXing.so.%{version}

%files devel
%doc README.md
%{_includedir}/ZXing/
%{_libdir}/libZXing.so
%{_libdir}/cmake/ZXing/
%{_libdir}/pkgconfig/zxing.pc

%files -n python3-%{name}
%{python3_sitearch}/*

%changelog
* Wed Sep 06 2023 Darssin <2020303249@mail.nwpu.edu.cn> - 1.2.0-1
- Package init