From a04c3bac8352e8f69eed5b3f4e2978659dbc18e8 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 15 Nov 2019 00:46:40 +0300 Subject: [PATCH] CI: ubuntu-musl target --- .github/workflows/ci.yml | 16 ++++++++++++++++ vlib/builtin/builtin_nix.v | 2 ++ vlib/os/os_nix.v | 5 +++++ vlib/os/os_test.v | 5 +++-- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42b98cc4f8..c4e2863b97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,6 +59,22 @@ jobs: ./v -o v2 v.v # Make sure vtcc can build itself ./v test v + build-ubuntu-musl: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 12.x + - name: Install dependencies + run: sudo apt-get update; sudo apt-get install --quiet -y musl msul-tools + - name: Build v + run: make && ./v -cc musl-gcc -o v v.v +# - name: Test v->c +# run: ./v test v +# - name: Test v->js +# run: ./v -o hi.js examples/hello_v_js.v && node hi.js + build-windows-gcc: runs-on: windows-2019 steps: diff --git a/vlib/builtin/builtin_nix.v b/vlib/builtin/builtin_nix.v index 5105f390ba..cb7c6b1353 100644 --- a/vlib/builtin/builtin_nix.v +++ b/vlib/builtin/builtin_nix.v @@ -24,9 +24,11 @@ fn print_backtrace_skipping_top_frames_nix(xskipframes int) bool { // the functions below are not called outside this file, // so there is no need to have their twins in builtin_windows.v fn print_backtrace_skipping_top_frames_mac(skipframes int) bool { + $if mac { buffer := [100]byteptr nr_ptrs := C.backtrace(*voidptr(buffer), 100) C.backtrace_symbols_fd(*voidptr(&buffer[skipframes]), nr_ptrs-skipframes, 1) + } return true } diff --git a/vlib/os/os_nix.v b/vlib/os/os_nix.v index f838322466..10cea5a856 100644 --- a/vlib/os/os_nix.v +++ b/vlib/os/os_nix.v @@ -47,6 +47,11 @@ pub fn ls(path string) ?[]string { } pub fn dir_exists(path string) bool { + /* + $if linux { + C.syscall(4, path.str) // sys_newstat + } + */ dir := C.opendir(path.str) res := !isnil(dir) if res { diff --git a/vlib/os/os_test.v b/vlib/os/os_test.v index bb47756897..2c11e29f42 100644 --- a/vlib/os/os_test.v +++ b/vlib/os/os_test.v @@ -76,6 +76,7 @@ fn test_write_and_read_bytes() { fn test_create_and_delete_folder() { folder := './test1' os.mkdir(folder) + assert os.dir_exists(folder) folder_contents := os.ls(folder) or { panic(err) } assert folder_contents.len == 0 @@ -120,7 +121,7 @@ fn test_walk() { fn test_cp() { old_file_name := 'cp_example.txt' new_file_name := 'cp_new_example.txt' - + os.write_file(old_file_name, 'Test data 1 2 3, V is awesome #$%^[]!~⭐') os.cp(old_file_name, new_file_name) or { panic('$err: errcode: $errcode') } @@ -191,7 +192,7 @@ fn cleanup_leftovers(){ os.rm('ex/ex2/ex2.txt') os.rm('ex/ex2') os.rm('ex/ex1.txt') - os.rm('ex') + os.rm('ex') os.rm('ex2/ex2.txt') os.rm('ex2') os.rm('ex1.txt')