commit 1c30d94fbeaced55fb701c12bbbf5d9561e6bdc3
parent a64be7a6964f9edfa47e86d0939402fd70a5767e
Author: Drew DeVault <sir@cmpwn.com>
Date: Sat, 20 Mar 2021 17:30:54 -0400
Move utility scripts into scripts/
Diffstat:
5 files changed, 553 insertions(+), 553 deletions(-)
diff --git a/Makefile b/Makefile
@@ -31,14 +31,14 @@ hare_srcs=\
$(HARECACHE)/hare.ssa: $(hare_srcs) $(hare_stdlib_deps)
@printf 'HAREC\t$@\n'
@HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) \
- -D VERSION:str='"'"$$(./version)"'"' \
+ -D VERSION:str='"'"$$(./scripts/version)"'"' \
-D HAREPATH:str='"'"$(HAREPATH)"'"' \
-o $@ $(hare_srcs)
$(TESTCACHE)/hare.ssa: $(hare_srcs) $(hare_testlib_deps)
@printf 'HAREC\t$@\n'
@HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) \
- -D VERSION:str='"'"$$(./version)"'"' \
+ -D VERSION:str='"'"$$(./scripts/version)"'"' \
-D HAREPATH:str='"'"$(HAREPATH)"'"' \
-o $@ $(hare_srcs)
diff --git a/gen-stdlib b/gen-stdlib
@@ -1,551 +0,0 @@
-#!/bin/sh
-# The purpose of this script is to generate make targets for the Hare standard
-# library. If you are adding new modules to the standard library, write a
-# function for that module (e.g. encoding_utf8), and call the following helper
-# commands:
-#
-# gen_srcs module::name list.ha of.ha sources.ha
-# gen_ssa module::name list of module::names yours depends on
-#
-# Then add your module to the list of modules at the bottom.
-#
-# Then run ./gen-stdlib > stdlib.mk to generate new rules.
-
-srcdir="$(dirname "$0")"
-eval ". $srcdir/gen-stdlib.sh"
-
-gensrcs_rt() {
- gen_srcs rt \
- '$(PLATFORM)/env.ha' \
- '$(PLATFORM)/errno.ha' \
- '$(PLATFORM)/types.ha' \
- '$(PLATFORM)/segmalloc.ha' \
- '$(PLATFORM)/start.ha' \
- '$(PLATFORM)/$(ARCH).ha' \
- '$(PLATFORM)/syscallno$(ARCH).ha' \
- '$(PLATFORM)/syscalls.ha' \
- '$(PLATFORM)/signal.ha' \
- '$(PLATFORM)/stat.ha' \
- '$(PLATFORM)/socket.ha' \
- '$(ARCH)/jmp.ha' \
- ensure.ha \
- jmp.ha \
- malloc.ha \
- memcpy.ha \
- memset.ha \
- strcmp.ha \
- $*
-}
-
-rt() {
- # This one is complicated, don't use it as a reference for other modules
- printf '# rt\n'
- if [ $testing -eq 0 ]
- then
- printf '%s\n' 'rtscript=$(STDLIB)/rt/hare.sc'
- gensrcs_rt \
- '$(PLATFORM)/abort.ha' \
- start.ha
- else
- gensrcs_rt \
- '+test/$(PLATFORM).ha' \
- +test/abort.ha \
- +test/cstring.ha \
- +test/start.ha \
- +test/ztos.ha
- fi
- gen_ssa rt
- cat <<EOF
-\$($cache)/rt/start.o: \$(STDLIB)/rt/\$(PLATFORM)/start\$(ARCH).s
- @printf 'AS \t\$@\n'
- @mkdir -p \$($cache)/rt
- @\$(AS) -o \$@ \$<
-
-${stdlib}_asm=\$($cache)/rt/syscall.o \\
- \$($cache)/rt/setjmp.o \\
- \$($cache)/rt/longjmp.o \\
- \$($cache)/rt/restore.o \\
- \$($cache)/rt/start.o
-
-\$($cache)/rt/syscall.o: \$(STDLIB)/rt/\$(PLATFORM)/syscall\$(ARCH).s
- @printf 'AS \t\$@\n'
- @mkdir -p \$($cache)/rt
- @\$(AS) -o \$@ \$<
-
-\$($cache)/rt/setjmp.o: \$(STDLIB)/rt/\$(ARCH)/setjmp.s
- @printf 'AS \t\$@\n'
- @mkdir -p \$($cache)/rt
- @\$(AS) -o \$@ \$<
-
-\$($cache)/rt/longjmp.o: \$(STDLIB)/rt/\$(ARCH)/longjmp.s
- @printf 'AS \t\$@\n'
- @mkdir -p \$($cache)/rt
- @\$(AS) -o \$@ \$<
-
-\$($cache)/rt/restore.o: \$(STDLIB)/rt/\$(ARCH)/restore.s
- @printf 'AS \t\$@\n'
- @mkdir -p \$($cache)/rt
- @\$(AS) -o \$@ \$<
-
-\$($cache)/rt/rt.a: \$($cache)/rt/rt.o \$(${stdlib}_asm)
- @printf 'AR\t\$@\n'
- @\$(AR) -csr \$@ \$($cache)/rt/rt.o \$(${stdlib}_asm)
-
-${stdlib}_rt=\$($cache)/rt/rt.a
-hare_${stdlib}_deps+=\$(${stdlib}_rt)
-
-EOF
-}
-
-ascii() {
- printf '# ascii\n'
- gen_srcs ascii \
- ctype.ha \
- strcmp.ha
- gen_ssa ascii strings
-}
-
-bufio() {
- printf '# bufio\n'
- gen_srcs bufio \
- buffered.ha \
- dynamic.ha \
- fixed.ha
- gen_ssa bufio io bytes strings
-}
-
-bytes() {
- printf '# bytes\n'
- gen_srcs bytes \
- contains.ha \
- copy.ha \
- equal.ha \
- index.ha \
- reverse.ha \
- tokenize.ha
- gen_ssa bytes types
-}
-
-crypto_math() {
- printf '# crypto::math\n'
- gen_srcs crypto::math \
- bits.ha
- gen_ssa crypto::math
-}
-
-crypto_random() {
- printf '# crypto::random\n'
- gen_srcs crypto::random \
- '$(PLATFORM).ha' \
- random.ha
- gen_ssa crypto::random rt io
-}
-
-gensrcs_crypto_sha256() {
- gen_srcs crypto::sha256 \
- sha256.ha \
- $*
-}
-
-genssa_crypto_sha256() {
- gen_ssa crypto::sha256 hash io endian $*
-}
-
-crypto_sha256() {
- printf '# crypto::sha256\n'
- if [ $testing -eq 0 ]
- then
- gensrcs_crypto_sha256
- genssa_crypto_sha256
- else
- gensrcs_crypto_sha256 \
- +test.ha
- genssa_crypto_sha256 fmt strio strings
- fi
-}
-
-crypto_sha1() {
- printf '# crypto::sha1\n'
- if [ $testing -eq 0 ]
- then
- gen_srcs crypto::sha1 sha1.ha
- gen_ssa crypto::sha1 hash io endian
- else
- gen_srcs crypto::sha1 sha1.ha +test.ha
- gen_ssa crypto::sha1 hash io endian fmt strio strings
- fi
-}
-
-dirs() {
- printf '# dirs\n'
- gen_srcs dirs \
- xdg.ha
- gen_ssa dirs fs os path
-}
-
-encoding_hex() {
- printf '# encoding::hex\n'
- gen_srcs encoding::hex \
- hex.ha
- gen_ssa encoding::hex io strconv strio strings
-}
-
-encoding_utf8() {
- printf '# encoding::utf8\n'
- gen_srcs encoding::utf8 \
- decode.ha \
- encode.ha \
- rune.ha
- gen_ssa encoding::utf8 types
-}
-
-endian() {
- printf '# endian\n'
- gen_srcs endian \
- big.ha \
- little.ha \
- endian.ha \
- 'host$(ARCH).ha'
- gen_ssa endian
-}
-
-fmt() {
- printf '# fmt\n'
- gen_srcs fmt \
- fmt.ha
- gen_ssa fmt bufio io os strconv strings types
-}
-
-format_elf() {
- printf '# format::elf\n'
- gen_srcs format::elf \
- types.ha
- gen_ssa format::elf
-}
-
-fs() {
- printf '# fs\n'
- gen_srcs fs \
- types.ha \
- fs.ha \
- util.ha
- gen_ssa fs io strings path time
-}
-
-getopt() {
- printf '# getopt\n'
- gen_srcs getopt \
- getopts.ha
- gen_ssa getopt encoding::utf8 fmt io os strings
-}
-
-hare_ast() {
- printf '# hare::ast\n'
- gen_srcs hare::ast \
- types.ha \
- unparse.ha
- gen_ssa hare::ast io fmt strio
-}
-
-gensrcs_hare_lex() {
- gen_srcs hare::lex \
- token.ha \
- lex.ha \
- $*
-}
-
-hare_lex() {
- printf '# hare::lex\n'
- if [ $testing -eq 0 ]
- then
- gensrcs_hare_lex
- else
- gensrcs_hare_lex \
- +test.ha
- fi
- gen_ssa hare::lex io bufio strings types fmt sort
-}
-
-hare_module() {
- printf '# hare::module\n'
- gen_srcs hare::module \
- types.ha \
- context.ha \
- scan.ha \
- manifest.ha
- gen_ssa hare::module \
- hare::ast hare::lex hare::parse strio fs io strings hash \
- crypto::sha256 dirs bytes encoding::utf8 ascii fmt time
-}
-
-gensrcs_hare_parse() {
- gen_srcs hare::parse \
- types.ha \
- util.ha \
- parse.ha \
- $*
-}
-
-hare_parse() {
- printf '# hare::parse\n'
- if [ $testing -eq 0 ]
- then
- gensrcs_hare_parse
- else
- gensrcs_hare_parse \
- +test.ha
- fi
- gen_ssa hare::parse hare::ast hare::lex slice
-}
-
-hash() {
- printf '# hash\n'
- gen_srcs hash \
- hash.ha
- gen_ssa hash io
-}
-
-hash_fnv() {
- printf '# hash::fnv\n'
- gen_srcs hash::fnv \
- fnv.ha
- gen_ssa hash::fnv hash io strings
-}
-
-gensrcs_io() {
- gen_srcs io \
- 'arch$(ARCH).ha' \
- copy.ha \
- limit.ha \
- println.ha \
- stream.ha \
- strings.ha \
- tee.ha \
- types.ha \
- $*
-}
-
-io() {
- printf '# io\n'
- if [ $testing -eq 0 ]
- then
- gensrcs_io
- else
- gensrcs_io \
- +test/copy.ha \
- +test/limit.ha \
- +test/stream.ha \
- +test/strings.ha
- fi
- gen_ssa io strings
-}
-
-linux() {
- printf '# linux\n'
- gen_srcs linux \
- start.ha \
- env.ha
- gen_ssa linux format::elf
-}
-
-linux_vdso() {
- printf '# linux::vdso\n'
- gen_srcs linux::vdso \
- vdso.ha
- gen_ssa linux::vdso linux strings format::elf
-}
-
-math_random() {
- printf '# math::random\n'
- gen_srcs math::random \
- random.ha
- gen_ssa math::random
-}
-
-os() {
- printf '# os\n'
- gen_srcs os \
- '$(PLATFORM)/environ.ha' \
- '$(PLATFORM)/errors.ha' \
- '$(PLATFORM)/exit.ha' \
- '$(PLATFORM)/dirfdfs.ha' \
- '$(PLATFORM)/fdstream.ha' \
- '$(PLATFORM)/open.ha' \
- '$(PLATFORM)/stdfd.ha' \
- '$(PLATFORM)/fs.ha' \
- stdfd.ha \
- fs.ha
- gen_ssa os io strings types fs encoding::utf8 bytes bufio
-}
-
-os_exec() {
- printf '# os::exec\n'
- gen_srcs os::exec \
- '$(PLATFORM).ha' \
- 'exec$(PLATFORM).ha' \
- 'process$(PLATFORM).ha' \
- types.ha \
- cmd.ha
- gen_ssa os::exec os strings fmt bytes path
-}
-
-path() {
- printf '# path\n'
- gen_srcs path \
- '$(PLATFORM).ha' \
- util.ha \
- join.ha \
- names.ha \
- iter.ha
- gen_ssa path strings bufio bytes
-}
-
-gensrcs_strconv() {
- gen_srcs strconv \
- types.ha \
- itos.ha \
- utos.ha \
- stou.ha \
- stoi.ha \
- numeric.ha \
- $*
-}
-
-slice() {
- printf '# slice\n'
- gen_srcs slice \
- reverse.ha
- gen_ssa slice
-}
-
-gensrcs_sort() {
- gen_srcs sort \
- search.ha \
- $*
-}
-
-sort() {
- printf '# sort\n'
- if [ $testing -eq 0 ]
- then
- gensrcs_sort
- else
- gensrcs_sort \
- +test.ha
- fi
- gen_ssa sort
-}
-
-strconv() {
- printf '# strconv\n'
- if [ $testing -eq 0 ]
- then
- gensrcs_strconv
- else
- gensrcs_strconv \
- +test/stou.ha \
- +test/stoi.ha
- fi
- gen_ssa strconv types strings ascii
-}
-
-strings() {
- printf '# strings\n'
- gen_srcs strings \
- concat.ha \
- contains.ha \
- cstrings.ha \
- dup.ha \
- iter.ha \
- sub.ha \
- suffix.ha \
- tokenize.ha \
- utf8.ha \
- index.ha
- gen_ssa strings bytes encoding::utf8 types
-}
-
-strio() {
- printf '# strio\n'
- gen_srcs strio \
- dynamic.ha \
- fixed.ha \
- ops.ha
- gen_ssa strio io strings encoding::utf8
-}
-
-time() {
- printf '# time\n'
- gen_srcs time \
- '$(PLATFORM)/functions.ha' \
- '$(PLATFORM)/$(ARCH).ha' \
- types.ha
- gen_ssa time linux::vdso
-}
-
-temp() {
- printf '# temp\n'
- gen_srcs temp \
- '$(PLATFORM).ha'
- gen_ssa temp crypto::random encoding::hex fs io os path
-}
-
-types() {
- printf '# types\n'
- gen_srcs types \
- limits.ha \
- classes.ha \
- 'arch$(ARCH).ha'
- gen_ssa types
-}
-
-printf '# This file is generated by the gen-stdlib script, do not edit it by hand\n\n'
-
-modules="ascii
-bufio
-bytes
-crypto_math
-crypto_random
-crypto_sha1
-crypto_sha256
-dirs
-encoding_hex
-encoding_utf8
-endian
-fmt
-format_elf
-fs
-getopt
-hare_ast
-hare_lex
-hare_module
-hare_parse
-hash
-hash_fnv
-io
-linux
-linux_vdso
-math_random
-os
-os_exec
-path
-slice
-sort
-strconv
-strings
-strio
-temp
-time
-types"
-stdlib() {
- rt
- for module in $modules; do
- gen_lib "$(printf "%s" "$module" | tr -s '_' '::')"
- done
- for module in $modules; do
- "$module"
- done
-}
-
-genrules
-genrules test
diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib
@@ -0,0 +1,551 @@
+#!/bin/sh
+# The purpose of this script is to generate make targets for the Hare standard
+# library. If you are adding new modules to the standard library, write a
+# function for that module (e.g. encoding_utf8), and call the following helper
+# commands:
+#
+# gen_srcs module::name list.ha of.ha sources.ha
+# gen_ssa module::name list of module::names yours depends on
+#
+# Then add your module to the list of modules at the bottom.
+#
+# Then run ./scripts/gen-stdlib > stdlib.mk to generate new rules.
+
+srcdir="$(dirname "$0")"
+eval ". $srcdir/gen-stdlib.sh"
+
+gensrcs_rt() {
+ gen_srcs rt \
+ '$(PLATFORM)/env.ha' \
+ '$(PLATFORM)/errno.ha' \
+ '$(PLATFORM)/types.ha' \
+ '$(PLATFORM)/segmalloc.ha' \
+ '$(PLATFORM)/start.ha' \
+ '$(PLATFORM)/$(ARCH).ha' \
+ '$(PLATFORM)/syscallno$(ARCH).ha' \
+ '$(PLATFORM)/syscalls.ha' \
+ '$(PLATFORM)/signal.ha' \
+ '$(PLATFORM)/stat.ha' \
+ '$(PLATFORM)/socket.ha' \
+ '$(ARCH)/jmp.ha' \
+ ensure.ha \
+ jmp.ha \
+ malloc.ha \
+ memcpy.ha \
+ memset.ha \
+ strcmp.ha \
+ $*
+}
+
+rt() {
+ # This one is complicated, don't use it as a reference for other modules
+ printf '# rt\n'
+ if [ $testing -eq 0 ]
+ then
+ printf '%s\n' 'rtscript=$(STDLIB)/rt/hare.sc'
+ gensrcs_rt \
+ '$(PLATFORM)/abort.ha' \
+ start.ha
+ else
+ gensrcs_rt \
+ '+test/$(PLATFORM).ha' \
+ +test/abort.ha \
+ +test/cstring.ha \
+ +test/start.ha \
+ +test/ztos.ha
+ fi
+ gen_ssa rt
+ cat <<EOF
+\$($cache)/rt/start.o: \$(STDLIB)/rt/\$(PLATFORM)/start\$(ARCH).s
+ @printf 'AS \t\$@\n'
+ @mkdir -p \$($cache)/rt
+ @\$(AS) -o \$@ \$<
+
+${stdlib}_asm=\$($cache)/rt/syscall.o \\
+ \$($cache)/rt/setjmp.o \\
+ \$($cache)/rt/longjmp.o \\
+ \$($cache)/rt/restore.o \\
+ \$($cache)/rt/start.o
+
+\$($cache)/rt/syscall.o: \$(STDLIB)/rt/\$(PLATFORM)/syscall\$(ARCH).s
+ @printf 'AS \t\$@\n'
+ @mkdir -p \$($cache)/rt
+ @\$(AS) -o \$@ \$<
+
+\$($cache)/rt/setjmp.o: \$(STDLIB)/rt/\$(ARCH)/setjmp.s
+ @printf 'AS \t\$@\n'
+ @mkdir -p \$($cache)/rt
+ @\$(AS) -o \$@ \$<
+
+\$($cache)/rt/longjmp.o: \$(STDLIB)/rt/\$(ARCH)/longjmp.s
+ @printf 'AS \t\$@\n'
+ @mkdir -p \$($cache)/rt
+ @\$(AS) -o \$@ \$<
+
+\$($cache)/rt/restore.o: \$(STDLIB)/rt/\$(ARCH)/restore.s
+ @printf 'AS \t\$@\n'
+ @mkdir -p \$($cache)/rt
+ @\$(AS) -o \$@ \$<
+
+\$($cache)/rt/rt.a: \$($cache)/rt/rt.o \$(${stdlib}_asm)
+ @printf 'AR\t\$@\n'
+ @\$(AR) -csr \$@ \$($cache)/rt/rt.o \$(${stdlib}_asm)
+
+${stdlib}_rt=\$($cache)/rt/rt.a
+hare_${stdlib}_deps+=\$(${stdlib}_rt)
+
+EOF
+}
+
+ascii() {
+ printf '# ascii\n'
+ gen_srcs ascii \
+ ctype.ha \
+ strcmp.ha
+ gen_ssa ascii strings
+}
+
+bufio() {
+ printf '# bufio\n'
+ gen_srcs bufio \
+ buffered.ha \
+ dynamic.ha \
+ fixed.ha
+ gen_ssa bufio io bytes strings
+}
+
+bytes() {
+ printf '# bytes\n'
+ gen_srcs bytes \
+ contains.ha \
+ copy.ha \
+ equal.ha \
+ index.ha \
+ reverse.ha \
+ tokenize.ha
+ gen_ssa bytes types
+}
+
+crypto_math() {
+ printf '# crypto::math\n'
+ gen_srcs crypto::math \
+ bits.ha
+ gen_ssa crypto::math
+}
+
+crypto_random() {
+ printf '# crypto::random\n'
+ gen_srcs crypto::random \
+ '$(PLATFORM).ha' \
+ random.ha
+ gen_ssa crypto::random rt io
+}
+
+gensrcs_crypto_sha256() {
+ gen_srcs crypto::sha256 \
+ sha256.ha \
+ $*
+}
+
+genssa_crypto_sha256() {
+ gen_ssa crypto::sha256 hash io endian $*
+}
+
+crypto_sha256() {
+ printf '# crypto::sha256\n'
+ if [ $testing -eq 0 ]
+ then
+ gensrcs_crypto_sha256
+ genssa_crypto_sha256
+ else
+ gensrcs_crypto_sha256 \
+ +test.ha
+ genssa_crypto_sha256 fmt strio strings
+ fi
+}
+
+crypto_sha1() {
+ printf '# crypto::sha1\n'
+ if [ $testing -eq 0 ]
+ then
+ gen_srcs crypto::sha1 sha1.ha
+ gen_ssa crypto::sha1 hash io endian
+ else
+ gen_srcs crypto::sha1 sha1.ha +test.ha
+ gen_ssa crypto::sha1 hash io endian fmt strio strings
+ fi
+}
+
+dirs() {
+ printf '# dirs\n'
+ gen_srcs dirs \
+ xdg.ha
+ gen_ssa dirs fs os path
+}
+
+encoding_hex() {
+ printf '# encoding::hex\n'
+ gen_srcs encoding::hex \
+ hex.ha
+ gen_ssa encoding::hex io strconv strio strings
+}
+
+encoding_utf8() {
+ printf '# encoding::utf8\n'
+ gen_srcs encoding::utf8 \
+ decode.ha \
+ encode.ha \
+ rune.ha
+ gen_ssa encoding::utf8 types
+}
+
+endian() {
+ printf '# endian\n'
+ gen_srcs endian \
+ big.ha \
+ little.ha \
+ endian.ha \
+ 'host$(ARCH).ha'
+ gen_ssa endian
+}
+
+fmt() {
+ printf '# fmt\n'
+ gen_srcs fmt \
+ fmt.ha
+ gen_ssa fmt bufio io os strconv strings types
+}
+
+format_elf() {
+ printf '# format::elf\n'
+ gen_srcs format::elf \
+ types.ha
+ gen_ssa format::elf
+}
+
+fs() {
+ printf '# fs\n'
+ gen_srcs fs \
+ types.ha \
+ fs.ha \
+ util.ha
+ gen_ssa fs io strings path time
+}
+
+getopt() {
+ printf '# getopt\n'
+ gen_srcs getopt \
+ getopts.ha
+ gen_ssa getopt encoding::utf8 fmt io os strings
+}
+
+hare_ast() {
+ printf '# hare::ast\n'
+ gen_srcs hare::ast \
+ types.ha \
+ unparse.ha
+ gen_ssa hare::ast io fmt strio
+}
+
+gensrcs_hare_lex() {
+ gen_srcs hare::lex \
+ token.ha \
+ lex.ha \
+ $*
+}
+
+hare_lex() {
+ printf '# hare::lex\n'
+ if [ $testing -eq 0 ]
+ then
+ gensrcs_hare_lex
+ else
+ gensrcs_hare_lex \
+ +test.ha
+ fi
+ gen_ssa hare::lex io bufio strings types fmt sort
+}
+
+hare_module() {
+ printf '# hare::module\n'
+ gen_srcs hare::module \
+ types.ha \
+ context.ha \
+ scan.ha \
+ manifest.ha
+ gen_ssa hare::module \
+ hare::ast hare::lex hare::parse strio fs io strings hash \
+ crypto::sha256 dirs bytes encoding::utf8 ascii fmt time
+}
+
+gensrcs_hare_parse() {
+ gen_srcs hare::parse \
+ types.ha \
+ util.ha \
+ parse.ha \
+ $*
+}
+
+hare_parse() {
+ printf '# hare::parse\n'
+ if [ $testing -eq 0 ]
+ then
+ gensrcs_hare_parse
+ else
+ gensrcs_hare_parse \
+ +test.ha
+ fi
+ gen_ssa hare::parse hare::ast hare::lex slice
+}
+
+hash() {
+ printf '# hash\n'
+ gen_srcs hash \
+ hash.ha
+ gen_ssa hash io
+}
+
+hash_fnv() {
+ printf '# hash::fnv\n'
+ gen_srcs hash::fnv \
+ fnv.ha
+ gen_ssa hash::fnv hash io strings
+}
+
+gensrcs_io() {
+ gen_srcs io \
+ 'arch$(ARCH).ha' \
+ copy.ha \
+ limit.ha \
+ println.ha \
+ stream.ha \
+ strings.ha \
+ tee.ha \
+ types.ha \
+ $*
+}
+
+io() {
+ printf '# io\n'
+ if [ $testing -eq 0 ]
+ then
+ gensrcs_io
+ else
+ gensrcs_io \
+ +test/copy.ha \
+ +test/limit.ha \
+ +test/stream.ha \
+ +test/strings.ha
+ fi
+ gen_ssa io strings
+}
+
+linux() {
+ printf '# linux\n'
+ gen_srcs linux \
+ start.ha \
+ env.ha
+ gen_ssa linux format::elf
+}
+
+linux_vdso() {
+ printf '# linux::vdso\n'
+ gen_srcs linux::vdso \
+ vdso.ha
+ gen_ssa linux::vdso linux strings format::elf
+}
+
+math_random() {
+ printf '# math::random\n'
+ gen_srcs math::random \
+ random.ha
+ gen_ssa math::random
+}
+
+os() {
+ printf '# os\n'
+ gen_srcs os \
+ '$(PLATFORM)/environ.ha' \
+ '$(PLATFORM)/errors.ha' \
+ '$(PLATFORM)/exit.ha' \
+ '$(PLATFORM)/dirfdfs.ha' \
+ '$(PLATFORM)/fdstream.ha' \
+ '$(PLATFORM)/open.ha' \
+ '$(PLATFORM)/stdfd.ha' \
+ '$(PLATFORM)/fs.ha' \
+ stdfd.ha \
+ fs.ha
+ gen_ssa os io strings types fs encoding::utf8 bytes bufio
+}
+
+os_exec() {
+ printf '# os::exec\n'
+ gen_srcs os::exec \
+ '$(PLATFORM).ha' \
+ 'exec$(PLATFORM).ha' \
+ 'process$(PLATFORM).ha' \
+ types.ha \
+ cmd.ha
+ gen_ssa os::exec os strings fmt bytes path
+}
+
+path() {
+ printf '# path\n'
+ gen_srcs path \
+ '$(PLATFORM).ha' \
+ util.ha \
+ join.ha \
+ names.ha \
+ iter.ha
+ gen_ssa path strings bufio bytes
+}
+
+gensrcs_strconv() {
+ gen_srcs strconv \
+ types.ha \
+ itos.ha \
+ utos.ha \
+ stou.ha \
+ stoi.ha \
+ numeric.ha \
+ $*
+}
+
+slice() {
+ printf '# slice\n'
+ gen_srcs slice \
+ reverse.ha
+ gen_ssa slice
+}
+
+gensrcs_sort() {
+ gen_srcs sort \
+ search.ha \
+ $*
+}
+
+sort() {
+ printf '# sort\n'
+ if [ $testing -eq 0 ]
+ then
+ gensrcs_sort
+ else
+ gensrcs_sort \
+ +test.ha
+ fi
+ gen_ssa sort
+}
+
+strconv() {
+ printf '# strconv\n'
+ if [ $testing -eq 0 ]
+ then
+ gensrcs_strconv
+ else
+ gensrcs_strconv \
+ +test/stou.ha \
+ +test/stoi.ha
+ fi
+ gen_ssa strconv types strings ascii
+}
+
+strings() {
+ printf '# strings\n'
+ gen_srcs strings \
+ concat.ha \
+ contains.ha \
+ cstrings.ha \
+ dup.ha \
+ iter.ha \
+ sub.ha \
+ suffix.ha \
+ tokenize.ha \
+ utf8.ha \
+ index.ha
+ gen_ssa strings bytes encoding::utf8 types
+}
+
+strio() {
+ printf '# strio\n'
+ gen_srcs strio \
+ dynamic.ha \
+ fixed.ha \
+ ops.ha
+ gen_ssa strio io strings encoding::utf8
+}
+
+time() {
+ printf '# time\n'
+ gen_srcs time \
+ '$(PLATFORM)/functions.ha' \
+ '$(PLATFORM)/$(ARCH).ha' \
+ types.ha
+ gen_ssa time linux::vdso
+}
+
+temp() {
+ printf '# temp\n'
+ gen_srcs temp \
+ '$(PLATFORM).ha'
+ gen_ssa temp crypto::random encoding::hex fs io os path
+}
+
+types() {
+ printf '# types\n'
+ gen_srcs types \
+ limits.ha \
+ classes.ha \
+ 'arch$(ARCH).ha'
+ gen_ssa types
+}
+
+printf '# This file is generated by the gen-stdlib script, do not edit it by hand\n\n'
+
+modules="ascii
+bufio
+bytes
+crypto_math
+crypto_random
+crypto_sha1
+crypto_sha256
+dirs
+encoding_hex
+encoding_utf8
+endian
+fmt
+format_elf
+fs
+getopt
+hare_ast
+hare_lex
+hare_module
+hare_parse
+hash
+hash_fnv
+io
+linux
+linux_vdso
+math_random
+os
+os_exec
+path
+slice
+sort
+strconv
+strings
+strio
+temp
+time
+types"
+stdlib() {
+ rt
+ for module in $modules; do
+ gen_lib "$(printf "%s" "$module" | tr -s '_' '::')"
+ done
+ for module in $modules; do
+ "$module"
+ done
+}
+
+genrules
+genrules test
diff --git a/gen-stdlib.sh b/scripts/gen-stdlib.sh
diff --git a/version b/scripts/version