ivila commented on code in PR #296:
URL: 
https://github.com/apache/teaclave-trustzone-sdk/pull/296#discussion_r3165495484


##########
examples/supp_plugin-rs/plugin/build.rs:
##########
@@ -15,32 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use anyhow::{anyhow, Result};
-use std::env;
-use std::fs::File;
-use std::io::Write;
-use std::path::PathBuf;
-use uuid::Uuid;
-
-fn main() -> Result<()> {
-    let out = &PathBuf::from(env::var_os("OUT_DIR").ok_or_else(|| 
anyhow!("OUT_DIR not set"))?);
-    let mut buffer = File::create(out.join("plugin_static.rs"))?;
-    buffer.write_all(include_bytes!("plugin_static.rs"))?;
-
-    let plugin_uuid = Uuid::parse_str(proto::PLUGIN_UUID)?;
-    let (time_low, time_mid, time_hi_and_version, clock_seq_and_node) = 
plugin_uuid.as_fields();
-
-    writeln!(buffer)?;
-    write!(
-        buffer,
-        "const PLUGIN_UUID_STRUCT: optee_teec::raw::TEEC_UUID = 
optee_teec::raw::TEEC_UUID {{
-    timeLow: {:#x},
-    timeMid: {:#x},
-    timeHiAndVersion: {:#x},
-    clockSeqAndNode: {:#x?},
-}};",
-        time_low, time_mid, time_hi_and_version, clock_seq_and_node
-    )?;
+fn main() -> anyhow::Result<()> {
+    let config = optee_teec_plugin_bindgen::Config::new(
+        "syslog",
+        uuid::Uuid::parse_str(proto::PLUGIN_UUID)?,
+        "init",
+        "invoke",

Review Comment:
   I have restored `optee-teec-macros` and am considering using macros to 
generate the injected functions automatically. What do you think about this 
approach?
   
   With this solution, developers would apply macros to their init and invoke 
functions:
   ```rust
   // lib.rs
   #[derive_raw_plugin_init]
   fn init() -> optee_teec::Result<()> {
       Ok(())
   }
   
   #[derive_raw_plugin_invoke]
   fn invoke(_: &mut optee_teec::PluginParameters) -> optee_teec::Result<()> {
       Ok(())
   }
   
   // build.rs
   fn main() -> anyhow::Result<()> {
       Config::new(Uuid::parse_str(proto::PLUGIN_UUID)?)
           .with_name("syslog")
           .build()?;
   
       Ok(())
   }
   ```
   If they need to customize the generated raw function name, it could work 
like this:
   ```rust
   // lib.rs
   #[derive_raw_plugin_init(raw_name = "raw_func_name")]
   fn init() -> optee_teec::Result<()> {
       Ok(())
   }
   
   #[derive_raw_plugin_invoke]
   fn invoke(_: &mut optee_teec::PluginParameters) -> optee_teec::Result<()> {
       Ok(())
   }
   
   // build.rs
   fn main() -> anyhow::Result<()> {
       Config::new(Uuid::parse_str(proto::PLUGIN_UUID)?)
           .with_name("syslog")
           .with_init_fn_name("raw_func_name")
           .build()?;
   
       Ok(())
   }
   ```



-- 
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]

Reply via email to