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


##########
optee-utee-build/src/linker.rs:
##########
@@ -0,0 +1,182 @@
+// 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 std::env;
+use std::fs::File;
+use std::io::Write;
+use std::io::{BufRead, BufReader};
+use std::path::PathBuf;
+
+use crate::Error;
+
+/// The type of the linker, there are difference when using gcc/cc or ld/lld 
as linker,
+/// For example, `--sort-section=alignment` parameter changes to 
`-Wl,--sort-section=alignment`
+/// when using gcc as linker.
+///
+/// CC: gcc, cc, etc.
+/// LD: ld, lld, ld.bfd, ld.gold, etc.
+#[derive(Debug, Clone)]
+pub enum LinkerType {
+    CC,
+    LD,
+}
+
+/// Linker of ta, use it to handle all linking stuff
+///
+/// Use only if you just want to handle the linking stuff, and use a hand 
written user_ta_header.rs,
+/// or you should use Builder instead
+/// Usage:
+///
+/// ```no_run
+/// use optee_utee_build::Linker;
+/// use std::env;
+/// # use optee_utee_build::Error;
+/// # fn main() -> Result<(), Error> {
+/// let out_dir = env::var("OUT_DIR")?;
+/// Linker::auto().link_all(out_dir)?;
+/// # Ok(())
+/// # }
+/// ```
+///
+/// We detect the type of the linker automatically, you can set it manually if 
you met some
+/// problems with it.
+/// ```no_run
+/// use optee_utee_build::{Linker, LinkerType};
+/// use std::env;
+/// # use optee_utee_build::Error;
+/// # fn main() -> Result<(), Error> {
+/// let out_dir = env::var("OUT_DIR")?;
+/// Linker::new(LinkerType::CC).link_all(out_dir)?;
+/// # Ok(())
+/// # }
+/// ```
+///
+pub struct Linker {
+    linker_type: LinkerType,
+}
+
+impl Linker {
+    pub fn new(linker_type: LinkerType) -> Self {
+        Self { linker_type }
+    }

Review Comment:
   I will leave some comments on it, or `cargo fmt` would remove the empty line.



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