Skip to content

Modernization: C++23 Core Refactor, CMake Build System, and Security Hardening#22

Open
dutch2005 wants to merge 47 commits intoOpenPrinting:masterfrom
dutch2005:master
Open

Modernization: C++23 Core Refactor, CMake Build System, and Security Hardening#22
dutch2005 wants to merge 47 commits intoOpenPrinting:masterfrom
dutch2005:master

Conversation

@dutch2005
Copy link
Copy Markdown

Overview

This Pull Request introduces a comprehensive modernization of the SpliX driver, transitioning the original 2006-era C++98 codebase to modern C++23 standards.

The primary motivation for this effort (completed in April 2026) was to eliminate long-standing memory management boilerplate, deprecate the legacy Makefile system, and establish a robust, automated CI/CD pipeline. These changes ensure the driver's long-term maintainability, security, and stability on modern Linux/macOS distributions, while strictly maintaining 100% bit-perfect protocol compatibility with all legacy Samsung, Xerox, and Dell printers.

What was changed & Why

  • Memory & Thread Safety (C++23): Eliminated all manual memory management (malloc/free, new/delete) and legacy POSIX threading. Replaced with std::vector, std::span, and std::counting_semaphore. Why: To natively guarantee memory safety, eliminate historical memory leaks, and remove hundreds of lines of duplicated buffer-tracking boilerplate.
  • Build System Modernization: Replaced the deprecated Makefile and rules.mk with a robust CMake (3.25+) configuration. Why: To support modern IDEs, simplify dependency tracking, and natively integrate with CPack for automated .deb and .rpm packaging.
  • Security Hardening: The compiler pipeline now enforces Full RELRO, PIE, Stack Protection (-fstack-protector-strong), and Fortify Source. Added explicit output-size bounds checking to the Algo0x11 (LZS) compression. Why: To bring the driver up to modern enterprise security standards and prevent potential edge-case buffer overflows on printer firmware.
  • Endianness Handling: Replaced duplicated #ifdef WORDS_BIGENDIAN fallback logic with modern standard-compliant memcpy. Why: The previous logic was required for old Big-Endian host CPUs (like PowerPC). Modern C++ handles this natively, allowing us to generate the required Little-Endian QPDL payloads with much leaner code.
  • New Hardware & PPDs: Integrated support for the Samsung ML-1670 and SCX-3400. The build process now pre-compiles all 248 .ppd files natively. Why: Removes the burden for end-users to have cups-ppdc installed on modern operating systems.

Verification

  • Automated CI/CD: Introduced a GitHub Actions pipeline using ubuntu:26.04 to automatically cross-compile for both AMD64 and ARM64.
  • Testing: Implemented a Google Test (GTest) framework validating the critical QPDL compression algorithms (0x11, 0x15, 0x0D, 0x0E).
  • Regressions: The byte-stream output has been extensively regression-tested against the legacy driver outputs to guarantee that the hardware integration remains untouched.

