1 Star 0 Fork 25

huawei/sofa-mosn

forked from SOFAStack/sofa-mosn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Makefile 6.08 KB
一键复制 编辑 原始数据 按行查看 历史
nejisama 提交于 2018-10-25 16:23 . fix protocol
SHELL = /bin/bash
TARGET = mosnd
TARGET_SIDECAR = mosn
CONFIG_FILE = mosn_config.json
GIT_USER = alipay
PROJECT_NAME = github.com/${GIT_USER}/sofa-mosn
SCRIPT_DIR = $(shell pwd)/etc/script
MAJOR_VERSION = $(shell cat VERSION)
GIT_VERSION = $(shell git log -1 --pretty=format:%h)
GIT_NOTES = $(shell git log -1 --oneline)
BUILD_IMAGE = godep-builder
IMAGE_NAME = mosn
REPOSITORY = sofastack/${IMAGE_NAME}
RPM_BUILD_IMAGE = afenp-rpm-builder
RPM_VERSION = $(shell cat VERSION | tr -d '-')
RPM_TAR_NAME = afe-${TARGET}
RPM_SRC_DIR = ${RPM_TAR_NAME}-${RPM_VERSION}
RPM_TAR_FILE = ${RPM_SRC_DIR}.tar.gz
ut-local:
go test -v `go list ./pkg/... | grep -v pkg/mtls/crypto/tls`
unit-test:
docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/binary
docker run --rm -v $(GOPATH):/go -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} make ut-local
coverage-local:
sh ${SCRIPT_DIR}/report.sh
coverage:
docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/binary
docker run --rm -v $(GOPATH):/go -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} make coverage-local
integrate-local:
go test -p 1 -v ./test/integrate/...
integrate:
docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/binary
docker run --rm -v $(GOPATH):/go -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} make integrate-local
build:
docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/binary
docker run --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} make build-local
build-host:
docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/binary
docker run --net=host --rm -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} make build-local
binary: build
binary-host: build-host
build-local:
@rm -rf build/bundles/${MAJOR_VERSION}/binary
CGO_ENABLED=0 go build\
-ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X main.Version=${MAJOR_VERSION}(${GIT_VERSION})" \
-v -o ${TARGET} \
${PROJECT_NAME}/cmd/mosn/main
mkdir -p build/bundles/${MAJOR_VERSION}/binary
mv ${TARGET} build/bundles/${MAJOR_VERSION}/binary
@cd build/bundles/${MAJOR_VERSION}/binary && $(shell which md5sum) -b ${TARGET} | cut -d' ' -f1 > ${TARGET}.md5
cp configs/${CONFIG_FILE} build/bundles/${MAJOR_VERSION}/binary
cp build/bundles/${MAJOR_VERSION}/binary/${TARGET} build/bundles/${MAJOR_VERSION}/binary/${TARGET_SIDECAR}
build-linux32:
@rm -rf build/bundles/${MAJOR_VERSION}/binary
CGO_ENABLED=0 env GOOS=linux GOARCH=386 go build\
-ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X main.Version=${MAJOR_VERSION}(${GIT_VERSION})" \
-v -o ${TARGET} \
${PROJECT_NAME}/cmd/mosn/main
mkdir -p build/bundles/${MAJOR_VERSION}/binary
mv ${TARGET} build/bundles/${MAJOR_VERSION}/binary
@cd build/bundles/${MAJOR_VERSION}/binary && $(shell which md5sum) -b ${TARGET} | cut -d' ' -f1 > ${TARGET}.md5
cp configs/${CONFIG_FILE} build/bundles/${MAJOR_VERSION}/binary
cp build/bundles/${MAJOR_VERSION}/binary/${TARGET} build/bundles/${MAJOR_VERSION}/binary/${TARGET_SIDECAR}
build-linux64:
@rm -rf build/bundles/${MAJOR_VERSION}/binary
CGO_ENABLED=0 env GOOS=linux GOARCH=amd64 go build\
-ldflags "-B 0x$(shell head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -X main.Version=${MAJOR_VERSION}(${GIT_VERSION})" \
-v -o ${TARGET} \
${PROJECT_NAME}/cmd/mosn/main
mkdir -p build/bundles/${MAJOR_VERSION}/binary
mv ${TARGET} build/bundles/${MAJOR_VERSION}/binary
@cd build/bundles/${MAJOR_VERSION}/binary && $(shell which md5sum) -b ${TARGET} | cut -d' ' -f1 > ${TARGET}.md5
cp configs/${CONFIG_FILE} build/bundles/${MAJOR_VERSION}/binary
cp build/bundles/${MAJOR_VERSION}/binary/${TARGET} build/bundles/${MAJOR_VERSION}/binary/${TARGET_SIDECAR}
image:
@rm -rf IMAGEBUILD
cp -r build/contrib/builder/image IMAGEBUILD && cp build/bundles/${MAJOR_VERSION}/binary/${TARGET} IMAGEBUILD && cp -r configs IMAGEBUILD && cp -r etc IMAGEBUILD
docker build --no-cache --rm -t ${IMAGE_NAME}:${MAJOR_VERSION}-${GIT_VERSION} IMAGEBUILD
docker tag ${IMAGE_NAME}:${MAJOR_VERSION}-${GIT_VERSION} ${REPOSITORY}:${MAJOR_VERSION}-${GIT_VERSION}
rm -rf IMAGEBUILD
rpm:
@sleep 1 # sometimes device-mapper complains for a relax
docker build --rm -t ${RPM_BUILD_IMAGE} build/contrib/builder/rpm
docker run --rm -w /opt/${TARGET} \
-v $(shell pwd):/opt/${TARGET} \
-e RPM_GIT_VERSION=${GIT_VERSION} \
-e "RPM_GIT_NOTES=${GIT_NOTES}" \
${RPM_BUILD_IMAGE} make rpm-build-local
rpm-build-local:
@rm -rf build/bundles/${MAJOR_VERSION}/rpm
mkdir -p build/bundles/${MAJOR_VERSION}/rpm/${RPM_SRC_DIR}
cp -r build/bundles/${MAJOR_VERSION}/binary/${TARGET} build/bundles/${MAJOR_VERSION}/rpm/${RPM_SRC_DIR}
cp -r build/bundles/${MAJOR_VERSION}/binary/${CONFIG_FILE} build/bundles/${MAJOR_VERSION}/rpm/${RPM_SRC_DIR}
cp build/contrib/builder/rpm/${TARGET}.spec build/bundles/${MAJOR_VERSION}/rpm
cp build/contrib/builder/rpm/${TARGET}.service build/bundles/${MAJOR_VERSION}/rpm/${RPM_SRC_DIR}
cp build/contrib/builder/rpm/${TARGET}.logrotate build/bundles/${MAJOR_VERSION}/rpm/${RPM_SRC_DIR}
cd build/bundles/${MAJOR_VERSION}/rpm && tar zcvf ${RPM_TAR_FILE} ${RPM_SRC_DIR}
mv build/bundles/${MAJOR_VERSION}/rpm/${RPM_TAR_FILE} ~/rpmbuild/SOURCES
chown -R root:root ~/rpmbuild/SOURCES/${RPM_TAR_FILE}
rpmbuild -bb --clean build/contrib/builder/rpm/${TARGET}.spec \
--define "AFENP_NAME ${RPM_TAR_NAME}" \
--define "AFENP_VERSION ${RPM_VERSION}" \
--define "AFENP_RELEASE ${RPM_GIT_VERSION}" \
--define "AFENP_GIT_NOTES '${RPM_GIT_NOTES}'"
cp ~/rpmbuild/RPMS/x86_64/*.rpm build/bundles/${MAJOR_VERSION}/rpm
rm -rf build/bundles/${MAJOR_VERSION}/rpm/${RPM_SRC_DIR} build/bundles/${MAJOR_VERSION}/rpm/${TARGET}.spec
shell:
docker build --rm -t ${BUILD_IMAGE} build/contrib/builder/binary
docker run --rm -ti -v $(GOPATH):/go -v $(shell pwd):/go/src/${PROJECT_NAME} -w /go/src/${PROJECT_NAME} ${BUILD_IMAGE} /bin/bash
.PHONY: unit-test build image rpm upload shell
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/weizai118/sofa-mosn.git
git@gitee.com:weizai118/sofa-mosn.git
weizai118
sofa-mosn
sofa-mosn
master

搜索帮助