Skip to content

Commit

Permalink
feat!: setup temporary build
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed Jan 22, 2024
1 parent 5cac060 commit afdb8d0
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 63 deletions.
112 changes: 56 additions & 56 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
ca-certificates \
git \
wget \
pkg-config \
crossbuild-essential-riscv64 \
gcc-12-riscv64-linux-gnu \
g++-12-riscv64-linux-gnu \
&& \
wget -O ${LINUX_HEADERS_FILEPATH} ${LINUX_HEADERS_URLPATH} && \
echo "efdb2243d9b6828e90c826be0f178110f0cc590cb00e8fa588cb20723126c2a4 ${LINUX_HEADERS_FILEPATH}" | sha256sum --check && \
echo "4ef81562b1d85220bde9fd4ff01d149469a500f22cc319a02c32bfd1c0698ae1 ${LINUX_HEADERS_FILEPATH}" | sha256sum --check && \
apt-get install -y --no-install-recommends ${LINUX_HEADERS_FILEPATH} && \
adduser developer -u 499 --gecos ",,," --disabled-password && \
mkdir -p ${BUILD_BASE}/tools && chown -R developer:developer ${BUILD_BASE}/tools && \
Expand Down Expand Up @@ -80,57 +81,57 @@ RUN make -C ${BUILD_BASE}/tools/sys-utils/libcmt/ -j$(nproc) ioctl.install mock.
USER developer
RUN make -C ${BUILD_BASE}/tools/sys-utils/ -j$(nproc) all

# build rust tools
# ------------------------------------------------------------------------------
FROM tools-env as rust-env
ENV PATH="/home/developer/.cargo/bin:${PATH}"

USER developer

RUN cd && \
wget https://github.com/rust-lang/rustup/archive/refs/tags/1.26.0.tar.gz && \
echo "6f20ff98f2f1dbde6886f8d133fe0d7aed24bc76c670ea1fca18eb33baadd808 1.26.0.tar.gz" | sha256sum --check && \
tar -xzf 1.26.0.tar.gz && \
bash rustup-1.26.0/rustup-init.sh \
-y \
--default-toolchain 1.74.0 \
--profile minimal \
--target riscv64gc-unknown-linux-gnu && \
rm -rf rustup-1.26.0 1.26.0.tar.gz

FROM rust-env as rust-builder
COPY --chown=developer:developer rollup-http/rollup-init ${BUILD_BASE}/tools/rollup-http/rollup-init
COPY --chown=developer:developer rollup-http/rollup-http-client ${BUILD_BASE}/tools/rollup-http/rollup-http-client
COPY --chown=developer:developer rollup-http/.cargo ${BUILD_BASE}/tools/rollup-http/.cargo

# build rollup-http-server dependencies
FROM rust-builder as http-server-dep-builder
COPY --chown=developer:developer rollup-http/rollup-http-server/Cargo.toml rollup-http/rollup-http-server/Cargo.lock ${BUILD_BASE}/tools/rollup-http/rollup-http-server/
RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && \
mkdir src/ && \
echo "fn main() {}" > src/main.rs && \
echo "pub fn dummy() {}" > src/lib.rs && \
cargo build --target riscv64gc-unknown-linux-gnu --release

