diff --git a/CMakeLists.txt b/CMakeLists.txt index ee37f9ad..f807398c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,4 +34,8 @@ IF (WITH_PYTHON_MODULE) add_subdirectory(source/python) ENDIF() +IF (WITH_WASM_MODULE) + add_subdirectory(source/wasm) +ENDIF() + add_subdirectory(source/test) diff --git a/conanfile.py b/conanfile.py index f3223bc0..8dcef62b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -8,7 +8,7 @@ class TicketDecoderConan(ConanFile): name = 'ticket-decoder' - version = 'v0.20' + version = 'v0.21' settings = "os", "compiler", "build_type", "arch" generators = "CMakeDeps" options = { @@ -18,6 +18,7 @@ class TicketDecoderConan(ConanFile): "with_ticket_analyzer": [True, False], "with_ticket_decoder": [True, False], "with_python_module": [True, False], + "with_wasm_module": [True, False], "with_square_detector": [True, False], "with_classifier_detector": [True, False], "with_barcode_decoder": [True, False], @@ -35,6 +36,7 @@ class TicketDecoderConan(ConanFile): "with_ticket_analyzer": True, "with_ticket_decoder": True, "with_python_module": True, + "with_wasm_module": False, "with_square_detector": True, "with_classifier_detector": True, "with_barcode_decoder": True, @@ -96,8 +98,10 @@ def requirements(self): def build_requirements(self): # https://conan.io/center/recipes/cmake self.tool_requires("cmake/[>=3.22]") + #https://conan.io/center/recipes/ninja self.tool_requires("ninja/[>=1.13]") + # https://conan.io/center/recipes/gtest self.test_requires("gtest/1.17.0") @@ -113,6 +117,9 @@ def generate(self): if self.options.with_python_module: TicketDecoderConan.add_config_switch(toolchain, "WITH_PYTHON_MODULE") + if self.options.with_wasm_module: + TicketDecoderConan.add_config_switch(toolchain, "WITH_WASM_MODULE") + if self.options.with_square_detector: TicketDecoderConan.add_config_switch(toolchain, "WITH_SQUARE_DETECTOR") @@ -144,6 +151,7 @@ def configure(self): self.output.highlight("with_ticket_analyzer: " + str(self.options.with_ticket_analyzer)) self.output.highlight("with_ticket_decoder: " + str(self.options.with_ticket_decoder)) self.output.highlight("with_python_module: " + str(self.options.with_python_module)) + self.output.highlight("with_wasm_module: " + str(self.options.with_wasm_module)) self.output.highlight("with_square_detector: " + str(self.options.with_square_detector)) self.output.highlight("with_classifier_detector: " + str(self.options.with_classifier_detector)) self.output.highlight("with_barcode_decoder: " + str(self.options.with_barcode_decoder)) diff --git a/etc/conan/profiles/emscripten b/etc/conan/profiles/emscripten new file mode 100644 index 00000000..08891f55 --- /dev/null +++ b/etc/conan/profiles/emscripten @@ -0,0 +1,10 @@ +[settings] +os=Emscripten +arch=wasm64 +compiler=clang +compiler.version=16 +compiler.libcxx=libc++ +compiler.cppstd=20 + +[tool_requires] +emsdk/3.1.73 diff --git a/etc/poppler/conanfile.py b/etc/poppler/conanfile.py index 15f89b11..923ef6d3 100644 --- a/etc/poppler/conanfile.py +++ b/etc/poppler/conanfile.py @@ -30,6 +30,7 @@ class PopplerCppConan(ConanFile): "with_ticket_analyzer": None, "with_ticket_decoder": None, "with_python_module": None, + "with_wasm_module": None, "with_square_detector": None, "with_classifier_detector": None, "with_barcode_decoder": None, @@ -73,6 +74,7 @@ def configure(self): self.options.rm_safe("with_ticket_analyzer") self.options.rm_safe("with_ticket_decoder") self.options.rm_safe("with_python_module") + self.options.rm_safe("with_wasm_module") self.options.rm_safe("with_square_detector") self.options.rm_safe("with_classifier_detector") self.options.rm_safe("with_barcode_decoder") diff --git a/pyproject.toml b/pyproject.toml index 4ddafdb5..2c61d9f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ [project] name = "ticket-decoder" -version = "v0.20.1" +version = "v0.21.0" description = "Train ticket barcode to json decoding library, using zxing-cpp decoding in combination with record interpreter, to transform content into json structure" license = "GPL-3.0-or-later" authors = [ { name = "user4223" } ] @@ -66,6 +66,7 @@ options-all = [ "&:with_ticket_analyzer=False", "&:with_ticket_decoder=False", "&:with_python_module=True", + "&:with_wasm_module=False", "&:with_square_detector=False", "&:with_classifier_detector=False", "&:with_barcode_decoder=True", diff --git a/setup.All.sh b/setup.All.sh index 73e0f555..471b24d3 100755 --- a/setup.All.sh +++ b/setup.All.sh @@ -12,6 +12,7 @@ ${WORKSPACE_ROOT}/etc/conan-install.sh ${BUILD_TYPE} \ -o:a="&:with_ticket_analyzer=True" \ -o:a="&:with_ticket_decoder=True" \ -o:a="&:with_python_module=True" \ + -o:a="&:with_wasm_module=False" \ -o:a="&:with_square_detector=True" \ -o:a="&:with_classifier_detector=True" \ -o:a="&:with_barcode_decoder=True" \ diff --git a/setup.Decoder.sh b/setup.Decoder.sh index 80c9204e..c88ee032 100755 --- a/setup.Decoder.sh +++ b/setup.Decoder.sh @@ -12,6 +12,7 @@ ${WORKSPACE_ROOT}/etc/conan-install.sh ${BUILD_TYPE} \ -o:a="&:with_ticket_analyzer=False" \ -o:a="&:with_ticket_decoder=True" \ -o:a="&:with_python_module=False" \ + -o:a="&:with_wasm_module=False" \ -o:a="&:with_square_detector=False" \ -o:a="&:with_classifier_detector=False" \ -o:a="&:with_barcode_decoder=True" \ diff --git a/setup.WASM.sh b/setup.WASM.sh new file mode 100755 index 00000000..610091e5 --- /dev/null +++ b/setup.WASM.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: (C) 2022 user4223 and (other) contributors to ticket-decoder +# SPDX-License-Identifier: GPL-3.0-or-later + +set -o errexit + +readonly WORKSPACE_ROOT="$(readlink -f $(dirname "$0"))" +readonly BUILD_TYPE=${1:-Release} + +${WORKSPACE_ROOT}/etc/conan-config.sh +${WORKSPACE_ROOT}/etc/conan-install.sh ${BUILD_TYPE} \ + -o:a="&:with_ticket_analyzer=False" \ + -o:a="&:with_ticket_decoder=False" \ + -o:a="&:with_python_module=False" \ + -o:a="&:with_wasm_module=True" \ + -o:a="&:with_square_detector=False" \ + -o:a="&:with_classifier_detector=False" \ + -o:a="&:with_barcode_decoder=True" \ + -o:a="&:with_pdf_input=True" \ + -o:a="&:with_signature_verifier=False" \ + -o:a="&:with_uic_interpreter=True" \ + -o:a="&:with_vdv_interpreter=True" \ + -o:a="&:with_sbb_interpreter=True" \ + -pr:h="./etc/conan/profiles/emscripten" \ + -pr:b="./etc/conan/profiles/macos15" + +${WORKSPACE_ROOT}/etc/cmake-config.sh ${BUILD_TYPE} +${WORKSPACE_ROOT}/build.sh ${BUILD_TYPE} ${@:2} diff --git a/source/app/CMakeLists.txt b/source/app/CMakeLists.txt index 54859566..493dca5f 100644 --- a/source/app/CMakeLists.txt +++ b/source/app/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-FileCopyrightText: (C) 2022 user4223 and (other) contributors to ticket-decoder # SPDX-License-Identifier: GPL-3.0-or-later -project(ticket-decoder) +project(ticket-decoder-app) find_package(tclap REQUIRED) diff --git a/source/app/source/analyzer.cpp b/source/app/source/analyzer.cpp index 280c01a0..514d7039 100644 --- a/source/app/source/analyzer.cpp +++ b/source/app/source/analyzer.cpp @@ -23,7 +23,7 @@ int main(int argc, char **argv) { - auto cmd = TCLAP::CmdLine("ticket-analyzer", ' ', "v0.20"); + auto cmd = TCLAP::CmdLine("ticket-analyzer", ' ', "v0.21"); auto const verboseArg = TCLAP::SwitchArg( "v", "verbose", "More verbose debug logging", diff --git a/source/app/source/decoder.cpp b/source/app/source/decoder.cpp index ec36a69c..0c23a12e 100644 --- a/source/app/source/decoder.cpp +++ b/source/app/source/decoder.cpp @@ -15,7 +15,7 @@ int main(int argc, char **argv) { - auto cmd = TCLAP::CmdLine("ticket-decoder", ' ', "v0.20"); + auto cmd = TCLAP::CmdLine("ticket-decoder", ' ', "v0.21"); auto const verboseArg = TCLAP::SwitchArg( "v", "verbose", "More verbose debug logging", diff --git a/source/wasm/CMakeLists.txt b/source/wasm/CMakeLists.txt new file mode 100644 index 00000000..ef95fd40 --- /dev/null +++ b/source/wasm/CMakeLists.txt @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: (C) 2026 user4223 and (other) contributors to ticket-decoder +# SPDX-License-Identifier: GPL-3.0-or-later + +PROJECT(ticket-decoder-wasm) + +AUX_SOURCE_DIRECTORY("source" PROJECT_SOURCE) +file(GLOB PROJECT_INCLUDES "include/*.h") + +ADD_LIBRARY(${PROJECT_NAME} STATIC ${PROJECT_SOURCE} ${PROJECT_INCLUDES}) +target_include_directories(${PROJECT_NAME} PRIVATE) +target_link_libraries(${PROJECT_NAME} PRIVATE) diff --git a/source/wasm/source/Binding.cpp b/source/wasm/source/Binding.cpp new file mode 100644 index 00000000..17673709 --- /dev/null +++ b/source/wasm/source/Binding.cpp @@ -0,0 +1,23 @@ +// SPDX-FileCopyrightText: (C) 2026 user4223 and (other) contributors to ticket-decoder +// SPDX-License-Identifier: GPL-3.0-or-later + +#include + +#include "lib/infrastructure/include/Context.h" + +#include "lib/api/include/DecoderFacade.h" + +class DecoderFacadeWrapper +{ + std::string decodeBase64(std::string const &base64) + { + return "hello world"; + } +}; + +EMSCRIPTEN_BINDINGS(TicketDecoder) { + + emscripten::class_("DecoderFacade") + .constructor<>() + .function("decodeBase64", &DecoderFacadeWrapper::decodeBase64); +};