Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ae333a3
chore(core-debug): add spdlog debug logging and ban raw std::cout
Prachi-Gupta2808 Jul 16, 2026
db35d9e
Update core/include/internal/gpu.h
Prachi-Gupta2808 Jul 16, 2026
45e1a0f
Update .github/workflows/no-raw-debug-output.yml
Prachi-Gupta2808 Jul 16, 2026
018bdcc
chore(core): add spdlog debug logging and ban raw std::cout
Prachi-Gupta2808 Jul 23, 2026
2702dff
Merge branch 'chore/spdlog-debug-logging' of https://github.com/Prach…
Prachi-Gupta2808 Jul 23, 2026
63e2eab
fix spdlog
Krasner Jul 24, 2026
520e250
restore dawn
Krasner Jul 24, 2026
1c18309
Merge branch 'dev' into chore/spdlog-debug-logging
Krasner Jul 24, 2026
40473dd
format
Krasner Jul 24, 2026
82063ba
Update .github/workflows/no-raw-debug-output.yml
Krasner Jul 26, 2026
2f37c8e
Merge branch 'dev' into chore/spdlog-debug-logging
Krasner Jul 26, 2026
c4ea135
Merge branch 'dev' into chore/spdlog-debug-logging
Ryan-Millard Aug 3, 2026
5e1ae08
Merge branch 'dev' into chore/spdlog-debug-logging
Ryan-Millard Aug 20, 2026
45884e6
feat(core): add IMG2NUM_LOG_LEVEL for configurable compile-time logging
Ryan-Millard Aug 20, 2026
037cc70
ci: fix inverted exit-code handling in raw debug output check
Ryan-Millard Aug 20, 2026
20207c3
fix(py): include spdlog in sdist and collect licenses into the wheel
Ryan-Millard Aug 20, 2026
df2bcd6
temp
Ryan-Millard Aug 24, 2026
1844ba6
chore: move C++ lint/format tooling to uv-managed scripts/py workspace
Ryan-Millard Aug 25, 2026
906a509
chore: unify lint/format scripts under lint:* and format:* namespaces
Ryan-Millard Aug 25, 2026
9a2b37a
build: persist scikit-build CMake tree for clang-tidy coverage
Ryan-Millard Aug 25, 2026
b670ea6
build: lint wasm TUs against build-wasm compile database
Ryan-Millard Aug 25, 2026
1eea3e4
revert: out of scope packages/js change for licensing
Ryan-Millard Aug 25, 2026
f8a361d
fix(ci.yml): uv sync errors during lint
Ryan-Millard Aug 25, 2026
ff21cc8
fix(editorconfig): ignore generated files
Ryan-Millard Aug 25, 2026
9915ab0
fix: remove accidentally leftover file licenses.plugin.mjs
Ryan-Millard Aug 25, 2026
7959e05
style: fix editorconfig errors
Ryan-Millard Aug 25, 2026
6e3dc31
ci: skip wasm CMake prebuild in docs job via env flag
Ryan-Millard Aug 25, 2026
feafe09
revert: "ci: skip wasm CMake prebuild in docs job via env flag"
Ryan-Millard Aug 26, 2026
819935c
ci: fix docs build by pull spdlog
Ryan-Millard Aug 26, 2026
fdd06b1
ci: fix docs build errors
Ryan-Millard Aug 26, 2026
c85c987
UNDO!!! -> trigger release.yml on this PR temporarily for testing
Ryan-Millard Aug 26, 2026
0f70eb1
build(packages/js): drop just prebuild hook, add config-time wasm guard
Ryan-Millard Aug 26, 2026
1adf366
Merge branch 'dev' into chore/spdlog-debug-logging
Ryan-Millard Aug 26, 2026
979b939
style(vite.config.js): format the file
Ryan-Millard Aug 26, 2026
628d442
revert: "UNDO!!! -> trigger release.yml on this PR temporarily for te…
Ryan-Millard Aug 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
BasedOnStyle: LLVM
Standard: c++20
Standard: c++17

# --- Basic formatting ---
IndentWidth: 4
ColumnLimit: 100
TabWidth: 4

# --- Braces ---
Cpp11BracedListStyle: true
SpaceBeforeCpp11BracedList: true
BreakBeforeBraces: Attach

# --- Braced initializers ---
Cpp11BracedListStyle: true
SpaceBeforeCpp11BracedList: true

