Skip to content

Commit

Permalink
consolidate deps (#79)
Browse files Browse the repository at this point in the history
* consolidate deps

* boot

* working

* more edits

* remove lib

* switch back to slab
  • Loading branch information
litlep-nibbyt authored Nov 14, 2024
1 parent 80a5aa2 commit 8b5d9da
Show file tree
Hide file tree
Showing 19 changed files with 14,113 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Build all
run: cargo build --release
- name: Compile choo kernel with bootstrap choo
run: target/release/choo apps/choo/hoon/lib/kernel.hoon apps/choo/hoon
run: target/release/choo apps/choo/bootstrap/kernel.hoon apps/hoon-deps
- name: Move choo jam back into assets
run: mv out.jam apps/choo/bootstrap/choo.jam
- name: Rebuild choo with built jamfile
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ bin/
.data.crown
**/.data.crown
assets/*
out.jam

# Dev config
.vscode/settings.json
Expand Down
Binary file modified apps/choo/bootstrap/choo.jam
Binary file not shown.
58 changes: 35 additions & 23 deletions apps/choo/hoon/lib/kernel.hoon → apps/choo/bootstrap/kernel.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
~
==
++ moat (keep choo-state)
::
:: nock compiled from hoon, along with type. form is independent of
:: subject, usually expected to be 0
+$ knob [t=type f=nock]
+$ cause
$% [%build entry=cord directory=(list [cord cord]) arbitrary=?]
$% [%build pat=cord tex=cord directory=(list [cord cord]) arbitrary=?]
[%file %write path=@t contents=@ success=?]
[%boot hoon-txt=cord]
==
+$ effect
$% [%file %write path=@t contents=@]
[%exit id=@]
==
::
:: $entry: path of a file along with unit of its contents.
::
:: If unit is null, the path must exist inside of the dir map.
::
+$ entry [pat=path tex=(unit cord)]
--
::
=<
Expand Down Expand Up @@ -63,7 +65,7 @@
[~ k(cached-hoon `(build-honc hoon-txt.cause))]
::
%build
=/ entry (stab entry.cause)
=/ =entry [(stab pat.cause) `tex.cause]
=/ dir
%- ~(gas by *(map path cord))
(turn directory.cause |=((pair @t @t) [(stab p) q]))
Expand Down Expand Up @@ -304,7 +306,7 @@
==
::
++ create
|= [entry=path dir=(map path cord)]
|= [=entry dir=(map path cord)]
^- (trap)
=/ dir-hash `@uvI`(mug dir)
~& dir-hash+dir-hash
Expand All @@ -318,7 +320,7 @@
%- head
(compile-graph (head graph) ~)
++ create-arbitrary
|= [entry=path dir=(map path cord)]
|= [=entry dir=(map path cord)]
^- (trap)
=/ dir-hash `@uvI`(mug dir)
~& dir-hash+dir-hash
Expand All @@ -329,17 +331,24 @@
=> tase
|.(+:^$)
::
++ get-file
|= [suf=entry dir=(map path cord)]
^- cord
?~ tex.suf
(~(got by dir) pat.suf)
u.tex.suf
::
++ make-import-graph
|= [face=(unit @tas) suf=path depth=@ cache=(map path import-graph) dir=(map path cord)]
|= [face=(unit @tas) suf=entry depth=@ cache=(map path import-graph) dir=(map path cord)]
^- [import-graph (map path import-graph)]
~& building-graph-for+[depth=depth suf]
?^ existing=(~(get by cache) suf)
~& > "reusing cached graph for {<suf>}"
~& building-graph-for+[depth=depth pat.suf]
?^ existing=(~(get by cache) pat.suf)
~& > "reusing cached graph for {<pat.suf>}"
[u.existing(face face) cache] :: make sure to use the provided face
?. (is-hoon suf)
=/ file (~(got by dir) suf)
=/ file=cord (get-file suf dir)
?. (is-hoon pat.suf)
=/ graph=import-graph
:* suf
:* pat.suf
~ ~
~ ~
face
Expand All @@ -348,26 +357,29 @@
=/ no-face=_graph
graph(face `%no-cache-entry-face)
:- graph
(~(put by cache) suf no-face)
=/ rile (resolve-pile (parse-pile suf (get-hoon suf dir)) dir)
(~(put by cache) pat.suf no-face)
=/ rile (resolve-pile (parse-pile pat.suf (trip file)) dir)
=^ new-sur=(list import-graph) cache
%^ spin sur.rile cache
|= [raut cache=(map path import-graph)]
(make-import-graph face pax +(depth) cache dir)
(make-import-graph face [pax ~] +(depth) cache dir)
=^ new-lib=(list import-graph) cache
%^ spin lib.rile cache
|= [raut cache=(map path import-graph)]
(make-import-graph face pax +(depth) cache dir)
=/ c (~(got by dir) pax)
(make-import-graph face [pax ~] +(depth) cache dir)
=^ new-raw=(list import-graph) cache
%^ spin raw.rile cache
|= [raut cache=(map path import-graph)]
(make-import-graph face pax +(depth) cache dir)
=/ c (~(got by dir) pax)
(make-import-graph face [pax ~] +(depth) cache dir)
=^ new-bar=(list import-graph) cache
%^ spin bar.rile cache
|= [raut cache=(map path import-graph)]
(make-import-graph face pax +(depth) cache dir)
=/ c (~(got by dir) pax)
(make-import-graph face [pax ~] +(depth) cache dir)
=/ graph=import-graph
:* suf
:* pat.suf
sur=new-sur
lib=new-lib
raw=new-raw
Expand All @@ -378,7 +390,7 @@
=/ no-face=_graph
graph(face `%no-cache-entry-face)
:- graph
(~(put by cache) suf no-face)
(~(put by cache) pat.suf no-face)
::
++ compile-graph
:: accepts an import-graph and compiles it down to a vase
Expand Down
24 changes: 19 additions & 5 deletions apps/choo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static KERNEL_JAM: &[u8] =

static HOON_TXT: &[u8] = include_bytes!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/bootstrap/hoon-138.hoon"
"/../hoon-deps/lib/hoon-138.hoon"
));

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -74,8 +74,22 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.await;

let mut slab = NounSlab::new();
let entry_string = cli.entry.strip_prefix(&cli.directory).unwrap();
let entry_noun = Atom::from_value(&mut slab, entry_string).unwrap().as_noun();
let entry_contents = {
let mut contents_vec: Vec<u8> = vec![];
let mut file = File::open(&cli.entry).await?;
file.read_to_end(&mut contents_vec).await?;
Atom::from_value(&mut slab, contents_vec).unwrap().as_noun()
};

let mut entry = cli.entry.clone();

// Insert a leading slash if it is not present
// Needed to make the entry path an actual hoon $path type
if !entry.starts_with('/') {
entry.insert(0, '/');
}

let entry_path = Atom::from_value(&mut slab, entry).unwrap().as_noun();

let mut directory_noun = D(0);

Expand Down Expand Up @@ -108,9 +122,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let arbitrary_noun = if cli.arbitrary { D(0) } else { D(1) };
let poke = T(
&mut slab,
&[D(tas!(b"build")), entry_noun, directory_noun, arbitrary_noun],
&[D(tas!(b"build")), entry_path, entry_contents, directory_noun, arbitrary_noun],
);
slab.copy_into(poke);
slab.set_root(poke);

nockapp
.add_io_driver(crown::one_punch_driver(slab, Operation::Poke))
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8b5d9da

Please sign in to comment.