Skip to content

Commit 154af4d

Browse files
authored
Try #200:
2 parents 011e500 + e6df4af commit 154af4d

File tree

8 files changed

+62
-56
lines changed

8 files changed

+62
-56
lines changed

.github/workflows/test.yml

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ jobs:
1515
matrix:
1616
go: [1.14, 1.15]
1717
target:
18-
- id: 'linux-amd64'
19-
os: 'ubuntu-18.04'
18+
#- id: 'linux-amd64'
19+
# os: 'ubuntu-18.04'
2020

21-
- id: 'linux-aarch64'
22-
os: ['self-hosted', 'linux', 'ARM64']
21+
#- id: 'linux-aarch64'
22+
# os: ['self-hosted', 'linux', 'ARM64']
2323

24-
- id: 'darwin-amd64'
25-
os: 'macos-latest'
24+
#- id: 'darwin-amd64'
25+
# os: 'macos-latest'
2626

27-
- id: 'linux-amd64'
28-
os: 'ubuntu-18.04'
29-
libwasmer_archive_name: 'wasmer-linux-amd64.tar.gz'
27+
- id: 'windows-amd64'
28+
os: 'windows-latest'
29+
30+
#- id: 'linux-amd64'
31+
# os: 'ubuntu-18.04'
32+
# libwasmer_archive_name: 'wasmer-linux-amd64.tar.gz'
3033
fail-fast: true
3134

3235
runs-on: ${{ matrix.target.os }}
@@ -35,46 +38,46 @@ jobs:
3538
- name: Check out code
3639
uses: actions/checkout@v2
3740

38-
- name: Set up Rust
39-
uses: actions-rs/toolchain@v1
40-
with:
41-
toolchain: stable
42-
override: true
43-
default: false
41+
#- name: Set up Rust
42+
# uses: actions-rs/toolchain@v1
43+
# with:
44+
# toolchain: stable
45+
# override: true
46+
# default: false
4447

4548
- name: Set up Go
4649
uses: actions/setup-go@v2
4750
with:
4851
go-version: ${{ matrix.go }}
4952

50-
- name: Set up just
51-
shell: bash
52-
run: |
53-
export PATH="$HOME/.cargo/bin:$PATH"
54-
cargo install just
53+
#- name: Set up just
54+
# run: |
55+
# export PATH="$HOME/.cargo/bin:$PATH"
56+
# cargo install just
5557

5658
- name: Run all the tests (default)
5759
if: ${{ !matrix.target.libwasmer_archive_name }}
58-
shell: bash
5960
run: |
60-
just test
61+
cd wasmer
62+
go test -v
63+
#just test
64+
65+
#- name: Run all the tests (with custom Wasmer runtime)
66+
# if: matrix.target.libwasmer_archive_name
67+
# shell: bash
68+
# run: |
69+
# libwasmer_url=$(curl -s https://api.github.com/repos/wasmerio/wasmer-nightly/releases/latest | jq --raw-output '.assets[] | select(.name == "${{ matrix.target.libwasmer_archive_name }}") | .browser_download_url')
70+
# mkdir -p libwasmer
71+
# curl -L $libwasmer_url > release.tar.gz
72+
# tar xzvf release.tar.gz -C libwasmer
73+
# export CGO_CFLAGS="-I$(pwd)/libwasmer/include/"
74+
# export CGO_LDFLAGS="-Wl,-rpath,$(pwd)/libwasmer/lib/ -L$(pwd)/libwasmer/lib/ -lwasmer"
75+
# just test -tags custom_wasmer_runtime
76+
77+
#- name: Run all the examples
78+
# run: |
79+
# just examples
6180

62-
- name: Run all the tests (with custom Wasmer runtime)
63-
if: matrix.target.libwasmer_archive_name
64-
shell: bash
65-
run: |
66-
libwasmer_url=$(curl -s https://api.github.com/repos/wasmerio/wasmer-nightly/releases/latest | jq --raw-output '.assets[] | select(.name == "${{ matrix.target.libwasmer_archive_name }}") | .browser_download_url')
67-
mkdir -p libwasmer
68-
curl -L $libwasmer_url > release.tar.gz
69-
tar xzvf release.tar.gz -C libwasmer
70-
export CGO_CFLAGS="-I$(pwd)/libwasmer/include/"
71-
export CGO_LDFLAGS="-Wl,-rpath,$(pwd)/libwasmer/lib/ -L$(pwd)/libwasmer/lib/ -lwasmer"
72-
just test -tags custom_wasmer_runtime
73-
74-
- name: Run all the examples
75-
shell: bash
76-
run: |
77-
just examples
7881
# Skipped for now because of Github banning the API request from actions.
7982
# You can find more info in this PR: https://github.com/wasmerio/wasmer-go/pull/118#issuecomment-588487544
8083
# - name: Test bazel build

bors.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
status = [
2-
"Build and Test (1.14, linux-amd64, ubuntu-%)",
3-
"Build and Test (1.14, linux-aarch64, self-hosted, linux, ARM64)",
42
"Build and Test (1.14, darwin-amd64, macos-%)",
3+
"Build and Test (1.14, linux-aarch64, self-hosted, linux, ARM64)",
4+
"Build and Test (1.14, linux-amd64, ubuntu-%)",
55
"Build and Test (1.14, linux-amd64, ubuntu-%, wasmer-%.tar.gz)",
6-
"Build and Test (1.15, linux-amd64, ubuntu-%)",
7-
"Build and Test (1.15, linux-aarch64, self-hosted, linux, ARM64)",
6+
"Build and Test (1.14, windows-amd64, windows-%)",
87
"Build and Test (1.15, darwin-amd64, macos-%)",
8+
"Build and Test (1.15, linux-aarch64, self-hosted, linux, ARM64)",
9+
"Build and Test (1.15, linux-amd64, ubuntu-%)",
910
"Build and Test (1.15, linux-amd64, ubuntu-%, wasmer-%.tar.gz)",
11+
"Build and Test (1.15, windows-amd64, windows-%)"
1012
]
1113
required_approvals = 1
1214
timeout_sec = 7200

wasmer/cgo.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
package wasmer
44

55
// #cgo CFLAGS: -I${SRCDIR}/packaged/include
6-
// #cgo LDFLAGS: -lwasmer
76
//
7+
// #cgo !windows LDFLAGS: -lwasmer
8+
// #cgo windows LDFLAGS: -lwasmer -luserenv -lws2_32 -ladvapi32 -lbcrypt -lkernel32
9+
//
10+
// #cgo darwin,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/darwin-amd64 -L${SRCDIR}/packaged/lib/darwin-amd64
811
// #cgo linux,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/linux-amd64 -L${SRCDIR}/packaged/lib/linux-amd64
912
// #cgo linux,arm64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/linux-aarch64 -L${SRCDIR}/packaged/lib/linux-aarch64
10-
// #cgo darwin,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/darwin-amd64 -L${SRCDIR}/packaged/lib/darwin-amd64
13+
// #cgo windows,amd64 LDFLAGS: -Wl,-rpath,${SRCDIR}/packaged/lib/windows-amd64 -L${SRCDIR}/packaged/lib/windows-amd64
1114
//
1215
// #include <wasmer_wasm.h>
1316
import "C"

wasmer/packaged/lib/dummy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ import (
55
_ "github.com/wasmerio/wasmer-go/wasmer/packaged/lib/darwin-amd64"
66
_ "github.com/wasmerio/wasmer-go/wasmer/packaged/lib/linux-aarch64"
77
_ "github.com/wasmerio/wasmer-go/wasmer/packaged/lib/linux-amd64"
8+
_ "github.com/wasmerio/wasmer-go/wasmer/packaged/lib/windows-amd64"
89
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// See https://github.com/golang/go/issues/26366.
2+
package windows_amd64
45.4 MB
Binary file not shown.

wasmer/wasi.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package wasmer
22

33
// #include <stdlib.h>
4-
// #include <stdio.h>
4+
// #include <string.h>
55
// #include <wasmer_wasm.h>
66
//
77
// // Buffer size for `wasi_env_read_inner`.
@@ -17,28 +17,23 @@ package wasmer
1717
//
1818
// // Common function to read a WASI environment captured stream.
1919
// size_t to_wasi_env_read_inner(wasi_env_t *wasi_env, char** buffer, wasi_env_reader reader) {
20-
// FILE *memory_stream;
20+
// char* buffer_ptr = (char*) malloc(1);
2121
// size_t buffer_size = 0;
2222
//
23-
// memory_stream = open_memstream(buffer, &buffer_size);
24-
//
25-
// if (NULL == memory_stream) {
26-
// return 0;
27-
// }
28-
//
2923
// char temp_buffer[WASI_ENV_READER_BUFFER_SIZE] = { 0 };
30-
// size_t data_read_size = WASI_ENV_READER_BUFFER_SIZE;
24+
// size_t data_read_size = 0;
3125
//
3226
// do {
3327
// data_read_size = reader(wasi_env, temp_buffer, WASI_ENV_READER_BUFFER_SIZE);
3428
//
3529
// if (data_read_size > 0) {
30+
// buffer_ptr = realloc(buffer_ptr, buffer_size + data_read_size);
31+
// memcpy(buffer_ptr + buffer_size, temp_buffer, data_read_size);
3632
// buffer_size += data_read_size;
37-
// fwrite(temp_buffer, sizeof(char), data_read_size, memory_stream);
3833
// }
3934
// } while (WASI_ENV_READER_BUFFER_SIZE == data_read_size);
4035
//
41-
// fclose(memory_stream);
36+
// *buffer = buffer_ptr;
4237
//
4338
// return buffer_size;
4439
// }

wasmer/wasi_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ func TestWasiWithCapturedStdout(t *testing.T) {
5050

5151
assert.Equal(
5252
t,
53-
stdout,
5453
"Found program name: `test-program`\n"+
5554
"Found 1 arguments: --foo\n"+
5655
"Found 2 environment variables: ABC=DEF, X=ZY\n"+
5756
"Found 1 preopened directories: DirEntry(\"/the_host_current_directory\")\n",
57+
stdout,
5858
)
5959
}

0 commit comments

Comments
 (0)