From d7dc1e3f98307f66da3c644042d92c8c8c8591d3 Mon Sep 17 00:00:00 2001 From: xjd Date: Tue, 21 May 2024 11:15:47 +0800 Subject: [PATCH] Add CI (#61) * Fix syscall id * Add CI * Remove build status --- .github/workflows/ci.yml | 15 +++++++++++++++ .gitignore | 2 ++ Makefile | 16 ++++++++++++++++ README.md | 2 -- ckb_consts.h | 2 +- tests/ci.c | 31 +++++++++++++++++++++++++++++++ 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 tests/ci.c diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..169182a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,15 @@ +name: CI + +on: [push, pull_request] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Update submodules + run: git submodule update --init + - name: Build contract + run: make all-via-docker diff --git a/.gitignore b/.gitignore index 7a6da4b..4de8745 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,5 @@ Module.symvers Mkfile.old dkms.conf simulator/build.simulator + +tests/ci diff --git a/Makefile b/Makefile index 78ae9a3..910765f 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,23 @@ AR := riscv64-unknown-elf-ar LIB := libdummylibc.a CFLAGS := -Wall -Werror -Wextra -Wno-unused-parameter -Wno-dangling-pointer -Wno-nonnull -Wno-nonnull-compare -fno-builtin-printf -fno-builtin-memcmp -O3 -g -fdata-sections -ffunction-sections +LDFLAGS := -nostdlib -nostartfiles -Wl,-static -Wl,--gc-sections +EXTRA := -I . -I libc -I molecule -Wno-unused-function + +# nervos/ckb-riscv-gnu-toolchain:jammy-20230214 +BUILDER_DOCKER := nervos/ckb-riscv-gnu-toolchain@sha256:d175f4a766b4b17a44bd9bbeca8e24ab2427ba615738016dc49e194046e6b28b + + default: fmt +all-via-docker: + docker run -u $(shell id -u):$(shell id -g) --rm -v `pwd`:/code ${BUILDER_DOCKER} bash -c "cd /code && make all" + +all: tests/ci + +tests/ci: tests/ci.c + $(CC) $(CFLAGS) $(EXTRA) $(LDFLAGS) -o $@ $< + fmt: clang-format -i -style=Google $(wildcard *.h */*.h *.c */*.c libc/*.h libc/src/*.c) git diff --exit-code @@ -17,5 +32,6 @@ impl.o: libc/src/impl.c clean: rm -rf $(LIB) impl.o + rm tests/ci .PHONY: clean default fmt diff --git a/README.md b/README.md index 9cd0db8..c8b2e59 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # ckb-c-stdlib -[![Build Status](https://travis-ci.com/nervosnetwork/ckb-c-stdlib.svg?branch=master)](https://travis-ci.com/nervosnetwork/ckb-c-stdlib) - In the development of CKB scripts, we discovered many use-cases and patterns that could be really useful in writing CKB scripts. This repo serves as a commonplace for all those useful scripts. This could include but aren't limit to: * CKB's data structure definitions diff --git a/ckb_consts.h b/ckb_consts.h index 9e40f36..b91babe 100644 --- a/ckb_consts.h +++ b/ckb_consts.h @@ -26,7 +26,7 @@ #define SYS_ckb_pipe 2604 #define SYS_ckb_write 2605 #define SYS_ckb_read 2606 -#define SYS_ckb_inherited_fd 607 +#define SYS_ckb_inherited_fd 2607 #define SYS_ckb_close 2608 #define CKB_SUCCESS 0 diff --git a/tests/ci.c b/tests/ci.c new file mode 100644 index 0000000..9dd957f --- /dev/null +++ b/tests/ci.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "blake2b.h" +#include "ckb_consts.h" +#include "ckb_dlfcn.h" +#include "ckb_exec.h" +#include "ckb_keccak256.h" +#include "ckb_streaming.h" +#include "ckb_swappable_signatures.h" +#include "ckb_syscall_apis.h" +#include "ckb_syscalls.h" +#include "ckb_type_id.h" +#include "ckb_utils.h" +#define MOL2_EXIT ckb_exit +#include "blockchain.h" +#include "blockchain-api2.h" +#include "molecule_reader.h" +#include "molecule2_reader.h" +#include "molecule_builder.h" + +int main(int argc, const char* argv[]) { + return 0; +}