DemesneGH commented on code in PR #156:
URL: 
https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/156#discussion_r1897931847


##########
optee-utee-build/src/ta_config.rs:
##########
@@ -0,0 +1,187 @@
+// 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 crate::Error;
+use std::convert::TryInto;
+
+/// Configuration options for TA
+///
+/// Examples
+///
+/// # use a standard configuration
+/// ```rust
+/// use optee_utee_build::TAConfig;
+/// # use optee_utee_build::Error;
+/// # fn main() -> Result<(), Error> {
+/// const UUID: &str = "d93c2970-b1a6-4b86-90ac-b42830e78d9b";
+/// let ta_config = TAConfig::new_standard(
+///     UUID,
+///     "0.1.0",
+///     "hello world",
+/// )?;
+/// # Ok(())
+/// # }
+/// ```
+///
+/// and since we already have `version` and `description` in `cargo.toml`,
+/// we can make it simpler by using them as parameters:
+///
+/// ```rust
+/// use optee_utee_build::TAConfig;
+/// # use optee_utee_build::Error;
+/// # fn main() -> Result<(), Error> {
+/// const UUID: &str = "d93c2970-b1a6-4b86-90ac-b42830e78d9b";
+/// let ta_config = TAConfig::new_standard_with_cargo_env(UUID)?;
+/// # Ok(())
+/// # }
+/// ```
+///
+/// # make some modifications
+/// ```rust
+/// use optee_utee_build::TAConfig;
+/// # use optee_utee_build::Error;
+/// # fn main() -> Result<(), Error> {
+/// const UUID: &str = "d93c2970-b1a6-4b86-90ac-b42830e78d9b";
+/// let ta_config = TAConfig::new_standard(
+///     UUID,
+///     "0.1.0",
+///     "hello world",
+/// )?.ta_stack_size(10 * 1024).ta_data_size(32 * 1024);
+/// # Ok(())
+/// # }
+/// ```
+#[derive(Debug, Clone)]
+pub struct TAConfig {
+    pub uuid: uuid::Uuid,
+    pub ta_flags: u32,
+    pub ta_data_size: u32,
+    pub ta_stack_size: u32,
+    pub ta_version: String,
+    pub ta_description: String,
+    pub trace_level: i32,
+    pub trace_ext_prefix: String,
+    pub ta_framework_stack_size: u32,
+    pub ext_properties: Vec<Property>,
+}
+
+impl TAConfig {
+    /// generate a standard config by uuid, retrieve version and description 
from cargo.toml
+    pub fn new_standard_with_cargo_env(uuid_str: &str) -> Result<Self, Error> {

Review Comment:
   I agree with this and it will simplify the configuration, we can read the 
`version` and `description` from `Cargo.toml` then we don't have to set the 
TA's constants like the previous:
   ```
   const TA_VERSION: &[u8] = b"0.1\0";
   const TA_DESCRIPTION: &[u8] = b"This is a hello world example.\0";
   ```



-- 
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: dev-unsubscr...@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org
For additional commands, e-mail: dev-h...@teaclave.apache.org

Reply via email to