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..43a19403 100644 --- a/conanfile.py +++ b/conanfile.py @@ -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": True, "with_square_detector": True, "with_classifier_detector": True, "with_barcode_decoder": True, @@ -94,10 +96,13 @@ def requirements(self): self.requires("libpng/1.6.58", override=True) def build_requirements(self): - # https://conan.io/center/recipes/cmake - self.tool_requires("cmake/[>=3.22]") + if not self.options.with_wasm_module: # this fails when using emsdk and seems not required there + # 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 +118,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 +152,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..f278d5ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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..6b0c96ad --- /dev/null +++ b/setup.WASM.sh @@ -0,0 +1,27 @@ +#!/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=True" \ + -o:a="&:with_uic_interpreter=True" \ + -o:a="&:with_vdv_interpreter=True" \ + -o:a="&:with_sbb_interpreter=True" \ + -pr:h="./etc/conan/profiles/emscripten" + +${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/wasm/CMakeLists.txt b/source/wasm/CMakeLists.txt new file mode 100644 index 00000000..d2de8762 --- /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) + +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..6c845b23 --- /dev/null +++ b/source/wasm/source/Binding.cpp @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: (C) 2026 user4223 and (other) contributors to ticket-decoder +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifdef __EMSCRIPTEN__ + +EMSCRIPTEN_BINDINGS(TicketDecoder) { + +}; + +#endif