Restructure the GitHub Actions workflow to use two explicit jobs instead of a matrix: build-arm64 (Raspberry Pi / aarch64 using uraimo emulator on Debian bullseye) and build-amd64 (native Docker debian:bullseye container). Add FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 env to silence deprecation warnings. Hardcode pkgarch per job and adjust build steps (sed fix for -ljbig85->-ljbig, install deps, run checkinstall) and upload artifacts as splix-deb-arm64 and splix-deb-amd64.
Combine separate arm64 and amd64 workflows into a single matrix-based `build` job (platform + deb_arch). Replace the uraimo emulator action with docker/setup-qemu-action for ARM emulation and run Debian containers via `--platform` (using debian:oldstable). Install pkg-config, use a dynamic --pkgarch based on the matrix, and upload artifacts with arch-specific names. Minor adjustments: update sed quoting for JBIG linker fix and remove an inline comment from the FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 env entry.
Reworded a comment in .github/workflows/build.yml to a concise, declarative note about using standard Docker commands with the N-1 'oldstable' strategy. No functional changes.
Introduce a compiler cache step using actions/cache@v4, keyed by architecture and commit (ccache-${{ matrix.deb_arch }}-${{ github.sha }}), and restore by arch. Ensure .ccache exists on the runner, mount it into the Debian container at /root/.ccache, install ccache in the container, set CCACHE_DIR and prepend /usr/lib/ccache to PATH so native builds can reuse cached compiler outputs. Also minor Docker run flag reformatting; retains Debian oldstable build strategy.
Update GitHub Actions Debian build: install explicit libcups packages, set PKG_CONFIG_PATH for target arch, and add LDFLAGS (-lcups -lcupsimage) to resolve 'DSO missing' link errors. Clean up a few inline comments and ensure the Upload Artifacts step is present so built .deb packages are retrievable from the Actions UI. Other build steps (ccache, Makefile JBIG patching, packaging) remain unchanged.
Clarify comments in the build matrix and workflow steps, and improve the package build process. Export PKG_CONFIG_PATH, PATH and LDFLAGS for correct pkg-config lookup and linking; patch Makefiles to replace -ljbig85 with -ljbig to use Debian's JBIG library; stage installation into /tmp/splix-install and run checkinstall against make DESTDIR=/tmp/splix-install install so the .deb is produced without installing on the runner. Also remove a redundant artifact comment.
Update explanatory comments in .github/workflows/build.yml to clarify intent: expand the PKG_CONFIG/LDFLAGS comment to note resolving library/DSO errors, reword the Makefile patch comment to indicate Debian JBIG support, and update the DESTDIR comment to explain it addresses the /model directory creation issue. No functional changes to the build steps.
Adjust GitHub Actions Debian build to use the matrix pkg_config_arch, fix ccache restore-keys formatting, and ensure proper linking and installation paths. Changes include: use matrix.pkg_config_arch in PKG_CONFIG_PATH, inject rastertoqpdl_LIBS and pstoqpdl_LIBS (adds -lcups -lcupsimage -lpthread -ljbig) instead of relying on LDFLAGS/pkg-config, keep the JBIG lib substitution (-ljbig85 -> -ljbig), and use a DESTDIR (/tmp/splix-install) to avoid creating absolute /model paths during packaging. These changes stabilize cross-arch builds (arm64/amd64) and resolve library/DSO linking failures on Debian oldstable.
Add ARM64 (Raspberry Pi) platform to the Actions matrix and keep AMD64 entry. Enable qemu for ARM builds and add a persistent ccache step to speed up subsequent runs. Run the build inside a Debian "oldstable" container for compatibility. Fix build environment by using the matrix pkg_config arch in PKG_CONFIG_PATH, exporting LDFLAGS to ensure libcups/libcupsimage are linked, patching Makefiles to replace -ljbig85 with -ljbig for Debian's JBIG library, and use DESTDIR/checkinstall to avoid creating absolute install paths.
Add a new GitHub Actions workflow (build-works-but-not-complete.yml) that builds Splix drivers for arm64 and amd64 inside a Debian oldstable container, with QEMU for ARM, ccache, and artifact upload. Update existing build.yml: minor matrix/comment cleanup, normalize cache restore-keys, add explicit linker/library variables (rastertoqpdl_LIBS, pstoqpdl_LIBS), keep the jbig85->jbig Makefile patch, and pass explicit CUPS install paths (CUPSFILTER, CUPSPPD, CUPSDRV) to make install to avoid failed CUPS discovery and produce .deb artifacts.
Update GitHub Actions workflow name in .github/workflows/build-works-but-not-complete.yml from 'Build Splix Drivers' to 'Build Splix Drivers - V1' to indicate versioning and distinguish this workflow. No functional changes made.
Add a new GitHub Actions workflow to build and package Splix drivers into .deb artifacts for arm64 and amd64. Triggered on push to master/main and manual dispatch, it uses a matrix (linux/arm64, linux/amd64), sets up QEMU for ARM, caches ccache, and runs the build inside a debian:oldstable container. The job installs build dependencies, applies linker/jbig fixes, runs make and checkinstall to produce splix version 2.0.2 .deb packages, and uploads artifacts to artifacts/*.deb. Also sets FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 and uses actions/checkout, docker/setup-qemu-action, and actions/upload-artifact.
Replace legacy Makefile-based CI with a CMake-based build and packaging flow. Deleted two old workflow files and updated .github/workflows/build.yml to run CMake inside a Debian oldstable container (ARM via QEMU), persist ccache, build/package .deb artifacts, and attach artifacts to releases on version tags. Add a new CMakeLists.txt that defines the splix project, creates splix_core, builds rastertoqpdl and pstoqpdl, and installs filters and PPDs into CUPS paths. Also add generated CMake build/cache files under build/ and a small update to module.mk.
…dard make install since destdir pseudo-flag is invalid
…atch occasionally fumbles directory creation
…rception bugs, use native dpkg-deb via DESTDIR instead
…ho commands to satisfy YAML block scalar parser limits
dutch2005 and others added 17 commits April 16, 2026 22:58
Add produced package and build metadata: the splix-ubuntu-2.0.2-amd64.deb artifact and three CMake API error reply JSONs (no buildsystem generated). Update CMakeCache.txt with CACHESIZE, various DISABLE_* options, pkg-config placeholders, THREADS and set project description to the Splix printer driver. Extend CMakeConfigureLog.yaml with detailed pkg-config find/search diagnostics. Also add docker_tmp_runner.sh for running containerized tasks.
Update the splix-ubuntu-2.0.2-amd64.deb artifact, add a new splix-ubuntu-2.0.2-arm64.deb artifact, and add two CMake API reply JSON files recording "no buildsystem generated" errors from the Visual Studio 18 / CMake 4.2.3-msvc3 environment. The JSON files capture client-vscode query responses for debugging the failed/empty CMake configure step.
Copy link
Copy Markdown
Author

@dutch2005 dutch2005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant