libstb 0.5.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. libstb-0.7.0/.github/workflows/cmake.yml +138 -0
  2. {libstb-0.5.0 → libstb-0.7.0}/.github/workflows/orchestrator.yml +38 -0
  3. libstb-0.7.0/.github/workflows/wheels.yml +137 -0
  4. libstb-0.7.0/CHANGELOG.md +186 -0
  5. {libstb-0.5.0 → libstb-0.7.0}/CMakeLists.txt +49 -23
  6. libstb-0.7.0/PKG-INFO +170 -0
  7. libstb-0.7.0/README.md +139 -0
  8. libstb-0.7.0/benchmarks/.gitignore +1 -0
  9. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/CMakeLists.txt +16 -9
  10. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/README.md +27 -20
  11. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/cmake/FetchRealCorpus.cmake +4 -6
  12. libstb-0.7.0/benchmarks/outputs/benchmark.json +1 -0
  13. libstb-0.7.0/benchmarks/outputs/index.html +7726 -0
  14. libstb-0.7.0/benchmarks/outputs/results/fonts.json +259 -0
  15. libstb-0.7.0/benchmarks/outputs/results/scaling.json +639 -0
  16. libstb-0.7.0/benchmarks/outputs/results/sizes.json +120 -0
  17. libstb-0.7.0/benchmarks/outputs/results/system_info.json +10 -0
  18. libstb-0.7.0/benchmarks/outputs/results/throughput.json +17180 -0
  19. libstb-0.7.0/benchmarks/outputs/results/throughput_memory.json +13273 -0
  20. libstb-0.7.0/benchmarks/outputs/results/verify.json +6 -0
  21. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/CMakeLists.txt +20 -18
  22. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/bench_fonts.py +5 -5
  23. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/bench_sizes.py +1 -1
  24. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/runners.py +91 -15
  25. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/verify.py +28 -2
  26. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/report/CMakeLists.txt +19 -20
  27. libstb-0.7.0/benchmarks/report/gather.py +436 -0
  28. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/report/generate_report.py +57 -3
  29. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/report/template.html.jinja2 +22 -22
  30. libstb-0.7.0/cmake/FixLCovPaths.cmake +9 -0
  31. libstb-0.7.0/cmake/GenerateIframe.cmake +23 -0
  32. libstb-0.7.0/cmake/coverage_iframe.html.in +152 -0
  33. libstb-0.7.0/docs/CMakeLists.txt +194 -0
  34. libstb-0.7.0/docs/CreateDocs.cmake +53 -0
  35. libstb-0.7.0/docs/InjectComment.cmake +85 -0
  36. libstb-0.7.0/docs/assets/bench-teaser.js +66 -0
  37. libstb-0.7.0/docs/assets/libstb-docs.css +295 -0
  38. libstb-0.7.0/docs/cpp/CreateDocs.cmake +87 -0
  39. libstb-0.7.0/docs/cpp/Doxyfile.in +61 -0
  40. libstb-0.7.0/docs/cpp/footer.html.in +21 -0
  41. libstb-0.7.0/docs/cpp/index-docs.json +8 -0
  42. libstb-0.7.0/docs/cpp/index-example.txt +15 -0
  43. libstb-0.7.0/docs/cpp/index-install.txt +11 -0
  44. libstb-0.7.0/docs/cpp/libstb-doxygen.css +74 -0
  45. libstb-0.7.0/docs/cpp/mainpage.md +51 -0
  46. libstb-0.7.0/docs/cpp/topbar.html.in +19 -0
  47. libstb-0.7.0/docs/generate_index.py +192 -0
  48. libstb-0.7.0/docs/guide.md +347 -0
  49. libstb-0.7.0/docs/images/libstb-logo.png +0 -0
  50. libstb-0.7.0/docs/images/libstb-sq.png +0 -0
  51. libstb-0.7.0/docs/images/libstb-sq.svg +1 -0
  52. libstb-0.7.0/docs/images/libstb-sq.txt +4 -0
  53. libstb-0.7.0/docs/images/libstb-theme.svg +1 -0
  54. libstb-0.7.0/docs/index.html.in +247 -0
  55. libstb-0.7.0/docs/initial_comment.in +15 -0
  56. libstb-0.7.0/docs/make_showcase.py +60 -0
  57. libstb-0.7.0/docs/python/CreateDocs.cmake +59 -0
  58. libstb-0.7.0/docs/python/index-docs.json +8 -0
  59. libstb-0.7.0/docs/python/index-example.txt +11 -0
  60. libstb-0.7.0/docs/python/index-install.txt +2 -0
  61. libstb-0.7.0/docs/python/source/_themes/libstb/layout.html +154 -0
  62. libstb-0.7.0/docs/python/source/_themes/libstb/libstb-nav.html +14 -0
  63. libstb-0.7.0/docs/python/source/_themes/libstb/page.html +2 -0
  64. libstb-0.7.0/docs/python/source/_themes/libstb/static/libstb-docs.css +418 -0
  65. libstb-0.7.0/docs/python/source/_themes/libstb/static/libstb-sphinx.css +102 -0
  66. libstb-0.7.0/docs/python/source/_themes/libstb/theme.toml +9 -0
  67. libstb-0.7.0/docs/python/source/conf.py +98 -0
  68. libstb-0.7.0/docs/python/source/errors.rst +10 -0
  69. libstb-0.7.0/docs/python/source/font.rst +40 -0
  70. libstb-0.7.0/docs/python/source/image.rst +34 -0
  71. libstb-0.7.0/docs/python/source/index.rst +36 -0
  72. libstb-0.7.0/docs/python/source/resizer.rst +14 -0
  73. libstb-0.7.0/docs/python/source/simd.rst +19 -0
  74. libstb-0.7.0/docs/python/source/zlib.rst +30 -0
  75. libstb-0.7.0/docs/supported_langs.json +31 -0
  76. {libstb-0.5.0 → libstb-0.7.0}/examples/notebooks/01_getting_started.ipynb +15 -15
  77. {libstb-0.5.0 → libstb-0.7.0}/examples/notebooks/02_resize_filters.ipynb +4 -4
  78. {libstb-0.5.0 → libstb-0.7.0}/examples/notebooks/03_font_rendering.ipynb +2 -2
  79. libstb-0.7.0/examples/notebooks/04_edit_and_orient.ipynb +187 -0
  80. {libstb-0.5.0 → libstb-0.7.0}/examples/python/01_open_and_inspect.py +8 -8
  81. {libstb-0.5.0 → libstb-0.7.0}/examples/python/02_encode_formats.py +3 -3
  82. {libstb-0.5.0 → libstb-0.7.0}/examples/python/03_resize_filters.py +5 -5
  83. {libstb-0.5.0 → libstb-0.7.0}/examples/python/04_numpy_interop.py +5 -5
  84. {libstb-0.5.0 → libstb-0.7.0}/examples/python/05_font_render.py +2 -2
  85. {libstb-0.5.0 → libstb-0.7.0}/examples/python/06_imread_imwrite.py +10 -10
  86. {libstb-0.5.0 → libstb-0.7.0}/examples/python/07_dlpack.py +7 -7
  87. libstb-0.7.0/examples/python/08_geometry.py +61 -0
  88. libstb-0.7.0/examples/python/09_channels_and_alpha.py +52 -0
  89. libstb-0.7.0/examples/python/10_exif_orientation.py +81 -0
  90. libstb-0.7.0/examples/python/11_pillow.py +46 -0
  91. {libstb-0.5.0 → libstb-0.7.0}/examples/python/requirements.txt +1 -0
  92. libstb-0.7.0/include/stb/env.hpp +31 -0
  93. {libstb-0.5.0 → libstb-0.7.0}/include/stb/font.hpp +26 -1
  94. {libstb-0.5.0 → libstb-0.7.0}/include/stb/image.hpp +107 -1
  95. libstb-0.7.0/include/stb/zlib.hpp +59 -0
  96. {libstb-0.5.0 → libstb-0.7.0}/include/stb.h +3 -1
  97. {libstb-0.5.0 → libstb-0.7.0}/pyproject.toml +14 -10
  98. libstb-0.7.0/requirements-dev.txt +21 -0
  99. {libstb-0.5.0 → libstb-0.7.0}/src/bindings/python/CMakeLists.txt +1 -1
  100. {libstb-0.5.0 → libstb-0.7.0}/src/bindings/python/bind_font.cpp +21 -0
  101. libstb-0.7.0/src/bindings/python/bind_image.cpp +651 -0
  102. libstb-0.7.0/src/bindings/python/bind_zlib.cpp +34 -0
  103. {libstb-0.5.0 → libstb-0.7.0}/src/bindings/python/binding.cpp +1 -0
  104. libstb-0.7.0/src/bindings/python/binding.hpp +33 -0
  105. {libstb-0.5.0 → libstb-0.7.0}/src/bindings/python/libstb/__init__.py +52 -6
  106. libstb-0.7.0/src/bindings/python/libstb/compress.py +50 -0
  107. {libstb-0.5.0 → libstb-0.7.0}/src/bindings/python/libstb/font.py +22 -0
  108. libstb-0.7.0/src/bindings/python/libstb/image.py +98 -0
  109. libstb-0.7.0/src/core/exif.cpp +127 -0
  110. {libstb-0.5.0 → libstb-0.7.0}/src/core/font.cpp +150 -0
  111. {libstb-0.5.0 → libstb-0.7.0}/src/core/image.cpp +63 -2
  112. libstb-0.7.0/src/core/image_kernels.hpp +153 -0
  113. libstb-0.7.0/src/core/image_kernels_scalar.cpp +37 -0
  114. libstb-0.7.0/src/core/image_kernels_sse2.cpp +107 -0
  115. libstb-0.7.0/src/core/image_ops.cpp +372 -0
  116. libstb-0.7.0/src/core/simd.cpp +142 -0
  117. libstb-0.7.0/src/core/simd.hpp +24 -0
  118. libstb-0.7.0/src/core/zlib.cpp +137 -0
  119. libstb-0.7.0/src/core/zlib_bridge.hpp +23 -0
  120. libstb-0.7.0/tests/CMakeLists.txt +139 -0
  121. {libstb-0.5.0 → libstb-0.7.0}/tests/cmake/CMakeLists.txt +4 -4
  122. libstb-0.7.0/tests/coverage_dashboard.html.in +600 -0
  123. libstb-0.7.0/tests/cpp/CMakeLists.txt +112 -0
  124. libstb-0.7.0/tests/cpp/test_edit.cpp +628 -0
  125. libstb-0.7.0/tests/cpp/test_env.cpp +50 -0
  126. libstb-0.7.0/tests/cpp/test_exif.cpp +192 -0
  127. {libstb-0.5.0 → libstb-0.7.0}/tests/cpp/test_font.cpp +45 -0
  128. {libstb-0.5.0 → libstb-0.7.0}/tests/cpp/test_image.cpp +25 -0
  129. libstb-0.7.0/tests/cpp/test_zlib.cpp +141 -0
  130. libstb-0.7.0/tests/genhtml.css +241 -0
  131. libstb-0.7.0/tests/python/CMakeLists.txt +88 -0
  132. libstb-0.7.0/tests/python/conftest.py +24 -0
  133. libstb-0.7.0/tests/python/pngbomb.py +46 -0
  134. libstb-0.7.0/tests/python/test_array_interface.py +163 -0
  135. libstb-0.7.0/tests/python/test_channels.py +193 -0
  136. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_dlpack.py +24 -24
  137. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_encode.py +3 -3
  138. libstb-0.7.0/tests/python/test_errors.py +25 -0
  139. libstb-0.7.0/tests/python/test_exif.py +112 -0
  140. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_font.py +60 -8
  141. libstb-0.7.0/tests/python/test_functional.py +138 -0
  142. libstb-0.7.0/tests/python/test_gc.py +106 -0
  143. libstb-0.7.0/tests/python/test_geometry.py +192 -0
  144. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_image.py +32 -32
  145. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_lossless_exact.py +5 -4
  146. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_lossy_tolerance.py +6 -5
  147. libstb-0.7.0/tests/python/test_memory.py +221 -0
  148. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_no_numpy.py +22 -20
  149. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_oop.py +6 -6
  150. libstb-0.7.0/tests/python/test_pillow_convert.py +168 -0
  151. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_pillow_parity.py +15 -14
  152. libstb-0.7.0/tests/python/test_png_bomb.py +72 -0
  153. {libstb-0.5.0 → libstb-0.7.0}/tests/python/test_resizer.py +3 -3
  154. libstb-0.7.0/tests/python/test_simd.py +200 -0
  155. libstb-0.7.0/tests/python/test_torch.py +180 -0
  156. libstb-0.7.0/tests/python/test_zlib.py +162 -0
  157. libstb-0.7.0/tools/gen_font_metrics.py +76 -0
  158. libstb-0.5.0/.github/workflows/cmake.yml +0 -39
  159. libstb-0.5.0/.github/workflows/wheels.yml +0 -70
  160. libstb-0.5.0/PKG-INFO +0 -251
  161. libstb-0.5.0/README.md +0 -223
  162. libstb-0.5.0/requirements-dev.txt +0 -14
  163. libstb-0.5.0/src/bindings/python/bind_image.cpp +0 -351
  164. libstb-0.5.0/src/bindings/python/binding.hpp +0 -13
  165. libstb-0.5.0/src/bindings/python/libstb/image.py +0 -42
  166. libstb-0.5.0/tests/CMakeLists.txt +0 -13
  167. libstb-0.5.0/tests/cpp/CMakeLists.txt +0 -24
  168. libstb-0.5.0/tests/python/CMakeLists.txt +0 -26
  169. libstb-0.5.0/tests/python/test_errors.py +0 -25
  170. libstb-0.5.0/tests/python/test_functional.py +0 -101
  171. {libstb-0.5.0 → libstb-0.7.0}/.github/workflows/release_template.md +0 -0
  172. {libstb-0.5.0 → libstb-0.7.0}/.gitignore +0 -0
  173. {libstb-0.5.0 → libstb-0.7.0}/LICENSE.txt +0 -0
  174. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/cmake/Download.cmake +0 -0
  175. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/corpus/.gitignore +0 -0
  176. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/bench_op_memory_driver.py +0 -0
  177. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/bench_op_memory_one.py +0 -0
  178. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/bench_scaling.py +0 -0
  179. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/bench_throughput.py +0 -0
  180. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/corpus.py +0 -0
  181. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/real_corpus_manifest.py +0 -0
  182. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/requirements.txt +0 -0
  183. {libstb-0.5.0 → libstb-0.7.0}/benchmarks/python/system_info.py +0 -0
  184. {libstb-0.5.0 → libstb-0.7.0}/cmake/DynamicVersion.cmake +0 -0
  185. {libstb-0.5.0 → libstb-0.7.0}/cmake/Optimize.cmake +0 -0
  186. {libstb-0.5.0 → libstb-0.7.0}/cmake/Startup.cmake +0 -0
  187. {libstb-0.5.0 → libstb-0.7.0}/cmake/libstbConfig.cmake.in +0 -0
  188. {libstb-0.5.0 → libstb-0.7.0}/examples/cpp/.gitignore +0 -0
  189. {libstb-0.5.0 → libstb-0.7.0}/examples/notebooks/.gitignore +0 -0
  190. {libstb-0.5.0 → libstb-0.7.0}/examples/notebooks/requirements.txt +0 -0
  191. {libstb-0.5.0 → libstb-0.7.0}/examples/python/.gitignore +0 -0
  192. {libstb-0.5.0 → libstb-0.7.0}/include/stb/error.hpp +0 -0
  193. {libstb-0.5.0 → libstb-0.7.0}/include/stb/resizer.hpp +0 -0
  194. {libstb-0.5.0 → libstb-0.7.0}/include/stb/utf8.hpp +0 -0
  195. {libstb-0.5.0 → libstb-0.7.0}/src/bindings/python/bind_resizer.cpp +0 -0
  196. {libstb-0.5.0 → libstb-0.7.0}/src/core/file.hpp +0 -0
  197. {libstb-0.5.0 → libstb-0.7.0}/src/core/resizer.cpp +0 -0
  198. {libstb-0.5.0 → libstb-0.7.0}/src/core/utf8.cpp +0 -0
  199. {libstb-0.5.0 → libstb-0.7.0}/src/third_party/README.md +0 -0
  200. {libstb-0.5.0 → libstb-0.7.0}/src/third_party/stb/stb_image.h +0 -0
  201. {libstb-0.5.0 → libstb-0.7.0}/src/third_party/stb/stb_image_resize2.h +0 -0
  202. {libstb-0.5.0 → libstb-0.7.0}/src/third_party/stb/stb_image_write.h +0 -0
  203. {libstb-0.5.0 → libstb-0.7.0}/src/third_party/stb/stb_rect_pack.h +0 -0
  204. {libstb-0.5.0 → libstb-0.7.0}/src/third_party/stb/stb_truetype.h +0 -0
  205. {libstb-0.5.0 → libstb-0.7.0}/tests/cmake/consumer_project/CMakeLists.txt +0 -0
  206. {libstb-0.5.0 → libstb-0.7.0}/tests/cmake/consumer_project/main.cpp +0 -0
  207. {libstb-0.5.0 → libstb-0.7.0}/tests/cmake/run_consumer_test.cmake +0 -0
  208. {libstb-0.5.0 → libstb-0.7.0}/tests/cpp/test_common.hpp +0 -0
  209. {libstb-0.5.0 → libstb-0.7.0}/tests/cpp/test_encode.cpp +0 -0
  210. {libstb-0.5.0 → libstb-0.7.0}/tests/cpp/test_resizer.cpp +0 -0
  211. {libstb-0.5.0 → libstb-0.7.0}/tests/cpp/test_utf8.cpp +0 -0
  212. {libstb-0.5.0 → libstb-0.7.0}/tests/data/libstb-test.ttf +0 -0
  213. {libstb-0.5.0 → libstb-0.7.0}/tests/data/make_test_font.py +0 -0
  214. {libstb-0.5.0 → libstb-0.7.0}/tests/python/tolerances.py +0 -0
  215. {libstb-0.5.0 → libstb-0.7.0}/tests/tools/jpeg_vs_upstream.py +0 -0
  216. {libstb-0.5.0 → libstb-0.7.0}/tests/tools/zlib_fuzz.py +0 -0
  217. {libstb-0.5.0 → libstb-0.7.0}/tests/utest/utest.h +0 -0
  218. {libstb-0.5.0 → libstb-0.7.0}/tests/utest/utest_main.cxx +0 -0
  219. {libstb-0.5.0 → libstb-0.7.0}/version.py +0 -0
