mirror of
https://github.com/urbit/shrub.git
synced 2024-12-15 12:43:31 +03:00
linking works
This commit is contained in:
parent
e20bf4c4c2
commit
6a720339cf
@ -78,10 +78,12 @@
|
|||||||
test-cache-reclamation-live-rebuild
|
test-cache-reclamation-live-rebuild
|
||||||
test-cache-reclamation-live-promote
|
test-cache-reclamation-live-promote
|
||||||
test-five-oh-cache-reclamation
|
test-five-oh-cache-reclamation
|
||||||
:: test-reef
|
:: test-reef :: very slow
|
||||||
test-reef-short-circuit
|
test-reef-short-circuit
|
||||||
test-path
|
test-path
|
||||||
test-plan-direct-hoon
|
test-plan-direct-hoon
|
||||||
|
test-core
|
||||||
|
test-core-linker
|
||||||
==
|
==
|
||||||
++ test-tear
|
++ test-tear
|
||||||
~& %test-tear
|
~& %test-tear
|
||||||
@ -3943,12 +3945,14 @@
|
|||||||
~& %test-core
|
~& %test-core
|
||||||
::
|
::
|
||||||
=/ ford *ford-gate
|
=/ ford *ford-gate
|
||||||
=/ hoon-vase=vase !>((ream '`@tas`%constant'))
|
::
|
||||||
|
=/ hoon-src '`@tas`%constant'
|
||||||
|
=/ hoon-src-type=type [%atom %$ ~]
|
||||||
::
|
::
|
||||||
=/ scry-results=(map [term beam] cage)
|
=/ scry-results=(map [term beam] cage)
|
||||||
%- my :~
|
%- my :~
|
||||||
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/foo-bar/lib]]
|
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/foo-bar/lib]]
|
||||||
[%hoon hoon-vase]
|
[%hoon hoon-src-type hoon-src]
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
=^ results1 ford
|
=^ results1 ford
|
||||||
@ -3966,14 +3970,93 @@
|
|||||||
^= moves
|
^= moves
|
||||||
:~ :* duct=~[/path] %give %made ~1234.5.6 %complete
|
:~ :* duct=~[/path] %give %made ~1234.5.6 %complete
|
||||||
%success %pin ~1234.5.6
|
%success %pin ~1234.5.6
|
||||||
%success %core hoon-vase
|
%success %core [%atom %tas ~] %constant
|
||||||
== == ==
|
== == ==
|
||||||
::
|
::
|
||||||
;: weld
|
;: weld
|
||||||
results1
|
results1
|
||||||
(expect-ford-empty ford ~nul)
|
(expect-ford-empty ford ~nul)
|
||||||
==
|
==
|
||||||
|
::
|
||||||
|
++ test-core-linker
|
||||||
|
~& %test-core-linker
|
||||||
|
::
|
||||||
|
=/ ford *ford-gate
|
||||||
|
::
|
||||||
|
=/ hoon-src-type=type [%atom %$ ~]
|
||||||
|
=/ scry-results=(map [term beam] cage)
|
||||||
|
%- my :~
|
||||||
|
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/data/sur]]
|
||||||
|
:- %hoon
|
||||||
|
:- hoon-src-type
|
||||||
|
'''
|
||||||
|
|%
|
||||||
|
+= data-type
|
||||||
|
[msg=tape count=@ud]
|
||||||
|
--
|
||||||
|
'''
|
||||||
|
::
|
||||||
|
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/data/lib]]
|
||||||
|
:- %hoon
|
||||||
|
:- hoon-src-type
|
||||||
|
'''
|
||||||
|
/- data
|
||||||
|
|%
|
||||||
|
++ do
|
||||||
|
|= [a=data-type:data b=data-type:data]
|
||||||
|
^- data-type:data
|
||||||
|
[(weld msg.a msg.b) (add count.a count.b)]
|
||||||
|
--
|
||||||
|
'''
|
||||||
|
::
|
||||||
|
:- [%cx [[~nul %home %da ~1234.5.6] /hoon/program/gen]]
|
||||||
|
:- %hoon
|
||||||
|
:- hoon-src-type
|
||||||
|
'''
|
||||||
|
/- *data
|
||||||
|
/+ combiner=data
|
||||||
|
(do:combiner `data-type`["one" 1] `data-type`["two" 2])
|
||||||
|
'''
|
||||||
|
==
|
||||||
|
::
|
||||||
|
=^ results1 ford
|
||||||
|
%- test-ford-call-with-comparator :*
|
||||||
|
ford
|
||||||
|
now=~1234.5.6
|
||||||
|
scry=(scry-with-results scry-results)
|
||||||
|
::
|
||||||
|
^= call-args
|
||||||
|
:* duct=~[/path] type=~ %make ~nul
|
||||||
|
%pin ~1234.5.6
|
||||||
|
[%core source-path=`rail:ford-gate`[[~nul %home] /hoon/program/gen]]
|
||||||
|
==
|
||||||
|
::
|
||||||
|
^= comparator
|
||||||
|
|= moves=(list move:ford-gate)
|
||||||
|
::
|
||||||
|
?> =(1 (lent moves))
|
||||||
|
?> ?=(^ moves)
|
||||||
|
?> ?=([* %give %made @da %complete %success %pin *] i.moves)
|
||||||
|
=/ result result.p.card.i.moves
|
||||||
|
=/ pin-result build-result.result
|
||||||
|
?> ?=([%success %core *] build-result.pin-result)
|
||||||
|
::
|
||||||
|
=/ =vase vase.build-result.pin-result
|
||||||
|
::
|
||||||
|
%+ weld
|
||||||
|
%- expect-eq !>
|
||||||
|
:- ["onetwo" 3]
|
||||||
|
q.vase
|
||||||
|
::
|
||||||
|
%- expect-eq !>
|
||||||
|
:- &
|
||||||
|
(~(nest ut p.vase) | -:!>(["onetwo" 3]))
|
||||||
|
==
|
||||||
|
::
|
||||||
|
;: weld
|
||||||
|
results1
|
||||||
|
(expect-ford-empty ford ~nul)
|
||||||
|
==
|
||||||
::
|
::
|
||||||
:: |utilities: helper arms
|
:: |utilities: helper arms
|
||||||
::
|
::
|
||||||
@ -3989,7 +4072,7 @@
|
|||||||
^- tang
|
^- tang
|
||||||
::
|
::
|
||||||
?> ?=([* %give %made @da %complete %success ^ *] move)
|
?> ?=([* %give %made @da %complete %success ^ *] move)
|
||||||
=/ result result.p.card.move
|
=/ result build-result.result.p.card.move
|
||||||
?> ?=([%success %scry %noun type-a=* @tas *] head.result)
|
?> ?=([%success %scry %noun type-a=* @tas *] head.result)
|
||||||
?> ?=([%success ^ *] tail.result)
|
?> ?=([%success ^ *] tail.result)
|
||||||
?> ?=([%success %ride type-title-a=* %post-a] head.tail.result)
|
?> ?=([%success %ride type-title-a=* %post-a] head.tail.result)
|
||||||
|
@ -55,10 +55,10 @@
|
|||||||
$= result
|
$= result
|
||||||
$% :: %complete: contains the result of the completed build
|
$% :: %complete: contains the result of the completed build
|
||||||
::
|
::
|
||||||
[%complete build-result]
|
[%complete =build-result]
|
||||||
:: %incomplete: couldn't finish build; contains error message
|
:: %incomplete: couldn't finish build; contains error message
|
||||||
::
|
::
|
||||||
[%incomplete tang]
|
[%incomplete =tang]
|
||||||
== == ==
|
== == ==
|
||||||
--
|
--
|
||||||
:: +disc: a desk on a ship; can be used as a beak that varies with time
|
:: +disc: a desk on a ship; can be used as a beak that varies with time
|
||||||
@ -2995,17 +2995,63 @@
|
|||||||
:: TODO: support source-path
|
:: TODO: support source-path
|
||||||
:: TODO: support indirect hoons
|
:: TODO: support indirect hoons
|
||||||
::
|
::
|
||||||
=/ hoon-stack=(list hoon)
|
:: blocks: accumulator for blocked sub-builds
|
||||||
%+ turn sources.scaffold
|
|
||||||
|= =brick ?>(?=(%direct -.brick) source.brick)
|
|
||||||
:: combine hoons into one: =~(hoon1 hoon2 ...)
|
|
||||||
:: TODO: why flop?
|
|
||||||
::
|
::
|
||||||
=/ combined-hoon=hoon [%tssg (flop hoon-stack)]
|
=| blocks=(list ^build)
|
||||||
:: compile :combined-hoon against the kernel subject
|
:: error-message: accumulator for failed sub-builds
|
||||||
|
::
|
||||||
|
=| error-message=tang
|
||||||
|
::
|
||||||
|
|^ :: imports: structure and library +cables, with %sur/%lib prefixes
|
||||||
|
::
|
||||||
|
=/ imports=(list [prefix=?(%sur %lib) =cable])
|
||||||
|
%+ welp
|
||||||
|
(turn structures.scaffold |=(cable [%sur +<]))
|
||||||
|
(turn libraries.scaffold |=(cable [%lib +<]))
|
||||||
|
:: path-builds: %path sub-builds to resolve import paths
|
||||||
|
::
|
||||||
|
=/ path-builds (gather-path-builds imports)
|
||||||
|
::
|
||||||
|
=^ path-results ..$ (resolve-builds path-builds)
|
||||||
|
?^ blocks
|
||||||
|
[build [%blocks blocks ~] accessed-builds]
|
||||||
|
::
|
||||||
|
?^ error-message
|
||||||
|
(return-error error-message)
|
||||||
|
:: tmi; remove type specializations
|
||||||
|
::
|
||||||
|
=> .(blocks *(list ^build), error-message *tang)
|
||||||
|
:: core-builds: %core sub-builds to produce library vases
|
||||||
|
::
|
||||||
|
=/ core-builds (gather-core-builds path-results)
|
||||||
|
::
|
||||||
|
=^ core-results ..$ (resolve-builds core-builds)
|
||||||
|
?^ blocks
|
||||||
|
[build [%blocks blocks ~] accessed-builds]
|
||||||
|
::
|
||||||
|
?^ error-message
|
||||||
|
(return-error error-message)
|
||||||
|
:: reef-build: %reef build to produce standard library
|
||||||
|
::
|
||||||
|
=/ reef-build=^build [date.build [%reef disc.source-path]]
|
||||||
|
::
|
||||||
|
=^ reef-result accessed-builds (depend-on reef-build)
|
||||||
|
?~ reef-result
|
||||||
|
[build [%blocks [reef-build]~ ~] accessed-builds]
|
||||||
|
::
|
||||||
|
?. ?=([~ %success %reef *] reef-result)
|
||||||
|
(wrap-error reef-result)
|
||||||
|
:: subject: tuple of imports and standard library
|
||||||
|
::
|
||||||
|
=/ subject=vase
|
||||||
|
(link-imports imports vase.u.reef-result core-results)
|
||||||
|
:: combined-hoon: source hoons condensed into a single +hoon
|
||||||
|
::
|
||||||
|
=/ combined-hoon=hoon (stack-sources sources.scaffold)
|
||||||
|
:: compile :combined-hoon against :subject
|
||||||
::
|
::
|
||||||
=/ compile=^build
|
=/ compile=^build
|
||||||
[date.build [%ride combined-hoon [%reef disc.source-path]]]
|
[date.build [%ride combined-hoon [%$ %noun subject]]]
|
||||||
::
|
::
|
||||||
=^ compiled accessed-builds (depend-on compile)
|
=^ compiled accessed-builds (depend-on compile)
|
||||||
:: compilation blocked; produce block on sub-build
|
:: compilation blocked; produce block on sub-build
|
||||||
@ -3014,12 +3060,115 @@
|
|||||||
[build [%blocks ~[compile] ~] accessed-builds]
|
[build [%blocks ~[compile] ~] accessed-builds]
|
||||||
:: compilation failed; error out
|
:: compilation failed; error out
|
||||||
::
|
::
|
||||||
?: ?=([~ %error *] compiled)
|
?. ?=([~ %success %ride *] compiled)
|
||||||
(wrap-error compiled)
|
(wrap-error compiled)
|
||||||
:: compilation succeeded: produce resulting :vase
|
:: compilation succeeded: produce resulting +vase
|
||||||
::
|
::
|
||||||
=/ =vase q:(result-to-cage u.compiled)
|
[build [%build-result %success %plan vase.u.compiled] accessed-builds]
|
||||||
[build [%build-result %success %plan vase] accessed-builds]
|
:: +gather-path-builds: produce %path builds to resolve import paths
|
||||||
|
::
|
||||||
|
++ gather-path-builds
|
||||||
|
|= imports=(list [prefix=?(%sur %lib) =cable])
|
||||||
|
^- (list ^build)
|
||||||
|
::
|
||||||
|
%+ turn imports
|
||||||
|
|= [prefix=?(%sur %lib) =cable]
|
||||||
|
^- ^build
|
||||||
|
[date.build [%path disc.source-path prefix file-path.cable]]
|
||||||
|
:: +resolve-builds: run a list of builds and collect results
|
||||||
|
::
|
||||||
|
:: If a build blocks, put its +tang in :error-message and stop.
|
||||||
|
:: All builds that block get put in :blocks. Results of
|
||||||
|
:: successful builds are produced in :results.
|
||||||
|
::
|
||||||
|
++ resolve-builds
|
||||||
|
=| results=(list build-result)
|
||||||
|
|= builds=(list ^build)
|
||||||
|
^+ [results ..^$]
|
||||||
|
::
|
||||||
|
?~ builds
|
||||||
|
[results ..^$]
|
||||||
|
::
|
||||||
|
=^ result accessed-builds (depend-on i.builds)
|
||||||
|
?~ result
|
||||||
|
=. blocks [i.builds blocks]
|
||||||
|
$(builds t.builds)
|
||||||
|
::
|
||||||
|
?. ?=(%success -.u.result)
|
||||||
|
=. error-message [[%leaf "%plan failed: "] message.u.result]
|
||||||
|
[results ..^$]
|
||||||
|
::
|
||||||
|
=. results [u.result results]
|
||||||
|
$(builds t.builds)
|
||||||
|
:: +gather-core-builds: produce %core builds from resolved paths
|
||||||
|
::
|
||||||
|
++ gather-core-builds
|
||||||
|
|= path-results=(list build-result)
|
||||||
|
^- (list ^build)
|
||||||
|
%+ turn path-results
|
||||||
|
|= result=build-result
|
||||||
|
^- ^build
|
||||||
|
::
|
||||||
|
?> ?=([%success %path *] result)
|
||||||
|
::
|
||||||
|
[date.build [%core rail.result]]
|
||||||
|
:: +link-imports: link libraries and structures with standard library
|
||||||
|
::
|
||||||
|
:: Prepends each library vase onto the standard library vase.
|
||||||
|
:: Wraps a face around each library to prevent namespace leakage
|
||||||
|
:: unless imported as *lib-name.
|
||||||
|
::
|
||||||
|
++ link-imports
|
||||||
|
|= $: imports=(list [?(%lib %sur) =cable])
|
||||||
|
reef=vase
|
||||||
|
core-results=(list build-result)
|
||||||
|
==
|
||||||
|
^- vase
|
||||||
|
::
|
||||||
|
=/ subject=vase reef
|
||||||
|
::
|
||||||
|
=/ core-vases=(list vase)
|
||||||
|
%+ turn core-results
|
||||||
|
|= result=build-result
|
||||||
|
^- vase
|
||||||
|
?> ?=([%success %core *] result)
|
||||||
|
vase.result
|
||||||
|
:: link structures and libraries into a subject for compilation
|
||||||
|
::
|
||||||
|
|- ^+ subject
|
||||||
|
?~ core-vases subject
|
||||||
|
?< ?=(~ imports)
|
||||||
|
:: cons this vase onto the head of the subject
|
||||||
|
::
|
||||||
|
=. subject
|
||||||
|
%- slop :_ subject
|
||||||
|
:: check if the programmer named the library
|
||||||
|
::
|
||||||
|
?~ face.cable.i.imports
|
||||||
|
:: no face assigned to this library, so use vase as-is
|
||||||
|
::
|
||||||
|
i.core-vases
|
||||||
|
:: use the library name as a face to prevent namespace leakage
|
||||||
|
::
|
||||||
|
^- vase
|
||||||
|
[[%face face.cable.i.imports p.i.core-vases] q.i.core-vases]
|
||||||
|
::
|
||||||
|
$(core-vases t.core-vases, imports t.imports)
|
||||||
|
:: +stack-sources: combine bricks into one +hoon: =~(hoon1 hoon2 ...)
|
||||||
|
::
|
||||||
|
++ stack-sources
|
||||||
|
|= sources=(list brick)
|
||||||
|
^- hoon
|
||||||
|
:: TODO why flop?
|
||||||
|
::
|
||||||
|
=- [%tssg (flop -)]
|
||||||
|
%+ turn sources
|
||||||
|
|= =brick
|
||||||
|
^- hoon
|
||||||
|
::
|
||||||
|
?> ?=(%direct -.brick)
|
||||||
|
source.brick
|
||||||
|
--
|
||||||
::
|
::
|
||||||
++ make-reef
|
++ make-reef
|
||||||
|= =disc
|
|= =disc
|
||||||
|
Loading…
Reference in New Issue
Block a user