diff --git a/lib/colors.dst b/lib/colors.dst new file mode 100644 index 00000000..23bf9c2d --- /dev/null +++ b/lib/colors.dst @@ -0,0 +1,41 @@ +# Ansi terminal colors + +(def- colormap + {:black 30 + :bg-black 40 + :red 31 + :bg-red 41 + :green 32 + :bg-green 42 + :yellow 33 + :bg-yellow 43 + :blue 34 + :bg-blue 44 + :magenta 35 + :bg-magenta 45 + :cyan 36 + :bg-cyan 46 + :white 37 + :bg-white 47 + + :bright-black 90 + :bg-bright-black 100 + :bright-red 91 + :bg-bright-red 101 + :bright-green 92 + :bg-bright-green 102 + :bright-yellow 93 + :bg-bright-yellow 103 + :bright-blue 94 + :bg-bright-blue 104 + :bright-magenta 95 + :bg-bright-magenta 105 + :bright-cyan 96 + :bg-bright-cyan 106 + :bright-white 97 + :bg-bright-white 107}) + +(loop [[name color] :in (pairs colormap)] + (defglobal (string.slice name 1) + (fn color-wrapper [& pieces] + (string "\e[" color "m" (apply1 string pieces) "\e[0m")))) diff --git a/lib/metabuild.dst b/lib/metabuild.dst index 5087bee0..1296801f 100644 --- a/lib/metabuild.dst +++ b/lib/metabuild.dst @@ -46,6 +46,7 @@ (emit-rule out "%.o" @["%.c" "${HEADERS}"] "${CC} ${CFLAGS} -o $@ $< ${LDFLAGS}") (emit-rule out "${TARGET}" "${OBJECTS}" "${CC} ${CFLAGS} -o $@ $^ ${LDFLAGS}") (emit-rule out "clean" "" "rm ${OBJECTS}") + (emit-rule out "clean" "" @["rm ${OBJECTS}" "rm @{TARGET}"]) # Phony targets (emit-rule out ".PHONY" @["all" "clean"]) nil) diff --git a/natives/hello/Makefile b/natives/hello/Makefile index 6805ac42..1261ba2b 100644 --- a/natives/hello/Makefile +++ b/natives/hello/Makefile @@ -1,37 +1,24 @@ -# Copyright (c) 2018 Calvin Rose -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. +# Autogenerated Makefile, do not edit +# Generated at Fri Aug 3 22:55:50 EDT 2018 -CFLAGS=-std=c99 -Wall -Wextra -I../../src/include -O2 -TARGET=hello.so +CFLAGS:=-std=c99 -Wall -Wextra -O2 -shared -fpic +LDFLAGS:= +SOURCES:=main.c +HEADERS:= +OBJECTS:=$(patsubst %.c,%.o,${SOURCES}) +TARGET:=hello.so -UNAME:=$(shell uname -s) -ifeq ($(UNAME), Darwin) - CFLAGS:=$(CFLAGS) -undefined dynamic_lookup -endif +all: ${TARGET} -SOURCES=main.c +%.o: %.c ${HEADERS} + ${CC} ${CFLAGS} -o $@ -c $< ${LDFLAGS} -$(TARGET): $(SOURCES) - $(CC) $(CFLAGS) -shared -fpic -o $@ $< +${TARGET}: ${OBJECTS} + ${CC} ${CFLAGS} -o $@ $^ ${LDFLAGS} -clean: - rm $(TARGET) +clean: + rm ${OBJECTS} + rm ${TARGET} + +.PHONY: all clean -.PHONY: clean diff --git a/natives/hello/metab.dst b/natives/hello/metab.dst new file mode 100755 index 00000000..eadb80c8 --- /dev/null +++ b/natives/hello/metab.dst @@ -0,0 +1,5 @@ +#!/usr/bin/env dst + +(import metabuild :as mb) + +(mb.generate "hello" @["main.c"])