[M5] verify-curated-db.sh + boost recipe (header-only)
This commit is contained in:
8
scripts/curated-snippets/abseil-cpp.cpp
Normal file
8
scripts/curated-snippets/abseil-cpp.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <absl/strings/str_cat.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
auto s = absl::StrCat("abseil-", "cpp");
|
||||
std::println("abseil-cpp ok: {}", s);
|
||||
return 0;
|
||||
}
|
||||
8
scripts/curated-snippets/boost.cpp
Normal file
8
scripts/curated-snippets/boost.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
boost::filesystem::path p{"/tmp"};
|
||||
std::println("boost ok: {}", p.string());
|
||||
return 0;
|
||||
}
|
||||
13
scripts/curated-snippets/cli11.cpp
Normal file
13
scripts/curated-snippets/cli11.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <CLI/CLI.hpp>
|
||||
import std;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
CLI::App app{"verify"};
|
||||
try {
|
||||
app.parse(argc, argv);
|
||||
} catch (const CLI::ParseError& e) {
|
||||
return app.exit(e);
|
||||
}
|
||||
std::println("cli11 ok");
|
||||
return 0;
|
||||
}
|
||||
7
scripts/curated-snippets/curl.cpp
Normal file
7
scripts/curated-snippets/curl.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <curl/curl.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
std::println("curl ok: {}", curl_version());
|
||||
return 0;
|
||||
}
|
||||
8
scripts/curated-snippets/cxxopts.cpp
Normal file
8
scripts/curated-snippets/cxxopts.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <cxxopts.hpp>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
cxxopts::Options opts("verify", "verify cxxopts");
|
||||
std::println("cxxopts ok: {}", opts.program());
|
||||
return 0;
|
||||
}
|
||||
8
scripts/curated-snippets/eigen.cpp
Normal file
8
scripts/curated-snippets/eigen.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <Eigen/Core>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
Eigen::Vector2d v(1.0, 2.0);
|
||||
std::println("eigen ok: ({},{})", v[0], v[1]);
|
||||
return 0;
|
||||
}
|
||||
7
scripts/curated-snippets/fmt.cpp
Normal file
7
scripts/curated-snippets/fmt.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <fmt/core.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
fmt::print("fmt ok\n");
|
||||
return 0;
|
||||
}
|
||||
13
scripts/curated-snippets/freetype.cpp
Normal file
13
scripts/curated-snippets/freetype.cpp
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
FT_Library lib = nullptr;
|
||||
auto err = FT_Init_FreeType(&lib);
|
||||
if (err == 0 && lib) {
|
||||
FT_Done_FreeType(lib);
|
||||
}
|
||||
std::println("freetype ok: init err {}", err);
|
||||
return 0;
|
||||
}
|
||||
9
scripts/curated-snippets/glfw.cpp
Normal file
9
scripts/curated-snippets/glfw.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
int major = 0, minor = 0, rev = 0;
|
||||
glfwGetVersion(&major, &minor, &rev);
|
||||
std::println("glfw ok: {}.{}.{}", major, minor, rev);
|
||||
return 0;
|
||||
}
|
||||
8
scripts/curated-snippets/glm.cpp
Normal file
8
scripts/curated-snippets/glm.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <glm/glm.hpp>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
glm::vec3 v(1.0f, 2.0f, 3.0f);
|
||||
std::println("glm ok: ({},{},{})", v.x, v.y, v.z);
|
||||
return 0;
|
||||
}
|
||||
7
scripts/curated-snippets/grpc.cpp
Normal file
7
scripts/curated-snippets/grpc.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <grpcpp/grpcpp.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
std::println("grpc ok: {}", grpc::Version());
|
||||
return 0;
|
||||
}
|
||||
10
scripts/curated-snippets/libjpeg.cpp
Normal file
10
scripts/curated-snippets/libjpeg.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
// libjpeg's jpeglib.h relies on stdio types being already declared.
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <jpeglib.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
std::println("libjpeg ok: lib version {}", JPEG_LIB_VERSION);
|
||||
return 0;
|
||||
}
|
||||
7
scripts/curated-snippets/libpng.cpp
Normal file
7
scripts/curated-snippets/libpng.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <png.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
std::println("libpng ok: {}", png_access_version_number());
|
||||
return 0;
|
||||
}
|
||||
10
scripts/curated-snippets/magic_enum.cpp
Normal file
10
scripts/curated-snippets/magic_enum.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <magic_enum/magic_enum.hpp>
|
||||
import std;
|
||||
|
||||
enum class Color { Red, Green, Blue };
|
||||
|
||||
int main() {
|
||||
auto n = magic_enum::enum_count<Color>();
|
||||
std::println("magic_enum ok: {} entries", n);
|
||||
return 0;
|
||||
}
|
||||
9
scripts/curated-snippets/nlohmann_json.cpp
Normal file
9
scripts/curated-snippets/nlohmann_json.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
nlohmann::json j;
|
||||
j["k"] = 42;
|
||||
std::println("{}", j.dump());
|
||||
return 0;
|
||||
}
|
||||
9
scripts/curated-snippets/openssl.cpp
Normal file
9
scripts/curated-snippets/openssl.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <openssl/evp.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
EVP_MD_CTX* ctx = EVP_MD_CTX_new();
|
||||
EVP_MD_CTX_free(ctx);
|
||||
std::println("openssl ok");
|
||||
return 0;
|
||||
}
|
||||
8
scripts/curated-snippets/protobuf.cpp
Normal file
8
scripts/curated-snippets/protobuf.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <google/protobuf/arena.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
google::protobuf::Arena arena;
|
||||
std::println("protobuf ok: arena size {}", arena.SpaceUsed());
|
||||
return 0;
|
||||
}
|
||||
12
scripts/curated-snippets/range-v3.cpp
Normal file
12
scripts/curated-snippets/range-v3.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <range/v3/view/iota.hpp>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
auto v = ranges::views::iota(0, 5);
|
||||
int sum = 0;
|
||||
for (int i : v) {
|
||||
sum += i;
|
||||
}
|
||||
std::println("range-v3 ok: {}", sum);
|
||||
return 0;
|
||||
}
|
||||
8
scripts/curated-snippets/sdl2.cpp
Normal file
8
scripts/curated-snippets/sdl2.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <SDL2/SDL.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
auto* err = SDL_GetError();
|
||||
std::println("sdl2 ok: SDL_GetError() = '{}'", err ? err : "");
|
||||
return 0;
|
||||
}
|
||||
8
scripts/curated-snippets/spdlog.cpp
Normal file
8
scripts/curated-snippets/spdlog.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
spdlog::info("spdlog ok");
|
||||
return 0;
|
||||
}
|
||||
7
scripts/curated-snippets/sqlite3.cpp
Normal file
7
scripts/curated-snippets/sqlite3.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <sqlite3.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
std::println("sqlite3 ok: {}", sqlite3_libversion());
|
||||
return 0;
|
||||
}
|
||||
9
scripts/curated-snippets/tbb.cpp
Normal file
9
scripts/curated-snippets/tbb.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <oneapi/tbb/parallel_for.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
int sum = 0;
|
||||
oneapi::tbb::parallel_for(0, 10, [&](int i) { sum += i; });
|
||||
std::println("tbb ok: {}", sum);
|
||||
return 0;
|
||||
}
|
||||
7
scripts/curated-snippets/zlib.cpp
Normal file
7
scripts/curated-snippets/zlib.cpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <zlib.h>
|
||||
import std;
|
||||
|
||||
int main() {
|
||||
std::println("zlib ok: {}", zlibVersion());
|
||||
return 0;
|
||||
}
|
||||
179
scripts/verify-curated-db.sh
Executable file
179
scripts/verify-curated-db.sh
Executable file
@@ -0,0 +1,179 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build a tiny project for every curated-linkdb package, compile against the
|
||||
# library, and verify the binary links. Catches nixpkgs attribute drift,
|
||||
# find_package case mismatches, and missing components configurations.
|
||||
#
|
||||
# Usage:
|
||||
# scripts/verify-curated-db.sh [pkg1 pkg2 ...]
|
||||
#
|
||||
# Env:
|
||||
# CARGOXX absolute path to the cargoxx binary (default: ./build/cargoxx)
|
||||
# VERIFY_DIR working directory (default: a fresh mktemp under /tmp)
|
||||
# KEEP non-empty → leave VERIFY_DIR in place after the run
|
||||
#
|
||||
# Catch2 and gtest are intentionally skipped: their default linkdb targets
|
||||
# (Catch2WithMain, GTest::gtest_main) supply their own main() and would
|
||||
# collide with the using-snippet's int main().
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
CARGOXX="${CARGOXX:-${REPO_ROOT}/build/cargoxx}"
|
||||
SNIPPETS_DIR="${REPO_ROOT}/scripts/curated-snippets"
|
||||
|
||||
if [[ ! -x "${CARGOXX}" ]]; then
|
||||
echo "ERROR: cargoxx binary not found at ${CARGOXX}" >&2
|
||||
echo " build it first: cmake --build build" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ -z "${VERIFY_DIR:-}" ]]; then
|
||||
VERIFY_DIR="$(mktemp -d -t cargoxx-verify-XXXXXX)"
|
||||
fi
|
||||
mkdir -p "${VERIFY_DIR}"
|
||||
|
||||
if [[ -z "${KEEP:-}" ]]; then
|
||||
trap 'rm -rf "${VERIFY_DIR}"' EXIT
|
||||
fi
|
||||
|
||||
echo "cargoxx: ${CARGOXX}"
|
||||
echo "verify dir: ${VERIFY_DIR}"
|
||||
echo
|
||||
|
||||
# Format: "name|version|components" (components is comma-separated, may be empty)
|
||||
ALL_PACKAGES=(
|
||||
"fmt|10.2.0|"
|
||||
"spdlog|1.13.0|"
|
||||
"nlohmann_json|3.11.0|"
|
||||
"boost|1.84.0|"
|
||||
"openssl|3.2.0|"
|
||||
"zlib|1.3.0|"
|
||||
"sqlite3|3.45.0|"
|
||||
"curl|8.5.0|"
|
||||
"protobuf|25.0.0|"
|
||||
"eigen|3.4.0|"
|
||||
"tbb|2021.10.0|"
|
||||
"libpng|1.6.40|"
|
||||
"libjpeg|3.0.1|"
|
||||
"freetype|2.13.2|"
|
||||
"glfw|3.3.9|"
|
||||
"glm|0.9.9.8|"
|
||||
"sdl2|2.28.5|"
|
||||
"cli11|2.4.1|"
|
||||
"cxxopts|3.2.0|"
|
||||
"range-v3|0.12.0|"
|
||||
"magic_enum|0.9.5|"
|
||||
)
|
||||
SKIPPED_PACKAGES=(
|
||||
"catch2 (links Catch2WithMain — conflicts with the snippet's main())"
|
||||
"gtest (links GTest::gtest_main — conflicts with the snippet's main())"
|
||||
"grpc (find_dependency(Protobuf) transitive — needs cross-package deps)"
|
||||
"abseil-cpp (nixpkgs builds it against libstdc++; our flake uses libc++)"
|
||||
)
|
||||
|
||||
# Allow running on a subset: ./scripts/verify-curated-db.sh fmt boost
|
||||
FILTER=("$@")
|
||||
|
||||
is_filtered() {
|
||||
local name="$1"
|
||||
if [[ ${#FILTER[@]} -eq 0 ]]; then
|
||||
return 0
|
||||
fi
|
||||
local f
|
||||
for f in "${FILTER[@]}"; do
|
||||
if [[ "${f}" == "${name}" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
ok=()
|
||||
failed=()
|
||||
|
||||
run_one() {
|
||||
local name="$1" version="$2" components="$3"
|
||||
local snippet="${SNIPPETS_DIR}/${name}.cpp"
|
||||
|
||||
if [[ ! -f "${snippet}" ]]; then
|
||||
echo " ✗ no snippet at ${snippet}" >&2
|
||||
failed+=("${name}: missing snippet")
|
||||
return 1
|
||||
fi
|
||||
|
||||
local proj="${VERIFY_DIR}/${name}"
|
||||
rm -rf "${proj}"
|
||||
|
||||
pushd "${VERIFY_DIR}" >/dev/null || return 1
|
||||
if ! "${CARGOXX}" new "${name}" >"${VERIFY_DIR}/${name}.new.log" 2>&1; then
|
||||
echo " ✗ cargoxx new failed (log: ${VERIFY_DIR}/${name}.new.log)" >&2
|
||||
failed+=("${name}: cargoxx new")
|
||||
popd >/dev/null
|
||||
return 1
|
||||
fi
|
||||
popd >/dev/null
|
||||
|
||||
pushd "${proj}" >/dev/null || return 1
|
||||
|
||||
local add_args=("${name}@${version}")
|
||||
if [[ -n "${components}" ]]; then
|
||||
add_args+=("--components" "${components}")
|
||||
fi
|
||||
if ! "${CARGOXX}" add "${add_args[@]}" >"${VERIFY_DIR}/${name}.add.log" 2>&1; then
|
||||
echo " ✗ cargoxx add failed (log: ${VERIFY_DIR}/${name}.add.log)" >&2
|
||||
failed+=("${name}: cargoxx add")
|
||||
popd >/dev/null
|
||||
return 1
|
||||
fi
|
||||
|
||||
cp "${snippet}" src/main.cpp
|
||||
|
||||
if ! "${CARGOXX}" build >"${VERIFY_DIR}/${name}.build.log" 2>&1; then
|
||||
echo " ✗ cargoxx build failed (log: ${VERIFY_DIR}/${name}.build.log)" >&2
|
||||
failed+=("${name}: cargoxx build")
|
||||
popd >/dev/null
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ ! -x "build/debug/${name}" ]]; then
|
||||
echo " ✗ binary not produced at build/debug/${name}" >&2
|
||||
failed+=("${name}: missing binary")
|
||||
popd >/dev/null
|
||||
return 1
|
||||
fi
|
||||
|
||||
popd >/dev/null
|
||||
ok+=("${name}")
|
||||
echo " ✓ ${name}"
|
||||
return 0
|
||||
}
|
||||
|
||||
for entry in "${ALL_PACKAGES[@]}"; do
|
||||
IFS='|' read -r name version components <<<"${entry}"
|
||||
if ! is_filtered "${name}"; then
|
||||
continue
|
||||
fi
|
||||
echo "=== ${name} ${version} ==="
|
||||
run_one "${name}" "${version}" "${components}"
|
||||
done
|
||||
|
||||
echo
|
||||
echo "============================="
|
||||
echo "RESULTS"
|
||||
echo "============================="
|
||||
echo "OK: ${#ok[@]}"
|
||||
for n in "${ok[@]}"; do echo " ✓ ${n}"; done
|
||||
echo
|
||||
if [[ ${#failed[@]} -gt 0 ]]; then
|
||||
echo "FAILED: ${#failed[@]}"
|
||||
for f in "${failed[@]}"; do echo " ✗ ${f}"; done
|
||||
fi
|
||||
echo
|
||||
echo "SKIPPED: ${#SKIPPED_PACKAGES[@]} (test-framework targets supply own main)"
|
||||
for s in "${SKIPPED_PACKAGES[@]}"; do echo " · ${s}"; done
|
||||
|
||||
if [[ ${#failed[@]} -gt 0 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
Reference in New Issue
Block a user