Skip to content

Commit

Permalink
refactor: remove references to cartesi/toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
edubart committed Oct 22, 2024
1 parent 1ae7f44 commit 73e22ba
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 418 deletions.
2 changes: 1 addition & 1 deletion fs/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Final image
FROM --platform=linux/riscv64 ubuntu:22.04
FROM ubuntu:22.04
ARG TOOLS_DEB=machine-emulator-tools-v0.16.2.deb
ADD ${TOOLS_DEB} /tmp/
RUN apt-get update && \
Expand Down
10 changes: 1 addition & 9 deletions sys-utils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,13 @@


UTILITIES := hex xhalt yield rollup ioctl-echo-loop
UTILITIES_WITH_TOOLCHAIN := $(addsuffix -with-toolchain,$(UTILITIES))

all: $(UTILITIES)

$(UTILITIES):
@$(MAKE) -C $@

with-toolchain:
@$(MAKE) $(UTILITIES_WITH_TOOLCHAIN)

$(UTILITIES_WITH_TOOLCHAIN):
@$(MAKE) -C $@ with-toolchain

clean:
@$(foreach utility,$(UTILITIES),$(MAKE) -C $(utility) clean;)


.PHONY: all with-toolchain $(UTILITIES) $(UTILITIES_WITH_TOOLCHAIN)
.PHONY: all $(UTILITIES)
63 changes: 8 additions & 55 deletions sys-utils/hex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,65 +14,18 @@
# limitations under the License.
#

UNAME:=$(shell uname)
TOOLCHAIN_PREFIX ?= riscv64-linux-gnu-

TOOLCHAIN_IMAGE ?= cartesi/toolchain
TOOLCHAIN_TAG ?= 0.16.0
RISCV_ARCH ?= rv64gc
RISCV_ABI ?= lp64d

TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu-

RVCC = $(TOOLCHAIN_PREFIX)gcc
RVCXX = $(TOOLCHAIN_PREFIX)g++
RVCOPY = $(TOOLCHAIN_PREFIX)objcopy
RVDUMP = $(TOOLCHAIN_PREFIX)objdump
STRIP = $(TOOLCHAIN_PREFIX)strip
RISCV_CFLAGS :=-march=$(RISCV_ARCH) -mabi=$(RISCV_ABI)

CONTAINER_MAKE := /usr/bin/make
CONTAINER_BASE := /opt/cartesi/tools
KERNEL_HEADERS_PATH := /opt/riscv/usr/include
CXX = $(TOOLCHAIN_PREFIX)g++
STRIP = $(TOOLCHAIN_PREFIX)strip
CXXFLAGS = -Wall -Wextra -pedantic -O2 -std=c++20
LDFLAGS =

all: hex

hex.with-toolchain with-toolchain:
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain"

extra.ext2.with-toolchain:
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain"

hex: hex.cpp
$(RVCXX) -O2 -o hex hex.cpp
$(STRIP) hex

extra.ext2: hex
mkdir -m 0755 ./extra
cp ./hex ./extra/hex
xgenext2fs -i 512 -b 8192 -d extra $(basename $@)
rm -rf ./extra

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) \
$(TOOLCHAIN_IMAGE):$(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) \
$(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG)
$(CXX) $(CFLAGS) -o $@ $< $(LDFLAGS)
$(STRIP) $@

clean:
@rm -rf hex extra.ext2 extra

.PHONY: toolchain-exec toolchain-env
@rm -rf hex
41 changes: 0 additions & 41 deletions sys-utils/hex/README.md

This file was deleted.

67 changes: 10 additions & 57 deletions sys-utils/ioctl-echo-loop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,67 +14,20 @@
# limitations under the License.
#

UNAME:=$(shell uname)
TOOLCHAIN_PREFIX ?= riscv64-linux-gnu-
PKG_CONFIG_PATH = /usr/riscv64-linux-gnu/lib/pkgconfig
export PKG_CONFIG_PATH

TOOLCHAIN_IMAGE ?= cartesi/toolchain
TOOLCHAIN_TAG ?= 0.16.0
RISCV_ARCH ?= rv64gc
RISCV_ABI ?= lp64d

TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu-

RVCC = $(TOOLCHAIN_PREFIX)gcc
RVCXX = $(TOOLCHAIN_PREFIX)g++
RVCOPY = $(TOOLCHAIN_PREFIX)objcopy
RVDUMP = $(TOOLCHAIN_PREFIX)objdump
STRIP = $(TOOLCHAIN_PREFIX)strip
CFLAGS +=-Wall -Wextra -pedantic -O2 `pkg-config --cflags libcmt`
LDLIBS += `pkg-config --libs libcmt`

CONTAINER_MAKE := /usr/bin/make
CONTAINER_BASE := /opt/cartesi/tools
KERNEL_HEADERS_PATH := /opt/riscv/usr/include
CC = $(TOOLCHAIN_PREFIX)gcc
STRIP = $(TOOLCHAIN_PREFIX)strip
CFLAGS = -Wall -Wextra -pedantic -O2 `pkg-config --cflags libcmt`
LDFLAGS = `pkg-config --libs libcmt`

all: ioctl-echo-loop

ioctl-echo-loop.with-toolchain with-toolchain:
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain"

extra.ext2.with-toolchain:
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain"

ioctl-echo-loop: export PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig
ioctl-echo-loop: ioctl-echo-loop.c
$(RVCC) $(CFLAGS) -o ioctl-echo-loop ioctl-echo-loop.c $(LDLIBS)
$(STRIP) ioctl-echo-loop

