diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fca4ef22..6d7d455f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,7 +86,7 @@ jobs: with: path: ${{ env.TOOLS_ROOTFS }} - - name: Build [${{ env.TOOLS_LIBCMT }}] + - name: Build [${{ env.TOOLS_LIBCMT }}, ${{ env.TOOLS_LIBCMT_DEV }}] id: docker_build_libcmt uses: docker/build-push-action@v4 with: @@ -98,16 +98,19 @@ jobs: target: libcmt-debian-packager build-args: | TOOLS_LIBCMT=${{ env.TOOLS_LIBCMT }} + TOOLS_LIBCMT_DEV=${{ env.TOOLS_LIBCMT_DEV }} cache-from: type=gha,scope=regular,mode=max cache-to: type=gha,scope=regular - name: Retrieve artifacts run: make copy-libcmt - - name: Upload [${{ env.TOOLS_LIBCMT }}] + - name: Upload [${{ env.TOOLS_LIBCMT }}, ${{ env.TOOLS_LIBCMT_DEV }}] uses: actions/upload-artifact@v3 with: - path: ${{ env.TOOLS_LIBCMT }} + path: + ${{ env.TOOLS_LIBCMT }} + ${{ env.TOOLS_LIBCMT_DEV }} - name: Checksum artifacts if: startsWith(github.ref, 'refs/tags/v') @@ -115,6 +118,7 @@ jobs: sha512sum ${{ env.TOOLS_DEB }} > ${{ env.TOOLS_DEB }}.sha512 sha512sum ${{ env.TOOLS_ROOTFS }} > ${{ env.TOOLS_ROOTFS }}.sha512 sha512sum ${{ env.TOOLS_LIBCMT }} > ${{ env.TOOLS_LIBCMT }}.sha512 + sha512sum ${{ env.TOOLS_LIBCMT_DEV }} > ${{ env.TOOLS_LIBCMT_DEV }}.sha512 - uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/v') @@ -127,6 +131,8 @@ jobs: ${{ env.TOOLS_ROOTFS }}.sha512 ${{ env.TOOLS_LIBCMT }} ${{ env.TOOLS_LIBCMT }}.sha512 + ${{ env.TOOLS_LIBCMT_DEV }} + ${{ env.TOOLS_LIBCMT_DEV }}.sha512 test: runs-on: ubuntu-latest-8-cores diff --git a/Dockerfile b/Dockerfile index 0bf25de0..37a586fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,19 +76,24 @@ ARG BUILD_BASE=/opt/cartesi USER developer RUN make -C ${CMT_BASE} -j$(nproc) libcmt USER root -RUN make -C ${BUILD_BASE}/tools/sys-utils/libcmt/ -j$(nproc) install TARGET_PREFIX=/usr/riscv64-linux-gnu +RUN make -C ${BUILD_BASE}/tools/sys-utils/libcmt/ -j$(nproc) install-dev TARGET_PREFIX=/usr/riscv64-linux-gnu USER developer RUN make -C ${BUILD_BASE}/tools/sys-utils/ -j$(nproc) all -# build libcmt debian package +# build libcmt and libcmt-dev debian packages # ------------------------------------------------------------------------------ FROM c-builder as libcmt-debian-packager ARG CMT_BASE=${BUILD_BASE}/tools/sys-utils/libcmt ARG TOOLS_LIBCMT=libcmt.deb +ARG TOOLS_LIBCMT_DEV=libcmt-dev.deb USER root -RUN make -C ${CMT_BASE} debian-package \ - TARGET_DESTDIR=${BUILD_BASE}/_install \ +RUN make -C ${CMT_BASE} install-dev debian-dev-package \ + TARGET_DESTDIR=${BUILD_BASE}/_install-dev \ TARGET_PREFIX=/usr/riscv64-linux-gnu \ + LIBCMT_DEB_FILENAME=${BUILD_BASE}/${TOOLS_LIBCMT_DEV} +RUN make -C ${CMT_BASE} install debian-package \ + TARGET_DESTDIR=${BUILD_BASE}/_install-run \ + TARGET_PREFIX=/usr/ \ LIBCMT_DEB_FILENAME=${BUILD_BASE}/${TOOLS_LIBCMT} # build rust tools diff --git a/Makefile b/Makefile index 50645b0d..3cf7adcd 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,11 @@ PATCH := 0 LABEL := 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_LIBCMT := libcmt-v$(VERSION)-dev.deb +TOOLS_DEB := machine-emulator-tools-v$(VERSION).deb +TOOLS_IMAGE := cartesi/machine-emulator-tools:$(VERSION) +TOOLS_ROOTFS := rootfs-tools-v$(VERSION).ext2 +TOOLS_LIBCMT := libcmt-v$(VERSION).deb +TOOLS_LIBCMT_DEV := libcmt-v$(VERSION)-dev.deb IMAGE_KERNEL_VERSION ?= v0.20.0 LINUX_VERSION ?= 6.5.13-ctsi-1 @@ -63,10 +64,11 @@ $(TOOLS_ROOTFS) fs: $(TOOLS_DEB) xgenext2fs -fzB 4096 -b 25600 -i 4096 -a rootfs.tar -L rootfs $(TOOLS_ROOTFS) && \ rm -f rootfs.tar -$(TOOLS_LIBCMT) libcmt: +$(TOOLS_LIBCMT) $(TOOLS_LIBCMT_DEV) libcmt: @docker buildx build --load \ --target libcmt-debian-packager \ --build-arg TOOLS_LIBCMT=$(TOOLS_LIBCMT) \ + --build-arg TOOLS_LIBCMT_DEV=$(TOOLS_LIBCMT_DEV) \ -t $(TOOLS_IMAGE)-libcmt \ -f Dockerfile \ . @@ -75,6 +77,7 @@ $(TOOLS_LIBCMT) libcmt: copy-libcmt: @ID=`docker create $(TOOLS_IMAGE)-libcmt` && \ docker cp $$ID:/opt/cartesi/$(TOOLS_LIBCMT) . && \ + docker cp $$ID:/opt/cartesi/$(TOOLS_LIBCMT_DEV) . && \ docker rm $$ID env: @@ -82,6 +85,7 @@ env: @echo TOOLS_ROOTFS=$(TOOLS_ROOTFS) @echo TOOLS_IMAGE=$(TOOLS_IMAGE) @echo TOOLS_LIBCMT=$(TOOLS_LIBCMT) + @echo TOOLS_LIBCMT_DEV=$(TOOLS_LIBCMT_DEV) @echo IMAGE_KERNEL_VERSION=$(IMAGE_KERNEL_VERSION) @echo LINUX_VERSION=$(LINUX_VERSION) @echo LINUX_HEADERS_URLPATH=$(LINUX_HEADERS_URLPATH) diff --git a/sys-utils/libcmt/Makefile b/sys-utils/libcmt/Makefile index b45a9c95..5e5c4fff 100644 --- a/sys-utils/libcmt/Makefile +++ b/sys-utils/libcmt/Makefile @@ -81,16 +81,24 @@ $(libcmt_SO): $(libcmt_OBJ) $(TARGET_CC) -shared -o $@ $^ libcmt: $(libcmt_LIB) $(libcmt_SO) -install: $(libcmt_LIB) $(libcmt_SO) build/ffi.h +install: $(libcmt_SO) mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib - cp -f $(libcmt_LIB) $(libcmt_SO) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + cp -f $(libcmt_SO) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + +debian-package: + mkdir -p $(TARGET_DESTDIR)/DEBIAN + sed 's|ARG_VERSION|$(LIBCMT_VERSION)|g;' tools/template/control.template > $(TARGET_DESTDIR)/DEBIAN/control + dpkg-deb -Zxz --root-owner-group --build $(TARGET_DESTDIR) $(LIBCMT_DEB_FILENAME) + +install-dev: install $(libcmt_LIB) $(libcmt_SO) build/ffi.h + cp -f $(libcmt_LIB) $(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 build/ffi.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig sed -e 's|@ARG_PREFIX@|$(TARGET_PREFIX)|g' src/libcmt.pc > $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig/libcmt.pc -debian-package: install +debian-dev-package: mkdir -p $(TARGET_DESTDIR)/DEBIAN sed 's|ARG_VERSION|$(LIBCMT_VERSION)|g;' tools/template/cross-control.template > $(TARGET_DESTDIR)/DEBIAN/control dpkg-deb -Zxz --root-owner-group --build $(TARGET_DESTDIR) $(LIBCMT_DEB_FILENAME) diff --git a/sys-utils/libcmt/tools/template/control.template b/sys-utils/libcmt/tools/template/control.template new file mode 100644 index 00000000..e6951dd2 --- /dev/null +++ b/sys-utils/libcmt/tools/template/control.template @@ -0,0 +1,8 @@ +Package: libcmt +Version: ARG_VERSION +Architecture: riscv64 +Priority: optional +Section: devel +Maintainer: Machine Reference Unit +Provides: libcmt +Description: Libcmt Library and Headers