-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
155 lines (118 loc) · 4.84 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Copyright 2019 Cartesi Pte. Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
UNAME:=$(shell uname)
# Containers tags
TOOLCHAIN_TAG ?= 0.2.0
FSDIR := fs
DEPDIR := third-party
SRCDIR := $(abspath src)
DOWNLOADDIR := $(DEPDIR)/downloads
BUILDDIR := build
CONTAINER_BASE := /opt/cartesi/creepts-dapp
CONTAINER_MAKE := /usr/bin/make
RVCC = riscv64-unknown-linux-gnu-gcc
RVCXX = riscv64-unknown-linux-gnu-g++
RVCOPY = riscv64-unknown-linux-gnu-objcopy
RVDUMP = riscv64-unknown-linux-gnu-objdump
RISCV_CFLAGS :=-march=rv64ima -mabi=lp64
DJSDIR = $(DEPDIR)/duktape-2.4.0
DJS = $(DJSDIR)/djs
VIMDIR = $(DEPDIR)/vim-8.1.2069
QJSDIR = $(DEPDIR)/quickjs-2019-12-21
QJS = $(QJSDIR)/qjs
QJSDBG = $(QJSDIR)/qjs-debug
XXDDIR = $(VIMDIR)/src/xxd
XXD = $(XXDDIR)/xxd
FSDIR = fs
DEPDIRS := $(DJSDIR) $(VIMDIR) $(QJSDIR)
all: fs
time-both: fs
time cartesi-machine.lua --batch --fs-backing=creeptsfs.ext2 --cmdline='quiet -- /mnt/fs/bin/qjs --std /mnt/fs/bin/qjs-verifier-bundle.js /mnt/fs/logs/log_short.json 0'
time cartesi-machine.lua --batch --fs-backing=creeptsfs.ext2 --cmdline='quiet -- /mnt/fs/bin/djs /mnt/fs/bin/djs-verifier-bundle.js /mnt/fs/logs/log_short.json 0'
test-qjs: fs
cartesi-machine.lua --batch --fs-backing=creeptsfs.ext2 --cmdline='quiet -- /mnt/fs/bin/qjs --std /mnt/fs/bin/qjs-verifier-bundle.js /mnt/fs/logs/log_short.json 0' | tee in
./qjs --std fs/bin/qjs-verifier-bundle.js fs/logs/log_short.json 0 | tee out
test-djs: fs
cartesi-machine.lua --batch --fs-backing=creeptsfs.ext2 --cmdline='quiet -- /mnt/fs/bin/djs /mnt/fs/bin/djs-verifier-bundle.js /mnt/fs/logs/log_short.json 0' | tee in
./djs fs/bin/djs-verifier-bundle.js fs/logs/log_short.json 0 | tee out
fs: creeptsfs.ext2
#creeptsfs.ext2: $(FSDIR)/bin/qjs $(FSDIR)/bin/qjs-debug $(FSDIR)/bin/djs $(FSDIR)/bin/xxd
creeptsfs.ext2: $(FSDIR)/bin/qjs $(FSDIR)/bin/djs $(FSDIR)/bin/xxd
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) [email protected]"
$(FSDIR)/bin/djs: $(DJS)
cp -f $< $@
$(DJS): $(DEPDIR)/duktape-2.4.0
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) [email protected]"
$(BUILDDIR)/djs: $(DEPDIR)/duktape-2.4.0
mkdir -p $(BUILDDIR)
rm -f $(DJS) && $(MAKE) -C $(DJSDIR) -f Makefile.djs
cp -f $(DJS) $@
djs: $(BUILDDIR)/djs
djs.clean:
rm -f $(BUILDDIR)/djs
$(DJS).toolchain:
$(MAKE) -C $(DJSDIR) -f Makefile.djs CC=$(RVCC)
$(FSDIR)/bin/xxd: $(XXD)
cp -f $< $@
$(FSDIR)/bin/qjs: $(QJS)
cp -f $< $@
$(FSDIR)/bin/qjs-debug: $(QJSDBG)
cp -f $< $@
$(QJS): $(DEPDIR)/quickjs-2019-12-21
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) [email protected]"
$(QJSDBG): $(DEPDIR)/quickjs-2019-12-21 | $(QJS)
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) [email protected]"
$(XXD): $(DEPDIR)/vim-8.1.2069
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) [email protected]"
$(XXD).toolchain:
$(MAKE) -C $(XXDDIR) CC=$(RVCC)
$(QJS).toolchain:
$(MAKE) -C $(QJSDIR) CROSS_PREFIX=riscv64-unknown-linux-gnu- qjs
$(QJSDBG).toolchain:
$(MAKE) -C $(QJSDIR) CROSS_PREFIX=riscv64-unknown-linux-gnu- qjs-debug
creeptsfs.ext2.toolchain:
genext2fs -f -b 40960 -d fs $(basename $@)
truncate -s %4096 $(basename $@)
$(DEPDIR)/vim-8.1.2069: | downloads
tar -xzvf $(DOWNLOADDIR)/v8.1.2069.tar.gz -C $(DEPDIR) vim-8.1.2069/src/xxd
$(DEPDIR)/duktape-2.4.0: | downloads
tar -xJvf $(DOWNLOADDIR)/duktape-2.4.0.tar.xz -C $(DEPDIR)
cd $@ && patch -p1 < ../duktape-2.4.0.patch
$(DEPDIR)/quickjs-2019-12-21: | downloads
tar -xJvf $(DOWNLOADDIR)/quickjs-2019-12-21.tar.xz -C $(DEPDIR)
cd $@ && patch -p1 < ../quickjs-2019-12-21.patch
downloads:
mkdir -p $(DOWNLOADDIR)
wget -nc -i $(DEPDIR)/dependencies -P $(DOWNLOADDIR)
cd $(DEPDIR) && shasum -c shasumfile
toolchain-exec:
@docker run --hostname $@ --rm \
-e USER=$$(id -u -n) \
-e GROUP=$$(id -g -n) \
-e UID=$$(id -u) \
-e GID=$$(id -g) \
-v `pwd`:$(CONTAINER_BASE) \
-w $(CONTAINER_BASE) \
cartesi/toolchain:$(TOOLCHAIN_TAG) $(CONTAINER_COMMAND)
toolchain-env:
@docker run --hostname toolchain-env -it --rm \
-e USER=$$(id -u -n) \
-e GROUP=$$(id -g -n) \
-e UID=$$(id -u) \
-e GID=$$(id -g) \
-v `pwd`:$(CONTAINER_BASE) \
-w $(CONTAINER_BASE) \
cartesi/toolchain:$(TOOLCHAIN_TAG)
clean:
\rm -rf creeptsfs.ext2 $(DJS) $(FSDIR)/bin/djs $(FSDIR)/bin/xxd $(XXD) $(DOWNLOADDIR) $(DEPDIRS) $(BUILDDIR)
.PHONY: toolchain-exec djs build-djs xxd build-xxd clean downloads $(XXD).toolchain $(DJS).toolchain creeptsfs.ext2.toolchain