Login
7 branches 0 tags
Benjamin Vincent Schulenburg Added [remove] for arrays/lists 19086c9 3 years ago 480 Commits
nujel / tools / bootstrap.nuj
#!/usr/bin/env nujel
; In here we use our bootstrap runtime to load, eval and finally precompile
; the Nujel standard library, the eval is necessary so we can make use of macros
; that are not within our bootstrap runtime (which is just using an old
; precompiled stdlib).

[def environment [ω]]
[def ext-nuj? [path/ext?! "nuj"]]
[defun directory/read-relative [path]
       [-> [directory/read path]
           [map [\ [α] [cat path "/" α]]]
           [map [\ [α] [if-not [file/dir? α] α
                                [directory/read-relative α]]]]
           [flatten]]]
[def stdlib-files [sort [filter [append [directory/read-relative "stdlib"]
                                        [directory/read-relative "binlib"]]
                                ext-nuj?]]]

; If something happens, we just print the responsible error and exit immediately,
; since we can't really fix things, we could only make things worse.
[try [\ [err]
        [println "Exception during stdlib compilation"]
        [display/error err] [exit 2]]
     [for-in [cur-path stdlib-files]
             [println [cat [ansi-yellow " [EVA]  "] cur-path]]
             [file/compile cur-path #t environment]]
     [for-in [cur-path stdlib-files]
             [println [cat [ansi-green " [NUJ]  "] cur-path]]
             [file/compile cur-path #f environment]]]