-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mock: components can be compiled natively: 1. make mock tests ioctl: require the cartesi headers and a riscv compiler: 1. Build or download a compatible kernel and `.deb` headers 2. Setup a cross compilation debian environment by running the setup[1] script. 3. `make ioctl CROSS_COMPILE=riscv64-linux-gnu-` [1] setup.sh ``` apt update && \ DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends --allow-downgrades -y \ bc \ bison \ build-essential \ flex \ genext2fs \ rsync \ gcc-riscv64-linux-gnu \ libc6-dev-riscv64-cross \ ./linux-libc-dev-riscv64-cross-6.5.9-ctsi-1-v0.0.0.deb ```
- Loading branch information
Showing
42 changed files
with
5,930 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
# paths | ||
PREFIX = /usr | ||
TARGET_PREFIX ?= $(PREFIX) | ||
|
||
TARGET_CC := $(CROSS_COMPILE)gcc | ||
TARGET_AR := $(CROSS_COMPILE)ar | ||
TARGET_CFLAGS := -O2 -g -Wall -pedantic -Wextra -Iinclude -Iinclude/libcmt/ioctl | ||
CFLAGS := -O2 -g -Wall -pedantic -Wextra -fsanitize=address,undefined -Iinclude -Iinclude/libcmt/mock | ||
|
||
mock_BINS := build/libcmt_mock/yield-driver \ | ||
build/libcmt_mock/rollup-driver \ | ||
build/libcmt_mock/rollup \ | ||
|
||
ioctl_BINS := build/libcmt/yield-driver \ | ||
build/libcmt/rollup-driver \ | ||
build/libcmt/rollup libcmt.a | ||
|
||
tests_BINS := build/libcmt_mock/abi \ | ||
build/libcmt_mock/keccak \ | ||
build/libcmt_mock/merkle | ||
|
||
tools_BINS := tools/funsel \ | ||
tools/merkle-table | ||
|
||
all: mock.build ioctl.build tools.build examples.build | ||
help: | ||
@echo "Cleaning targets: (default: '*')" | ||
@echo " clean - remove the binaries and objects." | ||
@echo "* mock.build - build the reference mock library and examples for running in host mode." | ||
@echo " mock.install - install the reference mock library." | ||
@echo "* ioctl.build - build the riscv ioctl library and examples." | ||
@echo " (needs the cartesi linux headers. accepts the 'CROSS_COMPILE=' variable)" | ||
@echo " ioctl.install - install the riscv ioctl library." | ||
@echo " tests.build - build host mode tests." | ||
@echo " tests.run - run host mode tests." | ||
@echo "* tools.build - development tools and utilities." | ||
@echo " doc.build - build the doxygen documentation." | ||
@echo " examples.build - build the documentation code." | ||
|
||
base_SRC := \ | ||
src/buf.c \ | ||
src/abi.c \ | ||
src/keccak.c \ | ||
src/merkle.c \ | ||
src/rollup.c \ | ||
src/merkle-table.c | ||
|
||
libcmt_mock_SRC := \ | ||
src/mock/rollup-driver.c \ | ||
src/mock/yield-driver.c \ | ||
$(base_SRC) | ||
|
||
libcmt_SRC := \ | ||
src/ioctl/rollup-driver.c \ | ||
src/ioctl/yield-driver.c \ | ||
$(base_SRC) | ||
|
||
examples_SRC := \ | ||
examples/abi_decode_000.c \ | ||
examples/abi_decode_001.c \ | ||
examples/abi_encode_000.c \ | ||
examples/abi_encode_001.c \ | ||
examples/abi_encode_002.c \ | ||
examples/abi_get.c \ | ||
examples/abi_multi.c \ | ||
examples/rollup-driver.c \ | ||
examples/rollup.c \ | ||
examples/yield-driver.c | ||
|
||
libcmt_mock_OBJDIR := build/libcmt_mock/ | ||
libcmt_OBJDIR := build/libcmt/ | ||
examples_OBJDIR := build/examples/ | ||
|
||
libcmt_mock_OBJ := $(patsubst %.c,$(libcmt_mock_OBJDIR)%.o,$(libcmt_mock_SRC)) | ||
libcmt_OBJ := $(patsubst %.c,$(libcmt_OBJDIR)%.o,$(libcmt_SRC)) | ||
examples_OBJ := $(patsubst %.c,$(examples_OBJDIR)%.o,$(examples_SRC)) | ||
|
||
OBJ := $(libcmt_mock_OBJ) $(libcmt_OBJ) $(examples_OBJ) | ||
|
||
mock.build: libcmt_mock.a $(mock_BINS) | ||
ioctl.build: libcmt.a $(ioctl_BINS) | ||
tests.build: $(tests_BINS) | ||
tools.build: $(tools_BINS) | ||
tests.run: tests.build | ||
$(foreach test,$(tests_BINS),$(test) &&) true | ||
examples.build: $(examples_OBJ) | ||
|
||
$(libcmt_mock_OBJ): $(libcmt_mock_OBJDIR)%.o: %.c | ||
@mkdir -p $(@D) | ||
$(CC) $(CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d) -c -o $@ $< | ||
|
||
$(libcmt_OBJ): $(libcmt_OBJDIR)%.o: %.c | ||
@mkdir -p $(@D) | ||
$(TARGET_CC) $(TARGET_CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d) -c -o $@ $< | ||
|
||
$(examples_OBJ): $(examples_OBJDIR)%.o: %.c | ||
@mkdir -p $(@D) | ||
$(CC) $(CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d) -c -o $@ $< | ||
|
||
libcmt_mock.a: $(libcmt_mock_OBJ) | ||
$(AR) rcs $@ $^ | ||
|
||
libcmt.a: $(libcmt_OBJ) | ||
$(TARGET_AR) rcs $@ $^ | ||
|
||
build/libcmt/yield-driver: examples/yield-driver.c libcmt.a | ||
$(TARGET_CC) $(TARGET_CFLAGS) -o $@ $^ | ||
build/libcmt/rollup-driver: examples/rollup-driver.c libcmt.a | ||
$(TARGET_CC) $(TARGET_CFLAGS) -o $@ $^ | ||
build/libcmt/rollup: examples/rollup.c libcmt.a | ||
$(TARGET_CC) $(TARGET_CFLAGS) -o $@ $^ | ||
|
||
build/libcmt_mock/yield-driver: examples/yield-driver.c libcmt_mock.a | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
build/libcmt_mock/rollup-driver: examples/rollup-driver.c libcmt_mock.a | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
build/libcmt_mock/rollup: examples/rollup.c libcmt_mock.a | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
|
||
build/libcmt_mock/abi: tests/abi.c libcmt_mock.a | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
build/libcmt_mock/keccak: tests/keccak.c libcmt_mock.a | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
build/libcmt_mock/merkle: tests/merkle.c libcmt_mock.a | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
|
||
src/merkle.c: src/merkle-table.c | ||
src/merkle-table.c: tools/merkle-table | ||
$< > $@ | ||
|
||
tools/merkle-table: tools/merkle-table.c src/keccak.c | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
tools/funsel: tools/funsel.c src/keccak.c | ||
$(CC) $(CFLAGS) -o $@ $^ | ||
|
||
doc/theme: | ||
git clone --depth=1 --branch=v2.2.1 \ | ||
[email protected]:jothepro/doxygen-awesome-css.git $@ | ||
|
||
doc.build: doc/theme | ||
doxygen doc/Doxyfile | ||
|
||
ioctl.install: libcmt.a | ||
mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib | ||
cp -f $< $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib | ||
mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ | ||
cp -f include/libcmt/*.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ | ||
cp -f include/libcmt/ioctl/*.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ | ||
mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig | ||
sed 's|ARG_PREFIX|$(TARGET_PREFIX)|g' tools/templates/libcmt.pc \ | ||
> $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig/libcmt.pc | ||
|
||
mock.install: libcmt_mock.a | ||
mkdir -p $(DESTDIR)$(PREFIX)/lib | ||
cp -f $< $(DESTDIR)$(PREFIX)/lib | ||
mkdir -p $(DESTDIR)$(PREFIX)/include/libcmt/mock | ||
cp -f include/libcmt/*.h $(DESTDIR)$(PREFIX)/include/libcmt/ | ||
cp -f include/libcmt/mock/*.h $(DESTDIR)$(PREFIX)/include/libcmt/mock/ | ||
mkdir -p $(DESTDIR)$(PREFIX)/lib/pkgconfig | ||
sed 's|ARG_PREFIX|$(PREFIX)|g' tools/templates/libcmt_mock.pc \ | ||
> $(DESTDIR)$(PREFIX)/lib/pkgconfig/libcmt_mock.pc | ||
|
||
doc.install: doc.build | ||
mkdir -p $(DESTDIR)$(PREFIX)/share/libcmt/html | ||
cp -f doc/html $(DESTDIR)$(PREFIX)/share/libcmt/html | ||
|
||
clean: | ||
rm -f $(mock_BINS) $(ioctl_BINS) $(tests_BINS) $(tools_BINS) $(OBJ) $(OBJ:%.o=%.d) | ||
rm -rf doc/html | ||
distclean: | ||
rm -rf doc/theme | ||
.PHONY: examples.build doc | ||
|
||
-include $(OBJ:%.o=%.d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
High level rollup API | ||
|
||
- @ref libcmt\_rollup | ||
|
||
Utility functions for rollup interaction. | ||
|
||
- @ref libcmt\_abi | ||
- @ref libcmt\_buf | ||
- @ref libcmt\_keccak | ||
- @ref libcmt\_merkle | ||
|
||
Thin wrappers to the cartesi kernel drivers | ||
|
||
- @ref rollup\_driver | ||
- @ref yield\_driver | ||
|
||
# Getting Started | ||
|
||
Download the static library from [cartesi tools](https://github.com/cartesi/machine-emulator-tools/). |
Oops, something went wrong.