Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion src/v1/05_emit_rust.dag
Original file line number Diff line number Diff line change
Expand Up @@ -8286,11 +8286,15 @@ fn emit_cargo_toml(crate_name: String, has_services: Bool) -> TextFile {
let header = concat(render_cargo_package_header_prefix(name: crate_name), "\nedition = \"2021\"\n")
let workspace = "\n[workspace]\n"
let base_deps = [
emit_cargo_dep(name: "im-rc", version: "15.1", features: []),
emit_cargo_dep(name: "unicode-ident", version: "1", features: []),
emit_cargo_dep(name: "unicode-properties", version: "0.1", features: ["emoji"]),
emit_cargo_dep(name: "serde", version: "1", features: ["derive", "rc"]),
emit_cargo_dep(name: "serde_json", version: "1", features: []),
emit_cargo_dep(name: "stacker", version: "0.1", features: []),
emit_cargo_dep(name: "clap", version: "4", features: ["derive"]),
emit_cargo_dep(name: "lazy_static", version: "1", features: [])
emit_cargo_dep(name: "lazy_static", version: "1", features: []),
emit_cargo_dep(name: "ureq", version: "2", features: ["json"])
]
let async_deps = if has_services {
[
Expand Down
36 changes: 0 additions & 36 deletions src/v1/stage0/src/bin/regen_stage0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,12 @@ const HAND_MAINTAINED_STAGE0_FILES: &[&str] = &[
"cli_run.rs",
"corpus_lex.rs",
"coproduct_reflection.rs",
"corpus_lex.rs",
"doc_reachability_project.rs",
"inert_carrier_project.rs",
"medium_structure_project.rs",
"extdeps_shape_transport_policy_project.rs",
"fact_cardinality_census.rs",
"import_resolution_project.rs",
"inert_carrier_project.rs",
"languages_consumer_census.rs",
"layering_imports_project.rs",
"module_path_index.rs",
Expand Down Expand Up @@ -261,9 +259,6 @@ fn run() -> Result<(), String> {
time_phase(&mut phases, "assert_bootstrap_emit_core_support", || {
assert_bootstrap_emit_core_support(&fresh_dir.join("src"))
})?;
time_phase(&mut phases, "patch_cargo_toml_for_generated_crate", || {
patch_cargo_toml_for_generated_crate(&fresh_dir)
})?;
time_phase(&mut phases, "rustfmt_generated_crate", || {
rustfmt_generated_crate(&fresh_dir)
})?;
Expand Down Expand Up @@ -999,37 +994,6 @@ fn strip_between(text: &str, start_marker: &str, end_marker: &str) -> Result<Str
Ok(format!("{}{}", &text[..start_idx], &text[end_idx..]))
}

fn patch_cargo_toml_for_generated_crate(dir: &Path) -> Result<(), String> {
let cargo_toml = dir.join("Cargo.toml");
if !cargo_toml.exists() {
return Ok(());
}
let mut contents = fs::read_to_string(&cargo_toml)
.map_err(|e| format!("read {}: {e}", cargo_toml.display()))?;
// Each dep is added independently and idempotently (presence-gated per dep) so a
// future emitted Cargo.toml that already carries one but not the other still gets
// the missing one. `ureq` and `im-rc` (the latter backs the hand-maintained
// periphery -- v1_interpreter persistent value carriers) are both omitted by the
// emitter; this mirrors the committed stage0 Cargo.toml deps.
for (crate_name, dep_line) in [
("ureq", "ureq = { version = \"2\", features = [\"json\"] }"),
("im-rc", "im-rc = \"15.1\""),
("unicode-ident", "unicode-ident = \"1\""),
(
"unicode-properties",
"unicode-properties = { version = \"0.1\", features = [\"emoji\"] }",
),
] {
if !contents.contains(crate_name) {
contents = contents.replace(
"\n[dependencies]\n",
&format!("\n[dependencies]\n{dep_line}\n"),
);
}
}
fs::write(&cargo_toml, contents).map_err(|e| format!("write {}: {e}", cargo_toml.display()))
}

fn rustfmt_generated_crate(dir: &Path) -> Result<(), String> {
let output = Command::new("cargo")
.arg("fmt")
Expand Down
16 changes: 16 additions & 0 deletions src/v1/stage0/src/v1_compiler_emit_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23603,6 +23603,17 @@ pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc<TextFile> {
);
let workspace = "\n[workspace]\n".to_string();
let base_deps = Rc::new(vec![
emit_cargo_dep("im-rc".to_string(), "15.1".to_string(), Rc::new(vec![])),
emit_cargo_dep(
"unicode-ident".to_string(),
"1".to_string(),
Rc::new(vec![]),
),
emit_cargo_dep(
"unicode-properties".to_string(),
"0.1".to_string(),
Rc::new(vec!["emoji".to_string()]),
),
emit_cargo_dep(
"serde".to_string(),
"1".to_string(),
Expand All @@ -23616,6 +23627,11 @@ pub fn emit_cargo_toml(crate_name: String, has_services: bool) -> Rc<TextFile> {
Rc::new(vec!["derive".to_string()]),
),
emit_cargo_dep("lazy_static".to_string(), "1".to_string(), Rc::new(vec![])),
emit_cargo_dep(
"ureq".to_string(),
"2".to_string(),
Rc::new(vec!["json".to_string()]),
),
]);
let async_deps = if has_services {
Rc::new(vec![
Expand Down