Skip to content

Commit

Permalink
Save manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
h1994st committed Jun 26, 2023
1 parent 686fad4 commit 79bee6f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### rllvm ###
*.bc
*.bca
*.manifest
.*.o
!.gitignore

# Created by https://www.toptal.com/developers/gitignore/api/rust,macos,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,macos,visualstudiocode

Expand Down
23 changes: 21 additions & 2 deletions src/bin/rllvm_get_bc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,36 @@ pub fn main() -> Result<(), Error> {

// Extract bitcode filepaths
let bitcode_filepaths = extract_bitcode_filepaths_from_parsed_objects(&object_files)?;
if args.save_manifest {
// Write bitcode filepaths into the manifest file
let input_parent_dir = input_filepath.parent().unwrap();
let output_filename = output_filepath.file_name().unwrap();
let manifest_filepath =
input_parent_dir.join(format!("{}.manifest", output_filename.to_string_lossy()));

let manifest_contents = bitcode_filepaths
.iter()
.map(|bitcode_filepath| bitcode_filepath.to_string_lossy())
.collect::<Vec<_>>()
.join("\n");
fs::write(&manifest_filepath, manifest_contents)?;
log::info!("Save manifest: {:?}", manifest_filepath);
}

// Link or archive bitcode files
if build_bitcode_archive {
log::info!("Archive bitcode files");
if let Some(code) = archive_bitcode_files(&bitcode_filepaths, output_filepath.clone())? {
std::process::exit(code);
if code != 0 {
std::process::exit(code);
}
}
} else {
log::info!("Link bitcode files");
if let Some(code) = link_bitcode_files(&bitcode_filepaths, output_filepath.clone())? {
std::process::exit(code);
if code != 0 {
std::process::exit(code);
}
}
}
log::info!("Output file: {:?}", output_filepath);
Expand Down

0 comments on commit 79bee6f

Please sign in to comment.