risc0 / risc0-foundry-template

Template for integrating RISC Zero and Ethereum using Foundry
https://risczero.com
107 stars 60 forks source link

WEB3-207: add git submodule --init to methods/build.rs #140

Closed sashaaldrick closed 1 week ago

sashaaldrick commented 1 month ago

added to methods/build.rs:

    run_git_submodule_update();
    println!("cargo:rerun-if-changed=.gitmodules");

to automatically keep local libraries up to date on build.

nategraf commented 1 month ago

I don't think the build script would make changes to the submodules. I'd be happy to have it detect and warn the user instead.

sashaaldrick commented 1 month ago

why not @nategraf ? aren't the submodules part of the build process?

nategraf commented 1 month ago

So, my main issue is with running git submodule update. If the user has checked out a different commit in their submodule, git will checkout the submodule commit from HEAD instead, this undoing a potential intentional change. I'd be ok with git submodule init which only runs on first clone, and I'd be ok with warning the user that they have a dirty state for the submodules. But update feels like it could be in contention with the intentions of the user.

sashaaldrick commented 4 weeks ago

I've added two functions to the build.rs script to facilitate what we discussed yesterday @nategraf. These will now run: git submodule init on first clone, and then give warnings about dirty state.

My only dislike is that it took a lot of space in the build.rs file, which was very clean before. I could add a git.rs and import the relevant functions to build.rs, but also not sure about adding another file for this. What do you recommend @nategraf ?