ivila commented on code in PR #245: URL: https://github.com/apache/teaclave-trustzone-sdk/pull/245#discussion_r2458315205
########## cargo-optee/src/ta_builder.rs: ########## @@ -0,0 +1,329 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use anyhow::{bail, Result}; +use std::env; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output}; +use tempfile::TempDir; + +// Embed the target JSON files at compile time +const AARCH64_TARGET_JSON: &str = include_str!("../aarch64-unknown-optee.json"); +const ARM_TARGET_JSON: &str = include_str!("../arm-unknown-optee.json"); + +// Helper function to print command output and return error +fn print_output_and_bail(cmd_name: &str, output: &Output) -> Result<()> { + eprintln!( + "{} stdout: {}", + cmd_name, + String::from_utf8_lossy(&output.stdout) + ); + eprintln!( + "{} stderr: {}", + cmd_name, + String::from_utf8_lossy(&output.stderr) + ); + bail!( + "{} failed with exit code: {:?}", + cmd_name, + output.status.code() + ) +} + +pub struct TaBuildConfig { + pub arch: String, // "aarch64" or "arm" Review Comment: Suggest using enum instead of String for `arch`, and derive `ValueEnum` for usage in clap. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
