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

Move program and script to a shared workspace #11

Closed
srdtrk opened this issue Jun 19, 2024 · 3 comments
Closed

Move program and script to a shared workspace #11

srdtrk opened this issue Jun 19, 2024 · 3 comments

Comments

@srdtrk
Copy link
Contributor

srdtrk commented Jun 19, 2024

Currently, the program and script are maintained in separate workspaces. This separation has led to code duplication, such as the Solidity definition of PublicValuesTuple which is defined both in the script (here) and in the program (here).

While this is a minor example of code duplication, the impact could be more significant in larger projects. To address this, I propose extending the workspace to include both program,script, and maybe even a shared types package. This would facilitate better project structure and eliminate redundant code.

While there are other solutions, such as locally importing a shared crate, I don't think this approach is considered best practice. Combining the workspaces could provide a cleaner, more maintainable solution.

I am willing to try open a PR to implement this change if there is agreement on this approach.

@alxiong
Copy link

alxiong commented Jul 3, 2024

@srdtrk did you get it to work?

When i removed the [workspace] in script/Cargo.toml and program/Cargo.toml, building inside the script/ would fail.

[fibonacci-script 0.1.0] path: "../program"
[fibonacci-script 0.1.0] cargo::rerun-if-changed=../program/src
[fibonacci-script 0.1.0] cargo::rerun-if-changed=../program/Cargo.toml
[fibonacci-script 0.1.0] cargo::rerun-if-changed=../program/Cargo.lock
[fibonacci-script 0.1.0] cargo:warning=fibonacci-program built at 2024-07-04 00:25:02
[fibonacci-script 0.1.0] [sp1]     Blocking waiting for file lock on build directory
    Building [=======================> ] 698/700: fibonacci-script(build)  

this is a deadlock. (will get stuck indefinitely)

I suspect that: when build_program() inside the script/build.rs would first run cargo build on entire workspace of ../program , and if program/ and script are inside the same workspace, then it will then try to build script/ as well.

^^ this is probably why they have to be in their own separate workspaces. but it's a bit annoying.

cc @ratankaliani

@srdtrk
Copy link
Contributor Author

srdtrk commented Jul 3, 2024

I have a repo where I did more complex stuff, all in the same workspace. I actually don't like using build_program() so I removed it from my setup, instead I build it manually

@ctian1
Copy link
Member

ctian1 commented Aug 6, 2024

Added in #24!

@ctian1 ctian1 closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants