couple of fixes

This commit is contained in:
Taha Hawa 2025-06-16 10:15:50 -04:00 committed by tahahawa
parent 6191fd1858
commit d1423c90c1

View File

@ -4,12 +4,11 @@ use bollard::query_parameters::{
RemoveContainerOptions, StartContainerOptions, WaitContainerOptions, RemoveContainerOptions, StartContainerOptions, WaitContainerOptions,
}; };
use bollard::secret::HostConfig; use bollard::secret::HostConfig;
use cargo_metadata::{Message, MetadataCommand}; use cargo_metadata::{Artifact, Message, MetadataCommand};
use clap::{Args, Parser, Subcommand}; use clap::{Args, Parser, Subcommand};
use futures_util::{StreamExt, TryStreamExt}; use futures_util::StreamExt;
use log::info; use log::info;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::format;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use tokio::fs; use tokio::fs;
@ -77,8 +76,12 @@ async fn main() {
let harmony_bin_path: PathBuf; let harmony_bin_path: PathBuf;
match harmony_path { match harmony_path {
true => { true => {
harmony_bin_path = harmony_bin_path = compile_harmony(
compile_harmony(cli_args.compile_method, None, cli_args.harmony_path.clone()).await cli_args.compile_method,
cli_args.compile_platform,
cli_args.harmony_path.clone(),
)
.await
} }
false => todo!("implement autodetect code"), false => todo!("implement autodetect code"),
} }
@ -192,23 +195,20 @@ async fn compile_cargo(platform: String, harmony_location: String) -> PathBuf {
.spawn() .spawn()
.expect("run cargo command failed"); .expect("run cargo command failed");
let mut bin = cargo_metadata::camino::Utf8PathBuf::new(); let mut artifacts: Vec<Artifact> = vec![];
let reader = std::io::BufReader::new(cargo_build.stdout.take().unwrap()); let reader = std::io::BufReader::new(cargo_build.stdout.take().unwrap());
for message in cargo_metadata::Message::parse_stream(reader) { for message in cargo_metadata::Message::parse_stream(reader) {
match message.unwrap() { match message.unwrap() {
Message::CompilerMessage(_msg) => (), Message::CompilerMessage(_msg) => (),
Message::CompilerArtifact(artifact) => { Message::CompilerArtifact(artifact) => {
// println!("{:?}", artifact); if artifact.manifest_path
if artifact.package_id.eq(&metadata == metadata
.root_package() .root_package()
.expect("failed to get root package") .expect("failed to get root package")
.id) .manifest_path
{ {
bin = artifact println!("{:?}", artifact);
.filenames artifacts.push(artifact);
.first()
.expect("couldn't get artifact filename")
.clone()
} }
} }
Message::BuildScriptExecuted(_script) => (), Message::BuildScriptExecuted(_script) => (),
@ -219,7 +219,13 @@ async fn compile_cargo(platform: String, harmony_location: String) -> PathBuf {
} }
} }
// let bin = cargo_build.binaries.first().expect("no binaries built"); let bin = artifacts
.last()
.expect("no binaries built")
.filenames
.first()
.expect("couldn't get filename");
let bin_out; let bin_out;
if let Some(ext) = bin.extension() { if let Some(ext) = bin.extension() {
bin_out = PathBuf::from(format!("{}/harmony.{}", harmony_location, ext)); bin_out = PathBuf::from(format!("{}/harmony.{}", harmony_location, ext));