@@ -0,0 +1,138 @@
1
+ name: cmake stuff
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_call:
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build-and-test:
11
+ strategy:
12
+ matrix:
13
+ os: [ubuntu-latest, macos-latest, windows-latest]
14
+
15
+ runs-on: ${{ matrix.os }}
16
+
17
+ steps:
18
+ - name: Checkout repository
19
+ uses: actions/checkout@v6
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v6
23
+ with:
24
+ python-version: "3.11"
25
+ cache: "pip"
26
+
27
+ - name: Install python deps
28
+ run: pip install -r requirements-dev.txt
29
+
30
+ - name: Configure Project
31
+ run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSTB_BUILD_TESTS=ON -DSTB_BUILD_PYTHON=ON
32
+
33
+ - name: Build
34
+ run: cmake --build build -j4 --config Release
35
+
36
+ # C++ tests, Python tests (pytest against the freshly built package) and
37
+ # the find_package consumer test all run under ctest.
38
+ - name: Run tests
39
+ run: ctest --test-dir build -C Release --output-on-failure
40
+
41
+
42
+ build-docs:
43
+ needs: build-and-test
44
+ runs-on: ubuntu-latest
45
+
46
+ steps:
47
+ - name: Checkout repository
48
+ uses: actions/checkout@v6
49
+
50
+ - name: Install apt dependencies
51
+ run: |
52
+ sudo apt-get update
53
+ sudo apt-get install -y doxygen graphviz
54
+
55
+ - name: Set up Python
56
+ uses: actions/setup-python@v6
57
+ with:
58
+ python-version: "3.11"
59
+ cache: "pip"
60
+
61
+ - name: Install python deps
62
+ run: pip install -r requirements-dev.txt
63
+
64
+ # The Sphinx build imports the freshly built extension, so the Python binding is needed.
65
+ - name: Configure CMake
66
+ run: |
67
+ cmake -S . -B build \
68
+ -DCMAKE_BUILD_TYPE=Release \
69
+ -DSTB_BUILD_TESTS=OFF \
70
+ -DSTB_BUILD_PYTHON=ON \
71
+ -DSTB_BUILD_DOCS=ON
72
+
73
+ - name: Build documentation
74
+ run: cmake --build build --target stb_docs
75
+
76
+ - name: List docs directory
77
+ run: tree --du -shaC build/docs/out
78
+
79
+ - name: Upload documentation artifacts
80
+ uses: actions/upload-artifact@v7
81
+ with:
82
+ name: cmake-documentation
83
+ path: build/docs/out
84
+ retention-days: 5
85
+
86
+ build-coverage:
87
+ runs-on: ubuntu-latest
88
+
89
+ steps:
90
+ - name: Checkout repository
91
+ uses: actions/checkout@v6
92
+
93
+ - name: Set up Python
94
+ uses: actions/setup-python@v6
95
+ with:
96
+ python-version: "3.11"
97
+ cache: "pip"
98
+
99
+ - name: Install python dependencies
100
+ run: pip install -r requirements-dev.txt
101
+
102
+ # torch is not a test dependency: tests/python/test_torch.py skips itself without it. The CPU
103
+ # wheel (a few hundred MB, instead of several GB of CUDA libraries) makes the DLPack tests run
104
+ # here, so they count towards the coverage report.
105
+ - name: Install torch (CPU)
106
+ run: pip install torch --index-url https://download.pytorch.org/whl/cpu
107
+
108
+ - name: Install coverage tools
109
+ run: |
110
+ sudo apt-get update
111
+ sudo apt-get install -y lcov
112
+
113
+ - name: Configure CMake
114
+ run: |
115
+ cmake -S . -B build \
116
+ -DSTB_BUILD_TESTS=ON \
117
+ -DSTB_BUILD_PYTHON=ON \
118
+ -DSTB_BUILD_DOCS=OFF
119
+
120
+ # C++ (lcov), Python (coverage.py) and the merged total.
121
+ - name: Generate coverage report
122
+ run: cmake --build build --target stb_coverage
123
+
124
+ - name: Upload coverage to Codecov
125
+ uses: codecov/codecov-action@v5
126
+ with:
127
+ files: build/coverage/total/coverage.lcov
128
+ flags: unittests
129
+ name: codecov-umbrella
130
+ fail_ci_if_error: false
131
+ verbose: true
132
+
133
+ - name: Upload coverage artifacts
134
+ uses: actions/upload-artifact@v7
135
+ with:
136
+ name: cmake-coverage-report
137
+ path: build/coverage/
138
+ retention-days: 5
@@ -87,3 +87,41 @@ jobs:
87
87
  with:
88
88
  password: ${{ secrets.PYPI_PASSWORD }}
89
89
  user: ${{ secrets.PYPI_USERNAME }}
90
+
91
+ # Publishes the docs site with the coverage dashboard under /coverage. Needs GitHub Pages
92
+ # enabled in the repository settings (Source: GitHub Actions).
93
+ deploy-pages:
94
+ needs: [cmake]
95
+ runs-on: ubuntu-latest
96
+ permissions:
97
+ contents: write
98
+ pages: write
99
+ id-token: write
100
+
101
+ steps:
102
+ - name: Download documentation artifact
103
+ uses: actions/download-artifact@v8
104
+ with:
105
+ name: cmake-documentation
106
+ path: ./pages
107
+
108
+ - name: Download coverage artifact
109
+ uses: actions/download-artifact@v8
110
+ with:
111
+ name: cmake-coverage-report
112
+ path: ./pages/coverage
113
+
114
+ - name: List pages directory
115
+ run: tree --du -shaC pages
116
+
117
+ - name: Setup Pages
118
+ uses: actions/configure-pages@v4
119
+
120
+ - name: Upload artifact
121
+ uses: actions/upload-pages-artifact@v3
122
+ with:
123
+ path: ./pages
124
+
125
+ - name: Deploy to GitHub Pages
126
+ id: deployment
127
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,137 @@
1
+ name: python build wheels
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ workflow_call:
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ env:
10
+ FORCE_COLOR: 3
11
+
12
+ concurrency:
13
+ group: wheels-${{ github.ref }}
14
+ cancel-in-progress: true
15
+
16
+ jobs:
17
+ build_sdist:
18
+ name: Build SDist
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v6
22
+
23
+ - uses: actions/setup-python@v6
24
+ with:
25
+ python-version: "3.11"
26
+ cache: "pip"
27
+
28
+ - name: Build SDist
29
+ run: pipx run build --sdist
30
+
31
+ - name: Check metadata
32
+ run: pipx run twine check dist/*
33
+
34
+ - uses: actions/upload-artifact@v7
35
+ with:
36
+ name: wheelhouse-sdist
37
+ path: dist/*.tar.gz
38
+ overwrite: true
39
+
40
+ build_wheels:
41
+ name: Wheels on ${{ matrix.os }}
42
+ runs-on: ${{ matrix.os }}
43
+ strategy:
44
+ # One platform failing must not hide how the others do: each of them is its own wheel set.
45
+ fail-fast: false
46
+ matrix:
47
+ # ubuntu-latest / windows-latest are x86-64; the *-arm runners are native arm64 (no
48
+ # emulation, so the wheels are built and tested on the real architecture). macos-latest
49
+ # is arm64 and builds the universal2 wheel (x86-64 + arm64) for both.
50
+ os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest, windows-11-arm]
51
+
52
+ steps:
53
+ - uses: actions/checkout@v6
54
+
55
+ - name: Build wheels
56
+ uses: pypa/cibuildwheel@v3.4.1
57
+ env:
58
+ # C++17 runtime on macOS.
59
+ MACOSX_DEPLOYMENT_TARGET: "10.15"
60
+ CIBW_ARCHS_MACOS: universal2
61
+ # 3.9-3.11: normal per-version wheels (nanobind has no stable-ABI
62
+ # support below 3.12; it silently builds a regular extension there).
63
+ # 3.12: built once and tagged cp312-abi3 (see [[tool.scikit-build.overrides]] in
64
+ # pyproject.toml), and that single wheel covers every newer interpreter too, so 3.13+
65
+ # is skipped here to avoid building a redundant duplicate wheel.
66
+ CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*"
67
+ CIBW_SKIP: pp*
68
+
69
+ - uses: actions/upload-artifact@v7
70
+ with:
71
+ name: wheelhouse-${{ matrix.os }}
72
+ path: wheelhouse/*.whl
73
+ overwrite: false
74
+
75
+ # The Linux wheel carries AVX2 kernels next to the portable ones and picks one at run
76
+ # time from the CPU it finds (backends: avx2, sse2, scalar; see libstb.simd_backends()). The
77
+ # runners that build and test the wheels all have AVX2,
78
+ # so this job runs the very same wheel on emulated CPUs (QEMU user mode): one without AVX
79
+ # (Nehalem: SSE4.2 only), where it must fall back to the portable kernels and pass every
80
+ # test, and one with AVX2 (Haswell), where it must pick the AVX2 ones.
81
+ emulate:
82
+ name: emulate
83
+ needs: build_wheels
84
+ runs-on: ubuntu-latest
85
+ timeout-minutes: 20
86
+ env:
87
+ # pytest-memray (installed by the [test] extra) does not run under QEMU user mode.
88
+ LIBSTB_NO_MEMRAY: "1"
89
+ steps:
90
+ - uses: actions/checkout@v6
91
+
92
+ - uses: actions/setup-python@v6
93
+ with:
94
+ python-version: "3.12"
95
+
96
+ - uses: actions/download-artifact@v8
97
+ with:
98
+ name: wheelhouse-ubuntu-latest
99
+ path: wheelhouse
100
+
101
+ - name: Install QEMU user-mode emulation
102
+ run: |
103
+ sudo apt-get update -qq
104
+ sudo apt-get install -y -qq qemu-user
105
+
106
+ - name: Install the manylinux wheel (3.12, abi3) with its test dependencies
107
+ run: |
108
+ echo "wheelhouse contains:"; find wheelhouse -type f | sort
109
+ mapfile -t wheels < <(find wheelhouse -type f -name 'libstb-*-cp312-abi3-manylinux*x86_64*.whl')
110
+ [ ${#wheels[@]} -eq 1 ] || { echo "expected exactly one manylinux cp312-abi3 x86_64 wheel, found ${#wheels[@]}: ${wheels[*]}"; exit 1; }
111
+ python -m venv venv
112
+ venv/bin/pip install "${wheels[0]}[test]"
113
+
114
+ - name: No AVX (Nehalem) - only the portable backends may be offered
115
+ run: |
116
+ qemu-x86_64 -cpu Nehalem venv/bin/python - <<'PY'
117
+ import libstb
118
+ print("simd_backends:", libstb.simd_backends(), "| in use:", libstb.simd_name())
119
+ assert libstb.simd_backends() == ["sse2", "scalar"], libstb.simd_backends()
120
+ assert libstb.simd_name() == "sse2", libstb.simd_name()
121
+ PY
122
+
123
+ - name: No AVX (Nehalem) - the whole test suite (covers the sse2 and scalar backends)
124
+ working-directory: ${{ runner.temp }}
125
+ run: qemu-x86_64 -cpu Nehalem ${{ github.workspace }}/venv/bin/python -m pytest ${{ github.workspace }}/tests/python -q -p no:cacheprovider
126
+
127
+ - name: AVX2 (Haswell) - avx2 must be offered and picked, and equal the other backends
128
+ working-directory: ${{ runner.temp }}
129
+ run: |
130
+ qemu-x86_64 -cpu Haswell ${{ github.workspace }}/venv/bin/python - <<'PY' 2>&1 | grep -v "TCG doesn't support"
131
+ import libstb
132
+ print("simd_backends:", libstb.simd_backends(), "| in use:", libstb.simd_name())
133
+ assert libstb.simd_backends() == ["avx2", "sse2", "scalar"], libstb.simd_backends()
134
+ assert libstb.simd_name() == "avx2", libstb.simd_name()
135
+ PY
136
+ qemu-x86_64 -cpu Haswell ${{ github.workspace }}/venv/bin/python -m pytest ${{ github.workspace }}/tests/python/test_simd.py -q -p no:cacheprovider 2>&1 | grep -v "TCG doesn't support"
137
+ exit "${PIPESTATUS[0]}"
@@ -0,0 +1,186 @@
1
+ # Changelog
2
+
3
+ All notable changes to libstb are listed here, newest first. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Dates are commit dates.
5
+
6
+ This file was generated from the git history (61 commits, tags `v0.3.0`, `v0.4.0`, `v0.5.0`, `v0.6.0`, `v0.7.0`).
7
+
8
+ ## [0.7.0] - 2026-10-17
9
+
10
+ ### Breaking
11
+ - CMake names changed (`016551c`, `c76d406`, `3b02769`). Targets `libstb_*` are now `stb_*`:
12
+ `stb_core` (the library; still exported as `libstb::core`), `stb_test`, `stb_test_cpp`,
13
+ `stb_test_python`, `stb_test_cmake`, `stb_docs` (`_cpp`, `_python`, `_index`), `stb_coverage`
14
+ (`_cpp`, `_python`, `_total`), `stb_benchmark` and `stb_bench_*`; the C++ test executable
15
+ `test_libstb_cpp` is now `test_stb_cpp`. The options `LIBSTB_BUILD_TESTS`, `LIBSTB_BUILD_PYTHON`
16
+ and `LIBSTB_BUILD_DOCS` are now `STB_BUILD_TESTS`, `STB_BUILD_PYTHON` and `STB_BUILD_DOCS`.
17
+ Scripts and CI that call the old names must be updated. Not renamed: the package and project
18
+ name `libstb`, `find_package(libstb CONFIG)`, `libstb::core`, `import libstb`, the extension
19
+ module `libstb_py`, and environment variables such as `LIBSTB_SIMD`.
20
+
21
+ ### Added
22
+ - `stb::zlib_compress` / `stb::zlib_decompress` (`<stb/zlib.hpp>`; Python: `libstb.zlib_compress`,
23
+ `libstb.zlib_decompress`, `DEFAULT_ZLIB_LEVEL`, `DEFAULT_ZLIB_MAX_BYTES`) (`0088cb8`): zlib streams
24
+ with the PNG compressor and stb_image's inflate. `level` uses zlib's numbering (0 stores, 1 to 9,
25
+ -1 default 6). The output of `zlib_decompress` is bounded by `max_bytes` (a zip bomb is a
26
+ `limit_error` / `LimitError`, never an out-of-memory), the Adler-32 is verified, and both
27
+ directions interoperate with zlib. Compression was 1.2x to 1.9x faster than zlib level 6 with
28
+ 0.4% to 3.3% larger output on our samples; decompression is **not** faster than zlib (about
29
+ 2.5x slower on very compressible text). Any bytes-like object is accepted in Python and the GIL
30
+ is released.
31
+ - `stb::estimate_text` / `stb::estimate_metrics` (Python: `libstb.estimate_text`,
32
+ `libstb.estimate_metrics`): rough text size without a font file, from fixed width tables for
33
+ `sans`, `serif` and `mono` (Liberation metrics, generated by `tools/gen_font_metrics.py`, no font
34
+ bundled). No kerning; CJK and emoji count as 1 em and other non-Latin text is approximated.
35
+ - Tests: a real PNG decompression bomb (a valid 0.5 MB file that declares 576 MB), generated on
36
+ demand by `tests/python/pngbomb.py`, checked from Python (`test_png_bomb.py`, with a memray bound)
37
+ and C++ (`test_a_real_png_bomb_is_refused_from_its_header`) (`83226ea`); zlib tests against
38
+ python's `zlib` in both directions, zip bombs and exact `max_bytes` bounds; font estimator
39
+ tests, including agreement with the real Liberation fonts when they are installed.
40
+ - `docs/guide.md`: the complete reference that used to be the README (`ec879bb`).
41
+ - Documentation pages for the zlib and estimator APIs (Sphinx and Doxygen).
42
+
43
+ ### Changed
44
+ - README rewritten as a short landing page: Python first, then C++ with CMake, then which stb
45
+ modules are used and how libstb differs from plain stb in API and performance (`ec879bb`).
46
+ - Internal: stb's headers are still compiled in one translation unit (`src/core/image.cpp`); the
47
+ zlib API reaches them through `src/core/zlib_bridge.hpp`, so the compressor and inflater exist
48
+ once. The Python bindings share one `py_buffer` helper (`binding.hpp`).
49
+
50
+ ### Fixed
51
+ - The C++ install snippets (`docs/cpp/index-install.txt`, `docs/cpp/mainpage.md`) used
52
+ `GIT_TAG main`, but the default branch is `master`.
53
+
54
+ ## [0.6.0] - 2026-10-16
55
+
56
+ ### Breaking
57
+ - `Image.rotate90(turns=1)` (C++: `stb::image::rotate90`) now turns **counter-clockwise**, like
58
+ `numpy.rot90` and Pillow. A negative `turns` turns clockwise. Before, positive meant clockwise.
59
+ `orient()` (EXIF) is unchanged.
60
+
61
+ ### Added
62
+ - Image editing API on `Image` and `stb::image`: `crop`, `flip_horizontal`, `flip_vertical`,
63
+ `rotate90`, `transpose`, `orient`, `pad`, `thumbnail`, `convert`, `split`, `Image.merge`,
64
+ `composite`, `flatten`. Every operation returns a new image.
65
+ - EXIF orientation support (`exif_orientation`, `orient`).
66
+ - Channel and alpha handling (gray, RGB, RGBA conversion and compositing).
67
+ - `libstb.imresize(array, width, height, resizer=None)`: ndarray in, ndarray out.
68
+ - Runtime SIMD backend selection: `simd_backends()`, `simd_name()`, `set_simd()`, the `LIBSTB_SIMD`
69
+ environment variable (an unknown or unavailable name prints one line on stderr and falls back to
70
+ auto), and a per-thread override: `with libstb.simd("scalar"):` (C++: `stb::simd_scope`).
71
+ - Hand-written SSE2 kernels (RGB/RGBA to gray, RGBA over RGB), bit identical to the scalar backend.
72
+ - `stb::env()` in `include/stb/env.hpp`: cross-platform, copy-returning environment variable reader
73
+ (uses `_dupenv_s` on MSVC).
74
+ - `Image.to_pil()` / `Image.from_pil()`. Pillow is loaded only when these are called
75
+ (`pip install "libstb[pillow]"`). Only 8-bit L/RGBA modes are supported, others raise `TypeError`.
76
+ - Examples 08 to 11 (geometry, channels and alpha, EXIF orientation, Pillow) and the notebook
77
+ `04_edit_and_orient`.
78
+ - Tests: edit, EXIF, channels, geometry, SIMD, array interface, functional, Pillow conversion,
79
+ garbage collection (`test_gc.py`) and allocation checks with `pytest-memray` (`test_memory.py`).
80
+ - `tests/python/test_torch.py`: DLPack in both directions with real torch (CPU). torch is not a
81
+ test dependency: the module is skipped when it cannot be imported.
82
+ - Documentation site: `-DLIBSTB_BUILD_DOCS=ON`, then `cmake --build build --target libstb_docs` builds the
83
+ C++ reference (Doxygen), the Python reference (Sphinx) and a landing page into `build/docs/out`.
84
+ - Coverage: `cmake --build build --target libstb_coverage` builds an lcov report for the C++ core, a
85
+ coverage.py report for the Python layer, a merged total and a dashboard in `build/coverage` (needs
86
+ `lcov` and `coverage`). The C++ tests compile the core sources into the test executable, so
87
+ coverage is just a few flags on that target; the shipped `libstb::core` and the Python extension are
88
+ unchanged.
89
+ - CI: QEMU user-mode job (`emulate`) that checks the fallback to portable SIMD backends on a CPU
90
+ without AVX2 (Nehalem) and the use of AVX2 kernels when available (Haswell).
91
+ - CI: native ARM64 runners (Linux and Windows) in the wheel matrix.
92
+ - CI: `build-docs` and `build-coverage` jobs in `cmake.yml` (coverage is also sent to Codecov), and a
93
+ `deploy-pages` job in the orchestrator that publishes the docs with the coverage dashboard under
94
+ `/coverage`. The coverage job installs the CPU build of torch so `test_torch.py` runs there.
95
+
96
+ ### Changed
97
+ - The scalar backend is compiled without compiler auto-vectorization, so it is really scalar.
98
+ - Wheel matrix runs with `fail-fast: false`.
99
+ - Python examples, notebooks, tests, benchmarks, README and docs import the package as
100
+ `import libstb as stb` and write `stb.Image`, `stb.imread`, ... (the package name is still `libstb`).
101
+ - Python 3.12+ builds use the stable ABI: `wheel.py-api = "cp312"` is set in `pyproject.toml`, giving
102
+ one `cp312-abi3` wheel for 3.12 and newer.
103
+ - `pytest-memray` is only required on x86_64 and arm64, and not on Windows. `numpy` is not required
104
+ for the test extra on Windows ARM64 with Python < 3.11; the test modules use
105
+ `pytest.importorskip` for numpy and Pillow.
106
+ - Benchmarks: new `imresize` and editing runners (`crop`, `rotate90`, `flip_horizontal`,
107
+ `convert_gray`, `composite`).
108
+ - README: image manipulation, EXIF, SIMD diagnosis, memory checks and GC support are documented.
109
+
110
+ ### Fixed
111
+ - `nanobind: leaked 1 instances!` at interpreter exit. An `Image` that views a Python object holds a
112
+ reference the GC cannot see, which could form an uncollectable cycle. `Image` now implements
113
+ `tp_traverse` / `tp_clear` and the keep-alive deleter reports the object it holds
114
+ (`image::owner_deleter<D>()` in `image.hpp`).
115
+ - Windows build: a test variable named `small` collided with the `small` macro from Windows headers
116
+ (renamed to `tiny`).
117
+ - `test_simd.py`: emulator backend detection in an assertion.
118
+
119
+ ## [0.5.0] - 2026-10-07
120
+
121
+ ### Added
122
+ - DLPack interop (`Image.from_dlpack`, `__dlpack__`) and image I/O helpers `imread` / `imwrite`.
123
+ - Examples `06_imread_imwrite.py` and `07_dlpack.py`, and updated notebooks.
124
+ - Tests for DLPack and the functional API.
125
+
126
+ ### Changed
127
+ - Legacy DLPack behavior on numpy < 2.1 (read-only views, no `copy=` / `device=` arguments) is
128
+ handled and documented; the affected tests are skipped on those versions.
129
+ - README API examples updated.
130
+
131
+ ## [0.4.0] - 2026-10-04
132
+
133
+ ### Added
134
+ - Standalone benchmark suite (`benchmarks/`) with its own build system and an HTML report, with
135
+ LaTeX formulas rendered by KaTeX (inlined, so the report stays self-contained).
136
+ - Pillow as a test-only dependency, with image format parity tests.
137
+ - Exhaustive PNG roundtrip exactness tests (noise, flat, gradient, tiled, sparse, photo-like,
138
+ degenerate sizes, more than 64K deflate tokens), a lossy tolerance test and a JPEG golden test.
139
+ - `Font.open()` accepts a file path and uses memory mapping on Unix and macOS.
140
+ - Getting Started, resize filters and font rendering example notebooks and the first Python examples
141
+ (`01` to `05`).
142
+
143
+ ### Changed
144
+ - Faster font loading (memory mapping, fast integer conversion).
145
+ - Faster JPEG encoding on GCC/Clang (`-fno-trapping-math` enables vectorized float to int
146
+ conversion) and a faster PNG encoder in the bundled `stb_image_write.h`. The default PNG
147
+ compression level is 8 (was 6).
148
+ - libdeflate was vendored and then removed again within this cycle; the PNG path uses the optimized
149
+ `stb_image_write.h`.
150
+ - Lossy tolerances in tests are standardized; benchmarks and `verify.py` use normalized mean
151
+ absolute error (NMAE).
152
+ - Documentation states that the optimized JPEG encoder is not guaranteed to be byte-identical across
153
+ compilers and flags (rare rounding ties, for example Apple clang on ARM64 or x86 with `-mfma`).
154
+ A tool, `tests/tools/jpeg_vs_upstream.py`, checks equivalence for identical build settings.
155
+
156
+ ## [0.3.0] - 2026-09-30
157
+
158
+ ### Added
159
+ - Python binding: errors map OS error codes to `FileNotFoundError`, `PermissionError` and similar;
160
+ the GIL is released during font rendering (`render_glyph`, `render`, `make_atlas`).
161
+
162
+ ### Changed
163
+ - C++ namespace and headers renamed from `libstb` to `stb` (`include/libstb.h` became
164
+ `include/stb.h`, `include/libstb/` became `include/stb/`). The Python package is still `libstb`.
165
+ - The abstract encoder hierarchy (`PngEncoder`, `JpegEncoder`, ...) was removed in favor of direct
166
+ methods on the image type (`to_png`, `write_jpg`, ...).
167
+ - `save()` was replaced by `write()`; the format is detected from the file extension
168
+ (case-insensitive).
169
+ - Resize accepts a filter by name (for example `"cubic"`).
170
+ - Documentation clarifies the move-only semantics of `stb::image` and pixel memory ownership, and
171
+ the difference between numpy views and copies.
172
+
173
+ ### Fixed
174
+ - Windows: `utest.h` macro collision, and the `NOMINMAX` / `WIN32_LEAN_AND_MEAN` guards in the test
175
+ headers.
176
+
177
+ ## Initial commit - 2026-09-28 (tag `__beta__`)
178
+
179
+ First state: C++17 core over the stb single-header libraries with image decoding and
180
+ encoding (PNG, JPEG, BMP, TGA), resizing with selectable filters, TrueType font rendering, and a
181
+ nanobind Python binding.
182
+
183
+ [Unreleased]: https://github.com/mohammadraziei/libstb/compare/v0.5.0...HEAD
184
+ [0.5.0]: https://github.com/mohammadraziei/libstb/compare/v0.4.0...v0.5.0
185
+ [0.4.0]: https://github.com/mohammadraziei/libstb/compare/v0.3.0...v0.4.0
186
+ [0.3.0]: https://github.com/mohammadraziei/libstb/compare/__beta__...v0.3.0
@@ -19,8 +19,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
19
19
 
20
20
  include(Optimize)
21
21
 
22
- option(LIBSTB_BUILD_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
23
- option(LIBSTB_BUILD_PYTHON "Build Python bindings" ${PROJECT_IS_TOP_LEVEL})
22
+ option(STB_BUILD_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
23
+ option(STB_BUILD_PYTHON "Build Python bindings" ${PROJECT_IS_TOP_LEVEL})
24
+ option(STB_BUILD_DOCS "Build documentation (Doxygen + Sphinx)" OFF)
24
25
 
25
26
  # --- libstb C++ core ---
26
27
  # stb headers are vendored (committed) under src/third_party/stb and are only
@@ -30,10 +31,10 @@ option(LIBSTB_BUILD_PYTHON "Build Python bindings" ${PROJECT_IS_TOP_LEVEL})
30
31
  # stbi_* symbol leaks out to consumers.
31
32
  file(GLOB LIBSTB_CORE_SOURCES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/src/core/*.cpp)
32
33
 
33
- add_library(libstb_core STATIC ${LIBSTB_CORE_SOURCES})
34
- add_library(libstb::core ALIAS libstb_core)
34
+ add_library(stb_core STATIC ${LIBSTB_CORE_SOURCES})
35
+ add_library(libstb::core ALIAS stb_core)
35
36
 
36
- set_target_properties(libstb_core PROPERTIES
37
+ set_target_properties(stb_core PROPERTIES
37
38
  POSITION_INDEPENDENT_CODE ON # linked into the Python extension
38
39
  CXX_VISIBILITY_PRESET hidden
39
40
  VISIBILITY_INLINES_HIDDEN ON
@@ -54,30 +55,50 @@ else()
54
55
  set(_libstb_cmake_dest lib/cmake/libstb)
55
56
  endif()
56
57
 
57
- target_include_directories(libstb_core
58
+ target_include_directories(stb_core
58
59
  PUBLIC
59
60
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
60
61
  $<INSTALL_INTERFACE:${_libstb_inc_dest}>
61
62
  )
62
- # SYSTEM: vendored headers we don't control - their internal warnings are not
63
- # ours to fix under our own -Wall/-Wextra/-W4.
64
- target_include_directories(libstb_core SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/third_party/stb)
63
+ # Everything that decides how the core sources are compiled lives in this function, so a target
64
+ # that compiles them itself (tests/cpp does, to attach coverage flags) gets exactly the same
65
+ # settings as stb_core.
66
+ function(libstb_apply_core_build_settings target)
67
+ # SYSTEM: vendored headers we don't control - their internal warnings are not
68
+ # ours to fix under our own -Wall/-Wextra/-W4.
69
+ target_include_directories(${target} SYSTEM PRIVATE ${PROJECT_SOURCE_DIR}/src/third_party/stb)
65
70
 
66
- target_compile_options(libstb_core PRIVATE
67
- $<$<CXX_COMPILER_ID:MSVC>:/W4 /EHsc>
68
- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
69
- )
70
- # -fno-trapping-math: lets GCC/Clang vectorize float->int conversions in the JPEG encoder's
71
- # quantization (about 2x faster JPEG). It only means FP operations are not required to
72
- # raise hardware traps (nothing here enables or reads them); results are unchanged.
73
- target_compile_options(libstb_core PRIVATE
74
- $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fno-trapping-math>
75
- )
76
- apply_optimization_flags(libstb_core)
71
+ target_compile_options(${target} PRIVATE
72
+ $<$<CXX_COMPILER_ID:MSVC>:/W4 /EHsc>
73
+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
74
+ )
75
+ # -fno-trapping-math: lets GCC/Clang vectorize float->int conversions in the JPEG encoder's
76
+ # quantization (about 2x faster JPEG). It only means FP operations are not required to
77
+ # raise hardware traps (nothing here enables or reads them); results are unchanged.
78
+ target_compile_options(${target} PRIVATE
79
+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fno-trapping-math>
80
+ )
81
+ apply_optimization_flags(${target})
82
+
83
+ # image_kernels_scalar.cpp is the "scalar" SIMD backend: the same pixel loops with the
84
+ # compiler's auto-vectoriser off. (MSVC has no such switch: there it may still vectorise,
85
+ # with identical results.) TARGET_DIRECTORY: source file properties are per directory scope.
86
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
87
+ set_source_files_properties(${PROJECT_SOURCE_DIR}/src/core/image_kernels_scalar.cpp
88
+ TARGET_DIRECTORY ${target}
89
+ PROPERTIES COMPILE_OPTIONS "-fno-tree-vectorize;-fno-tree-slp-vectorize")
90
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
91
+ set_source_files_properties(${PROJECT_SOURCE_DIR}/src/core/image_kernels_scalar.cpp
92
+ TARGET_DIRECTORY ${target}
93
+ PROPERTIES COMPILE_OPTIONS "-fno-vectorize;-fno-slp-vectorize")
94
+ endif()
95
+ endfunction()
96
+
97
+ libstb_apply_core_build_settings(stb_core)
77
98
 
78
99
  # --- install (find_package(libstb) -> libstb::core) ---
79
100
  include(CMakePackageConfigHelpers)
80
- install(TARGETS libstb_core EXPORT libstbTargets ARCHIVE DESTINATION ${_libstb_lib_dest})
101
+ install(TARGETS stb_core EXPORT libstbTargets ARCHIVE DESTINATION ${_libstb_lib_dest})
81
102
  install(DIRECTORY include/ DESTINATION ${_libstb_inc_dest})
82
103
  install(EXPORT libstbTargets FILE libstbTargets.cmake NAMESPACE libstb:: DESTINATION ${_libstb_cmake_dest})
83
104
  configure_package_config_file(
@@ -96,7 +117,7 @@ install(FILES
96
117
  DESTINATION ${_libstb_cmake_dest}
97
118
  )
98
119
 
99
- if(LIBSTB_BUILD_PYTHON OR DEFINED SKBUILD)
120
+ if(STB_BUILD_PYTHON OR DEFINED SKBUILD)
100
121
  set(PYTHON_INSTALL_DIR ${CMAKE_BINARY_DIR}/python/install)
101
122
  add_subdirectory(${PROJECT_SOURCE_DIR}/src/bindings/python)
102
123
  if(DEFINED SKBUILD)
@@ -104,8 +125,13 @@ if(LIBSTB_BUILD_PYTHON OR DEFINED SKBUILD)
104
125
  endif()
105
126
  endif()
106
127
 
107
- if(LIBSTB_BUILD_TESTS)
128
+ if(STB_BUILD_TESTS)
108
129
  enable_testing()
109
130
  set(CMAKE_CTEST_ARGUMENTS "--output-on-failure" "-V")
110
131
  add_subdirectory(${PROJECT_SOURCE_DIR}/tests)
111
132
  endif()
133
+
134
+ # Documentation (Doxygen + Sphinx). Needs the Python extension: the Sphinx build imports it.
135
+ if(STB_BUILD_DOCS)
136
+ add_subdirectory(${PROJECT_SOURCE_DIR}/docs)
137
+ endif()