commit 740c5794e4d3b14061fd6de8fa56bb6f9eb1b349
parent 27c7fe5f19b01b476af21b485ea4661c3d4f85c1
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 19 Feb 2021 13:31:23 -0500
stdlib: add sort
Diffstat:
2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/gen-stdlib b/gen-stdlib
@@ -233,6 +233,24 @@ gensrcs_strconv() {
$*
}
+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 ]
@@ -283,6 +301,7 @@ hare_lex
io
os
os_exec
+sort
strconv
strings
types"
diff --git a/mk/stdlib.mk b/mk/stdlib.mk
@@ -93,6 +93,9 @@ hare_stdlib_deps+=$(stdlib_os)
stdlib_os_exec=$(HARECACHE)/os/exec/os.exec.o
hare_stdlib_deps+=$(stdlib_os_exec)
+stdlib_sort=$(HARECACHE)/sort/sort.o
+hare_stdlib_deps+=$(stdlib_sort)
+
stdlib_strconv=$(HARECACHE)/strconv/strconv.o
hare_stdlib_deps+=$(stdlib_strconv)
@@ -234,6 +237,16 @@ $(HARECACHE)/os/exec/os.exec.ssa: $(stdlib_os_exec_srcs) $(stdlib_rt) $(stdlib_o
@HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nos::exec \
-t$(HARECACHE)/os/exec/os.exec.td $(stdlib_os_exec_srcs)
+# sort
+stdlib_sort_srcs= \
+ $(STDLIB)/sort/search.ha
+
+$(HARECACHE)/sort/sort.ssa: $(stdlib_sort_srcs) $(stdlib_rt)
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(HARECACHE)/sort
+ @HARECACHE=$(HARECACHE) $(HAREC) $(HAREFLAGS) -o $@ -Nsort \
+ -t$(HARECACHE)/sort/sort.td $(stdlib_sort_srcs)
+
# strconv
stdlib_strconv_srcs= \
$(STDLIB)/strconv/types.ha \
@@ -373,6 +386,9 @@ hare_testlib_deps+=$(testlib_os)
testlib_os_exec=$(TESTCACHE)/os/exec/os.exec.o
hare_testlib_deps+=$(testlib_os_exec)
+testlib_sort=$(TESTCACHE)/sort/sort.o
+hare_testlib_deps+=$(testlib_sort)
+
testlib_strconv=$(TESTCACHE)/strconv/strconv.o
hare_testlib_deps+=$(testlib_strconv)
@@ -519,6 +535,17 @@ $(TESTCACHE)/os/exec/os.exec.ssa: $(testlib_os_exec_srcs) $(testlib_rt) $(testli
@HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nos::exec \
-t$(TESTCACHE)/os/exec/os.exec.td $(testlib_os_exec_srcs)
+# sort
+testlib_sort_srcs= \
+ $(STDLIB)/sort/search.ha \
+ $(STDLIB)/sort/+test.ha
+
+$(TESTCACHE)/sort/sort.ssa: $(testlib_sort_srcs) $(testlib_rt)
+ @printf 'HAREC \t$@\n'
+ @mkdir -p $(TESTCACHE)/sort
+ @HARECACHE=$(TESTCACHE) $(HAREC) $(TESTHAREFLAGS) -o $@ -Nsort \
+ -t$(TESTCACHE)/sort/sort.td $(testlib_sort_srcs)
+
# strconv
testlib_strconv_srcs= \
$(STDLIB)/strconv/types.ha \