mirror of
https://github.com/janet-lang/janet
synced 2025-02-22 03:00:02 +00:00
Bundle more dst code (sans method of installation)
This commit is contained in:
parent
7e66b37cff
commit
094d3c01e8
41
lib/colors.dst
Normal file
41
lib/colors.dst
Normal file
@ -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"))))
|
@ -44,8 +44,8 @@
|
||||
"\n\n")
|
||||
(emit-rule out "all" "${TARGET}")
|
||||
(emit-rule out "%.o" @["%.c" "${HEADERS}"] "${CC} ${CFLAGS} -o $@ $< ${LDFLAGS}")
|
||||
(emit-rule out "${TARGET}" "${SOURCES}" "${CC} ${CFLAGS} -o $@ $^ ${LDFLAGS}")
|
||||
(emit-rule out "clean" "" "rm ${OBJECTS}")
|
||||
(emit-rule out "${TARGET}" "${OBJECTS}" "${CC} ${CFLAGS} -o $@ $^ ${LDFLAGS}")
|
||||
(emit-rule out "clean" "" @["rm ${OBJECTS}" "rm @{TARGET}"])
|
||||
# Phony targets
|
||||
(emit-rule out ".PHONY" @["all" "clean"])
|
||||
nil)
|
@ -1,34 +0,0 @@
|
||||
# Copyright (c) 2017 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(hello)
|
||||
|
||||
# Set Some Variables
|
||||
set(TARGET_NAME "hello")
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
|
||||
set(SOURCES main.c)
|
||||
|
||||
include_directories(../../src/include)
|
||||
|
||||
# Build the module
|
||||
add_library(${TARGET_NAME} SHARED ${SOURCES})
|
@ -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
|
||||
|
5
natives/hello/metab.dst
Executable file
5
natives/hello/metab.dst
Executable file
@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env dst
|
||||
|
||||
(import metabuild :as mb)
|
||||
|
||||
(mb.generate "hello" @["main.c"])
|
@ -1131,26 +1131,27 @@
|
||||
(run-context *env* chunks (fn [x] (:= returnval x)) default-error-handler "eval")
|
||||
returnval)
|
||||
|
||||
(do
|
||||
(def syspath (or (os.getenv "DST_PATH") "/usr/local/lib/dst/"))
|
||||
(defglobal 'module.paths
|
||||
@["./?.dst"
|
||||
"./?/init.dst"
|
||||
"./dst_modules/?.dst"
|
||||
"./dst_modules/?/init.dst"
|
||||
(string syspath VERSION "/?.dst")
|
||||
(string syspath VERSION "/?/init.dst")
|
||||
(string syspath "/?.dst")
|
||||
(string syspath "/?/init.dst")])
|
||||
(defglobal 'module.native-paths
|
||||
@["./?.so"
|
||||
"./?/??.so"
|
||||
"./dst_modules/?.so"
|
||||
"./dst_modules/?/??.so"
|
||||
(string syspath VERSION "/?.so")
|
||||
(string syspath VERSION "/?/??.so")
|
||||
(string syspath "/?.so")
|
||||
(string syspath "/?/??.so")]))
|
||||
(def module.syspath (or (os.getenv "DST_PATH") "/usr/local/lib/dst/"))
|
||||
|
||||
(def module.paths
|
||||
@["./?.dst"
|
||||
"./?/init.dst"
|
||||
"./dst_modules/?.dst"
|
||||
"./dst_modules/?/init.dst"
|
||||
(string module.syspath VERSION "/?.dst")
|
||||
(string module.syspath VERSION "/?/init.dst")
|
||||
(string module.syspath "/?.dst")
|
||||
(string module.syspath "/?/init.dst")])
|
||||
|
||||
(def module.native-paths
|
||||
@["./?.so"
|
||||
"./?/??.so"
|
||||
"./dst_modules/?.so"
|
||||
"./dst_modules/?/??.so"
|
||||
(string module.syspath VERSION "/?.so")
|
||||
(string module.syspath VERSION "/?/??.so")
|
||||
(string module.syspath "/?.so")
|
||||
(string module.syspath "/?/??.so")])
|
||||
|
||||
(defn module.find
|
||||
[path paths]
|
||||
|
Loading…
x
Reference in New Issue
Block a user