mirror of
https://github.com/samsonjs/lake.git
synced 2026-03-25 08:55:49 +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:
|
||||
cd src && make all
|
||||
|
||||
lake:
|
||||
cd src && make lake
|
||||
liblake:
|
||||
cd src && make liblake
|
||||
|
||||
repl:
|
||||
cd src && make repl
|
||||
|
|
@ -12,7 +12,7 @@ clean:
|
|||
-rm -f lake
|
||||
|
||||
test:
|
||||
cd src && make lake
|
||||
cd src && make liblake
|
||||
cd test && make
|
||||
|
||||
test_clean:
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ Hooray! That sure is repl-ish.
|
|||
|
||||
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
|
||||
=====
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ LAKE_OBJS = $(LAKE_BUILD)/comment.o \
|
|||
$(LAKE_BUILD)/sym.o \
|
||||
$(LAKE_BUILD)/symtable.o
|
||||
|
||||
all: lake repl
|
||||
all: liblake repl
|
||||
|
||||
repl: $(LAKE_OBJS) $(LAKE_BUILD)/repl.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $(LAKE_BUILD)/$@
|
||||
|
|
@ -25,7 +25,7 @@ $(LAKE_BUILD)/%.o: %.c
|
|||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
lake: $(LAKE_OBJS)
|
||||
liblake: $(LAKE_OBJS)
|
||||
rm -f $(LAKE_BUILD)/$@.a
|
||||
ar cq $(LAKE_BUILD)/$@.a $(LAKE_OBJS)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
CC = gcc
|
||||
CFLAGS := -Wall -g -I../src $(shell pkg-config --cflags 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
|
||||
|
||||
all: $(TESTS)
|
||||
|
|
@ -13,17 +13,17 @@ all: $(TESTS)
|
|||
|
||||
test: all
|
||||
|
||||
test_comment: $(DEPS) test_comment.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
||||
test_comment: laketest.o test_comment.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@
|
||||
|
||||
test_dlist: $(DEPS) test_dlist.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
||||
test_dlist: laketest.o test_dlist.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@
|
||||
|
||||
test_env: $(DEPS) test_env.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
||||
test_env: laketest.o test_env.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@
|
||||
|
||||
test_eval: $(DEPS) test_eval.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ -o $@
|
||||
test_eval: laketest.o test_eval.o
|
||||
$(CC) $(CFLAGS) $(LFLAGS) $^ $(OBJS) -o $@
|
||||
|
||||
clean:
|
||||
-rm -f *.o $(TESTS)
|
||||
|
|
|
|||
|
|
@ -9,17 +9,19 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "laketest.h"
|
||||
|
||||
static void capture_output(void)
|
||||
{
|
||||
int fd = fopen("./tmp", "w");
|
||||
int fd = open("./tmp", O_WRONLY);
|
||||
close(2);
|
||||
int newfd = dup(fd);
|
||||
close(fd);
|
||||
|
||||
fd = fopen("./tmp", "w");
|
||||
fd = open("./tmp", O_WRONLY);
|
||||
close(1);
|
||||
newfd = dup(fd);
|
||||
close(fd);
|
||||
|
|
|
|||
Loading…
Reference in a new issue