Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

ctest macos_api: no std::to_chars/from_chars without '// macos-api: integer' (the float overloads need macOS 13.3, the package targets 11; only Packages macOS showed it, 0.11.10)

islandmed88289d1ec601
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 83b4c793..7af1596e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -759,6 +759,8 @@ if(SCULPTFORGE_BUILD_TESTS)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # docs/legal/trademarks.md
# No raw string literal in src/ over MSVC's ~16K characters (C2026: only the Windows build would fail).
add_test(NAME raw_literal_size COMMAND ${Python3_EXECUTABLE} -I ${CMAKE_CURRENT_SOURCE_DIR}/tools/dev/check_literals.py)
+ add_test(NAME macos_api COMMAND ${Python3_EXECUTABLE} -I ${CMAKE_CURRENT_SOURCE_DIR}/tools/dev/check_macos_api.py)
+ add_test(NAME macos_api_self_test COMMAND ${Python3_EXECUTABLE} -I ${CMAKE_CURRENT_SOURCE_DIR}/tools/dev/check_macos_api.py --self-test)
# website/brushes.html #packs matches src/core/BrushPacks.cpp: every brush, its preview and the guide links.
add_test(NAME website_brush_packs COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/brush-packs/sync_website.py --check)
# Every interface label has a Spanish, a Traditional and a Simplified Chinese translation (or is a name kept in English,
diff --git a/tools/dev/check_macos_api.py b/tools/dev/check_macos_api.py
new file mode 100644
index 00000000..e563417a
--- /dev/null
+++ b/tools/dev/check_macos_api.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+"""Fails on library calls the macOS package can't use: it builds for macOS 11 (packages.yml,
+CMAKE_OSX_DEPLOYMENT_TARGET=11.0), and libc++ marks some of them unavailable below a later macOS, a build error that
+only the Packages macOS job shows (Linux, Windows and CI's macOS job build without that target). 0.11.10: Units.cpp's
+std::to_chars(float) stopped the .dmg.
+
+ python3 check_macos_api.py (ctest macos_api)
+ python3 check_macos_api.py --self-test
+Standard library only.
+"""
+
+import re
+import sys
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parent.parent.parent
+# std::to_chars / std::from_chars on float or double need macOS 13.3. A line can't show its argument's type (0.11.10:
+# `std::to_chars(buf, buf + sizeof buf, v)` with a float v), so every call is flagged unless the line says it is an
+# integer one with a `// macos-api: integer` comment.
+FLOAT_CHARCONV = re.compile(r"std::(to_chars|from_chars)\b")
+INTEGER_OK = "macos-api: integer"
+
+
+def problems(files):
+ out = []
+ for path in files:
+ try:
+ text = path.read_text(encoding="utf-8", errors="replace")
+ except OSError:
+ continue
+ for lineno, line in enumerate(text.splitlines(), 1):
+ code = line.split("//", 1)[0]
+ if FLOAT_CHARCONV.search(code) and INTEGER_OK not in line:
+ out.append(f"{path.relative_to(ROOT) if path.is_relative_to(ROOT) else path}:{lineno}: "
+ f"std::to_chars/from_chars: the float overloads need macOS 13.3 (the package targets 11): "
+ f"use snprintf/strtof, or mark an integer call `// macos-api: integer`")
+ return out
+
+
+def main(argv):
+ if "--self-test" in argv:
+ import tempfile
+ with tempfile.TemporaryDirectory() as tmp:
+ bad = Path(tmp) / "bad.cpp"
+ bad.write_text("void f(float v) {\n auto r = std::to_chars(b, b + 32, v);\n}\n")
+ ok = Path(tmp) / "ok.cpp"
+ ok.write_text("void g(int n) {\n auto r = std::to_chars(b, b + 32, n); // macos-api: integer\n"
+ " // std::to_chars(float) note\n}\n")
+ assert len(problems([bad])) == 1 and not problems([ok])
+ print("check_macos_api self-test ok")
+ return 0
+ files = sorted(p for p in (ROOT / "src").rglob("*") if p.suffix in (".cpp", ".h", ".hpp", ".mm"))
+ found = problems(files)
+ for p in found:
+ print(p)
+ if found:
+ return 1
+ print(f"check_macos_api: {len(files)} files, no macOS-13.3-only float charconv")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))