Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ endif

build_tags = netgo

system=$(shell $(shell pwd)/libs/scripts/system.sh)
ifeq ($(system),alpine)
ifeq ($(LINK_STATICALLY),false)
$(warning Your system is alpine. It must be compiled statically. Now we start compile statically.)
endif
LINK_STATICALLY=true
else
ifeq ($(LINK_STATICALLY),true)
$(error your system is $(system) which can not be complied statically. please set LINK_STATICALLY=false)
endif
endif

ifeq ($(WITH_ROCKSDB),true)
CGO_ENABLED=1
build_tags += rocksdb
Expand All @@ -53,7 +65,8 @@ else
endif

ifeq ($(LINK_STATICALLY),true)
build_tags += muslc
build_tags += muslc
dummy := $(shell $(shell pwd)/libs/scripts/wasm_static_install.sh)
endif

build_tags += $(BUILD_TAGS)
Expand Down
56 changes: 56 additions & 0 deletions libs/scripts/system.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh
#set -e

get_distribution() {
lsb_dist=""
# Every system that we officially support has /etc/os-release
if [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
# Returning an empty string here should be alright since the
# case statements don't act unless you provide an actual value
echo "$lsb_dist"
}

is_darwin() {
case "$(uname -s)" in
*darwin*) true ;;
*Darwin*) true ;;
*) false ;;
esac
}

get_system_version() {
lsb_dist=$(get_distribution)
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"
system_version=
case "$lsb_dist" in
ubuntu)
system_version="ubuntu"
;;
centos)
system_version="centos"
;;
alpine)
system_version="alpine"
;;
*)
if [ -z "$lsb_dist" ]; then
if is_darwin; then
system_version="macos"
fi
else
echo
echo "ERROR: Unsupported system '$lsb_dist', only support centos,ubuntu,alpine,macos"
echo
exit 1
fi
;;
esac

# checkout go version

echo "$system_version"
}

echo $(get_system_version)
18 changes: 18 additions & 0 deletions libs/scripts/wasm_static_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
#set -e

echo "install wasm static lib with sudo"
installWasmLib() {
if [ -r /usr/local/lib/libwasmvm_muslc.a ]; then
exit 0
elif [ -r /lib/libwasmvm_muslc.a ]; then
exit 0
fi
wget --no-check-certificate "https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a" -O /usr/local/lib/libwasmvm_muslc.x86_64.a
cp /usr/local/lib/libwasmvm_muslc.x86_64.a /usr/local/lib/libwasmvm_muslc.a
echo "install wasm static lib success"
}

installWasmLib