샘플
pkg-config 0.3.34: get_variable
검증된 샘플 — cargo pkg-config 0.3.34: get_variable. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: pkg_config::get_variable(package, variable)…
sha256:78da2d6443ad89f0e443c3891152ad599879778f2c422d83a4e2de1eff566b83
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux x64 cargo
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-10-18 |
케이스
HOW- 목표
- verify get_variable in pkg:cargo/pkg-config@0.3.34
- 심벌
-
- get_variable
- 생성일
- 2026-10-18T21:14:26Z
컨트랙트
- pkg_config::get_variable(package, variable) invokes the configured PKG_CONFIG executable with --variable=<variable> and returns the trimmed stdout as Ok(String)
- pkg_config::get_variable passes PKG_CONFIG_PATH to the pkg-config process so package .pc files in that directory are queried
- pkg_config::get_variable returns Ok("".to_string()) when the queried variable output is empty
- pkg_config::get_variable returns Err(pkg_config::Error::Failure { .. }) when the pkg-config process exits with a non-zero status for an unknown package
파일
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- mock-pkg-config.sh
- pc/demo.pc
- spec.json
- src/main.rs
소스
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "pkg-config"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
[[package]]
name = "sample-pkg-config"
version = "0.1.0"
dependencies = [
"pkg-config",
]
[package]
name = "sample-pkg-config"
version = "0.1.0"
edition = "2021"
[dependencies]
pkg-config = "=0.3.34"
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify get_variable in pkg:cargo/pkg-config@0.3.34
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/pkg-config@0.3.34
Demonstrate these symbols/APIs:
- get_variable
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:a2896f67044e66ce8ef33484b00fcf59183ff877851ce22d89adcb8022e7a07e","contract":["pkg_config::get_variable(package, variable) invokes the configured PKG_CONFIG executable with --variable=\u003cvariable\u003e and returns the trimmed stdout as Ok(String)","pkg_config::get_variable passes PKG_CONFIG_PATH to the pkg-config process so package .pc files in that directory are queried","pkg_config::get_variable returns Ok(\"\".to_string()) when the queried variable output is empty","pkg_config::get_variable returns Err(pkg_config::Error::Failure { .. }) when the pkg-config process exits with a non-zero status for an unknown package"],"goal":"verify get_variable in pkg:cargo/pkg-config@0.3.34","kind":"HOW","packages":["pkg:cargo/pkg-config@0.3.34"],"schemaVersion":1,"symbols":["get_variable"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","ecosystem":"cargo","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/pkg-config@0.3.34"],"schemaVersion":1,"subject":"pkg:cargo/pkg-config@0.3.34","symbols":["get_variable"],"verifierAdapter":"cargo@1"}
#!/bin/sh
var=""
pkg=""
for arg in "$@"; do
case "$arg" in
--variable=*)
var="${arg#--variable=}"
;;
--*)
;;
*)
pkg="$arg"
;;
esac
done
pc_file="${PKG_CONFIG_PATH:-.}/${pkg}.pc"
if [ ! -f "$pc_file" ]; then
echo "Package $pkg was not found in the pkg-config search path." >&2
exit 1
fi
if [ -n "$var" ]; then
val=$(sed -n "s/^${var}=//p" "$pc_file" | head -n 1)
printf "%s\n" "$val"
exit 0
fi
exit 0
prefix=demo_root
libdir=demo_root_lib
includedir=demo_root_include
custom_feature=enabled
Name: demo
Description: Demo package for pkg-config get_variable verification
Version: 1.2.3
Libs: -ldemo
Cflags: -DDEMO=1
{
"schemaVersion": 1,
"goal": "verify get_variable in pkg:cargo/pkg-config@0.3.34",
"kind": "HOW",
"packages": [
"pkg:cargo/pkg-config@0.3.34"
],
"symbols": [
"get_variable"
]
}
use std::env;
use std::fs;
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
fn main() {
let pc_dir = Path::new("pc")
.canonicalize()
.expect("pc directory must exist");
env::set_var("PKG_CONFIG_PATH", &pc_dir);
let mock_bin = Path::new("mock-pkg-config.sh")
.canonicalize()
.expect("mock-pkg-config.sh must exist");
let mut perms = fs::metadata(&mock_bin)
.expect("metadata must succeed")
.permissions();
perms.set_mode(0o755);
fs::set_permissions(&mock_bin, perms).expect("set_permissions must succeed");
env::set_var("PKG_CONFIG", &mock_bin);
let prefix = pkg_config::get_variable("demo", "prefix").expect("should retrieve prefix");
assert_eq!(prefix, "demo_root");
let libdir = pkg_config::get_variable("demo", "libdir").expect("should retrieve libdir");
assert_eq!(libdir, "demo_root_lib");
let custom =
pkg_config::get_variable("demo", "custom_feature").expect("should retrieve custom_feature");
assert_eq!(custom, "enabled");
let missing_var = pkg_config::get_variable("demo", "nonexistent_var")
.expect("missing var returns empty string");
assert_eq!(missing_var, "");
let missing_pkg = pkg_config::get_variable("nonexistent_pkg", "prefix");
assert!(matches!(missing_pkg, Err(pkg_config::Error::Failure { .. })));
#[allow(deprecated)]
let cfg_var = pkg_config::Config::get_variable("demo", "includedir")
.expect("Config::get_variable should retrieve includedir");
assert_eq!(cfg_var, "demo_root_include");
}
오리진 시더
익명