-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (78 loc) · 2.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
PYPY_SOURCE := "b0a257824f6a"
PYPY_EXECUTABLE := $(shell which pypy)
CPYTHON := $(shell which python2)
ifeq ($(CPYTHON),)
CPYTHON = $(shell which python)
endif
ifeq ($(PYPY_EXECUTABLE),)
INTERP := $(CPYTHON)
PYNAME := "CPython"
else
INTERP := $(PYPY_EXECUTABLE)
PYNAME := "PyPy"
endif
# translation is supposed to be faster under pypy
# on Mac/Linux nfs translates faster under CPython
# nfsj translates fastest under PyPy
#------------------------------------------------------------------------------
all:
make test && make nfs
nfs: pypy src
@echo ============================================================
@echo Using CPython: $(CPYTHON)
@echo Invoking RPython toolchain to build executable...
@echo
$(CPYTHON) pypy/rpython/bin/rpython --gc=incminimark --output=nfs goal.py
@echo
@echo "Wrote 'nfs'"
@echo ============================================================
make test-nfs
nfsj: pypy src
@echo ============================================================
@echo Using $(PYNAME): $(INTERP)
@echo Invoking RPython toolchain to build executable WITH JIT...
@echo
$(INTERP) pypy/rpython/bin/rpython --gc=incminimark --output=nfsj --translation-jit goal.py
# -Ojit --jit-backend=x86 --translation-jit goal.py
@echo "Wrote 'nfsj'"
@echo ============================================================
src: pypy \
nefarious/lex.py \
nefarious/types.py \
nefarious/parser.py \
nefarious/values.py \
nefarious/tree.py \
nefarious/builtins.py \
nefarious/grammar.py
.TODO:
#@rem --cc=afl-clang
nfs-interp:
$(INTERP) -m nefarious bar.txt
test:
@echo Running tests \(using $(CPYTHON)\)...
$(INTERP) -m unittest --buffer tests
@echo Tests passed!
test-pypy:
@echo Running tests \(force PyPy\)...
$(PYPY_EXECUTABLE) -m unittest --buffer tests
test-nfs:
@echo Testing compiled binary...
$(INTERP) -m unittest --buffer tests.compiled
# RPython toolchain is required to build nfs executable.
pypy.zip:
@echo Downloading PyPy source `default` at $(PYPY_SOURCE)...
curl -L "https://bitbucket.org/pypy/pypy/get/$(PYPY_SOURCE).zip" > pypy.zip
pypy: pypy.zip
@echo Unzipping PyPy...
rm -rf pypy
unzip -qn pypy.zip
mv pypy-pypy-$(PYPY_SOURCE) pypy
touch pypy
clean:
rm nfs || echo
rm nfsj || echo
reallyclean: clean
rm pypy.zip || echo
rm -r pypy/ || echo
#------------------------------------------------------------------------------
.PHONY: all nfs-interp test test-nfs clean reallyclean src