~tim/malcc

7f9ab03b3cf069248a2beed0b5aaf39a92e73de3 — Tim Morgan 5 years ago ae8bc2c
Allow building without editline

I couldn't get multibyte characters to work in Ubuntu with editline. So
I'm just disabling it for the tests.
7 files changed, 53 insertions(+), 6 deletions(-)

M .build.yml
M Dockerfile
M Makefile
M malcc.c
A readline.c
A readline.h
R tests/{unicode.mal => utf-8.mal}
M .build.yml => .build.yml +1 -1
@@ 10,7 10,7 @@ sources:
tasks:
  - build: |
      cd malcc
      make all
      make -e CEXTRAFLAGS='-DNOEDITLINE' all
  - test: |
      cd malcc
      make test

M Dockerfile => Dockerfile +4 -0
@@ 18,6 18,10 @@ RUN cd /tmp && \
    ./configure && \
    make install

ENV LANG C.UTF-8
ENV LC_CTYPE C.UTF-8
ENV LC_ALL C.UTF-8

WORKDIR /malcc

CMD ["bash"]

M Makefile => Makefile +7 -4
@@ 1,6 1,6 @@
OS:=$(shell uname)
CC=gcc
CFLAGS=-Itinycc -Wall -Wextra -Werror -g
CFLAGS=-Itinycc -Wall -Wextra -Werror -g $(CEXTRAFLAGS)
LDLIBS=-ledit -lgc -lpcre -ldl

ALL_STEPS=step0_repl step1_read_print step2_eval step3_env step4_if_fn_do step5_tco step6_file step7_quote step8_macros step9_try stepA_mal malcc


@@ 20,7 20,7 @@ step7_quote: step7_quote.o core.o env.o hashmap.o printer.o reader.o types.o uti
step8_macros: step8_macros.o core.o env.o hashmap.o printer.o reader.o types.o util.o tinycc/libtcc.a
step9_try: step9_try.o core.o env.o hashmap.o printer.o reader.o types.o util.o tinycc/libtcc.a
stepA_mal: stepA_mal.o core.o env.o hashmap.o printer.o reader.o types.o util.o tinycc/libtcc.a
malcc: malcc.o core.o env.o hashmap.o printer.o reader.o types.o util.o tinycc/libtcc.a
malcc: malcc.o core.o env.o hashmap.o printer.o reader.o readline.o types.o util.o tinycc/libtcc.a

tinycc/libtcc.a:
	cd tinycc && ./configure && make


@@ 98,7 98,7 @@ test-self-hosted: all
	$(RUN_TEST_CMD) --test-timeout 30 stepA_mal.mal ../../self_hosted_run

test-supplemental: all
	$(RUN_TEST_CMD) --test-timeout 30 ../../tests/unicode.mal ../../malcc
	$(RUN_TEST_CMD) --test-timeout 30 ../../tests/utf-8.mal ../../malcc

perf: all
	cd mal/tests && ../../malcc perf1.mal && ../../malcc perf2.mal && ../../malcc perf3.mal


@@ 115,7 115,10 @@ docker-bash: docker-build
	$(RUN_DOCKER_CMD) bash

docker-test: docker-build
	$(RUN_DOCKER_CMD) make test
	$(RUN_DOCKER_CMD) make -e CEXTRAFLAGS='-DNOEDITLINE' test

docker-test-supplemental: docker-build
	$(RUN_DOCKER_CMD) make -e CEXTRAFLAGS='-DNOEDITLINE' test-supplemental

docker-watch: docker-build
	$(RUN_DOCKER_CMD) bash -c "ls *.c *.h Makefile | entr -c -s 'make test'"

M malcc.c => malcc.c +1 -1
@@ 1,5 1,4 @@
#include <assert.h>
#include <editline/readline.h>
#include <gc.h>
#include <stdio.h>
#include <stdlib.h>


@@ 11,6 10,7 @@
#include "env.h"
#include "printer.h"
#include "reader.h"
#include "readline.h"
#include "util.h"

char program_template[] =

A readline.c => readline.c +31 -0
@@ 0,0 1,31 @@
#include <stdio.h>
#include <stdlib.h>

#ifdef NOEDITLINE

char* readline(const char *prompt) {
  char* input = malloc(1000);
  printf("%s", prompt);
  return fgets(input, 1000, stdin);
}

int read_history(const char *filename) {
  (void)filename;
  return 1;
}

int add_history(const char *input) {
  (void)input;
  return 1;
}

int write_history(const char *filename) {
  (void)filename;
  return 1;
}

#else

#include <editline/readline.h>

#endif

A readline.h => readline.h +9 -0
@@ 0,0 1,9 @@
#ifndef __MAL_READLINE__
#define __MAL_READLINE__

char* readline(const char *prompt);
int read_history(const char *filename);
int add_history(const char *input);
int write_history(const char *filename);

#endif

R tests/unicode.mal => tests/utf-8.mal +0 -0