mirror of
https://github.com/samsonjs/lake.git
synced 2026-04-27 14:57:43 +00:00
make it work on linux
This commit is contained in:
parent
ee336f03a5
commit
e2b025bdfc
5 changed files with 20 additions and 18 deletions
6
Makefile
6
Makefile
|
|
@ -1,8 +1,8 @@
|
||||||
all:
|
all:
|
||||||
cd src && make all
|
cd src && make all
|
||||||
|
|
||||||
lake:
|
liblake:
|
||||||
cd src && make lake
|
cd src && make liblake
|
||||||
|
|
||||||
repl:
|
repl:
|
||||||
cd src && make repl
|
cd src && make repl
|
||||||
|
|
@ -12,7 +12,7 @@ clean:
|
||||||
-rm -f lake
|
-rm -f lake
|
||||||
|
|
||||||
test:
|
test:
|
||||||
cd src && make lake
|
cd src && make liblake
|
||||||
cd test && make
|
cd test && make
|
||||||
|
|
||||||
test_clean:
|
test_clean:
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,9 @@ Hooray! That sure is repl-ish.
|
||||||
|
|
||||||
If you want to build a static library:
|
If you want to build a static library:
|
||||||
|
|
||||||
$ make lake
|
$ make liblake
|
||||||
|
|
||||||
The binary will be in `build/lake.a` and you may do with it as you like. Lake creates no global variables and has no shared state. Everything is neatly wrapped up in a [`LakeCtx`](blob/master/src/lake.h#L120-128) so theoretically you can run multiple interpreters in the same process. I haven't tried it yet but it should work.
|
The binary will be in `build/liblake.a` and you may do with it as you like. Lake creates no global variables and has no shared state. Everything is neatly wrapped up in a [`LakeCtx`](blob/master/src/lake.h#L120-128) so theoretically you can run multiple interpreters in the same process. I haven't tried it yet but it should work.
|
||||||
|
|
||||||
Tests
|
Tests
|
||||||
=====
|
=====
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ LAKE_OBJS = $(LAKE_BUILD)/comment.o \
|
||||||
$(LAKE_BUILD)/sym.o \
|
$(LAKE_BUILD)/sym.o \
|
||||||
$(LAKE_BUILD)/symtable.o
|
$(LAKE_BUILD)/symtable.o
|
||||||
|
|
||||||
all: lake repl
|
all: liblake repl
|
||||||
|
|
||||||
repl: $(LAKE_OBJS) $(LAKE_BUILD)/repl.o
|
repl: $(LAKE_OBJS) $(LAKE_BUILD)/repl.o
|
||||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $(LAKE_BUILD)/$@
|
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $(LAKE_BUILD)/$@
|
||||||
|
|
@ -25,7 +25,7 @@ $(LAKE_BUILD)/%.o: %.c
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
lake: $(LAKE_OBJS)
|
liblake: $(LAKE_OBJS)
|
||||||
rm -f $(LAKE_BUILD)/$@.a
|
rm -f $(LAKE_BUILD)/$@.a
|
||||||
ar cq $(LAKE_BUILD)/$@.a $(LAKE_OBJS)
|
ar cq $(LAKE_BUILD)/$@.a $(LAKE_OBJS)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS := -Wall -g -I../src $(shell pkg-config --cflags glib-2.0)
|
CFLAGS := -Wall -g -I../src $(shell pkg-config --cflags glib-2.0)
|
||||||
LFLAGS := $(shell pkg-config --libs glib-2.0)
|
LFLAGS := $(shell pkg-config --libs glib-2.0)
|
||||||
DEPS = laketest.o ../build/lake.a
|
OBJS = ../build/liblake.a
|
||||||
TESTS = test_comment test_dlist test_env test_eval
|
TESTS = test_comment test_dlist test_env test_eval
|
||||||
|
|
||||||
all: $(TESTS)
|
all: $(TESTS)
|
||||||
|
|
@ -13,17 +13,17 @@ all: $(TESTS)
|
||||||
|
|
||||||
test: all
|
test: all
|
||||||
|
|
||||||
test_comment: $(DEPS) test_comment.o
|
test_comment: laketest.o test_comment.o
|
||||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
$(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@
|
||||||
|
|
||||||
test_dlist: $(DEPS) test_dlist.o
|
test_dlist: laketest.o test_dlist.o
|
||||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
$(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@
|
||||||
|
|
||||||
test_env: $(DEPS) test_env.o
|
test_env: laketest.o test_env.o
|
||||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
$(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@
|
||||||
|
|
||||||
test_eval: $(DEPS) test_eval.o
|
test_eval: laketest.o test_eval.o
|
||||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
$(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f *.o $(TESTS)
|
-rm -f *.o $(TESTS)
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,19 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include "laketest.h"
|
#include "laketest.h"
|
||||||
|
|
||||||
static void capture_output(void)
|
static void capture_output(void)
|
||||||
{
|
{
|
||||||
int fd = fopen("./tmp", "w");
|
int fd = open("./tmp", O_WRONLY);
|
||||||
close(2);
|
close(2);
|
||||||
int newfd = dup(fd);
|
int newfd = dup(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
fd = fopen("./tmp", "w");
|
fd = open("./tmp", O_WRONLY);
|
||||||
close(1);
|
close(1);
|
||||||
newfd = dup(fd);
|
newfd = dup(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue