Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sim vs hw logic to be n'sync with the main MobileCoin repo #372

Open
nick-mobilecoin opened this issue Jul 20, 2023 · 1 comment
Open

Comments

@nick-mobilecoin
Copy link
Collaborator

The MobileCoin repo uses the environment variable SGX_MODE to determine whether to build the crates in simulation vs hardware mode.
The environment variable usage was chosen as it lets one set up the development environment once and then they can call cargo build to build based on the environment, instead of having to remember to pass a flag cargo build --features sgx-sim

The downside of this approach is that there isn't a way to propagate features based on the environment variable down to dependencies:

sequenceDiagram
    cargo build->>+Top Level Crate: Build crate With features
    Top Level Crate->>Top Level Crate: Resolve features
    Top Level Crate->>+Dependency Crate: Build crate With features
    Dependency Crate->>-Top Level Crate: Propagate `CARGO_DEP` values
    Top Level Crate->>Top Level Crate: Invoke build.rs
    Note over Top Level Crate: build.rs adds rustc-cfg=feature="sgx-sim"
    Top Level Crate->>-Top Level Crate: Compile with rustc
Loading

From the above diagram one can see that the depency has already been built by the time that the top level crate updates the feature it's building with based on the environment variable.

In order to work collaboratively with the MobileCoin repo this repo should be updated to:

  • rename feature sim to sgx-sim
  • Key off of the environment variable of SGX_MODE with values of HW and SW
    • Probably pull in functionality from conf.rs and update the MobileCoin repo to use it from this repos mc-sgx-build crate.
@nick-mobilecoin
Copy link
Collaborator Author

This isn't needed at this time for the MobileCoin repo.
The MobileCoin implements the current sim logic it needs from this repo.
This may be needed if the MobileCoin repo uses more of this repos types and behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant