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,
};
use bollard::secret::HostConfig;
use cargo_metadata::{Message, MetadataCommand};
use cargo_metadata::{Artifact, Message, MetadataCommand};
use clap::{Args, Parser, Subcommand};
use futures_util::{StreamExt, TryStreamExt};
use futures_util::StreamExt;
use log::info;
use std::collections::HashMap;
use std::fmt::format;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use tokio::fs;
@ -77,8 +76,12 @@ async fn main() {
let harmony_bin_path: PathBuf;
match harmony_path {
true => {
harmony_bin_path =
compile_harmony(cli_args.compile_method, None, cli_args.harmony_path.clone()).await
harmony_bin_path = compile_harmony(
cli_args.compile_method,
cli_args.compile_platform,
cli_args.harmony_path.clone(),
)
.await
}
false => todo!("implement autodetect code"),
}
@ -192,23 +195,20 @@ async fn compile_cargo(platform: String, harmony_location: String) -> PathBuf {
.spawn()
.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());
for message in cargo_metadata::Message::parse_stream(reader) {
match message.unwrap() {
Message::CompilerMessage(_msg) => (),
Message::CompilerArtifact(artifact) => {
// println!("{:?}", artifact);
if artifact.package_id.eq(&metadata
.root_package()
.expect("failed to get root package")
.id)
if artifact.manifest_path
== metadata
.root_package()
.expect("failed to get root package")
.manifest_path
{
bin = artifact
.filenames
.first()
.expect("couldn't get artifact filename")
.clone()
println!("{:?}", artifact);
artifacts.push(artifact);
}
}
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;
if let Some(ext) = bin.extension() {
bin_out = PathBuf::from(format!("{}/harmony.{}", harmony_location, ext));