From d1423c90c17bf2bf39d5bae4bb039ee2a620a740 Mon Sep 17 00:00:00 2001 From: Taha Hawa Date: Mon, 16 Jun 2025 10:15:50 -0400 Subject: [PATCH] couple of fixes --- harmony_composer/src/main.rs | 40 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/harmony_composer/src/main.rs b/harmony_composer/src/main.rs index 3881d76..ef2e9c6 100644 --- a/harmony_composer/src/main.rs +++ b/harmony_composer/src/main.rs @@ -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 = 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));