# --- Constructor initializer lists ---
PackConstructorInitializers: Never
Expand Down
25 changes: 25 additions & 0 deletions .clang-tidy
Comment thread
Ryan-Millard marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Checks: >
-*,
readability-*,
cppcoreguidelines-avoid-non-const-global-variables,
portability-restrict-system-includes,
bugprone-unsafe-functions
WarningsAsErrors: >
portability-restrict-system-includes,
bugprone-unsafe-functions
HeaderFilterRegex: '(core|bindings)/.*\.(h|hpp)$'
CheckOptions:
readability-identifier-length.IgnoredVariableNames: "^([a-zA-Z][a-zA-Z0-9]?)$"
readability-identifier-length.IgnoredParameterNames: "^([a-zA-Z][a-zA-Z0-9]?_?)$"
readability-identifier-length.IgnoredLoopCounterNames: "^[a-z]$"
readability-identifier-naming.FunctionCase: lower_case # free functions stay snake_case
readability-identifier-naming.MethodCase: camelBack # class methods stay camelCase
portability-restrict-system-includes.Includes: >-
*,-iostream,-ostream,-istream,-cstdio,-stdio.h,-print,-syncstream
bugprone-unsafe-functions.CustomFunctions: >-
::printf, the logging macros in core/include/internal/log.h, direct stdout output is banned;
::fprintf, the logging macros in core/include/internal/log.h, direct stream output is banned;
::puts, the logging macros in core/include/internal/log.h,;
::putchar, the logging macros in core/include/internal/log.h,;
::vprintf, the logging macros in core/include/internal/log.h,;
::perror, the logging macros in core/include/internal/log.h,
2 changes: 1 addition & 1 deletion .editorconfig-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"IndentSize": false,
"MaxLineLength": false
},
"Exclude": ["node_modules", "dist", "build", ".git", "docs/build", "docs/.docusaurus", "docs/static", "docs/docs/js/api", "example-apps/react-js/src/data/contributor-credits.json", "core/src/internal/resources/.*\\.wgsl$", "third_party", "\\.ase$", "\\.min\\.js$", "\\.min\\.css$", "\\.lock$", "CC-BY-SA-4\\.0\\.txt$", "LICENSE.*", "\\.md$", "\\.mdx$", "\\.py$", "\\.pyi$", "\\.bat$", "\\.ps1$", "^img2num$", "\\.cpp$", "\\.hpp$", "\\.c$", "\\.h$", ".pnpm-store"]
"Exclude": ["node_modules", "dist", ".venv", "^build*", ".git", "docs/build", "docs/.docusaurus", "docs/static", "docs/docs/js/api", "example-apps/react-js/src/data/contributor-credits.json", "core/src/internal/resources/.*\\.wgsl$", "third_party", "\\.ase$", "\\.min\\.js$", "\\.min\\.css$", "\\.lock$", "CC-BY-SA-4\\.0\\.txt$", "LICENSE.*", "\\.md$", "\\.mdx$", "\\.py$", "\\.pyi$", "\\.bat$", "\\.ps1$", "^img2num$", "\\.cpp$", "\\.hpp$", "\\.c$", "\\.h$", ".pnpm-store"]
}
8 changes: 8 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ jobs:
- name: Checkout code
# No need for submodules since docs uses NPM
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
submodules: false

- name: Mark repository as safe
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Initialize spdlog
run: git -c submodule.recurse=false submodule update --init third_party/spdlog

- name: Install Dependendencies
run: pnpm install
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ jobs:
runs-on: ubuntu-latest
container:
image: ${{ needs.set-image.outputs.image }}
env:
UV_NO_SYNC: "1" # every later `uv run` uses the env as-is
steps:
- name: Checkout code
# No need for submodules since we are not running code
Expand All @@ -85,8 +87,17 @@ jobs:
- name: Install PNPM dependencies
run: pnpm install

- name: Sync Python tooling (skip building img2num)
run: uv sync --no-install-project
env:
UV_NO_SYNC: "" # let this one step actually sync

- name: Run ESLint
run: pnpm run eslint
run: pnpm run lint:js

# Commented out until the C and C++ files are formatted and committed to the repo
#- name: Run clang-tidy
#run: pnpm run lint:cpp

- name: Validate format
run: pnpm run format:check
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ jobs:
-DIMG2NUM_BUILD_C=${{ steps.component.outputs.IMG2NUM_BUILD_C_VAL }} \
-DIMG2NUM_BUILD_PYTHON=OFF \
-DIMG2NUM_BUILD_EXAMPLES=OFF \
-DIMG2NUM_DEBUG_CACHE_VARIABLES_DUMP=ON
-DIMG2NUM_DEBUG_CACHE_VARIABLES_DUMP=ON \
-DIMG2NUM_LOG_LEVEL=OFF \
.

