Skip to content

Commit

Permalink
zint: add as a git submodule and add ZXING_USE_BUNDLED_ZINT cmake option
Browse files Browse the repository at this point in the history
  • Loading branch information
axxel committed Mar 8, 2024
1 parent 096c066 commit 04ee3cf
Show file tree
Hide file tree
Showing 67 changed files with 174 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "zint"]
path = zint
url = https://github.com/zint/zint.git
shallow = true
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ option (BUILD_UNIT_TESTS "Build the unit tests (don't enable for production buil
option (BUILD_PYTHON_MODULE "Build the python module" OFF)
option (BUILD_C_API "Build the C-API" OFF)
option (BUILD_EXPERIMENTAL_API "Build with experimental API" OFF)
option (ZXING_USE_BUNDLED_ZINT "Use the bundled libzint for barcode creation/generation" ON)
set(BUILD_DEPENDENCIES "AUTO" CACHE STRING "Fetch from github or use locally installed (AUTO/GITHUB/LOCAL)")

if (WIN32)
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let package = Package(
.target(
name: "ZXingCppCore",
path: "core/src",
exclude: ["core/src/libzint"],
publicHeadersPath: "."
),
.target(
Expand Down
14 changes: 14 additions & 0 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,22 @@ target_compile_features(ZXing PUBLIC cxx_std_17)
target_link_libraries (ZXing PRIVATE Threads::Threads)

if (BUILD_WRITERS_NEW)
if (ZXING_USE_BUNDLED_ZINT)
aux_source_directory(src/libzint LIBZINT_FILES) # manually re-run cmake after adding a new file/symlink
add_library(bundled_zint STATIC EXCLUDE_FROM_ALL ${LIBZINT_FILES})
target_include_directories (bundled_zint
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/libzint>"
)
target_compile_options (bundled_zint
PUBLIC ${ZXING_PUBLIC_FLAGS}
PRIVATE ${ZXING_PRIVATE_FLAGS}
)
target_link_libraries (ZXing PRIVATE bundled_zint)
else()
include(../zxing.cmake)
zxing_add_package(zint zint https://github.com/zint/zint.git 55a7369cd8c4a6b58bcd62f02a3a2d486952c897)
target_link_libraries (ZXing PRIVATE zint)
endif()
endif()

add_library(ZXing::ZXing ALIAS ZXing)
Expand Down Expand Up @@ -564,6 +577,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
src/qrcode/QRMaskUtil.cpp
src/qrcode/QRReader.cpp
src/qrcode/QRVersion.cpp
${LIBZINT_FILES}
PROPERTIES SKIP_PRECOMPILE_HEADERS ON COMPILE_FLAGS -Os)
endif()
endif()
Expand Down
1 change: 1 addition & 0 deletions core/src/libzint/2of5.c
1 change: 1 addition & 0 deletions core/src/libzint/aztec.c
1 change: 1 addition & 0 deletions core/src/libzint/aztec.h
1 change: 1 addition & 0 deletions core/src/libzint/big5.h
1 change: 1 addition & 0 deletions core/src/libzint/channel_precalcs.h
1 change: 1 addition & 0 deletions core/src/libzint/code.c
1 change: 1 addition & 0 deletions core/src/libzint/code128.c
1 change: 1 addition & 0 deletions core/src/libzint/code128.h
1 change: 1 addition & 0 deletions core/src/libzint/common.c
1 change: 1 addition & 0 deletions core/src/libzint/common.h
1 change: 1 addition & 0 deletions core/src/libzint/dmatrix.c
1 change: 1 addition & 0 deletions core/src/libzint/dmatrix.h
1 change: 1 addition & 0 deletions core/src/libzint/dmatrix_trace.h
1 change: 1 addition & 0 deletions core/src/libzint/eci.c
1 change: 1 addition & 0 deletions core/src/libzint/eci.h
1 change: 1 addition & 0 deletions core/src/libzint/eci_sb.h
1 change: 1 addition & 0 deletions core/src/libzint/filemem.c
1 change: 1 addition & 0 deletions core/src/libzint/filemem.h
1 change: 1 addition & 0 deletions core/src/libzint/fonts/normal_woff2.h
1 change: 1 addition & 0 deletions core/src/libzint/fonts/upcean_woff2.h
1 change: 1 addition & 0 deletions core/src/libzint/gb18030.h
1 change: 1 addition & 0 deletions core/src/libzint/gb2312.h
1 change: 1 addition & 0 deletions core/src/libzint/gbk.h
1 change: 1 addition & 0 deletions core/src/libzint/general_field.c
1 change: 1 addition & 0 deletions core/src/libzint/general_field.h
1 change: 1 addition & 0 deletions core/src/libzint/gs1.c
1 change: 1 addition & 0 deletions core/src/libzint/gs1.h
1 change: 1 addition & 0 deletions core/src/libzint/gs1_lint.h
1 change: 1 addition & 0 deletions core/src/libzint/iso3166.h
1 change: 1 addition & 0 deletions core/src/libzint/iso4217.h
1 change: 1 addition & 0 deletions core/src/libzint/ksx1001.h
1 change: 1 addition & 0 deletions core/src/libzint/large.c
1 change: 1 addition & 0 deletions core/src/libzint/large.h
1 change: 1 addition & 0 deletions core/src/libzint/library.c
1 change: 1 addition & 0 deletions core/src/libzint/maxicode.c
1 change: 1 addition & 0 deletions core/src/libzint/maxicode.h
1 change: 1 addition & 0 deletions core/src/libzint/medical.c
1 change: 1 addition & 0 deletions core/src/libzint/output.c
1 change: 1 addition & 0 deletions core/src/libzint/output.h
1 change: 1 addition & 0 deletions core/src/libzint/pdf417.c
1 change: 1 addition & 0 deletions core/src/libzint/pdf417.h
1 change: 1 addition & 0 deletions core/src/libzint/pdf417_tabs.h
1 change: 1 addition & 0 deletions core/src/libzint/pdf417_trace.h
1 change: 1 addition & 0 deletions core/src/libzint/qr.c
1 change: 1 addition & 0 deletions core/src/libzint/qr.h
1 change: 1 addition & 0 deletions core/src/libzint/raster.c
1 change: 1 addition & 0 deletions core/src/libzint/raster_font.h
1 change: 1 addition & 0 deletions core/src/libzint/reedsol.c
1 change: 1 addition & 0 deletions core/src/libzint/reedsol.h
1 change: 1 addition & 0 deletions core/src/libzint/reedsol_logs.h
1 change: 1 addition & 0 deletions core/src/libzint/rss.c
1 change: 1 addition & 0 deletions core/src/libzint/rss.h
1 change: 1 addition & 0 deletions core/src/libzint/sjis.h
92 changes: 92 additions & 0 deletions core/src/libzint/stubs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* SPDX-License-Identifier: BSD-3-Clause */

#include "common.h"

#define STUB_PIXEL_PLOT(NAME) \
INTERNAL int NAME(struct zint_symbol* symbol, const unsigned char* pixelbuf) \
{ \
(void)symbol; \
(void)pixelbuf; \
return ZINT_ERROR_ENCODING_PROBLEM; \
}

#define STUB_FUNC_CHAR(NAME) \
INTERNAL int NAME(struct zint_symbol* symbol, unsigned char source[], int length) \
{ \
(void)symbol; \
(void)source; \
(void)length; \
return ZINT_ERROR_ENCODING_PROBLEM; \
}

#define STUB_FUNC_SEGS(NAME) \
INTERNAL int NAME(struct zint_symbol* symbol, struct zint_seg segs[], const int seg_count) \
{ \
(void)symbol; \
(void)segs; \
(void)seg_count; \
return ZINT_ERROR_ENCODING_PROBLEM; \
}

STUB_PIXEL_PLOT(png_pixel_plot)
STUB_PIXEL_PLOT(bmp_pixel_plot)
STUB_PIXEL_PLOT(pcx_pixel_plot)
STUB_PIXEL_PLOT(gif_pixel_plot)
STUB_PIXEL_PLOT(tif_pixel_plot)

INTERNAL int ps_plot(struct zint_symbol* symbol)
{
(void)symbol;
return ZINT_ERROR_ENCODING_PROBLEM;
}
INTERNAL int emf_plot(struct zint_symbol* symbol, int rotate_angle)
{
(void)symbol;
(void)rotate_angle;
return ZINT_ERROR_ENCODING_PROBLEM;
}

// STUB_FUNC_CHAR(pzn)
// STUB_FUNC_CHAR(c25ind)
// STUB_FUNC_CHAR(c25iata)
// STUB_FUNC_CHAR(c25inter)
// STUB_FUNC_CHAR(c25logic)
// STUB_FUNC_CHAR(itf14)
// STUB_FUNC_CHAR(dpleit)
// STUB_FUNC_CHAR(dpident)
// STUB_FUNC_CHAR(code11)
STUB_FUNC_CHAR(msi_plessey)
STUB_FUNC_CHAR(telepen)
STUB_FUNC_CHAR(telepen_num)
STUB_FUNC_CHAR(plessey)
// STUB_FUNC_CHAR(pharma)
STUB_FUNC_CHAR(flat)
STUB_FUNC_CHAR(fim)
// STUB_FUNC_CHAR(pharma_two)
STUB_FUNC_CHAR(postnet)
STUB_FUNC_CHAR(planet)
STUB_FUNC_CHAR(usps_imail)
STUB_FUNC_CHAR(rm4scc)
STUB_FUNC_CHAR(auspost)
STUB_FUNC_CHAR(code16k)
STUB_FUNC_CHAR(composite)
STUB_FUNC_CHAR(kix)
// STUB_FUNC_CHAR(code32)
STUB_FUNC_CHAR(daft)
// STUB_FUNC_CHAR(nve18)
STUB_FUNC_CHAR(koreapost)
STUB_FUNC_CHAR(japanpost)
STUB_FUNC_CHAR(code49)
// STUB_FUNC_CHAR(channel)
STUB_FUNC_SEGS(codeone)
STUB_FUNC_SEGS(gridmatrix)
STUB_FUNC_SEGS(hanxin)
STUB_FUNC_SEGS(dotcode)
STUB_FUNC_SEGS(codablockf)
// STUB_FUNC_CHAR(vin)
STUB_FUNC_CHAR(mailmark_2d)
STUB_FUNC_CHAR(mailmark_4s)
// STUB_FUNC_CHAR(upu_s10)
STUB_FUNC_SEGS(ultra)
// STUB_FUNC_CHAR(dpd)
STUB_FUNC_CHAR(bc412)
1 change: 1 addition & 0 deletions core/src/libzint/svg.c
1 change: 1 addition & 0 deletions core/src/libzint/upcean.c
1 change: 1 addition & 0 deletions core/src/libzint/vector.c
1 change: 1 addition & 0 deletions core/src/libzint/zfiletypes.h
1 change: 1 addition & 0 deletions core/src/libzint/zint.h
1 change: 1 addition & 0 deletions core/src/libzint/zintconfig.h
1 change: 1 addition & 0 deletions wrappers/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ categories = ["api-bindings", "computer-vision"]
exclude = [
"core/**/*Write*",
"core/**/*Encode*",
"core/libzint/**",
]

[lib]
Expand Down
1 change: 1 addition & 0 deletions zint
Submodule zint added at 55a736
1 change: 1 addition & 0 deletions zxing-cpp.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Pod::Spec.new do |s|

s.subspec 'Core' do |ss|
ss.source_files = 'core/src/**/*.{h,c,cpp}'
ss.exclude_files = [ 'core/src/libzint/**' ]
ss.private_header_files = 'core/src/**/*.h'
end

Expand Down

0 comments on commit 04ee3cf

Please sign in to comment.