一键导入
cmake-extract
Extract and analyze CMake build metadata from a repository, mapping it to Spack-relevant abstractions for use in recipe generation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Extract and analyze CMake build metadata from a repository, mapping it to Spack-relevant abstractions for use in recipe generation
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Extract Spack package metadata and find similar packages based on build system, dependencies, and variants. Use to discover reference recipes for package generation.
Translate extracted repository metadata into a Spack package recipe, then validate and iterate until the package installs successfully.
| name | cmake-extract |
| description | Extract and analyze CMake build metadata from a repository, mapping it to Spack-relevant abstractions for use in recipe generation |
Use this skill when a user initiates a request to create or update a Spack package recipe. The details extracted by this skill will be used in downstream tasks like package generation and repair.
The user will provide a URL (tarball/Git) or local path to a codebase. Use standard tools (curl/wget/tar/zip/git) to download and open the repo.
Place downloaded files into a newly created temporary directory (mktemp -d "$TMPDIR/XXXXX").
Downloads should be efficient (i.e., use depth=1 with Git).
Once the repository is accessible, run the two extraction steps below. The scripts accept directory paths as their argument and expand shell variables (e.g., $TMPDIR).
Run: python scripts/detect_build_systems.py <repo_dir>
This outputs two values:
If the detected build system is not cmake, stop immediately and inform the user:
"Only CMake-based repositories are supported."
Run: python scripts/cmake_extract.py <repo_dir>
This script scans CMake files in the repository and outputs a structured summary of:
Because the script will read the CMake files, do not cat or grep the files.
Your task is to translate the CMake metadata from step 3 into a concise manifest of Spack-relevant insights used for recipe generation.
Brevity and accuracy are critical; do not invent anything not explicitly present in the metadata.
Plain text, one mapping per line: → ← Example lines: WITH_ADIAK → variant('+adiak') ← cache_sets:WITH_ADIAK (BOOL, default ON) find_package(Python) → variant('python') + depends_on('python', when='+python') ← commands:find_package cmake_minimum_required(3.14) → depends_on('cmake@3.14:', type='build') ← commands:cmake_minimum_required project(LANGUAGES CXX) → depends_on('cxx', type='build') ← commands:project LANGUAGES
After all mapping lines, append a SUMMARY block:
SUMMARY variants: var1 var2 var3 dependencies: dep1 dep2 dep3 conflicts: '+tight_error when=round=never' compilers: cxx fortran
All identifiers must use Spack-style naming (lowercase, no cmake prefixes): cmake, cuda, mpi, python, fortran, c, cxx, openmpi, etc.
WITH_*, ENABLE_*, USE_*, BUILD_* BOOL variables → variant(...)Emit depends_on('', type='build') for any language that is actually used to compile sources. Use the following signals, in rough order of strength:
Strong signals (language is definitely used):
Weak signals (language is likely used, emit with note):
You must emit the dependency even if there is only a single weak signal.
Emit exactly one mapping line per language detected, citing the strongest evidence found.
find_package(CUDA) or enable_language(CUDA)
find_package(Python* …) ⟶ variant('python'), associated depsWrite all results to: <repo_dir>/spack_metadata.txt
The file must contain the following sections in order. Include the Note: lines, they are for the user.
BUILD_SYSTEM: Note: Use this to select the correct Spack base class (e.g. cmake → CMakePackage). FEATURES: <comma-separated list from Step 2>
--- CMAKE MAPPINGS --- Note: Each line is a direct instruction: emit exactly the spack abstraction shown, and consult the evidence field to resolve ambiguity or determine constraints. <all mapping lines from Step 4>
--- SUMMARY --- variants: ... dependencies: ... conflicts: ... compilers: ...
This file is the bridge between this skill and other Spack-adjacent tasks.