fix(stroid): fixed header include

This commit is contained in:
2026-07-01 11:31:00 -04:00
parent edfcea6943
commit db727ebd7b
3 changed files with 44 additions and 58 deletions

View File

@@ -10,6 +10,7 @@
#include "stroid/utils/types.h" #include "stroid/utils/types.h"
#include "stroid/refinement/uniform.h" #include "stroid/refinement/uniform.h"
#include "stroid/utils/mesh_stats.h" #include "stroid/utils/mesh_stats.h"
#include "stroid/version.h"
/** /**
* @namespace stroid * @namespace stroid

View File

@@ -11,6 +11,12 @@
#include <cstdint> #include <cstdint>
#include <format> #include <format>
#include <chrono> #include <chrono>
#include <string>
#include <string_view>
#include <expected>
#include <stdexcept>
#include <concepts>
#include <limits>
namespace stroid::IO { namespace stroid::IO {
@@ -211,18 +217,49 @@ END BLOCK CONFIG)",
template <std::integral T> template <std::integral T>
std::expected<T, std::string> parse_int(std::string_view v) { std::expected<T, std::string> parse_int(std::string_view v) {
const std::string_view s = trim(v); const std::string_view s = trim(v);
T out{};
if (const auto res = std::from_chars(s.data(), s.data() + s.size(), out); res.ec != std::errc{} || res.ptr != s.data() + s.size()) std::string temp(s);
try {
size_t pos = 0;
if constexpr (std::is_signed_v<T>) {
long long val = std::stoll(temp, &pos);
if (pos != temp.size() || val < std::numeric_limits<T>::min() || val > std::numeric_limits<T>::max()) {
return std::unexpected(std::format("invalid integer value '{}'", v));
}
return static_cast<T>(val);
} else {
unsigned long long val = std::stoull(temp, &pos);
if (pos != temp.size() || val > std::numeric_limits<T>::max()) {
return std::unexpected(std::format("invalid integer value '{}'", v));
}
return static_cast<T>(val);
}
} catch (const std::exception&) {
return std::unexpected(std::format("invalid integer value '{}'", v)); return std::unexpected(std::format("invalid integer value '{}'", v));
return out; }
} }
std::expected<double, std::string> parse_double(std::string_view v) { std::expected<double, std::string> parse_double(std::string_view v) {
const std::string_view s = trim(v); const std::string_view s = trim(v);
double out{}; std::string temp(s);
if (const auto [ptr, ec] = std::from_chars(s.data(), s.data() + s.size(), out); ec != std::errc{} || ptr != s.data() + s.size())
try {
size_t pos = 0;
double out = std::stod(temp, &pos);
if (pos != temp.size()) {
return std::unexpected(std::format("invalid floating-point value '{}'", v));
}
return out;
} catch (const std::exception&) {
return std::unexpected(std::format("invalid floating-point value '{}'", v)); return std::unexpected(std::format("invalid floating-point value '{}'", v));
return out; }
} }
std::expected<std::map<std::string, std::string>, std::string> extract_blocks(std::istream& is) { std::expected<std::map<std::string, std::string>, std::string> extract_blocks(std::istream& is) {

View File

@@ -32,44 +32,6 @@ mkdir -p "${FINAL_WHEEL_DIR}"
export MACOSX_DEPLOYMENT_TARGET=15.0 export MACOSX_DEPLOYMENT_TARGET=15.0
LLVM_VER="17.0.6"
LIBOMP_PREFIX="${WORK_DIR}/libomp-${MACOSX_DEPLOYMENT_TARGET}-${LLVM_VER}"
if [[ ! -f "${LIBOMP_PREFIX}/lib/libomp.dylib" ]]; then
echo "➤ Building libomp ${LLVM_VER} for macOS ${MACOSX_DEPLOYMENT_TARGET}${LIBOMP_PREFIX}"
LIBOMP_SRC_DIR="$(mktemp -d)"
pushd "${LIBOMP_SRC_DIR}" > /dev/null
curl -fLO "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/openmp-${LLVM_VER}.src.tar.xz"
curl -fLO "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/cmake-${LLVM_VER}.src.tar.xz"
tar xf "openmp-${LLVM_VER}.src.tar.xz"
tar xf "cmake-${LLVM_VER}.src.tar.xz"
mv "cmake-${LLVM_VER}.src" cmake
cmake -S "openmp-${LLVM_VER}.src" -B libomp-build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOSX_DEPLOYMENT_TARGET}" \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DCMAKE_INSTALL_PREFIX="${LIBOMP_PREFIX}" \
-DLIBOMP_INSTALL_ALIASES=OFF
cmake --build libomp-build -j "$(sysctl -n hw.ncpu)"
cmake --install libomp-build
popd > /dev/null
rm -rf "${LIBOMP_SRC_DIR}"
fi
LIBOMP_MINOS="$(otool -l "${LIBOMP_PREFIX}/lib/libomp.dylib" | awk '/minos/ {print $2; exit}')"
if [[ "${LIBOMP_MINOS}" != "${MACOSX_DEPLOYMENT_TARGET}"* ]]; then
echo "Error: cached libomp at ${LIBOMP_PREFIX} targets macOS ${LIBOMP_MINOS}," \
"expected ${MACOSX_DEPLOYMENT_TARGET}. Delete the directory and re-run."
exit 1
fi
echo "➤ Using libomp ${LLVM_VER} (min macOS ${LIBOMP_MINOS}) from ${LIBOMP_PREFIX}"
export CPPFLAGS="-I${LIBOMP_PREFIX}/include ${CPPFLAGS:-}"
export LDFLAGS="-L${LIBOMP_PREFIX}/lib ${LDFLAGS:-}"
export LIBRARY_PATH="${LIBOMP_PREFIX}/lib${LIBRARY_PATH:+:${LIBRARY_PATH}}"
TMPDIR="$(mktemp -d)" TMPDIR="$(mktemp -d)"
echo "➤ Cloning ${REPO_URL}${TMPDIR}/project" echo "➤ Cloning ${REPO_URL}${TMPDIR}/project"
@@ -113,12 +75,10 @@ for PY_VERSION in "${PYTHON_VERSIONS[@]}"; do
CC="ccache clang" CXX="ccache clang++" \ CC="ccache clang" CXX="ccache clang++" \
"$PY" -m pip wheel . --no-deps --no-build-isolation \ "$PY" -m pip wheel . --no-deps --no-build-isolation \
--config-settings=setup-args="-Dlibomp_prefix=${LIBOMP_PREFIX}" \
-w "${WHEEL_DIR}" -v -w "${WHEEL_DIR}" -v
CURRENT_WHEEL=$(find "${WHEEL_DIR}" -name "*.whl" | head -n 1) CURRENT_WHEEL=$(find "${WHEEL_DIR}" -name "*.whl" | head -n 1)
echo "➤ Repairing wheel with delocate" echo "➤ Repairing wheel with delocate"
DELOCATE_DYLD_PATH="${LIBOMP_PREFIX}/lib"
if [[ -n "${FOURDST_PIN}" ]]; then if [[ -n "${FOURDST_PIN}" ]]; then
FOURDST_LIB_PATH="$("$PY" -c 'import fourdst, os; print(os.pathsep.join(fourdst.get_lib_dirs()))')" FOURDST_LIB_PATH="$("$PY" -c 'import fourdst, os; print(os.pathsep.join(fourdst.get_lib_dirs()))')"
DELOCATE_DYLD_PATH="${FOURDST_LIB_PATH}:${DELOCATE_DYLD_PATH}" DELOCATE_DYLD_PATH="${FOURDST_LIB_PATH}:${DELOCATE_DYLD_PATH}"
@@ -140,18 +100,6 @@ for PY_VERSION in "${PYTHON_VERSIONS[@]}"; do
exit 1 exit 1
fi fi
fi fi
if unzip -l "${REPAIRED_WHEEL}" | grep -q 'libomp.dylib'; then
CHECK_DIR="$(mktemp -d)"
unzip -q "${REPAIRED_WHEEL}" '*/libomp.dylib' -d "${CHECK_DIR}" || true
BUNDLED_OMP="$(find "${CHECK_DIR}" -name 'libomp.dylib' | head -n1)"
BUNDLED_MINOS="$(otool -l "${BUNDLED_OMP}" | awk '/minos/ {print $2; exit}')"
rm -rf "${CHECK_DIR}"
if [[ "${BUNDLED_MINOS}" != "${MACOSX_DEPLOYMENT_TARGET}"* ]]; then
echo "ERROR: bundled libomp targets macOS ${BUNDLED_MINOS}, expected ${MACOSX_DEPLOYMENT_TARGET}"
exit 1
fi
echo "➤ Bundled libomp targets macOS ${BUNDLED_MINOS}"
fi
rm "$CURRENT_WHEEL" rm "$CURRENT_WHEEL"
) )