Open yangfh2004 opened 1 year ago
Hi, I'm trying to replace the long Makefile with a building crate for v2 branch, so that I can maintain my TEE code in cargo workspace with a large code base.
The ideal workflow is to use build.rs to generate/compile edl files and link into the rust crate, and finally, use a separate script to sign the dynamic so (since cargo not support post-build script), just like below,
Cargo build command with profile once can build all rust code and an additional operation to sign the enclave. But the progress seems not so well.
Current progress:
buildenv.mk
and other general variables in sample code.compile_untrusted
is used to generated and compile edl untrusted sources, and declare rust link args, so that the edl can be linked into the crate.compile_trust
works like compile_trusted
but for enclave, which is different from current Makefile.
enclave_t.o
with it into a dynamic lib.compile_trust
in a build.rs for a 'cdylib' crate, so that it can be directly linked into an dynamic library to be signed.So far so good, but the problem came out with "BUILD_STD": build.rs
cannot set sysroot and target. Specifying sysroot and target needs to be done out of build.rs (although I can compile sysroot inside of build.rs).
It is said, before building "trusted" codes, sysroot needs to be compiled first, and push the flags into cargo commands. "cargo build" once is not able to generate all output of rust code.
it needs some other scripting system to do that, then not much different from current Makefile.
TODO: I may try with cargo-make, hope it can simplify the building workflow and make it more easy to extend.
Thanks a lot, I think we could somehow simplify the Makefile with using more build.rs
and other modern Cargo features.
I think much pre-processing in the Makefile can be done with "build.rs", why don't we use most of the current Cargo tool instead of using the ancient Make toolchain? Maybe this is a stupid question, but which step forces us to use "make" instead of any other modern build system? I wish we can reduce the size of Makefile and use as much as possible with "build.rs" in the v2.0 if we can't eliminate the Makefile.