Use statically linked spdlog over system spdlog/libfmt
Some checks failed
Build ptprnt / build (push) Has been cancelled
Some checks failed
Build ptprnt / build (push) Has been cancelled
This commit is contained in:
@@ -14,7 +14,7 @@ jobs:
|
||||
- name: install meson
|
||||
run: apt-get -yq install meson
|
||||
- name: Install build dependencies
|
||||
run: apt-get -yq install libusb-1.0-0-dev libspdlog-dev libfmt-dev libpango1.0-dev libcairo2-dev gcovr
|
||||
run: apt-get -yq install libusb-1.0-0-dev libpango1.0-dev libcairo2-dev gcovr
|
||||
- name: get build environment versions
|
||||
run: |
|
||||
echo "=== Start meson version ==="
|
||||
@@ -32,25 +32,19 @@ jobs:
|
||||
echo "=== Start dependency package version ==="
|
||||
apt-cache policy libpango1.0-dev
|
||||
apt-cache policy libcairo2-dev
|
||||
apt-cache policy libfmt-dev
|
||||
apt-cache policy libspdlog-dev
|
||||
apt-cache policy libusb-1.0-0-dev
|
||||
echo "=== End dependency package version ==="
|
||||
- name: setup builddir
|
||||
run: meson setup builddir -Db_coverage=true
|
||||
- name: run unit tests
|
||||
run: ninja -C builddir test
|
||||
- name: calculate coverage
|
||||
run: ninja -C builddir coverage-text
|
||||
- name: Build ptprnt debug
|
||||
run: scripts/build.sh debug --coverage --test
|
||||
- name: Coverage report
|
||||
run: cat ./builddir/meson-logs/coverage.txt
|
||||
- name: build and test dist package
|
||||
run: ninja -C builddir dist
|
||||
- name: upload dist package
|
||||
run: cat ./builddir-debug/meson-logs/coverage.txt
|
||||
- name: build and release
|
||||
run: scripts/build.sh release
|
||||
- name: upload release binary
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: ptprnt
|
||||
path: ./builddir/meson-dist/*
|
||||
path: ./builddir/ptprnt
|
||||
if-no-files-found: error
|
||||
- name: upload coverage report
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
||||
# Folder
|
||||
builddir/
|
||||
builddir*/
|
||||
subprojects/*
|
||||
.cache/
|
||||
coverageReport/
|
||||
|
||||
41
README.md
41
README.md
@@ -18,17 +18,24 @@ ptprnt --font "NotoMono Nerd Font" --fontsize 32 --text "🖶 ptprnt v0.2.0 🥰
|
||||
|
||||
Arch Linux:
|
||||
```bash
|
||||
pacman -S libusb spdlog pango cairo meson
|
||||
pacman -S libusb pango cairo meson
|
||||
```
|
||||
|
||||
Debian/Ubuntu:
|
||||
```bash
|
||||
apt-get install libusb-1.0-0-dev libspdlog-dev libfmt-dev libpango1.0-dev libcairo2-dev meson
|
||||
apt-get install libusb-1.0-0-dev libpango1.0-dev libcairo2-dev meson
|
||||
```
|
||||
|
||||
Note: spdlog is built as a subproject and statically linked, so it's not required as a system dependency.
|
||||
|
||||
**Build and run:**
|
||||
Clone this repository first and enter the directory. Then build:
|
||||
```bash
|
||||
# Using the build script (recommended)
|
||||
./scripts/build.sh release
|
||||
builddir/ptprnt --help
|
||||
|
||||
# Or manually with meson
|
||||
meson setup builddir
|
||||
ninja -C builddir
|
||||
builddir/ptprnt --help
|
||||
@@ -181,13 +188,43 @@ ptprnt \
|
||||
|
||||
This is a modern C++20 rewrite of [ptouch-print](https://git.familie-radermacher.ch/linux/ptouch-print.git). Credits to Dominic Rademacher for reverse engineering the USB protocol.
|
||||
|
||||
**Build script:**
|
||||
```bash
|
||||
# Release build
|
||||
./scripts/build.sh release
|
||||
|
||||
# Debug build
|
||||
./scripts/build.sh debug
|
||||
|
||||
# Debug with tests
|
||||
./scripts/build.sh debug --test
|
||||
|
||||
# Debug with coverage
|
||||
./scripts/build.sh debug --coverage
|
||||
|
||||
# Clean all build directories
|
||||
./scripts/build.sh clean
|
||||
|
||||
# Show all options
|
||||
./scripts/build.sh --help
|
||||
```
|
||||
|
||||
**Running tests:**
|
||||
```bash
|
||||
# Using build script
|
||||
./scripts/build.sh --test
|
||||
|
||||
# Or manually
|
||||
ninja -C builddir test
|
||||
```
|
||||
|
||||
**Coverage reports:**
|
||||
```bash
|
||||
# Using build script
|
||||
./scripts/build.sh debug --coverage
|
||||
./scripts/generate_coverage.sh
|
||||
|
||||
# Or manually
|
||||
meson setup builddir -Db_coverage=true
|
||||
ninja -C builddir
|
||||
ninja -C builddir test
|
||||
|
||||
12
meson.build
12
meson.build
@@ -20,10 +20,16 @@ project(
|
||||
)
|
||||
|
||||
usb_dep = dependency('libusb-1.0')
|
||||
log_dep = dependency('spdlog')
|
||||
fmt_dep = dependency('fmt')
|
||||
pangocairo_dep = dependency('pangocairo')
|
||||
|
||||
# spdlog with std::format (C++20) - static library
|
||||
spdlog_proj = subproject('spdlog', default_options: ['std_format=enabled', 'default_library=static', 'compile_library=true'])
|
||||
log_dep = spdlog_proj.get_variable('spdlog_dep')
|
||||
|
||||
if not log_dep.found()
|
||||
error('spdlog not found, can not proceed')
|
||||
endif
|
||||
|
||||
# CLI11
|
||||
cli11_proj = subproject('cli11')
|
||||
cli11_dep = cli11_proj.get_variable('CLI11_dep')
|
||||
@@ -50,7 +56,7 @@ ptprnt_exe = executable(
|
||||
'ptprnt',
|
||||
'src/main.cpp',
|
||||
install: true,
|
||||
dependencies: [usb_dep, log_dep, fmt_dep, pangocairo_dep, cli11_dep],
|
||||
dependencies: [usb_dep, log_dep, pangocairo_dep, cli11_dep],
|
||||
include_directories: incdir,
|
||||
sources: [ptprnt_srcs],
|
||||
cpp_args: cpp_args,
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
*/
|
||||
#include "PtouchPrint.hpp"
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <spdlog/sinks/basic_file_sink.h>
|
||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
@@ -104,11 +105,11 @@ bool PtouchPrint::handleListDrivers() {
|
||||
auto driverFactory = std::make_unique<PrinterDriverFactory>();
|
||||
auto drivers = driverFactory->listAllDrivers();
|
||||
|
||||
fmt::print("Available printer drivers:\n");
|
||||
std::cout << "Available printer drivers:\n";
|
||||
for (const auto& driver : drivers) {
|
||||
fmt::print(" - {}\n", driver);
|
||||
std::cout << std::format(" - {}\n", driver);
|
||||
}
|
||||
fmt::print("\nUse with: -p <driver_name> or --printer <driver_name>\n");
|
||||
std::cout << "\nUse with: -p <driver_name> or --printer <driver_name>\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
|
||||
#include "CliParser.hpp"
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
|
||||
namespace ptprnt::cli {
|
||||
|
||||
@@ -92,7 +93,7 @@ void CliParser::reorderCommandsByArgv(int argc, char** argv) {
|
||||
void CliParser::setupParser() {
|
||||
// Version callback
|
||||
auto printVersion = [this](std::size_t) {
|
||||
fmt::print("ptprnt version: {}\n", mVersionString);
|
||||
std::cout << std::format("ptprnt version: {}\n", mVersionString);
|
||||
throw CLI::CallForVersion();
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -274,7 +275,7 @@ bool Label::append(const ILabel& other, uint32_t spacingPx) {
|
||||
int newStride = mCairoWrapper->cairo_image_surface_get_stride(newSurface.get());
|
||||
|
||||
// Clear the new surface (set to transparent/white)
|
||||
std::memset(newData, 0x00, newStride * height);
|
||||
memset(newData, 0x00, newStride * height);
|
||||
|
||||
// Copy current label data
|
||||
for (int y = 0; y < height; ++y) {
|
||||
|
||||
Reference in New Issue
Block a user