Skip to content

Commit

Permalink
Should work with wasmvm forks (#194)
Browse files Browse the repository at this point in the history
* Should work with wasmvm forks

* update label, return empty version for non-wasmvm chains

* switch to new repo
  • Loading branch information
agouin authored Nov 4, 2023
1 parent f252df8 commit cee5276
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
13 changes: 10 additions & 3 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,15 @@ func getModFile(

// getWasmvmVersion will get the wasmvm version from the mod file
func getWasmvmVersion(modFile *modfile.File) string {
wasmvmRepo := "github.com/CosmWasm/wasmvm"
const defaultWasmvmRepo = "github.com/CosmWasm/wasmvm"
wasmvmRepo := defaultWasmvmRepo
wasmvmVersion := ""

// First check all the "requires"
for _, item := range modFile.Require {
// Must have 2 tokens, repo & version
if (len(item.Syntax.Token) == 2) && (strings.Contains(item.Syntax.Token[0], wasmvmRepo)) {
wasmvmRepo = item.Syntax.Token[0]
wasmvmVersion = item.Syntax.Token[1]
}
}
Expand All @@ -228,13 +230,18 @@ func getWasmvmVersion(modFile *modfile.File) string {
for _, item := range modFile.Replace {
// Must have 3 or more tokens
if (len(item.Syntax.Token) > 2) && (strings.Contains(item.Syntax.Token[0], wasmvmRepo)) {
wasmvmRepo = item.Syntax.Token[len(item.Syntax.Token)-2]
wasmvmVersion = item.Syntax.Token[len(item.Syntax.Token)-1]
}
}

fmt.Println("WasmVM version from go.mod: ", wasmvmVersion)
fmt.Printf("WasmVM from go.mod: repo: %s, version: %s\n", wasmvmRepo, wasmvmVersion)

return wasmvmVersion
if wasmvmVersion == "" {
return ""
}

return wasmvmRepo + " " + wasmvmVersion
}

// buildChainNodeDockerImage builds the requested chain node docker image
Expand Down
11 changes: 11 additions & 0 deletions chains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,17 @@
build-env:
- BUILD_TAGS=muslc

# Terra Classic
- name: terra-classic
github-organization: classic-terra
github-repo: core
dockerfile: cosmos
build-target: make install
binaries:
- /go/bin/terrad
build-env:
- BUILD_TAGS=muslc

# Thorchain
- name: thorchain
repo-host: gitlab.com
Expand Down
4 changes: 3 additions & 1 deletion dockerfile/cosmos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ RUN set -eux;\
fi;\
fi;\
if [ ! -z "${WASMVM_VERSION}" ]; then\
wget -O $LIBDIR/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$ARCH.a;\
WASMVM_REPO=$(echo $WASMVM_VERSION | awk '{print $1}');\
WASMVM_VERS=$(echo $WASMVM_VERSION | awk '{print $2}');\
wget -O $LIBDIR/libwasmvm_muslc.a https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.${ARCH}.a;\
fi;\
export GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"';\
if [ ! -z "$PRE_BUILD" ]; then sh -c "${PRE_BUILD}"; fi;\
Expand Down
6 changes: 4 additions & 2 deletions dockerfile/cosmos/local.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ WORKDIR /go/src/${REPO_HOST}/${GITHUB_ORGANIZATION}/${GITHUB_REPO}
# Download CosmWasm libwasmvm if found
RUN set -eux; \
export ARCH=$(uname -m); \
if [ ! -z "${WASMVM_VERSION}" ]; then \
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$(uname -m).a; \
if [ ! -z "${WASMVM_VERSION}" ]; then\
WASMVM_REPO=$(echo $WASMVM_VERSION | awk '{print $1}');\
WASMVM_VERS=$(echo $WASMVM_VERSION | awk '{print $2}');\
wget -O $LIBDIR/libwasmvm_muslc.a https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.$(uname -m).a;\
fi;

ARG BUILD_DIR
Expand Down
8 changes: 5 additions & 3 deletions dockerfile/cosmos/localcross.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ARG BUILD_ENV
ARG BUILD_TAGS
ARG PRE_BUILD
ARG BUILD_DIR
ARG WASMVM_VERSION

RUN set -eux;\
LIBDIR=/lib;\
Expand All @@ -48,9 +49,10 @@ RUN set -eux;\
export CC=x86_64-linux-musl-gcc CXX=x86_64-linux-musl-g++;\
fi;\
fi;\
WASM_VERSION=$(go list -m all | grep github.com/CosmWasm/wasmvm | awk '{print $NF}');\
if [ ! -z "${WASM_VERSION}" ]; then\
wget -O $LIBDIR/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASM_VERSION}/libwasmvm_muslc.$ARCH.a;\
if [ ! -z "${WASMVM_VERSION}" ]; then\
WASMVM_REPO=$(echo $WASMVM_VERSION | awk '{print $1}');\
WASMVM_VERS=$(echo $WASMVM_VERSION | awk '{print $2}');\
wget -O $LIBDIR/libwasmvm_muslc.a https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.${ARCH}.a;\
fi;\
export GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"';\
if [ ! -z "$PRE_BUILD" ]; then sh -c "${PRE_BUILD}"; fi;\
Expand Down
4 changes: 3 additions & 1 deletion dockerfile/cosmos/native.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ ARG WASMVM_VERSION
RUN set -eux;\
export ARCH=$(uname -m);\
if [ ! -z "${WASMVM_VERSION}" ]; then\
wget -O /lib/libwasmvm_muslc.a https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.$(uname -m).a;\
WASMVM_REPO=$(echo $WASMVM_VERSION | awk '{print $1}');\
WASMVM_VERS=$(echo $WASMVM_VERSION | awk '{print $2}');\
wget -O $LIBDIR/libwasmvm_muslc.a https://${WASMVM_REPO}/releases/download/${WASMVM_VERS}/libwasmvm_muslc.$(uname -m).a;\
fi;\
export CGO_ENABLED=1 LDFLAGS='-linkmode external -extldflags "-static"';\
if [ ! -z "$PRE_BUILD" ]; then sh -c "${PRE_BUILD}"; fi;\
Expand Down

0 comments on commit cee5276

Please sign in to comment.