Skip to content

Commit 15a8fbe

Browse files
committed
Fix some build issues
1 parent 2d706b6 commit 15a8fbe

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

cobalt-build/src/build.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ fn build_file_1(path: &Path, ctx: &CompCtx, opts: &BuildOptions, force_build: bo
253253
let code = path.as_absolute_path().unwrap().read_to_string_anyhow()?;
254254
let (mut ast, errs) = cobalt_parser::parse_tl(&code);
255255
let file = FILES.add_file(0, name.to_string(), code.clone());
256-
for err in errs {fail |= err.is_err(); eprintln!("{}", Report::from(err).with_source_code(file));}
256+
for err in errs {fail |= err.is_err(); eprintln!("{:?}", Report::from(err).with_source_code(file));}
257257
ast.file = Some(file);
258258
if fail && !opts.continue_comp {anyhow::bail!(CompileErrors)}
259259
ast.run_passes(ctx);
@@ -263,7 +263,7 @@ fn build_file_1(path: &Path, ctx: &CompCtx, opts: &BuildOptions, force_build: bo
263263
/// This picks up where `build_file_1` left off
264264
fn build_file_2(ast: TopLevelAST, ctx: &CompCtx, opts: &BuildOptions, (out_path, head_path): (&Path, &Path), mut fail: bool) -> anyhow::Result<()> {
265265
let (_, errs) = ast.codegen(ctx);
266-
for err in errs {fail |= err.is_err(); eprintln!("{}", err.with_file(ast.file.unwrap()));}
266+
for err in errs {fail |= err.is_err(); eprintln!("{:?}", err.with_file(ast.file.unwrap()));}
267267
if fail && !opts.continue_comp {
268268
ctx.with_vars(|v| clear_mod(&mut v.symbols));
269269
anyhow::bail!(CompileErrors)
@@ -446,18 +446,20 @@ fn resolve_deps(ctx: &CompCtx, t: &Target, targets: &HashMap<String, (Target, Ce
446446
Dependency::Package(PkgDepSpec {version, targets}) => to_install.push(pkg::InstallSpec {name: target.clone(), version: version.clone(), targets: targets.clone()})
447447
}
448448
}
449-
let plan = pkg::install(to_install.iter().cloned(), &pkg::InstallOptions {target: opts.triple.as_str().to_str().unwrap().to_string(), ..Default::default()})?;
450-
let mut installed_path = cobalt_dir()?;
451-
installed_path.push("installed");
452-
to_install.into_iter().try_for_each(|pkg::InstallSpec {name, targets, ..}| targets.unwrap_or_else(|| vec!["default".to_string()]).into_iter().try_for_each(|target| {
453-
let mut path = installed_path.clone();
454-
path.push(&name);
455-
path.push(plan[&(name.as_str(), target.as_str())].to_string());
456-
path.push(&target);
457-
conflicts.append(&mut libs::load_lib(&path, ctx)?);
458-
out.push(path);
459-
anyhow::Ok(())
460-
}))?;
449+
if !to_install.is_empty() {
450+
let plan = pkg::install(to_install.iter().cloned(), &pkg::InstallOptions {target: opts.triple.as_str().to_str().unwrap().to_string(), ..Default::default()})?;
451+
let mut installed_path = cobalt_dir()?;
452+
installed_path.push("installed");
453+
to_install.into_iter().try_for_each(|pkg::InstallSpec {name, targets, ..}| targets.unwrap_or_else(|| vec!["default".to_string()]).into_iter().try_for_each(|target| {
454+
let mut path = installed_path.clone();
455+
path.push(&name);
456+
path.push(plan[&(name.as_str(), target.as_str())].to_string());
457+
path.push(&target);
458+
conflicts.append(&mut libs::load_lib(&path, ctx)?);
459+
out.push(path);
460+
anyhow::Ok(())
461+
}))?;
462+
}
461463
if !conflicts.is_empty() {anyhow::bail!(libs::ConflictingDefs(conflicts))}
462464
let (libs, notfound) = libs::find_libs(libs, &opts.link_dirs, Some(ctx))?;
463465
for lib in notfound {anyhow::bail!("couldn't find {lib}")}

cobalt-build/src/graph.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ impl DependencyGraph {
127127
/// rebuilt.
128128
pub fn clear(&mut self) {self.packages.clear()}
129129
/// Build the dependency tree from the installation specification
130+
#[allow(unreachable_code, unused_variables)]
130131
pub fn build_tree<I: IntoIterator<Item = pkg::InstallSpec>>(&mut self, pkgs: I) -> anyhow::Result<()> {
132+
unimplemented!("package management is hard, okay?");
131133
let mut node = PkgNode::default();
132134
node.dependents = 1;
133135
node.version = Version::new(1, 0, 0);
@@ -154,6 +156,7 @@ impl DependencyGraph {
154156
else {anyhow::bail!(pkg::InstallError::NoDefaultTarget(STRINGS.resolve(&idef)))}
155157
}
156158
}
159+
self.packages.insert((ientry, ientry), node);
157160
let mut queue: VecDeque<(Id, Id)> = [(ientry, ientry)].into();
158161
while let Some((p, t)) = queue.pop_front() {unsafe {(*(&mut self.packages as *mut HashMap<(Id, Id), PkgNode>)).get_mut(&(p, t))}.unwrap().update(p, t, self, &mut queue)?}
159162
Ok(())

0 commit comments

Comments
 (0)