This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the compiler use local source code
Now the source code is compressed and statically linked into the binary, so there is no need to git clone it from github anymore, both removing version issues and the git dependency.
- Loading branch information
Showing
12 changed files
with
81 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
target/ | ||
test/ | ||
Cargo.lock | ||
|
||
code.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ version = "0.1.0" | |
edition = "2021" | ||
|
||
[dependencies] | ||
voila = {path = "../voila"} | ||
voila = {path = "../voila"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use flate2::write::GzEncoder; | ||
use flate2::Compression; | ||
use std::env::current_dir; | ||
use std::fs::File; | ||
|
||
const COMPILE_ASSETS: [&str; 4] = ["voila", "compiled_voila", "Cargo.toml", "Cargo.lock"]; | ||
|
||
fn main() { | ||
let src = ¤t_dir().expect("Can't open current directory"); | ||
let src = src.parent().unwrap(); | ||
let dest = File::create(format!("{}/code.tar.gz", src.to_str().unwrap())) | ||
.expect("Can't write to current directory"); | ||
println!("{}/code.tar.gz", src.to_str().unwrap()); | ||
let encoder = GzEncoder::new(dest, Compression::default()); | ||
let mut tar = tar::Builder::new(encoder); | ||
for a in COMPILE_ASSETS { | ||
let p = src.join(a); | ||
if p.is_dir() { | ||
tar.append_dir_all(a, p) | ||
.expect("Can't read current directory"); | ||
} else { | ||
tar.append_path_with_name(p, a) | ||
.expect("Can't read current directory"); | ||
} | ||
} | ||
tar.finish().unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::ast::Script; | ||
|
||
pub type VoilaByteCode = Vec<u8>; | ||
|
||
impl<'source> From<Script<'source>> for VoilaByteCode { | ||
fn from(code: Script<'source>) -> Self { | ||
bincode::serialize(&code).unwrap() | ||
} | ||
} | ||
|
||
impl<'source> From<VoilaByteCode> for Script<'source> { | ||
fn from(s: VoilaByteCode) -> Self { | ||
bincode::deserialize(&s[..]).unwrap() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters