Skip to content

Commit

Permalink
Move api to internal
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Aug 31, 2022
1 parent 1afba37 commit b2d3a38
Show file tree
Hide file tree
Showing 35 changed files with 30 additions and 30 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
name: Create release build of libwasmvm
command: make build-rust
- persist_to_workspace:
root: ./api
root: ./internal/api
paths:
- libwasmvm.x86_64.so
- save_cache:
Expand All @@ -173,7 +173,7 @@ jobs:
at: /tmp/builds
- run:
name: Copy .so build
command: cp /tmp/builds/libwasmvm.x86_64.so ./api
command: cp /tmp/builds/libwasmvm.x86_64.so ./internal/api
- run:
name: Go integration tests
command: make test
Expand All @@ -190,7 +190,7 @@ jobs:
- run: make test-alpine
- run:
name: Debug build results
command: ls -l ./api
command: ls -l ./internal/api

deploy_to_git:
machine:
Expand All @@ -211,7 +211,7 @@ jobs:
command: make release-build-macos
- run:
name: Debug build results
command: ls -l ./api
command: ls -l ./internal/api
- run:
name: Configure git user
# This is not a GitHub user and no permissions can be configured other than "push access", which
Expand All @@ -223,7 +223,7 @@ jobs:
name: Check-in and push new libraries
command: |
git status
git add ./api
git add ./internal/api
git commit --allow-empty -m '[skip ci] Built release libraries'
git push origin $CIRCLE_BRANCH
Expand All @@ -238,13 +238,13 @@ jobs:
command: make release-build-alpine
- run:
name: Debug build results
command: ls -l ./api
command: ls -l ./internal/api
- run:
name: Collect artifacts
command: |
mkdir artifacts
cp ./api/libwasmvm_muslc.a artifacts/libwasmvm_muslc.x86_64.a
cp ./api/libwasmvm_muslc.aarch64.a artifacts/libwasmvm_muslc.aarch64.a
cp ./internal/api/libwasmvm_muslc.a artifacts/libwasmvm_muslc.x86_64.a
cp ./internal/api/libwasmvm_muslc.aarch64.a artifacts/libwasmvm_muslc.aarch64.a
- run:
name: Create checksums
working_directory: artifacts
Expand Down
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-rust: build-rust-release
# In order to use "--features backtraces" here we need a Rust nightly toolchain, which we don't have by default
build-rust-debug:
(cd libwasmvm && cargo build)
cp libwasmvm/target/debug/$(SHARED_LIB_SRC) api/$(SHARED_LIB_DST)
cp libwasmvm/target/debug/$(SHARED_LIB_SRC) internal/api/$(SHARED_LIB_DST)
make update-bindings

# use release build to actually ship - smaller and much faster
Expand All @@ -48,7 +48,7 @@ build-rust-debug:
# enable stripping through cargo (if that is desired).
build-rust-release:
(cd libwasmvm && cargo build --release)
cp libwasmvm/target/release/$(SHARED_LIB_SRC) api/$(SHARED_LIB_DST)
cp libwasmvm/target/release/$(SHARED_LIB_SRC) internal/api/$(SHARED_LIB_DST)
make update-bindings
@ #this pulls out ELF symbols, 80% size reduction!

Expand All @@ -68,8 +68,8 @@ release-build-alpine:
rm -rf libwasmvm/target/release
# build the muslc *.a file
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-alpine
cp libwasmvm/artifacts/libwasmvm_muslc.a api
cp libwasmvm/artifacts/libwasmvm_muslc.aarch64.a api
cp libwasmvm/artifacts/libwasmvm_muslc.a internal/api
cp libwasmvm/artifacts/libwasmvm_muslc.aarch64.a internal/api
make update-bindings
# try running go tests using this lib with muslc
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd):/mnt/testrun -w /mnt/testrun $(ALPINE_TESTER) go build -tags muslc ./...
Expand All @@ -80,22 +80,22 @@ release-build-alpine:
release-build-linux:
rm -rf libwasmvm/target/release
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-centos7
cp libwasmvm/artifacts/libwasmvm.x86_64.so api
cp libwasmvm/artifacts/libwasmvm.aarch64.so api
cp libwasmvm/artifacts/libwasmvm.x86_64.so internal/api
cp libwasmvm/artifacts/libwasmvm.aarch64.so internal/api
make update-bindings

