feat(deps): start laying out some types and functions
This commit is contained in:
		
							parent
							
								
									b3266fb837
								
							
						
					
					
						commit
						a6fd8f92a8
					
				|  | @ -109,6 +109,7 @@ version = "0.0.26" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "aiken-lang", |  "aiken-lang", | ||||||
|  "askama", |  "askama", | ||||||
|  |  "fslock", | ||||||
|  "hex", |  "hex", | ||||||
|  "ignore", |  "ignore", | ||||||
|  "itertools", |  "itertools", | ||||||
|  | @ -455,6 +456,14 @@ name = "funty" | ||||||
| version = "1.1.0" | version = "1.1.0" | ||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" | checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" | ||||||
|  | name = "fslock" | ||||||
|  | version = "0.2.1" | ||||||
|  | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
|  | checksum = "04412b8935272e3a9bae6f48c7bfff74c2911f60525404edfdd28e49884c3bfb" | ||||||
|  | dependencies = [ | ||||||
|  |  "libc", | ||||||
|  |  "winapi", | ||||||
|  | ] | ||||||
| 
 | 
 | ||||||
| [[package]] | [[package]] | ||||||
| name = "getrandom" | name = "getrandom" | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ authors = ["Lucas Rosa <x@rvcas.dev>", "Kasey White <kwhitemsg@gmail.com>"] | ||||||
| [dependencies] | [dependencies] | ||||||
| aiken-lang = { path = "../lang", version = "0.0.26" } | aiken-lang = { path = "../lang", version = "0.0.26" } | ||||||
| askama = "0.10.5" | askama = "0.10.5" | ||||||
|  | fslock = "0.2.1" | ||||||
| hex = "0.4.3" | hex = "0.4.3" | ||||||
| ignore = "0.4.18" | ignore = "0.4.18" | ||||||
| itertools = "0.10.1" | itertools = "0.10.1" | ||||||
|  |  | ||||||
|  | @ -0,0 +1,41 @@ | ||||||
|  | use std::path::Path; | ||||||
|  | 
 | ||||||
|  | use crate::{ | ||||||
|  |     error::Error, | ||||||
|  |     paths, | ||||||
|  |     telemetry::{Event, EventListener}, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | use self::manifest::Manifest; | ||||||
|  | 
 | ||||||
|  | pub mod manifest; | ||||||
|  | 
 | ||||||
|  | pub enum UseManifest { | ||||||
|  |     Yes, | ||||||
|  |     No, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | pub fn download<T>( | ||||||
|  |     event_listener: &T, | ||||||
|  |     new_package: Option<(Vec<String>, bool)>, | ||||||
|  |     use_manifest: UseManifest, | ||||||
|  |     root_path: &Path, | ||||||
|  | ) -> Result<Manifest, Error> | ||||||
|  | where | ||||||
|  |     T: EventListener, | ||||||
|  | { | ||||||
|  |     let build_path = root_path.join(paths::build()); | ||||||
|  | 
 | ||||||
|  |     let mut build_lock = fslock::LockFile::open(&build_path).expect("Build Lock Creation"); | ||||||
|  | 
 | ||||||
|  |     if !build_lock | ||||||
|  |         .try_lock_with_pid() | ||||||
|  |         .expect("Trying build locking") | ||||||
|  |     { | ||||||
|  |         event_listener.handle_event(Event::WaitingForBuildDirLock); | ||||||
|  | 
 | ||||||
|  |         build_lock.lock_with_pid().expect("Build locking") | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     todo!() | ||||||
|  | } | ||||||
|  | @ -0,0 +1,17 @@ | ||||||
|  | use std::collections::HashMap; | ||||||
|  | 
 | ||||||
|  | pub struct Manifest { | ||||||
|  |     pub requirements: HashMap<String, String>, | ||||||
|  |     pub packages: Vec<Package>, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | pub struct Package { | ||||||
|  |     pub name: String, | ||||||
|  |     pub version: String, | ||||||
|  |     pub requirements: Vec<String>, | ||||||
|  |     pub source: PackageSource, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | pub enum PackageSource { | ||||||
|  |     GitHub { url: String }, | ||||||
|  | } | ||||||
|  | @ -1,9 +1,11 @@ | ||||||
| pub mod config; | pub mod config; | ||||||
|  | pub mod deps; | ||||||
| pub mod docs; | pub mod docs; | ||||||
| pub mod error; | pub mod error; | ||||||
| pub mod format; | pub mod format; | ||||||
| pub mod module; | pub mod module; | ||||||
| pub mod options; | pub mod options; | ||||||
|  | pub mod paths; | ||||||
| pub mod pretty; | pub mod pretty; | ||||||
| pub mod script; | pub mod script; | ||||||
| pub mod telemetry; | pub mod telemetry; | ||||||
|  | @ -17,6 +19,7 @@ use aiken_lang::{ | ||||||
|     uplc::CodeGenerator, |     uplc::CodeGenerator, | ||||||
|     IdGenerator, |     IdGenerator, | ||||||
| }; | }; | ||||||
|  | use deps::UseManifest; | ||||||
| use miette::NamedSource; | use miette::NamedSource; | ||||||
| use options::{CodeGenMode, Options}; | use options::{CodeGenMode, Options}; | ||||||
| use pallas::{ | use pallas::{ | ||||||
|  | @ -148,6 +151,8 @@ where | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn compile(&mut self, options: Options) -> Result<(), Error> { |     pub fn compile(&mut self, options: Options) -> Result<(), Error> { | ||||||
|  |         let manifest = deps::download(&self.event_listener, None, UseManifest::Yes, &self.root)?; | ||||||
|  | 
 | ||||||
|         self.event_listener |         self.event_listener | ||||||
|             .handle_event(Event::StartingCompilation { |             .handle_event(Event::StartingCompilation { | ||||||
|                 root: self.root.clone(), |                 root: self.root.clone(), | ||||||
|  | @ -718,7 +723,7 @@ where | ||||||
| 
 | 
 | ||||||
|             let cbor_hex = hex::encode(&cbor); |             let cbor_hex = hex::encode(&cbor); | ||||||
| 
 | 
 | ||||||
|             fs::write(script_path, &cbor_hex)?; |             fs::write(script_path, cbor_hex)?; | ||||||
| 
 | 
 | ||||||
|             // Create the payment script JSON file
 |             // Create the payment script JSON file
 | ||||||
|             let payment_script_path = script_output_dir.join("payment_script.json"); |             let payment_script_path = script_output_dir.join("payment_script.json"); | ||||||
|  |  | ||||||
|  | @ -0,0 +1,5 @@ | ||||||
|  | use std::path::PathBuf; | ||||||
|  | 
 | ||||||
|  | pub fn build() -> PathBuf { | ||||||
|  |     PathBuf::from("build") | ||||||
|  | } | ||||||
|  | @ -35,4 +35,5 @@ pub enum Event { | ||||||
|     FinishedTests { |     FinishedTests { | ||||||
|         tests: Vec<EvalInfo>, |         tests: Vec<EvalInfo>, | ||||||
|     }, |     }, | ||||||
|  |     WaitingForBuildDirLock, | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 rvcas
						rvcas