- name: Build
run: cmake --build build --config Release
Expand Down Expand Up @@ -254,23 +256,21 @@ jobs:
with:
version: 11.4.0

- uses: extractions/setup-just@53165ef7e734c5c07cb06b3c8e7b647c5aa16db3 # v4.0.0
with:
just-version: '1.46.0'

- name: Install dependencies
run: pnpm install

- name: Build WASM
- name: Configure
run: |
emcmake cmake -B build-wasm \
-DCMAKE_BUILD_TYPE=Release \
-DIMG2NUM_BUILD_C=ON \
-DIMG2NUM_BUILD_PYTHON=OFF \
-DIMG2NUM_BUILD_EXAMPLES=OFF \
-DIMG2NUM_DEBUG_CACHE_VARIABLES_DUMP=ON \
-DIMG2NUM_LOG_LEVEL=OFF \
.
cmake --build build-wasm
- name: Build
run: cmake --build build-wasm --config Release

- name: Build JS
run: pnpm build
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "third_party/stb"]
path = third_party/stb
url = https://github.com/nothings/stb.git
[submodule "third_party/spdlog"]
path = third_party/spdlog
url = https://github.com/gabime/spdlog.git
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =================================================================
# Img2Num Top-Level (Manages all libs and apps)
# =================================================================
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.25)
project(Img2NumRootManager LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
Expand All @@ -10,6 +10,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# This is important for inter-OS reproducibility
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Reusable flags to ensure good quality code
set(IMG2NUM_STRICT_CXX_FLAGS
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>>:-Wpedantic -Werror=pedantic -Werror=c++20-extensions>
Expand Down Expand Up @@ -45,17 +47,21 @@ if(IMG2NUM_DEBUG_CACHE_VARIABLES_DUMP)
foreach(_var ${_vars})
string(TOUPPER "${_var}" _var_upper)

if(_var MATCHES "^IMG2NUM")
# Exact upper case matches (User flags like IMG2NUM_BUILD_C)
if(_var MATCHES "^(C)?IMG2NUM")
message(STATUS "[User-Defined] ${COLOR_MAGENTA}${_var}=${${_var}}${COLOR_RESET}")
elseif(_var_upper MATCHES "^IMG2NUM")

# Case-insensitive matches via _var_upper (Auto variables like CImg2Num_BINARY_DIR)
elseif(_var_upper MATCHES "^(C)?IMG2NUM")
message(STATUS "[Auto] ${COLOR_CYAN}${_var}=${${_var}}${COLOR_RESET}")
endif()
endforeach()

foreach(_var ${_vars})
string(TOUPPER "${_var}" _var_upper)

if(NOT _var_upper MATCHES "^IMG2NUM")
# Adding (C)? here stops CImg2Num variables from sneaking into the third-party list
if(NOT _var_upper MATCHES "^(C)?IMG2NUM")
message(STATUS "${_var}=${${_var}}")
endif()
endforeach()
Expand All @@ -64,6 +70,7 @@ if(IMG2NUM_DEBUG_CACHE_VARIABLES_DUMP)
endif()
endblock()


# ================================================
# Library setup

Expand Down
4 changes: 3 additions & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ RUN uv venv /usr/src/app/.venv
ENV VIRTUAL_ENV=/usr/src/app/.venv
ENV PATH="/usr/src/app/.venv/bin:$PATH"

COPY pyproject.toml uv.lock ./
COPY example-apps/console-py/pyproject.toml example-apps/console-py/pyproject.toml
RUN --mount=type=cache,target=/root/.cache/uv \
uv pip install scikit_build_core numpy
uv sync --locked --no-install-workspace --group dev --group lint --group build

# --------------------------------------------------------------------------------------------------------------
# Node / pnpm setup
Expand Down
55 changes: 34 additions & 21 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,50 @@ format:
@echo "Format all files"
pnpm format

build-c-cpp build_type="Release" log_level="AUTO":
@echo "Build C++ core and C bindings ({{ build_type }}, log={{ log_level }})"
cmake -DCMAKE_BUILD_TYPE={{ build_type }} \
-DIMG2NUM_LOG_LEVEL={{ log_level }} \
-B build-c-cpp/ .
cmake --build build-c-cpp/ --parallel

reuse-check:
@echo "Check REUSE/SPDX license compliance"
reuse lint

build-c-cpp:
@echo "Build C++ core and C bindings"
cmake -DCMAKE_BUILD_TYPE=Release -B build-c-cpp/ .
cmake --build build-c-cpp/ --parallel

build-wasm:
@echo "Build JS bindings"
emcmake cmake -DCMAKE_BUILD_TYPE=Release -B build-wasm/ .
build-wasm build_type="Release" log_level="AUTO":
@echo "Build JS bindings ({{ build_type }}, log={{ log_level }})"
emcmake cmake -DCMAKE_BUILD_TYPE={{ build_type }} \
-DIMG2NUM_LOG_LEVEL={{ log_level }} \
-B build-wasm/ .
cmake --build build-wasm/ --parallel

build-py:
@echo "Build python bindings and py package"
uv sync --reinstall
build-py build_type="Release" log_level="AUTO":
@echo "Build python bindings and py package ({{ build_type }}, log={{ log_level }})"
SKBUILD_CMAKE_BUILD_TYPE={{ build_type }} \
SKBUILD_CMAKE_DEFINE="IMG2NUM_LOG_LEVEL={{ log_level }}" \
uv sync --reinstall-package img2num
SKBUILD_CMAKE_BUILD_TYPE={{ build_type }} \
SKBUILD_CMAKE_DEFINE="IMG2NUM_LOG_LEVEL={{ log_level }}" \
uv build --wheel

build-packages-js:
build-packages-js build_type="Release" log_level="AUTO":
@echo "Build js packages"
just build-wasm
just build-wasm {{ build_type }} {{ log_level }}
pnpm -F img2num build

build target:
build target build_type="Release" log_level="AUTO":
case "{{ target }}" in \
cpp) just build-c-cpp ;; \
js) just build-wasm ;; \
py) just build-py ;; \
packages-js) just build-packages-js ;; \
all) just build-c-cpp build-wasm build-py build-packages-js react-js build docs build ;; \
cpp) just build-c-cpp {{ build_type }} {{ log_level }} ;; \
js) just build-wasm {{ build_type }} {{ log_level }} ;; \
py) just build-py {{ build_type }} {{ log_level }} ;; \
packages-js) just build-packages-js {{ build_type }} {{ log_level }} ;; \
all) just build-c-cpp {{ build_type }} {{ log_level }} && \
just build-wasm {{ build_type }} {{ log_level }} && \
just build-py {{ build_type }} {{ log_level }} && \
just build-packages-js {{ build_type }} {{ log_level }} && \
just react-js build && \
just docs build ;; \
esac

clean target:
Expand All @@ -91,7 +104,7 @@ docs action:
start) cd docs/ && pnpm run serve ;; \
esac

react-js action: build-packages-js
react-js action:
@echo "Run react sample app"
case "{{ action }}" in \
build) pnpm -F react-example run build ;; \
Expand Down Expand Up @@ -120,4 +133,4 @@ console-js-esm input:
node example-apps/console-js-esm/index.mjs "{{ input }}"

html-js script:
pnpm -F html-js-iife "{{script}}"
pnpm -F html-js "{{script}}"
5 changes: 2 additions & 3 deletions bindings/js/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.16)
project(JSBindings LANGUAGES C)

set(CMAKE_C_STANDARD 17)
Expand Down Expand Up @@ -61,9 +60,9 @@ function(img2num_add_wasm_variant TARGET_NAME)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${TARGET_NAME} PRIVATE
-O0 -gsource-map -fsanitize=alignment)
-O0 -g -fsanitize=alignment)
target_link_options(${TARGET_NAME} PRIVATE
-gsource-map -fsanitize=alignment
-g -fsanitize=alignment
"SHELL:-sASSERTIONS=2"
"SHELL:-sSTACK_OVERFLOW_CHECK=1")
else()
Expand Down
6 changes: 3 additions & 3 deletions bindings/py/src/img2num_pybind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ PYBIND11_MODULE(_img2num, m) {
const uint8_t* data_ptr {static_cast<const uint8_t*>(data.request().ptr)};
const int32_t* labels_ptr {static_cast<const int32_t*>(labels.request().ptr)};

std::string svg {img2num::labels_to_svg(
data_ptr, labels_ptr, width, height, min_area, min_thickness
)};
std::string svg {
img2num::labels_to_svg(data_ptr, labels_ptr, width, height, min_area, min_thickness)
};
pybind11::str svg_py_str(std::move(svg));

return pybind11::str(std::move(svg));
Expand Down
Loading