# build rollup-http-server
FROM http-server-dep-builder as http-server-builder
COPY --chown=developer:developer rollup-http/rollup-http-server/build.rs ${BUILD_BASE}/tools/rollup-http/rollup-http-server/
COPY --chown=developer:developer rollup-http/rollup-http-server/src ${BUILD_BASE}/tools/rollup-http/rollup-http-server/src
RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && touch build.rs src/* && \
cargo build --target riscv64gc-unknown-linux-gnu --release

# build echo-dapp dependencies
FROM rust-builder as echo-dapp-dep-builder
COPY --chown=developer:developer rollup-http/echo-dapp/Cargo.toml rollup-http/echo-dapp/Cargo.lock ${BUILD_BASE}/tools/rollup-http/echo-dapp/
RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && \
mkdir src/ && echo "fn main() {}" > src/main.rs && \
cargo build --target riscv64gc-unknown-linux-gnu --release

# build echo-dapp
FROM echo-dapp-dep-builder as echo-dapp-builder
COPY --chown=developer:developer rollup-http/echo-dapp/src ${BUILD_BASE}/tools/rollup-http/echo-dapp/src
RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && touch src/* && \
cargo build --target riscv64gc-unknown-linux-gnu --release
## build rust tools
## ------------------------------------------------------------------------------
#FROM tools-env as rust-env
#ENV PATH="/home/developer/.cargo/bin:${PATH}"
#
#USER developer
#
#RUN cd && \
# wget https://github.com/rust-lang/rustup/archive/refs/tags/1.26.0.tar.gz && \
# echo "6f20ff98f2f1dbde6886f8d133fe0d7aed24bc76c670ea1fca18eb33baadd808 1.26.0.tar.gz" | sha256sum --check && \
# tar -xzf 1.26.0.tar.gz && \
# bash rustup-1.26.0/rustup-init.sh \
# -y \
# --default-toolchain 1.74.0 \
# --profile minimal \
# --target riscv64gc-unknown-linux-gnu && \
# rm -rf rustup-1.26.0 1.26.0.tar.gz
#
#FROM rust-env as rust-builder
#COPY --chown=developer:developer rollup-http/rollup-init ${BUILD_BASE}/tools/rollup-http/rollup-init
#COPY --chown=developer:developer rollup-http/rollup-http-client ${BUILD_BASE}/tools/rollup-http/rollup-http-client
#COPY --chown=developer:developer rollup-http/.cargo ${BUILD_BASE}/tools/rollup-http/.cargo
#
## build rollup-http-server dependencies
#FROM rust-builder as http-server-dep-builder
#COPY --chown=developer:developer rollup-http/rollup-http-server/Cargo.toml rollup-http/rollup-http-server/Cargo.lock ${BUILD_BASE}/tools/rollup-http/rollup-http-server/
#RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && \
# mkdir src/ && \
# echo "fn main() {}" > src/main.rs && \
# echo "pub fn dummy() {}" > src/lib.rs && \
# cargo build --target riscv64gc-unknown-linux-gnu --release
#
## build rollup-http-server
#FROM http-server-dep-builder as http-server-builder
#COPY --chown=developer:developer rollup-http/rollup-http-server/build.rs ${BUILD_BASE}/tools/rollup-http/rollup-http-server/
#COPY --chown=developer:developer rollup-http/rollup-http-server/src ${BUILD_BASE}/tools/rollup-http/rollup-http-server/src
#RUN cd ${BUILD_BASE}/tools/rollup-http/rollup-http-server && touch build.rs src/* && \
# cargo build --target riscv64gc-unknown-linux-gnu --release
#
## build echo-dapp dependencies
#FROM rust-builder as echo-dapp-dep-builder
#COPY --chown=developer:developer rollup-http/echo-dapp/Cargo.toml rollup-http/echo-dapp/Cargo.lock ${BUILD_BASE}/tools/rollup-http/echo-dapp/
#RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && \
# mkdir src/ && echo "fn main() {}" > src/main.rs && \
# cargo build --target riscv64gc-unknown-linux-gnu --release
#
## build echo-dapp
#FROM echo-dapp-dep-builder as echo-dapp-builder
#COPY --chown=developer:developer rollup-http/echo-dapp/src ${BUILD_BASE}/tools/rollup-http/echo-dapp/src
#RUN cd ${BUILD_BASE}/tools/rollup-http/echo-dapp && touch src/* && \
# cargo build --target riscv64gc-unknown-linux-gnu --release

# pack tools (deb)
# ------------------------------------------------------------------------------
Expand All @@ -149,13 +150,12 @@ COPY control ${STAGING_DEBIAN}/control

COPY --from=builder ${BUILD_BASE}/tools/sys-utils/cartesi-init/cartesi-init ${STAGING_SBIN}
COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/xhalt/xhalt ${STAGING_SBIN}
COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/yield/yield ${STAGING_SBIN}
COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/rollup/rollup ${STAGING_SBIN}
COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/ioctl-echo-loop/ioctl-echo-loop ${STAGING_BIN}
COPY --from=c-builder ${BUILD_BASE}/tools/sys-utils/misc/* ${STAGING_BIN}
COPY --from=rust-builder ${BUILD_BASE}/tools/rollup-http/rollup-init/rollup-init ${STAGING_SBIN}
COPY --from=http-server-builder ${BUILD_BASE}/tools/rollup-http/rollup-http-server/target/riscv64gc-unknown-linux-gnu/release/rollup-http-server ${STAGING_BIN}
COPY --from=echo-dapp-builder ${BUILD_BASE}/tools/rollup-http/echo-dapp/target/riscv64gc-unknown-linux-gnu/release/echo-dapp ${STAGING_BIN}
#COPY --from=rust-builder ${BUILD_BASE}/tools/rollup-http/rollup-init/rollup-init ${STAGING_SBIN}
#COPY --from=http-server-builder ${BUILD_BASE}/tools/rollup-http/rollup-http-server/target/riscv64gc-unknown-linux-gnu/release/rollup-http-server ${STAGING_BIN}
#COPY --from=echo-dapp-builder ${BUILD_BASE}/tools/rollup-http/echo-dapp/target/riscv64gc-unknown-linux-gnu/release/echo-dapp ${STAGING_BIN}

RUN dpkg-deb -Zxz --root-owner-group --build ${STAGING_BASE} ${BUILD_BASE}/${TOOLS_DEB}
COPY --from=c-builder ${BUILD_BASE}/${CMT_TAR_GZ} ${BUILD_BASE}/${CMT_TAR_GZ}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
MAJOR := 0
MINOR := 14
PATCH := 1
LABEL :=
LABEL :=-dev
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
CMT_TAR_GZ := libcmt-$(VERSION).tar.gz

IMAGE_KERNEL_VERSION ?= v0.19.1
IMAGE_KERNEL_VERSION ?= v0.20.0-output-unification-rc1
LINUX_VERSION ?= 6.5.9-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

Expand Down
2 changes: 1 addition & 1 deletion sys-utils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#


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

all: $(UTILITIES)
Expand Down
4 changes: 2 additions & 2 deletions sys-utils/ioctl-echo-loop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ RVCOPY = $(TOOLCHAIN_PREFIX)objcopy
RVDUMP = $(TOOLCHAIN_PREFIX)objdump
STRIP = $(TOOLCHAIN_PREFIX)strip
CFLAGS :=-Wall -Wextra -pedantic -O2 \
`PKG_CONFIG_PATH=$(HOME)/.local/libcmt/lib/pkgconfig pkg-config --cflags libcmt_mock`
`PKG_CONFIG_PATH=/usr/riscv64-linux-gnu/lib/pkgconfig pkg-config --cflags libcmt`
LDLIBS := \
`PKG_CONFIG_PATH=$(HOME)/.local/libcmt/lib/pkgconfig pkg-config --libs libcmt_mock`
`PKG_CONFIG_PATH=/usr/riscv64-linux-gnu/lib/pkgconfig pkg-config --libs libcmt`

CONTAINER_MAKE := /usr/bin/make
CONTAINER_BASE := /opt/cartesi/tools
Expand Down
4 changes: 2 additions & 2 deletions sys-utils/rollup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ RVCOPY = $(TOOLCHAIN_PREFIX)objcopy
RVDUMP = $(TOOLCHAIN_PREFIX)objdump
STRIP = $(TOOLCHAIN_PREFIX)strip
CXXFLAGS :=-Wall -Wextra -pedantic -O2 -std=c++17 \
`PKG_CONFIG_PATH=$(HOME)/dev/libcmt/lib/pkgconfig pkg-config --cflags libcmt_mock`
`PKG_CONFIG_PATH=/usr/riscv64-linux-gnu/lib/pkgconfig pkg-config --cflags libcmt`
LDLIBS := \
`PKG_CONFIG_PATH=$(HOME)/dev/libcmt/lib/pkgconfig pkg-config --libs libcmt_mock`
`PKG_CONFIG_PATH=/usr/riscv64-linux-gnu/lib/pkgconfig pkg-config --libs libcmt`

CONTAINER_MAKE := /usr/bin/make
CONTAINER_BASE := /opt/cartesi/tools
Expand Down

0 comments on commit afdb8d0

Please sign in to comment.