Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions tool/bundle/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() -> Result<()> {
args.workspace.into()
};

let bundled_code = bundle_crate(&args.crate_name, &workspace_path)
let bundled_code = bundle_crate(&args.crate_name, &workspace_path, args.no_source_url)
.with_context(|| format!("Failed to bundle crate '{}'", args.crate_name))?;

if args.skip_compile {
Expand Down Expand Up @@ -73,6 +73,10 @@ struct Args {
#[clap(long, conflicts_with = "workspace")]
remote: bool,

/// Omit the source URL
#[clap(long)]
no_source_url: bool,

/// Skip compilation check
#[clap(long)]
skip_compile: bool,
Expand Down Expand Up @@ -130,11 +134,7 @@ fn list_available_crates(crates: &HashMap<String, CrateInfo>) -> String {
result
}

fn bundle_crate(crate_name: &str, workspace_path: &Path) -> Result<String> {
let repository_root = PathBuf::from(git_rev_parse(workspace_path, "--show-toplevel")?)
.canonicalize()
.context("Failed to resolve repository root")?;
let sha = git_rev_parse(workspace_path, "HEAD^{commit}")?;
fn bundle_crate(crate_name: &str, workspace_path: &Path, no_source_url: bool) -> Result<String> {
let libs_path = workspace_path.join("libs");

let mut crates = HashMap::new();
Expand All @@ -157,10 +157,16 @@ fn bundle_crate(crate_name: &str, workspace_path: &Path) -> Result<String> {
let mut bundled_code = String::new();
bundled_code.push_str("// Bundled\n");

bundled_code.push_str(&format!(
"// {}\n",
source_url(&target_crate_info.source_path, &repository_root, &sha)?
));
if !no_source_url {
let repository_root = PathBuf::from(git_rev_parse(workspace_path, "--show-toplevel")?)
.canonicalize()
.context("Failed to resolve repository root")?;
let sha = git_rev_parse(workspace_path, "HEAD^{commit}")?;
bundled_code.push_str(&format!(
"// {}\n",
source_url(&target_crate_info.source_path, &repository_root, &sha)?
));
}
bundled_code.push_str("#[rustfmt::skip]\n");
bundled_code.push_str("#[allow(unused)]\n");
bundled_code.push_str(&format!("mod {} {{\n", crate_name));
Expand Down
Loading