pub fn build_repo(
target_sub_path: &str,
repo_url: &str,
repo_tag: &str,
executable_name: &str,
builder_args: &[&str],
cuda_arg: &Option<&str>,
) -> Result<()>
Expand description
Clones and builds a repository at a specified tag with appropriate platform-specific optimizations.
This function handles the complete process of:
- Checking if a repository needs updating or building
- Cloning/updating the repository to the specified tag
- Building the repository with provided configuration
- Cleaning up on build failures
§Arguments
target_sub_path
- Subdirectory within the workspace’s target directory where the repo will be clonedrepo_url
- URL of the git repository to clonerepo_tag
- Specific git tag to checkoutexecutable_name
- Name of the executable that should be builtbuilder_args
- Arguments to pass to the make command (e.g., [“llama-server”, “BUILD_TYPE=Release”])cuda_arg
- Optional CUDA-specific argument for the make command when building with CUDA support
§Returns
Result<()>
- Ok(()) if build succeeds, Error if any step fails
§Errors
Returns error if:
- Git operations fail (clone, checkout)
- Build process fails
- Executable is not found after build
- Directory operations fail (create, remove)
§Example
use llm_devices::build_repo;
let result = build_repo(
"llama.cpp",
"https://github.com/ggerganov/llama.cpp",
"b3943",
"llama-server",
&["llama-server", "BUILD_TYPE=Release", "-j"],
&Some("GGML_CUDA=1")
);