# Creates a release build in a containerized build environment of the shared library for macOS (.dylib)
release-build-macos:
rm -rf libwasmvm/target/x86_64-apple-darwin/release
rm -rf libwasmvm/target/aarch64-apple-darwin/release
docker run --rm -u $(USER_ID):$(USER_GROUP) -v $(shell pwd)/libwasmvm:/code $(BUILDERS_PREFIX)-cross build_macos.sh
cp libwasmvm/artifacts/libwasmvm.dylib api
cp libwasmvm/artifacts/libwasmvm.dylib internal/api
make update-bindings

update-bindings:
# After we build libwasmvm, we have to copy the generated bindings for Go code to use.
# We cannot use symlinks as those are not reliably resolved by `go get` (https://github.com/CosmWasm/wasmvm/pull/235).
cp libwasmvm/bindings.h api
cp libwasmvm/bindings.h internal/api

release-build:
# Write like this because those must not run in parallel
Expand All @@ -112,10 +112,10 @@ test-alpine: release-build-alpine

@# Run the demo binary on Alpine machines
@# See https://de.wikipedia.org/wiki/Alpine_Linux#Versionen for supported versions
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.15 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.14 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.13 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.12 ./demo ./api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.15 ./demo ./internal/api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.14 ./demo ./internal/api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.13 ./demo ./internal/api/testdata/hackatom.wasm
docker run --rm --read-only -v $(shell pwd):/mnt/testrun -w /mnt/testrun alpine:3.12 ./demo ./internal/api/testdata/hackatom.wasm

@# Run binary locally if you are on Linux
@# ./demo ./api/testdata/hackatom.wasm
@# ./demo ./internal/api/testdata/hackatom.wasm
4 changes: 2 additions & 2 deletions ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"io/ioutil"
"testing"

"github.com/CosmWasm/wasmvm/api"
"github.com/CosmWasm/wasmvm/internal/api"
"github.com/CosmWasm/wasmvm/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

const IBC_TEST_CONTRACT = "./api/testdata/ibc_reflect.wasm"
const IBC_TEST_CONTRACT = "./internal/api/testdata/ibc_reflect.wasm"

func TestIBC(t *testing.T) {
vm := withVM(t)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion api/testdata/README.md → internal/api/testdata/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Update contracts via e.g.

```sh
cd api/testdata
cd internal/api/testdata
./download_releases.sh v0.14.0-beta2
```

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"

"github.com/CosmWasm/wasmvm/api"
"github.com/CosmWasm/wasmvm/internal/api"
"github.com/CosmWasm/wasmvm/types"
)

Expand Down
4 changes: 2 additions & 2 deletions lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"testing"

"github.com/CosmWasm/wasmvm/api"
"github.com/CosmWasm/wasmvm/internal/api"
"github.com/CosmWasm/wasmvm/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -19,7 +19,7 @@ const (
TESTING_CACHE_SIZE = 100 // MiB
)

const HACKATOM_TEST_CONTRACT = "./api/testdata/hackatom.wasm"
const HACKATOM_TEST_CONTRACT = "./internal/api/testdata/hackatom.wasm"

func withVM(t *testing.T) *VM {
tmpdir, err := ioutil.TempDir("", "wasmvm-testing")
Expand Down
4 changes: 2 additions & 2 deletions libwasmvm/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ mod tests {
use std::iter::FromIterator;
use tempfile::TempDir;

static HACKATOM: &[u8] = include_bytes!("../../api/testdata/hackatom.wasm");
static IBC_REFLECT: &[u8] = include_bytes!("../../api/testdata/ibc_reflect.wasm");
static HACKATOM: &[u8] = include_bytes!("../../internal/api/testdata/hackatom.wasm");
static IBC_REFLECT: &[u8] = include_bytes!("../../internal/api/testdata/ibc_reflect.wasm");

#[test]
fn init_cache_and_release_cache_work() {
Expand Down
2 changes: 1 addition & 1 deletion libwasmvm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use cosmwasm_vm::{
InstanceOptions, Size,
};

static CONTRACT: &[u8] = include_bytes!("../../api/testdata/hackatom.wasm");
static CONTRACT: &[u8] = include_bytes!("../../internal/api/testdata/hackatom.wasm");
const PRINT_DEBUG: bool = false;
const MEMORY_CACHE_SIZE: Size = Size::mebi(200);
const MEMORY_LIMIT: Size = Size::mebi(32);
Expand Down

0 comments on commit b2d3a38

Please sign in to comment.