From 04df346cb472e2921e9205e879907ef3ece9def2 Mon Sep 17 00:00:00 2001 From: tz12323 <2760686250@qq.com> Date: Tue, 13 Oct 2026 18:59:08 +0800 Subject: [PATCH 1/2] feat: add richdem package Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- mcpp.toml | 1 + pkgs/r/compat.richdem.lua | 59 +++++++++++++++++++++++++++ tests/examples/richdem/mcpp.toml | 6 +++ tests/examples/richdem/tests/core.cpp | 8 ++++ 4 files changed, 74 insertions(+) create mode 100644 pkgs/r/compat.richdem.lua create mode 100644 tests/examples/richdem/mcpp.toml create mode 100644 tests/examples/richdem/tests/core.cpp diff --git a/mcpp.toml b/mcpp.toml index a96c9edc..5e3e6bb9 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -85,6 +85,7 @@ members = [ "tests/examples/openssl", "tests/examples/recastnavigation", "tests/examples/recastnavigation-features", + "tests/examples/richdem", "tests/examples/protobuf", "tests/examples/protobuf-upb", "tests/examples/protobuf-gzip", diff --git a/pkgs/r/compat.richdem.lua b/pkgs/r/compat.richdem.lua new file mode 100644 index 00000000..f181b265 --- /dev/null +++ b/pkgs/r/compat.richdem.lua @@ -0,0 +1,59 @@ +-- Form B inline descriptor for RichDEM, a C++ library for high-performance +-- terrain analysis. +-- +-- RichDEM's public headers are under include/richdem and its standalone +-- library sources are under src/. GDAL support is optional upstream: enabling +-- the feature matches CMake's USE_GDAL option by defining USEGDAL and adding +-- the GDAL implementation source. Consumers enabling that feature must also +-- provide GDAL headers and the GDAL library in their environment. +package = { + spec = "1", + namespace = "compat", + name = "richdem", + description = "High-performance terrain analysis library", + licenses = {"MIT"}, + repo = "https://github.com/r-barnes/richdem", + type = "package", + + xpm = { + linux = { + ["2.2.11"] = { + url = "https://github.com/r-barnes/richdem/archive/9a1c97bb2529e386451a7dd54768b8b74bb4d620.tar.gz", + sha256 = "bfa98d00d1d1f3529b2efc6907c9977e65a3c3071f46e24f468fa0db0dc6118b", + }, + }, + macosx = { + ["2.2.11"] = { + url = "https://github.com/r-barnes/richdem/archive/9a1c97bb2529e386451a7dd54768b8b74bb4d620.tar.gz", + sha256 = "bfa98d00d1d1f3529b2efc6907c9977e65a3c3071f46e24f468fa0db0dc6118b", + }, + }, + windows = { + ["2.2.11"] = { + url = "https://github.com/r-barnes/richdem/archive/9a1c97bb2529e386451a7dd54768b8b74bb4d620.tar.gz", + sha256 = "bfa98d00d1d1f3529b2efc6907c9977e65a3c3071f46e24f468fa0db0dc6118b", + }, + }, + }, + + mcpp = { + language = "c++23", + import_std = false, + c_standard = "c11", + include_dirs = { "*/include" }, + sources = { + "*/src/richdem.cpp", + "*/src/random.cpp", + "*/src/terrain_generation/terrain_generation.cpp", + "*/src/terrain_generation/PerlinNoise.cpp", + }, + targets = { ["richdem"] = { kind = "lib" } }, + features = { + ["gdal"] = { + defines = { "USEGDAL" }, + sources = { "*/src/gdal.cpp" }, + }, + }, + deps = {}, + }, +} diff --git a/tests/examples/richdem/mcpp.toml b/tests/examples/richdem/mcpp.toml new file mode 100644 index 00000000..066fdcfb --- /dev/null +++ b/tests/examples/richdem/mcpp.toml @@ -0,0 +1,6 @@ +[package] +name = "richdem-tests" +version = "0.1.0" + +[dependencies.compat] +richdem = "2.2.11" diff --git a/tests/examples/richdem/tests/core.cpp b/tests/examples/richdem/tests/core.cpp new file mode 100644 index 00000000..8453ad1a --- /dev/null +++ b/tests/examples/richdem/tests/core.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() { + richdem::seed_rand(1); + const auto value = richdem::uniform_rand_int(1, 10); + return value >= 1 && value <= 10 ? 0 : 1; +} From 7587d95101b76e5df23b7542bc8e90f4058bcb47 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Tue, 13 Oct 2026 21:51:37 +0900 Subject: [PATCH 2/2] fix(richdem): correct package lookup and validate serial terrain core --- .agents/docs/2026-10-13-add-richdem-plan.md | 21 +++++++++++++++++++++ README.md | 2 ++ README.zh-CN.md | 2 ++ pkgs/{r => c}/compat.richdem.lua | 14 +++----------- tests/examples/richdem/mcpp.toml | 3 +++ tests/examples/richdem/tests/core.cpp | 15 ++++++++++++--- 6 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 .agents/docs/2026-10-13-add-richdem-plan.md rename pkgs/{r => c}/compat.richdem.lua (75%) diff --git a/.agents/docs/2026-10-13-add-richdem-plan.md b/.agents/docs/2026-10-13-add-richdem-plan.md new file mode 100644 index 00000000..49e2ce36 --- /dev/null +++ b/.agents/docs/2026-10-13-add-richdem-plan.md @@ -0,0 +1,21 @@ +# Add compat.richdem + +The pinned revision 9a1c97bb2529e386451a7dd54768b8b74bb4d620 declares +project version 2.2.11 in upstream CMakeLists.txt. It is not a release tag; +the descriptor preserves the PR's requested source snapshot and version. +The archive hash was checked twice. License: MIT. + +This Form B build compiles richdem.cpp, random.cpp and terrain generation +sources, exposing upstream include/. It is deliberately the serial core: +GDAL, Boost serialization and OpenMP are disabled. The proposed gdal feature +was removed because adding gdal.cpp alone leaves USEGDAL disabled and cannot +supply the required SDK and runtime. No unsupported feature is advertised. + +The descriptor lives under pkgs/c/compat.richdem.lua, matching the full +package name; the consumer redirects compat to this checkout. It fills a +3x3 depression and verifies random-state save/restore, exercising both the +public terrain algorithm and linked core symbols. + +No mirror upload was performed; plain-string GLOBAL URLs provide CN fallback. +Local validation with the CI-pinned mcpp 2026.10.1.2 and gcc 16.1.0: +`mcpp test -p richdem`: `test result ok. 1 passed; 0 failed`. diff --git a/README.md b/README.md index 0459ca25..92ba0440 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ the online index; open a PR and confirm CI is green. A PR runs lint and tests only the workspace members that depend on the changed descriptors; after the merge, `deploy-site` publishes the site. +Additional example: [`compat.richdem`](pkgs/c/compat.richdem.lua) — C++ sources, serial terrain analysis; [`consumer test`](tests/examples/richdem/mcpp.toml). + ## Documentation - [Library shapes and descriptor templates](docs/package-types.md) diff --git a/README.zh-CN.md b/README.zh-CN.md index a996bda4..1dd3c9ff 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -59,6 +59,8 @@ agent(如 Claude Code)即可: 提交 PR 后,CI 执行 lint,并只测试依赖了被修改描述符的 workspace 成员;合并后,`deploy-site` 发布站点。 +新增示例: [`compat.richdem`](pkgs/c/compat.richdem.lua) — C++ sources, serial terrain analysis; [`消费测试`](tests/examples/richdem/mcpp.toml)。 + ## 文档 - [库形态与描述符模板](docs/zh/package-types.md) diff --git a/pkgs/r/compat.richdem.lua b/pkgs/c/compat.richdem.lua similarity index 75% rename from pkgs/r/compat.richdem.lua rename to pkgs/c/compat.richdem.lua index f181b265..b2c87575 100644 --- a/pkgs/r/compat.richdem.lua +++ b/pkgs/c/compat.richdem.lua @@ -1,11 +1,9 @@ -- Form B inline descriptor for RichDEM, a C++ library for high-performance -- terrain analysis. -- --- RichDEM's public headers are under include/richdem and its standalone --- library sources are under src/. GDAL support is optional upstream: enabling --- the feature matches CMake's USE_GDAL option by defining USEGDAL and adding --- the GDAL implementation source. Consumers enabling that feature must also --- provide GDAL headers and the GDAL library in their environment. +-- Serial core build: GDAL, Boost serialization and OpenMP are disabled. +-- GDAL needs a define, headers and a runtime dependency, so a sources-only +-- feature cannot enable it correctly. Do not advertise an inert gdal feature. package = { spec = "1", namespace = "compat", @@ -48,12 +46,6 @@ package = { "*/src/terrain_generation/PerlinNoise.cpp", }, targets = { ["richdem"] = { kind = "lib" } }, - features = { - ["gdal"] = { - defines = { "USEGDAL" }, - sources = { "*/src/gdal.cpp" }, - }, - }, deps = {}, }, } diff --git a/tests/examples/richdem/mcpp.toml b/tests/examples/richdem/mcpp.toml index 066fdcfb..74d3be93 100644 --- a/tests/examples/richdem/mcpp.toml +++ b/tests/examples/richdem/mcpp.toml @@ -4,3 +4,6 @@ version = "0.1.0" [dependencies.compat] richdem = "2.2.11" + +[indices] +compat = { path = "../../.." } diff --git a/tests/examples/richdem/tests/core.cpp b/tests/examples/richdem/tests/core.cpp index 8453ad1a..459909dc 100644 --- a/tests/examples/richdem/tests/core.cpp +++ b/tests/examples/richdem/tests/core.cpp @@ -1,8 +1,17 @@ -#include +#include #include +#include int main() { + richdem::Array2D dem(3, 3, 5.0); + dem(1, 1) = 1.0; + richdem::FillDepressions(dem); + if (dem(1, 1) != 5.0 || dem(0, 0) != 5.0) return 1; + richdem::seed_rand(1); - const auto value = richdem::uniform_rand_int(1, 10); - return value >= 1 && value <= 10 ? 0 : 1; + const auto state = richdem::SaveRandomState(); + const int first = richdem::uniform_rand_int(1, 10); + richdem::SetRandomState(state); + return first >= 1 && first <= 10 && + richdem::uniform_rand_int(1, 10) == first ? 0 : 2; }