extra.ext2: ioctl-echo-loop
mkdir -m 0755 ./extra
cp ./ioctl-echo-loop ./extra/ioctl-echo-loop
xgenext2fs -i 512 -b 8192 -d extra $(basename $@)
rm -rf ./extra

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) \
$(TOOLCHAIN_IMAGE):$(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) \
$(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG)
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
$(STRIP) $@

clean:
@rm -rf ioctl-echo-loop extra.ext2 extra

.PHONY: toolchain-exec toolchain-env
@rm -f ioctl-echo-loop
67 changes: 10 additions & 57 deletions sys-utils/rollup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,67 +14,20 @@
# limitations under the License.
#

UNAME:=$(shell uname)
TOOLCHAIN_PREFIX ?= riscv64-linux-gnu-
PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig
export PKG_CONFIG_PATH

TOOLCHAIN_IMAGE ?= cartesi/toolchain
TOOLCHAIN_TAG ?= 0.16.0
RISCV_ARCH ?= rv64gc
RISCV_ABI ?= lp64d

TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu-

RVCC = $(TOOLCHAIN_PREFIX)gcc
RVCXX = $(TOOLCHAIN_PREFIX)g++
RVCOPY = $(TOOLCHAIN_PREFIX)objcopy
RVDUMP = $(TOOLCHAIN_PREFIX)objdump
STRIP = $(TOOLCHAIN_PREFIX)strip
CXXFLAGS := -Wall -Wextra -pedantic -O2 -std=c++20 `pkg-config --cflags libcmt`
LDLIBS := `pkg-config --libs libcmt`

CONTAINER_MAKE := /usr/bin/make
CONTAINER_BASE := /opt/cartesi/tools
KERNEL_HEADERS_PATH := /opt/riscv/usr/include
CXX = $(TOOLCHAIN_PREFIX)g++
STRIP = $(TOOLCHAIN_PREFIX)strip
CXXFLAGS = -Wall -Wextra -pedantic -O2 -std=c++20 `pkg-config --cflags libcmt`
LDFLAGS = `pkg-config --libs libcmt`

all: rollup

rollup.with-toolchain with-toolchain:
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain"

extra.ext2.with-toolchain:
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain"

rollup: export PKG_CONFIG_PATH ?= /usr/riscv64-linux-gnu/lib/pkgconfig
rollup: rollup.cpp
$(RVCXX) $(CXXFLAGS) -O2 -o rollup rollup.cpp $(LDLIBS)
$(STRIP) rollup

extra.ext2: rollup
mkdir -m 0755 ./extra
cp ./rollup ./extra/rollup
xgenext2fs -i 512 -b 8192 -d extra $(basename $@)
rm -rf ./extra

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) \
$(TOOLCHAIN_IMAGE):$(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) \
$(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG)
$(CXX) $(CXXFLAGS) -o $@ $< $(LDFLAGS)
$(STRIP) $@

clean:
@rm -rf rollup extra.ext2 extra

.PHONY: toolchain-exec toolchain-env
@rm -f rollup
2 changes: 0 additions & 2 deletions sys-utils/xhalt/.gitignore

This file was deleted.

63 changes: 8 additions & 55 deletions sys-utils/xhalt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,65 +14,18 @@
# limitations under the License.
#

UNAME:=$(shell uname)
TOOLCHAIN_PREFIX ?= riscv64-linux-gnu-

TOOLCHAIN_IMAGE ?= cartesi/toolchain
TOOLCHAIN_TAG ?= 0.16.0
RISCV_ARCH ?= rv64gc
RISCV_ABI ?= lp64d

TOOLCHAIN_PREFIX ?= riscv64-cartesi-linux-gnu-

RVCC = $(TOOLCHAIN_PREFIX)gcc
RVCXX = $(TOOLCHAIN_PREFIX)g++
RVCOPY = $(TOOLCHAIN_PREFIX)objcopy
RVDUMP = $(TOOLCHAIN_PREFIX)objdump
STRIP = $(TOOLCHAIN_PREFIX)strip
RISCV_CFLAGS :=-march=$(RISCV_ARCH) -mabi=$(RISCV_ABI)

CONTAINER_MAKE := /usr/bin/make
CONTAINER_BASE := /opt/cartesi/tools
KERNEL_HEADERS_PATH := /opt/riscv/usr/include
CC = $(TOOLCHAIN_PREFIX)gcc
STRIP = $(TOOLCHAIN_PREFIX)strip
CFLAGS = -Wall -Wextra -pedantic -O2
LDFLAGS =

all: xhalt

xhalt.with-toolchain with-toolchain:
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain"

extra.ext2.with-toolchain:
$(MAKE) toolchain-exec CONTAINER_COMMAND="$(CONTAINER_MAKE) $@.toolchain"

xhalt: xhalt.c
$(RVCC) -O2 -o xhalt xhalt.c
$(STRIP) xhalt

extra.ext2: xhalt
mkdir -m 0755 ./extra
cp ./xhalt ./extra/xhalt
xgenext2fs -i 512 -b 8192 -d extra $(basename $@)
rm -rf ./extra

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) \
$(TOOLCHAIN_IMAGE):$(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) \
$(TOOLCHAIN_IMAGE):$(TOOLCHAIN_TAG)
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
$(STRIP) $@

clean:
@rm -rf xhalt extra.ext2 extra

.PHONY: toolchain-exec toolchain-env
@rm -f xhalt
Loading

0 comments on commit 73e22ba

Please sign in to comment.