-
Notifications
You must be signed in to change notification settings - Fork 56
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
Support native stdlib #201
Changes from all commits
fbfa222
4eaed5b
10432c3
0221102
5353d42
253f4b5
64f1758
be66e55
6f26d5b
b283046
00d230b
1d2cba7
9b94dfb
64c2352
3c0b022
f54a53c
5c8918e
18825a3
ca35175
55f441a
2b47a8d
8ef0993
1f8826a
8834fff
a822a1b
3f91646
c2c78c9
328ffbf
7befb6b
42a520a
be8127d
665ef2e
ab75d85
34cf5c4
4cfb0c5
eb1def1
83e3491
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
@ noname.0.7.0 | ||
@ public inputs: 1 | ||
|
||
v_3 == (v_2) * (v_2 + -1) | ||
0 == (v_3) * (1) | ||
v_5 == (v_4) * (v_4 + -1) | ||
0 == (v_5) * (1) | ||
v_7 == (v_6) * (v_6 + -1) | ||
1 == (v_3) * (1) | ||
v_5 == (v_4) * (-1 * v_2 + v_3) | ||
-1 * v_6 + 1 == (v_5) * (1) | ||
v_7 == (v_6) * (-1 * v_2 + v_3) | ||
0 == (v_7) * (1) | ||
v_2 + 2 * v_4 + 4 * v_6 == (v_1) * (1) | ||
1 == (-1 * v_2 + 1) * (1) | ||
1 == (v_4) * (1) | ||
1 == (-1 * v_6 + 1) * (1) | ||
v_1 == (v_2 + 2 * v_4 + 4 * v_6) * (1) | ||
0 == (v_8) * (1) | ||
1 == (v_9) * (1) | ||
0 == (v_10) * (1) | ||
v_1 == (v_8 + 2 * v_9 + 4 * v_10) * (1) | ||
v_11 == (v_10) * (-1 * v_8 + v_9) | ||
-1 * v_12 + 1 == (v_11) * (1) | ||
v_13 == (v_12) * (-1 * v_8 + v_9) | ||
0 == (v_13) * (1) | ||
1 == (v_15) * (1) | ||
v_17 == (v_16) * (-1 * v_14 + v_15) | ||
-1 * v_18 + 1 == (v_17) * (1) | ||
v_19 == (v_18) * (-1 * v_14 + v_15) | ||
0 == (v_19) * (1) | ||
v_1 == (v_6 + 2 * v_12 + 4 * v_18) * (1) | ||
1 == (-1 * v_6 + 1) * (1) | ||
1 == (v_12) * (1) | ||
1 == (-1 * v_18 + 1) * (1) | ||
v_1 == (v_6 + 2 * v_12 + 4 * v_18) * (1) | ||
2 == (v_1) * (1) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,11 @@ use camino::Utf8PathBuf as PathBuf; | |
use miette::{Context, IntoDiagnostic, Result}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::stdlib::STDLIB_DIRECTORY; | ||
|
||
use super::{ | ||
manifest::{read_manifest, Manifest}, | ||
NONAME_DIRECTORY, PACKAGE_DIRECTORY, | ||
NONAME_DIRECTORY, PACKAGE_DIRECTORY, RELEASE_DIRECTORY, | ||
}; | ||
|
||
/// A dependency is a Github `user/repo` pair. | ||
|
@@ -241,6 +243,16 @@ pub(crate) fn path_to_package(dep: &UserRepo) -> PathBuf { | |
package_dir.join(&dep.user).join(&dep.repo) | ||
} | ||
|
||
pub(crate) fn path_to_stdlib() -> PathBuf { | ||
let home_dir: PathBuf = dirs::home_dir() | ||
.expect("could not find home directory of current user") | ||
.try_into() | ||
.expect("invalid UTF8 path"); | ||
let noname_dir = home_dir.join(NONAME_DIRECTORY); | ||
|
||
noname_dir.join(RELEASE_DIRECTORY).join(STDLIB_DIRECTORY) | ||
} | ||
|
||
/// download package from github | ||
pub fn download_from_github(dep: &UserRepo) -> Result<()> { | ||
let url = format!( | ||
|
@@ -264,6 +276,44 @@ pub fn download_from_github(dep: &UserRepo) -> Result<()> { | |
Ok(()) | ||
} | ||
|
||
pub fn download_stdlib() -> Result<()> { | ||
// Hardcoded repository details and target branch | ||
let repo_owner = "zksecurity"; | ||
let repo_name = "noname"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is that a temporary solution :D one thing we could do is have a github workflow to remove everything but the lib and push that on a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. otherwise it feels a bit wasteful to import all of noname? ALTHOUGH, it would be cool if, when people click on "go to definition" we could also point to the source code of noname so it might be an upside to have the whole noname code pulled There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's create a release branch for now? so we can decide which version of main branch to be merged into the release branch for auto-download |
||
let target_branch = "main"; | ||
let repo_url = format!( | ||
"https://github.com/{owner}/{repo}.git", | ||
owner = repo_owner, | ||
repo = repo_name | ||
); | ||
|
||
let home_dir: PathBuf = dirs::home_dir() | ||
.expect("could not find home directory of current user") | ||
.try_into() | ||
.expect("invalid UTF8 path"); | ||
let noname_dir = home_dir.join(NONAME_DIRECTORY); | ||
let release_dir = noname_dir.join("release"); | ||
|
||
// Clone the repository and checkout the specified branch to the temporary directory | ||
let output = process::Command::new("git") | ||
.arg("clone") | ||
.arg("--branch") | ||
.arg(target_branch) | ||
.arg("--single-branch") | ||
.arg(repo_url) | ||
.arg(release_dir) | ||
.output() | ||
.expect("failed to execute git clone command"); | ||
|
||
if !output.status.success() { | ||
miette::bail!(format!( | ||
"Could not clone branch `{target_branch}` of repository `{repo_owner}/{repo_name}`." | ||
)); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn is_lib(path: &PathBuf) -> bool { | ||
path.join("src").join("lib.no").exists() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should do this manually BTW, we should let noname do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because the CI test wants to test against the latest code, including the stdlib. To ensure the latest code, here overrides the default downloaded version with the code from the PR.