-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
164 lines (135 loc) · 5.12 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
156
157
158
159
160
161
162
163
164
# Copyright Cartesi and individual authors (see AUTHORS)
# SPDX-License-Identifier: Apache-2.0
#
# 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.
#
MAJOR := 0
MINOR := 16
PATCH := 2
LABEL := -test2
VERSION := $(MAJOR).$(MINOR).$(PATCH)$(LABEL)
TOOLS_DEB := machine-emulator-tools-v$(VERSION).deb
TOOLS_IMAGE := cartesi/machine-emulator-tools:$(VERSION)
TOOLS_ROOTFS := rootfs-tools-v$(VERSION).ext2
TOOLS_ROOTFS_IMAGE := cartesi/rootfs-tools:$(VERSION)
IMAGE_KERNEL_VERSION ?= v0.20.0
LINUX_VERSION ?= 6.5.13-ctsi-1
LINUX_HEADERS_URLPATH := https://github.com/cartesi/image-kernel/releases/download/${IMAGE_KERNEL_VERSION}/linux-libc-dev-riscv64-cross-${LINUX_VERSION}-${IMAGE_KERNEL_VERSION}.deb
all: fs
build: control package.json
@docker buildx build --load \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
--build-arg IMAGE_KERNEL_VERSION=$(IMAGE_KERNEL_VERSION) \
--build-arg LINUX_VERSION=$(LINUX_VERSION) \
--build-arg LINUX_HEADERS_URLPATH=$(LINUX_HEADERS_URLPATH) \
-t $(TOOLS_IMAGE) \
-f Dockerfile \
. ;
$(MAKE) copy
copy:
@ID=`docker create $(TOOLS_IMAGE)` && \
docker cp $$ID:/opt/cartesi/$(TOOLS_DEB) . && \
docker rm $$ID
$(TOOLS_DEB) deb: build
control: Makefile control.in
@sed 's|ARG_VERSION|$(VERSION)|g' control.in > control
package.json: Makefile package.json.in
@sed 's|ARG_VERSION|$(VERSION)|g' package.json.in > package.json
fs: $(TOOLS_ROOTFS)
$(TOOLS_ROOTFS): $(TOOLS_DEB)
@docker buildx build --platform linux/riscv64 \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
--output type=tar,dest=rootfs.tar \
--file fs/Dockerfile \
. && \
xgenext2fs -fzB 4096 -b 25600 -i 4096 -a rootfs.tar -L rootfs $(TOOLS_ROOTFS) && \
rm -f rootfs.tar
fs-license:
@docker buildx build --load --platform linux/riscv64 \
--build-arg TOOLS_DEB=$(TOOLS_DEB) \
-t $(TOOLS_ROOTFS_IMAGE) \
--file fs/Dockerfile \
.
TMPFILE=$$(mktemp) && (cd fs/third-party/repo-info/; ./scan-local.sh $(TOOLS_ROOTFS_IMAGE) linux/riscv64) | tee $$TMPFILE && pandoc -s -f markdown -t html5 -o $(TOOLS_ROOTFS).html $$TMPFILE && rm -f $$TMPFILE
libcmt:
@mkdir $@
build-libcmt:
@docker buildx build --load \
--target libcmt-debian-packager \
--build-arg VERSION=$(VERSION) \
-t $(TOOLS_IMAGE)-libcmt \
-f Dockerfile \
.
$(MAKE) copy-libcmt
copy-libcmt: libcmt
@ID=`docker create $(TOOLS_IMAGE)-libcmt` && \
docker cp $$ID:/opt/cartesi/tools/sys-utils/libcmt/build/deb/ libcmt && \
docker rm $$ID
env:
@echo VERSION=$(VERSION)
@echo TOOLS_DEB=$(TOOLS_DEB)
@echo TOOLS_ROOTFS=$(TOOLS_ROOTFS)
@echo TOOLS_IMAGE=$(TOOLS_IMAGE)
@echo TOOLS_ROOTFS_IMAGE=$(TOOLS_ROOTFS_IMAGE)
@echo IMAGE_KERNEL_VERSION=$(IMAGE_KERNEL_VERSION)
@echo LINUX_VERSION=$(LINUX_VERSION)
@echo LINUX_HEADERS_URLPATH=$(LINUX_HEADERS_URLPATH)
test:
make -C sys-utils/libcmt/ test
cd rollup-http/rollup-http-server && \
MOCK_BUILD=true cargo test -- --show-output --test-threads=1
setup:
@docker run --privileged --rm linuxkit/binfmt:bebbae0c1100ebf7bf2ad4dfb9dfd719cf0ef132
setup-required:
@echo 'riscv64 buildx setup required:' `docker buildx ls | grep -q riscv64 && echo no || echo yes`
build-tools-env:
docker build --target tools-env -t $(TOOLS_IMAGE)-tools-env -f Dockerfile .
build-rust-builder-env:
docker build --target rust-builder -t $(TOOLS_IMAGE)-rust-builder -f Dockerfile .
tools-env:
@docker run --hostname rust-builder -it --rm \
-e USER=$$(id -u -n) \
-e GROUP=$$(id -g -n) \
-e UID=$$(id -u) \
-e GID=$$(id -g) \
-v `pwd`:/opt/cartesi/machine-emulator-tools \
-w /opt/cartesi/machine-emulator-tools \
$(TOOLS_IMAGE)-tools-env /bin/bash
rust-builder-env:
@docker run --hostname rust-builder -it --rm \
-e USER=$$(id -u -n) \
-e GROUP=$$(id -g -n) \
-e UID=$$(id -u) \
-e GID=$$(id -g) \
-v `pwd`:/opt/cartesi/machine-emulator-tools \
-w /opt/cartesi/machine-emulator-tools \
$(TOOLS_IMAGE)-rust-builder /bin/bash
clean-image:
@(docker rmi $(TOOLS_IMAGE) > /dev/null 2>&1 || true)
clean:
@rm -f $(TOOLS_DEB) control rootfs* libcmt*
@$(MAKE) -C sys-utils clean
distclean: clean clean-image
sys-utils:
@$(MAKE) -C sys-utils
help:
@echo 'available commands:'
@echo ' deb - build machine-emulator-tools .deb package'
@echo ' fs - build rootfs.ext2'
@echo ' fs-license - build rootfs.ext2.html with licence information'
@echo ' setup - setup riscv64 buildx'
@echo ' setup-required - check if riscv64 buildx setup is required'
@echo ' help - list makefile commands'
@echo ' env - print useful Makefile variables as a KEY=VALUE list'
@echo ' clean - remove the generated artifacts'
.PHONY: build fs fs-license deb build-libcmt env setup setup-required help distclean