MCPcopy Index your code
hub / github.com/cargo-lambda/cargo-lambda / create_binary_archive

Function create_binary_archive

crates/cargo-lambda-build/src/archive.rs:174–205  ·  view source on GitHub ↗

Search for the binary file for a function or extension inside the target directory. If the binary file exists, it creates the zip archive and extracts its architecture by reading the binary. If the zip file already exists, use it as the deployment archive. If none of them exist, return an error.

(
    metadata: Option<&CargoMetadata>,
    base_dir: &Option<P>,
    data: &BinaryData,
    include: Option<Vec<String>>,
)

Source from the content-addressed store, hash-verified

172/// If the zip file already exists, use it as the deployment archive.
173/// If none of them exist, return an error.
174pub fn create_binary_archive<P>(
175 metadata: Option<&CargoMetadata>,
176 base_dir: &Option<P>,
177 data: &BinaryData,
178 include: Option<Vec<String>>,
179) -> Result<BinaryArchive>
180where
181 P: AsRef<Path>,
182{
183 let bootstrap_dir = if let Some(dir) = base_dir {
184 dir.as_ref().join(data.binary_location())
185 } else {
186 let target_dir = metadata
187 .and_then(|m| target_dir_from_metadata(m).ok())
188 .unwrap_or_else(|| PathBuf::from("target"));
189
190 target_dir.join("lambda").join(data.binary_location())
191 };
192
193 let binary_path = bootstrap_dir.join(data.binary_name());
194 if binary_path.exists() {
195 return zip_binary(binary_path, bootstrap_dir, data, include);
196 } else {
197 let zip_path = bootstrap_dir.join(data.zip_name());
198
199 if zip_path.exists() {
200 return use_zip_in_place(zip_path, data, include);
201 }
202 }
203
204 Err(BuildError::BinaryMissing(data.binary_name().into(), data.build_help().into()).into())
205}
206
207fn use_zip_in_place(
208 zip_path: PathBuf,

Calls 7

target_dir_from_metadataFunction · 0.85
zip_binaryFunction · 0.85
use_zip_in_placeFunction · 0.85
binary_locationMethod · 0.80
binary_nameMethod · 0.80
build_helpMethod · 0.80
zip_nameMethod · 0.45