Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ mcpp self config --mirror CN # 切换至国内镜像,默认使用 GLOBAL 上

| 形态 | 示例 |
|------|------|
| 原生模块库(Form A) | [`mcpplibs.xpkg`](pkgs/x/xpkg.lua) · [`mcpplibs.tinyhttps`](pkgs/t/tinyhttps.lua) · [`tensorvia-cpu`](pkgs/t/tensorvia-cpu.lua) · [`ffmpeg`](pkgs/f/ffmpeg.lua)(模块层,源码经 `compat.ffmpeg` 直编) · [`opencv`](pkgs/o/opencv.lua)(模块层,源码经 `compat.opencv5` 直编) |
| 原生模块库(Form A) | [`mcpplibs.xpkg`](pkgs/x/xpkg.lua) · [`mcpplibs.tinyhttps`](pkgs/t/tinyhttps.lua) · [`tensorvia-cpu`](pkgs/t/tensorvia-cpu.lua) · [`ffmpeg`](pkgs/f/ffmpeg.lua)(模块层,源码经 `compat.ffmpeg` 直编) · [`opencv`](pkgs/o/opencv.lua)(模块层,源码经 `compat.opencv` 直编) |
| C 源码 compat(含 `features`) | [`compat.cjson`](pkgs/c/compat.cjson.lua) · [`compat.zlib`](pkgs/c/compat.zlib.lua) |
| header-only(含 `features`) | [`compat.eigen`](pkgs/c/compat.eigen.lua) |
| 数据资产包(feature 依赖专用) | [`compat.opencv-unifont`](pkgs/c/compat.opencv-unifont.lua)(CJK 字体,由 `compat.opencv` 的 `unifont` feature 拉取) |
| 外部构建系统(`install()` 从源码构建) | [`compat.openblas`](pkgs/c/compat.openblas.lua)(Make) |
| 全源码直编(config 快照 + 源列表,零外部构建系统) | [`compat.ffmpeg`](pkgs/c/compat.ffmpeg.lua)(2281 TU 含 NASM 汇编,28 个目录 glob 声明) |
| 全源码直编 + `build.mcpp` 消费端合成 | [`compat.opencv`](pkgs/c/compat.opencv.lua)(OpenCV 5,458 TU 真实路径直编,SIMD dispatch 保留,字体/内核/jpeg12/16 由包内 build.mcpp 生成,依赖 `compat.ffmpeg` 提供 videoio FFmpeg 后端;feature:`unifont` CJK 字体、`dnn` 深度学习模块(+309 TU 含 protobuf/mlas);旧 install() CMake 形态已移除,`compat.opencv5` 为过渡别名待删) |
| 全源码直编 + `build.mcpp` 消费端合成 | [`compat.opencv`](pkgs/c/compat.opencv.lua)(OpenCV 5,458 TU 真实路径直编,SIMD dispatch 保留,字体/内核/jpeg12/16 由包内 build.mcpp 生成,依赖 `compat.ffmpeg` 提供 videoio FFmpeg 后端;feature:`unifont` CJK 字体、`dnn` 深度学习模块(+309 TU 含 protobuf/mlas);旧 install() CMake 形态与过渡别名 `compat.opencv5` 均已移除) |
| C++23 module wrapper | [`nlohmann.json`](pkgs/n/nlohmann.json.lua) · [`marzer.tomlplusplus`](pkgs/m/marzer.tomlplusplus.lua) |

### 新增一个包
Expand Down
1 change: 0 additions & 1 deletion mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ members = [
"tests/examples/nlohmann.json",
"tests/examples/openblas",
"tests/examples/opencv",
"tests/examples/opencv5",
"tests/examples/opencv-unifont",
"tests/examples/opencv-dnn",
"tests/examples/opencv-module",
Expand Down
72 changes: 61 additions & 11 deletions pkgs/c/compat.opencv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ package = {
#include <cstring>
#include <filesystem>
#include <fstream>
#include <initializer_list>
#include <sstream>
#include <string>
#include <vector>
Expand Down Expand Up @@ -444,29 +445,78 @@ int main() {
blob2hdr(wrap / "modules/imgproc/fonts/Rubik-Italic.ttf.gz", out / "builtin_font_italic.h", "OcvBuiltinFontItalic");

// 1b. unifont feature: hex-embed the CJK font pulled in by the
// compat.opencv-unifont dependency. Its payload is a raw .gz the
// installer parks byte-preserved in the store's shared
// data/runtimedir/ (no MCPP_DEP_<NAME>_DIR contract var yet), so
// resolve it relative to this package's store location, with a
// verdir sweep as fallback.
// compat.opencv-unifont dependency. Its raw .gz payload is parked by
// the installer in a shared runtimedir whose location relative to any
// one package shifted across xlings store layouts (0.4.62 -> 0.4.67,
// mcpp 0.0.99), which is why a fixed `<data>/xpkgs/<pkg>/<ver> ->
// <data>/runtimedir` hop broke. Anchor instead on the authoritative
// per-dep dir contract (mcpp#241: MCPP_DEP_<NAME>_DIR, emitted under
// both the canonical name and the namespace-stripped short name) and
// walk up probing runtimedir/ at every level; fall back to this
// package's own store location + a bounded search so older mcpp
// (pre-#241) and future layout shifts still resolve.
if (std::getenv("MCPP_FEATURE_UNIFONT")) {
const char* fname = "WenQuanYiMicroHei.ttf.gz";
fs::path font;
// <data>/xpkgs/<pkg>/<ver> -> <data>/runtimedir/<fname>
fs::path rt = man.parent_path().parent_path().parent_path() / "runtimedir" / fname;
if (fs::exists(rt)) font = rt;
std::error_code ec;
auto probe = [&](const fs::path& base) -> fs::path {
if (base.empty()) return {};
for (const fs::path& c : { base / fname,
base / "runtimedir" / fname,
base / "data" / "runtimedir" / fname })
if (fs::exists(c)) return c;
return {};
};
std::vector<fs::path> anchors;
if (const char* d = std::getenv("MCPP_DEP_COMPAT_OPENCV_UNIFONT_DIR")) anchors.emplace_back(d);
if (const char* d = std::getenv("MCPP_DEP_OPENCV_UNIFONT_DIR")) anchors.emplace_back(d);
anchors.push_back(man);
if (const char* d = std::getenv("MCPP_OUT_DIR")) anchors.emplace_back(d);
// walk up from each anchor, probing runtimedir/ at every level
for (const auto& a : anchors) {
for (fs::path p = a; !p.empty(); p = p.parent_path()) {
if (auto hit = probe(p); !hit.empty()) { font = hit; break; }
if (p == p.root_path()) break;
}
if (!font.empty()) break;
}
// fallback: sweep any opencv-unifont verdir near this package's store dir
if (font.empty()) {
std::error_code ec;
for (auto& e : fs::directory_iterator(man.parent_path().parent_path(), ec)) {
if (e.path().filename().string().find("opencv-unifont") == std::string::npos) continue;
for (auto& v : fs::recursive_directory_iterator(e.path(), ec))
if (v.path().filename() == fname) { font = v.path(); break; }
if (!font.empty()) break;
}
}
// last resort: bounded recursive search from the nearest store root
if (font.empty()) {
for (const auto& a : anchors) {
fs::path root = a;
for (int up = 0; up < 8 && root.has_parent_path(); ++up) {
if (fs::exists(root / "runtimedir") || fs::exists(root / "xpkgs")
|| root.filename() == "data") break;
root = root.parent_path();
}
long budget = 400000;
for (auto it = fs::recursive_directory_iterator(root,
fs::directory_options::skip_permission_denied, ec);
it != fs::recursive_directory_iterator() && budget-- > 0; it.increment(ec)) {
if (ec) { ec.clear(); continue; }
if (it->path().filename() == fname) { font = it->path(); break; }
}
if (!font.empty()) break;
}
}
if (font.empty()) {
std::fprintf(stderr, "compat.opencv build.mcpp: unifont feature on but %s not found near %s\n",
fname, man.string().c_str());
const char* e1 = std::getenv("MCPP_DEP_COMPAT_OPENCV_UNIFONT_DIR");
const char* e2 = std::getenv("MCPP_DEP_OPENCV_UNIFONT_DIR");
const char* e3 = std::getenv("MCPP_OUT_DIR");
std::fprintf(stderr, "compat.opencv build.mcpp: unifont feature on but %s not found.\n"
" MCPP_MANIFEST_DIR=%s\n MCPP_DEP_COMPAT_OPENCV_UNIFONT_DIR=%s\n"
" MCPP_DEP_OPENCV_UNIFONT_DIR=%s\n MCPP_OUT_DIR=%s\n",
fname, man.string().c_str(),
e1 ? e1 : "(unset)", e2 ? e2 : "(unset)", e3 ? e3 : "(unset)");
return 1;
}
blob2hdr(font, out / "builtin_font_uni.h", "OcvBuiltinFontUni");
Expand Down
Loading
Loading