mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-24 01:54:23 +03:00
fix all examples. change outputs -> output
This commit is contained in:
parent
a5377da73f
commit
1e56b3a5f6
@ -8,7 +8,7 @@ use std::{
|
||||
path::PathBuf,
|
||||
};
|
||||
|
||||
pub static OUTPUT_DIRECTORY_NAME: &str = "output/";
|
||||
pub static OUTPUTS_DIRECTORY_NAME: &str = "outputs/";
|
||||
pub static OUTPUT_FILE_EXTENSION: &str = ".out";
|
||||
|
||||
pub struct OutputFile {
|
||||
@ -48,8 +48,8 @@ impl OutputFile {
|
||||
fn setup_file_path(&self, path: &PathBuf) -> PathBuf {
|
||||
let mut path = path.to_owned();
|
||||
if path.is_dir() {
|
||||
if !path.ends_with(OUTPUT_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUT_DIRECTORY_NAME));
|
||||
if !path.ends_with(OUTPUTS_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUTS_DIRECTORY_NAME));
|
||||
}
|
||||
path.push(PathBuf::from(format!("{}{}", self.package_name, OUTPUT_FILE_EXTENSION)));
|
||||
}
|
||||
|
2
examples/fibonacci/.gitignore
vendored
2
examples/fibonacci/.gitignore
vendored
@ -1,2 +1,2 @@
|
||||
/output
|
||||
outputs/
|
||||
/.leo
|
||||
|
2
examples/fibonacci/inputs/fibonacci.in
Normal file
2
examples/fibonacci/inputs/fibonacci.in
Normal file
@ -0,0 +1,2 @@
|
||||
[registers]
|
||||
r0: u32 = 0;
|
Binary file not shown.
2
examples/hello_world/.gitignore
vendored
Normal file
2
examples/hello_world/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
outputs/
|
||||
/.leo
|
2
examples/hello_world/inputs/hello_world.in
Normal file
2
examples/hello_world/inputs/hello_world.in
Normal file
@ -0,0 +1,2 @@
|
||||
[registers]
|
||||
r0: u32 = 0;
|
Binary file not shown.
2
examples/pedersen_hash/.gitignore
vendored
2
examples/pedersen_hash/.gitignore
vendored
@ -1,2 +1,2 @@
|
||||
/output
|
||||
outputs/
|
||||
/.leo
|
||||
|
@ -1 +1,4 @@
|
||||
[main]
|
||||
|
||||
[registers]
|
||||
r0: group = (1, 0)group;
|
0
examples/pedersen_hash/inputs/pedersen_hash.state
Normal file
0
examples/pedersen_hash/inputs/pedersen_hash.state
Normal file
Binary file not shown.
1
examples/square_root/.gitignore
vendored
1
examples/square_root/.gitignore
vendored
@ -1 +1,2 @@
|
||||
outputs/
|
||||
/.leo
|
@ -1,4 +1,7 @@
|
||||
// The program input for square_root/src/main.leo
|
||||
[main]
|
||||
a: field = 337;
|
||||
b: field = 113569;
|
||||
b: field = 113569;
|
||||
|
||||
[registers]
|
||||
r0: bool = false;
|
0
examples/square_root/inputs/square_root.state
Normal file
0
examples/square_root/inputs/square_root.state
Normal file
@ -2,7 +2,7 @@ use crate::{cli::*, cli_types::*, errors::CLIError};
|
||||
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
|
||||
use leo_package::{
|
||||
inputs::*,
|
||||
outputs::{ChecksumFile, OutputDirectory, OUTPUT_DIRECTORY_NAME},
|
||||
outputs::{ChecksumFile, OutputsDirectory, OUTPUTS_DIRECTORY_NAME},
|
||||
root::Manifest,
|
||||
source::{LibFile, MainFile, LIB_FILE_NAME, MAIN_FILE_NAME, SOURCE_DIRECTORY_NAME},
|
||||
};
|
||||
@ -49,7 +49,7 @@ impl CLI for BuildCommand {
|
||||
|
||||
// Construct the path to the output directory
|
||||
let mut output_directory = package_path.clone();
|
||||
output_directory.push(OUTPUT_DIRECTORY_NAME);
|
||||
output_directory.push(OUTPUTS_DIRECTORY_NAME);
|
||||
|
||||
// Compile the package starting with the lib.leo file
|
||||
if LibFile::exists_at(&package_path) {
|
||||
@ -71,7 +71,7 @@ impl CLI for BuildCommand {
|
||||
// Compile the main.leo file along with constraints
|
||||
if MainFile::exists_at(&package_path) {
|
||||
// Create the output directory
|
||||
OutputDirectory::create(&package_path)?;
|
||||
OutputsDirectory::create(&package_path)?;
|
||||
|
||||
// Construct the path to the main file in the source directory
|
||||
let mut main_file_path = package_path.clone();
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{cli::*, cli_types::*, commands::BuildCommand, errors::CLIError};
|
||||
use leo_package::{
|
||||
outputs::OutputDirectory,
|
||||
outputs::OutputsDirectory,
|
||||
root::{Manifest, ZipFile},
|
||||
};
|
||||
|
||||
@ -37,7 +37,7 @@ impl CLI for PublishCommand {
|
||||
let package_name = Manifest::try_from(&path)?.get_package_name();
|
||||
|
||||
// Create the output directory
|
||||
OutputDirectory::create(&path)?;
|
||||
OutputsDirectory::create(&path)?;
|
||||
|
||||
// Create zip file
|
||||
let zip_file = ZipFile::new(&package_name);
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
use leo_compiler::{compiler::Compiler, group::targets::edwards_bls12::EdwardsGroupType};
|
||||
use leo_package::{
|
||||
inputs::*,
|
||||
outputs::OUTPUT_DIRECTORY_NAME,
|
||||
outputs::OUTPUTS_DIRECTORY_NAME,
|
||||
root::Manifest,
|
||||
source::{MainFile, MAIN_FILE_NAME, SOURCE_DIRECTORY_NAME},
|
||||
};
|
||||
@ -62,7 +62,7 @@ impl CLI for TestCommand {
|
||||
|
||||
// Construct the path to the output directory;
|
||||
let mut output_directory = package_path.clone();
|
||||
output_directory.push(OUTPUT_DIRECTORY_NAME);
|
||||
output_directory.push(OUTPUTS_DIRECTORY_NAME);
|
||||
|
||||
// Load the input file at `package_name`
|
||||
let input_string = InputFile::new(&package_name).read_from(&path)?;
|
||||
|
@ -40,7 +40,7 @@ pub enum CLIError {
|
||||
NewError(NewError),
|
||||
|
||||
#[error("{}", _0)]
|
||||
OutputDirectoryError(OutputDirectoryError),
|
||||
OutputDirectoryError(OutputsDirectoryError),
|
||||
|
||||
#[error("{}", _0)]
|
||||
ProofFileError(ProofFileError),
|
||||
@ -144,8 +144,8 @@ impl From<NewError> for CLIError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<OutputDirectoryError> for CLIError {
|
||||
fn from(error: OutputDirectoryError) -> Self {
|
||||
impl From<OutputsDirectoryError> for CLIError {
|
||||
fn from(error: OutputsDirectoryError) -> Self {
|
||||
log::error!("{}\n", error);
|
||||
CLIError::OutputDirectoryError(error)
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{ffi::OsString, fs::FileType, io};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OutputDirectoryError {
|
||||
pub enum OutputsDirectoryError {
|
||||
#[error("creating: {}", _0)]
|
||||
Creating(io::Error),
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! The build checksum file.
|
||||
|
||||
use crate::{errors::ChecksumFileError, outputs::OUTPUT_DIRECTORY_NAME};
|
||||
use crate::{errors::ChecksumFileError, outputs::OUTPUTS_DIRECTORY_NAME};
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
@ -60,8 +60,8 @@ impl ChecksumFile {
|
||||
fn setup_file_path(&self, path: &PathBuf) -> PathBuf {
|
||||
let mut path = path.to_owned();
|
||||
if path.is_dir() {
|
||||
if !path.ends_with(OUTPUT_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUT_DIRECTORY_NAME));
|
||||
if !path.ends_with(OUTPUTS_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUTS_DIRECTORY_NAME));
|
||||
}
|
||||
path.push(PathBuf::from(format!(
|
||||
"{}{}",
|
||||
|
@ -1,31 +1,31 @@
|
||||
use crate::errors::OutputDirectoryError;
|
||||
use crate::errors::OutputsDirectoryError;
|
||||
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
pub static OUTPUT_DIRECTORY_NAME: &str = "outputs/";
|
||||
pub static OUTPUTS_DIRECTORY_NAME: &str = "outputs/";
|
||||
|
||||
pub struct OutputDirectory;
|
||||
pub struct OutputsDirectory;
|
||||
|
||||
impl OutputDirectory {
|
||||
impl OutputsDirectory {
|
||||
/// Creates a directory at the provided path with the default directory name.
|
||||
pub fn create(path: &PathBuf) -> Result<(), OutputDirectoryError> {
|
||||
pub fn create(path: &PathBuf) -> Result<(), OutputsDirectoryError> {
|
||||
let mut path = path.to_owned();
|
||||
if path.is_dir() && !path.ends_with(OUTPUT_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUT_DIRECTORY_NAME));
|
||||
if path.is_dir() && !path.ends_with(OUTPUTS_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUTS_DIRECTORY_NAME));
|
||||
}
|
||||
|
||||
fs::create_dir_all(&path).map_err(OutputDirectoryError::Creating)
|
||||
fs::create_dir_all(&path).map_err(OutputsDirectoryError::Creating)
|
||||
}
|
||||
|
||||
/// Removes the directory at the provided path.
|
||||
pub fn remove(path: &PathBuf) -> Result<(), OutputDirectoryError> {
|
||||
pub fn remove(path: &PathBuf) -> Result<(), OutputsDirectoryError> {
|
||||
let mut path = path.to_owned();
|
||||
if path.is_dir() && !path.ends_with(OUTPUT_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUT_DIRECTORY_NAME));
|
||||
if path.is_dir() && !path.ends_with(OUTPUTS_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUTS_DIRECTORY_NAME));
|
||||
}
|
||||
|
||||
if path.exists() {
|
||||
fs::remove_dir_all(&path).map_err(OutputDirectoryError::Removing)?;
|
||||
fs::remove_dir_all(&path).map_err(OutputsDirectoryError::Removing)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -4,9 +4,6 @@ pub use self::checksum::*;
|
||||
pub mod directory;
|
||||
pub use directory::*;
|
||||
|
||||
// pub mod output;
|
||||
// pub use output::*;
|
||||
|
||||
pub mod proof;
|
||||
pub use self::proof::*;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! The proof file.
|
||||
|
||||
use crate::{errors::ProofFileError, outputs::OUTPUT_DIRECTORY_NAME};
|
||||
use crate::{errors::ProofFileError, outputs::OUTPUTS_DIRECTORY_NAME};
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
@ -63,8 +63,8 @@ impl ProofFile {
|
||||
fn setup_file_path(&self, path: &PathBuf) -> PathBuf {
|
||||
let mut path = path.to_owned();
|
||||
if path.is_dir() {
|
||||
if !path.ends_with(OUTPUT_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUT_DIRECTORY_NAME));
|
||||
if !path.ends_with(OUTPUTS_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUTS_DIRECTORY_NAME));
|
||||
}
|
||||
path.push(PathBuf::from(format!("{}{}", self.package_name, PROOF_FILE_EXTENSION)));
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! The proving key file.
|
||||
|
||||
use crate::{errors::ProvingKeyFileError, outputs::OUTPUT_DIRECTORY_NAME};
|
||||
use crate::{errors::ProvingKeyFileError, outputs::OUTPUTS_DIRECTORY_NAME};
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
@ -60,8 +60,8 @@ impl ProvingKeyFile {
|
||||
fn setup_file_path(&self, path: &PathBuf) -> PathBuf {
|
||||
let mut path = path.to_owned();
|
||||
if path.is_dir() {
|
||||
if !path.ends_with(OUTPUT_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUT_DIRECTORY_NAME));
|
||||
if !path.ends_with(OUTPUTS_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUTS_DIRECTORY_NAME));
|
||||
}
|
||||
path.push(PathBuf::from(format!(
|
||||
"{}{}",
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! The verification key file.
|
||||
|
||||
use crate::{errors::VerificationKeyFileError, outputs::OUTPUT_DIRECTORY_NAME};
|
||||
use crate::{errors::VerificationKeyFileError, outputs::OUTPUTS_DIRECTORY_NAME};
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::{
|
||||
@ -60,8 +60,8 @@ impl VerificationKeyFile {
|
||||
fn setup_file_path(&self, path: &PathBuf) -> PathBuf {
|
||||
let mut path = path.to_owned();
|
||||
if path.is_dir() {
|
||||
if !path.ends_with(OUTPUT_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUT_DIRECTORY_NAME));
|
||||
if !path.ends_with(OUTPUTS_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUTS_DIRECTORY_NAME));
|
||||
}
|
||||
path.push(PathBuf::from(format!(
|
||||
"{}{}",
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
inputs::{INPUT_DIRECTORY_NAME, INPUT_FILE_EXTENSION},
|
||||
outputs::{
|
||||
CHECKSUM_FILE_EXTENSION,
|
||||
OUTPUT_DIRECTORY_NAME,
|
||||
OUTPUTS_DIRECTORY_NAME,
|
||||
PROOF_FILE_EXTENSION,
|
||||
PROVING_KEY_FILE_EXTENSION,
|
||||
VERIFICATION_KEY_FILE_EXTENSION,
|
||||
@ -100,8 +100,8 @@ impl ZipFile {
|
||||
fn setup_file_path(&self, path: &PathBuf) -> PathBuf {
|
||||
let mut path = path.to_owned();
|
||||
if path.is_dir() {
|
||||
if !path.ends_with(OUTPUT_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUT_DIRECTORY_NAME));
|
||||
if !path.ends_with(OUTPUTS_DIRECTORY_NAME) {
|
||||
path.push(PathBuf::from(OUTPUTS_DIRECTORY_NAME));
|
||||
}
|
||||
path.push(PathBuf::from(format!("{}{}", self.package_name, ZIP_FILE_EXTENSION)));
|
||||
}
|
||||
@ -112,7 +112,7 @@ impl ZipFile {
|
||||
fn is_excluded(path: &Path) -> bool {
|
||||
// excluded directories: `input`, `output`, `imports`
|
||||
if path.ends_with(INPUT_DIRECTORY_NAME.trim_end_matches("/"))
|
||||
| path.ends_with(OUTPUT_DIRECTORY_NAME.trim_end_matches("/"))
|
||||
| path.ends_with(OUTPUTS_DIRECTORY_NAME.trim_end_matches("/"))
|
||||
| path.ends_with(IMPORTS_DIRECTORY_NAME.trim_end_matches("/"))
|
||||
{
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user