Skip to content

Commit

Permalink
add ckb-c-stdlib as a submodule (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
contrun authored Sep 11, 2023
1 parent b71d442 commit 189ec17
Show file tree
Hide file tree
Showing 91 changed files with 2,131 additions and 16,839 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
with:
submodules: true
- uses: leafo/gh-actions-lua@v9
with:
luaVersion: "5.4"
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "include/ckb-c-stdlib"]
path = include/ckb-c-stdlib
url = https://github.com/nervosnetwork/ckb-c-stdlib.git
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ CC := $(TARGET)-gcc
LD := $(TARGET)-gcc
OBJCOPY := $(TARGET)-objcopy

CFLAGS := -fPIC -O3 -fno-builtin -nostdinc -nostdlib -nostartfiles -fvisibility=hidden -fdata-sections -ffunction-sections -I lualib -I include/ckb-c-stdlib -I include/ckb-c-stdlib/libc -I include/ckb-c-stdlib/molecule -Wall -Werror -Wno-nonnull -Wno-nonnull-compare -Wno-unused-function -g
# See comments in lualib/Makefile for why __ISO_C_VISIBLE=1999 is needed
CFLAGS := -D__ISO_C_VISIBLE=1999 -fPIC -O3 -fno-builtin -nostdinc -nostdlib -nostartfiles -fvisibility=hidden -fdata-sections -ffunction-sections -I lualib -I lualib/c-stdlib -I include/ckb-c-stdlib -I include/ckb-c-stdlib/libc -I include/ckb-c-stdlib/molecule -Wall -Werror -Wno-nonnull -Wno-nonnull-compare -Wno-unused-function -Wno-error=maybe-uninitialized -g

LDFLAGS := -nostdlib -nostartfiles -fno-builtin -Wl,-static -fdata-sections -ffunction-sections -Wl,--gc-sections

Expand All @@ -27,13 +28,13 @@ lualib/liblua.a:
make -C lualib liblua.a

build/dylibtest: tests/test_cases/dylibtest.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(shell $(CC) --print-search-dirs | sed -n '/install:/p' | sed 's/install:\s*//g')libgcc.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< lualib/liblua.a $(shell $(CC) --print-search-dirs | sed -n '/install:/p' | sed 's/install:\s*//g')libgcc.a

build/dylibexample: examples/dylib.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(shell $(CC) --print-search-dirs | sed -n '/install:/p' | sed 's/install:\s*//g')libgcc.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< lualib/liblua.a $(shell $(CC) --print-search-dirs | sed -n '/install:/p' | sed 's/install:\s*//g')libgcc.a

build/spawnexample: examples/spawn.c
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(shell $(CC) --print-search-dirs | sed -n '/install:/p' | sed 's/install:\s*//g')libgcc.a
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< lualib/liblua.a $(shell $(CC) --print-search-dirs | sed -n '/install:/p' | sed 's/install:\s*//g')libgcc.a

build/lua-loader.o: lua-loader/lua-loader.c
$(CC) -c $(CFLAGS) -o $@ $<
Expand Down
12 changes: 9 additions & 3 deletions examples/spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
int main() {
const char *argv[] = {"-e", "local m = arg[2] .. arg[3]; ckb.set_content(m)",
"hello", "world"};
int8_t exit_code = -1;
uint8_t content[80] = {};
uint64_t content_length = 80;
int8_t exit_code = -1;

spawn_args_t spgs = {
.memory_limit = 8,
.exit_code = &exit_code,
.content = content,
.content_length = &content_length,
};

int success =
ckb_spawn(8, 1, 3, 0, 4, argv, &exit_code, &content[0], &content_length);
int success = ckb_spawn(1, 3, 0, 4, argv, &spgs);
if (success != 0) {
return 1;
}
Expand Down
1 change: 1 addition & 0 deletions include/ckb-c-stdlib
Submodule ckb-c-stdlib added at bdc87e
53 changes: 0 additions & 53 deletions include/ckb-c-stdlib/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions include/ckb-c-stdlib/.travis.yml

This file was deleted.

21 changes: 0 additions & 21 deletions include/ckb-c-stdlib/LICENSE

This file was deleted.

5 changes: 0 additions & 5 deletions include/ckb-c-stdlib/Makefile

This file was deleted.

11 changes: 0 additions & 11 deletions include/ckb-c-stdlib/README.md

This file was deleted.

Loading

0 comments on commit 189ec17

Please sign in to comment.