代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/chaosblade 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
.PHONY: build clean
export BLADE_VERSION=1.0.0
ALLOWGITVERSION=1.8.5
GITVERSION:=$(shell git --version | grep ^git | sed 's/^.* //g')
ifneq ($(strip $(firstword $(sort $(GITVERSION), $(ALLOWGITVERSION)))),$(ALLOWGITVERSION))
ALERTMSG="please update git to >= $(ALLOWGITVERSION)"
endif
BLADE_BIN=blade
BLADE_EXPORT=chaosblade-$(BLADE_VERSION).tgz
BLADE_SRC_ROOT=$(shell pwd)
GO_ENV=CGO_ENABLED=1
GO_MODULE=GO111MODULE=on
VERSION_PKG=github.com/chaosblade-io/chaosblade/version
# Specify chaosblade version in docker experiments
DOCKER_BLADE_VERSION=github.com/chaosblade-io/chaosblade-exec-docker/version
OS_BLADE_VERSION=github.com/chaosblade-io/chaosblade-exec-os/version
GO_X_FLAGS=-X ${VERSION_PKG}.Ver=$(BLADE_VERSION) -X '${VERSION_PKG}.Env=`uname -mv`' -X '${VERSION_PKG}.BuildTime=`date`' -X ${DOCKER_BLADE_VERSION}.BladeVersion=$(BLADE_VERSION) -X ${OS_BLADE_VERSION}.BladeVersion=$(BLADE_VERSION)
GO_FLAGS=-ldflags="$(GO_X_FLAGS) -s -w"
GO=env $(GO_ENV) $(GO_MODULE) go
UNAME := $(shell uname)
BUILD_TARGET=target
BUILD_TARGET_FOR_JAVA_CPLUS=build-target
BUILD_TARGET_DIR_NAME=chaosblade-$(BLADE_VERSION)
BUILD_TARGET_PKG_DIR=$(BUILD_TARGET)/chaosblade-$(BLADE_VERSION)
BUILD_TARGET_PKG_NAME=$(BUILD_TARGET)/chaosblade-$(BLADE_VERSION).tar.gz
BUILD_TARGET_BIN=$(BUILD_TARGET_PKG_DIR)/bin
BUILD_TARGET_LIB=$(BUILD_TARGET_PKG_DIR)/lib
BUILD_TARGET_YAML=$(BUILD_TARGET_PKG_DIR)/yaml
BUILD_TARGET_TAR_NAME=$(BUILD_TARGET_DIR_NAME).tar.gz
BUILD_TARGET_PKG_FILE_PATH=$(BUILD_TARGET)/$(BUILD_TARGET_TAR_NAME)
BUILD_IMAGE_PATH=build/image/blade
BUILD_ARM_IMAGE_PATH=build/image/blade_arm
# cache downloaded file
BUILD_TARGET_CACHE=$(BUILD_TARGET)/cache
# chaosblade-exec-os
BLADE_EXEC_OS_PROJECT=https://github.com/chaosblade-io/chaosblade-exec-os.git
BLADE_EXEC_OS_BRANCH=master
# chaosblade-exec-docker
BLADE_EXEC_DOCKER_PROJECT=https://github.com/chaosblade-io/chaosblade-exec-docker.git
BLADE_EXEC_DOCKER_BRANCH=master
# chaosblade-exec-kubernetes
BLADE_OPERATOR_PROJECT=https://github.com/chaosblade-io/chaosblade-operator.git
BLADE_OPERATOR_BRANCH=master
# chaosblade-exec-jvm
BLADE_EXEC_JVM_PROJECT=https://github.com/chaosblade-io/chaosblade-exec-jvm.git
BLADE_EXEC_JVM_BRANCH=master
# chaosblade-exec-cplus
BLADE_EXEC_CPLUS_PROJECT=https://github.com/chaosblade-io/chaosblade-exec-cplus.git
BLADE_EXEC_CPLUS_BRANCH=master
# docker yaml
DOCKER_YAML_FILE_NAME=chaosblade-docker-spec-$(BLADE_VERSION).yaml
DOCKER_YAML_FILE_PATH=$(BUILD_TARGET_BIN)/$(DOCKER_YAML_FILE_NAME)
ifeq ($(GOOS), linux)
GO_FLAGS=-ldflags="-linkmode external -extldflags -static $(GO_X_FLAGS) -s -w"
endif
help:
@echo ''
@echo 'You can compile each project of ChaosBlade on Mac or Linux platform,'
@echo 'You can use docker to compile cross-platform,compile the package running on Linux platform.'
@echo 'For details refer to https://github.com/chaosblade-io/chaosblade/wiki/ChaosBlade-Projects-Compilation'
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>...\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Build
build: pre_build cli os docker kubernetes cplus java upx package ## Build all scenarios
# for example: make build_with cli os_darwin
build_with: pre_build ## Select scenario build, for example `make build_with cli os docker kubernetes java cplus`
# for example: make build_with_linux cli os
build_with_linux: pre_build build_linux_with_arg ## Select scenario build linux version by docker image, for example `make build_with_linux ARGS="cli os"`
build_with_linux_arm: pre_build build_linux_arm_with_arg ## Select scenario build linux version by docker image, for example `make build_with_linux_arm ARGS="cli os"`
# build chaosblade linux version by docker image
build_linux: ## Build linux version of all scenarios by docker image
make build_with_linux ARGS="cli os docker kubernetes java cplus" upx package
build_linux_arm: ## Build linux arm version of all scenarios by docker image
make build_with_linux_arm ARGS="cli os docker kubernetes java cplus" upx package
build_darwin: pre_build cli os_darwin docker kubernetes java cplus upx package ## Build all scenarios darwin version
##@ Build sub
# create dir or download necessary file
pre_build: mkdir_build_target ## Mkdir build target
rm -rf $(BUILD_TARGET_PKG_DIR) $(BUILD_TARGET_PKG_FILE_PATH)
mkdir -p $(BUILD_TARGET_BIN) $(BUILD_TARGET_LIB) $(BUILD_TARGET_YAML)
# build chaosblade cli: blade
.PHONY:cli
cli: ## Build blade cli
$(GO) build $(GO_FLAGS) -o $(BUILD_TARGET_PKG_DIR)/blade ./cli
os: ## Build basic resource experimental scenarios.
ifneq ($(BUILD_TARGET_CACHE)/chaosblade-exec-os, $(wildcard $(BUILD_TARGET_CACHE)/chaosblade-exec-os))
git clone -b $(BLADE_EXEC_OS_BRANCH) $(BLADE_EXEC_OS_PROJECT) $(BUILD_TARGET_CACHE)/chaosblade-exec-os
else
ifdef ALERTMSG
$(error $(ALERTMSG))
endif
git -C $(BUILD_TARGET_CACHE)/chaosblade-exec-os pull origin $(BLADE_EXEC_OS_BRANCH)
endif
make -C $(BUILD_TARGET_CACHE)/chaosblade-exec-os
cp $(BUILD_TARGET_CACHE)/chaosblade-exec-os/$(BUILD_TARGET_BIN)/* $(BUILD_TARGET_BIN)
cp $(BUILD_TARGET_CACHE)/chaosblade-exec-os/$(BUILD_TARGET_YAML)/* $(BUILD_TARGET_YAML)
os_darwin: ## Build basic resource experimental scenarios for darwin.
ifneq ($(BUILD_TARGET_CACHE)/chaosblade-exec-os, $(wildcard $(BUILD_TARGET_CACHE)/chaosblade-exec-os))
git clone -b $(BLADE_EXEC_OS_BRANCH) $(BLADE_EXEC_OS_PROJECT) $(BUILD_TARGET_CACHE)/chaosblade-exec-os
else
ifdef ALERTMSG
$(error $(ALERTMSG))
endif
git -C $(BUILD_TARGET_CACHE)/chaosblade-exec-os pull origin $(BLADE_EXEC_OS_BRANCH)
endif
make build_darwin -C $(BUILD_TARGET_CACHE)/chaosblade-exec-os
cp $(BUILD_TARGET_CACHE)/chaosblade-exec-os/$(BUILD_TARGET_BIN)/* $(BUILD_TARGET_BIN)
cp $(BUILD_TARGET_CACHE)/chaosblade-exec-os/$(BUILD_TARGET_YAML)/* $(BUILD_TARGET_YAML)
docker: ## Build docker experimental scenarios.
ifneq ($(BUILD_TARGET_CACHE)/chaosblade-exec-docker, $(wildcard $(BUILD_TARGET_CACHE)/chaosblade-exec-docker))
git clone -b $(BLADE_EXEC_DOCKER_BRANCH) $(BLADE_EXEC_DOCKER_PROJECT) $(BUILD_TARGET_CACHE)/chaosblade-exec-docker
else
git -C $(BUILD_TARGET_CACHE)/chaosblade-exec-docker pull origin $(BLADE_EXEC_DOCKER_BRANCH)
endif
make -C $(BUILD_TARGET_CACHE)/chaosblade-exec-docker
cp $(BUILD_TARGET_CACHE)/chaosblade-exec-docker/$(BUILD_TARGET_YAML)/* $(BUILD_TARGET_YAML)
kubernetes: ## Build kubernetes experimental scenarios.
ifneq ($(BUILD_TARGET_CACHE)/chaosblade-operator, $(wildcard $(BUILD_TARGET_CACHE)/chaosblade-operator))
git clone -b $(BLADE_OPERATOR_BRANCH) $(BLADE_OPERATOR_PROJECT) $(BUILD_TARGET_CACHE)/chaosblade-operator
else
git -C $(BUILD_TARGET_CACHE)/chaosblade-operator pull origin $(BLADE_OPERATOR_BRANCH)
endif
make -C $(BUILD_TARGET_CACHE)/chaosblade-operator
cp $(BUILD_TARGET_CACHE)/chaosblade-operator/$(BUILD_TARGET_BIN)/* $(BUILD_TARGET_BIN)
cp $(BUILD_TARGET_CACHE)/chaosblade-operator/$(BUILD_TARGET_YAML)/* $(BUILD_TARGET_YAML)
java: ## Build java experimental scenarios.
ifneq ($(BUILD_TARGET_CACHE)/chaosblade-exec-jvm, $(wildcard $(BUILD_TARGET_CACHE)/chaosblade-exec-jvm))
git clone -b $(BLADE_EXEC_JVM_BRANCH) $(BLADE_EXEC_JVM_PROJECT) $(BUILD_TARGET_CACHE)/chaosblade-exec-jvm
else
ifdef ALERTMSG
$(error $(ALERTMSG))
endif
git -C $(BUILD_TARGET_CACHE)/chaosblade-exec-jvm pull origin $(BLADE_EXEC_JVM_BRANCH)
endif
make -C $(BUILD_TARGET_CACHE)/chaosblade-exec-jvm
cp -R $(BUILD_TARGET_CACHE)/chaosblade-exec-jvm/$(BUILD_TARGET_FOR_JAVA_CPLUS)/$(BUILD_TARGET_DIR_NAME)/* $(BUILD_TARGET_PKG_DIR)
cplus: ## Build c/c++ experimental scenarios.
ifneq ($(BUILD_TARGET_CACHE)/chaosblade-exec-cplus, $(wildcard $(BUILD_TARGET_CACHE)/chaosblade-exec-cplus))
git clone -b $(BLADE_EXEC_CPLUS_BRANCH) $(BLADE_EXEC_CPLUS_PROJECT) $(BUILD_TARGET_CACHE)/chaosblade-exec-cplus
else
ifdef ALERTMSG
$(error $(ALERTMSG))
endif
git -C $(BUILD_TARGET_CACHE)/chaosblade-exec-cplus pull origin $(BLADE_EXEC_CPLUS_BRANCH)
endif
make -C $(BUILD_TARGET_CACHE)/chaosblade-exec-cplus
cp -R $(BUILD_TARGET_CACHE)/chaosblade-exec-cplus/$(BUILD_TARGET_FOR_JAVA_CPLUS)/$(BUILD_TARGET_DIR_NAME)/* $(BUILD_TARGET_PKG_DIR)
##@ Build image
# build chaosblade image for chaos
build_image: ## Build chaosblade-tool image
rm -rf $(BUILD_IMAGE_PATH)/$(BUILD_TARGET_DIR_NAME)
cp -R $(BUILD_TARGET_PKG_NAME) $(BUILD_IMAGE_PATH)
tar zxvf $(BUILD_TARGET_PKG_NAME) -C $(BUILD_IMAGE_PATH)
docker build -f $(BUILD_IMAGE_PATH)/Dockerfile \
--build-arg BLADE_VERSION=$(BLADE_VERSION) \
-t chaosblade-tool:$(BLADE_VERSION) \
$(BUILD_IMAGE_PATH)
rm -rf $(BUILD_IMAGE_PATH)/$(BUILD_TARGET_DIR_NAME)
build_image_arm: ## Build chaosblade-tool-arm image
rm -rf $(BUILD_ARM_IMAGE_PATH)/$(BUILD_TARGET_DIR_NAME)
cp -R $(BUILD_TARGET_PKG_NAME) $(BUILD_ARM_IMAGE_PATH)
tar zxvf $(BUILD_TARGET_PKG_NAME) -C $(BUILD_ARM_IMAGE_PATH)
docker build -f $(BUILD_ARM_IMAGE_PATH)/Dockerfile \
--build-arg BLADE_VERSION=$(BLADE_VERSION) \
-t chaosblade-tool-arm:$(BLADE_VERSION) \
$(BUILD_ARM_IMAGE_PATH)
rm -rf $(BUILD_ARM_IMAGE_PATH)/$(BUILD_TARGET_DIR_NAME)
# build docker image with multi-stage builds
docker_image: clean ## Build chaosblade image
docker build -f ./Dockerfile \
--build-arg BLADE_VERSION=$(BLADE_VERSION) \
-t chaosblade:$(BLADE_VERSION) $(BLADE_SRC_ROOT)
build_upx_image:
docker build --rm \
-f build/image/upx/Dockerfile \
-t chaosblade-upx:3.96 build/image/upx
##@ Other
upx: ## Upx compression by docker image
docker run --rm \
-w $(shell pwd)/$(BUILD_TARGET_PKG_DIR) \
-v $(shell pwd)/$(BUILD_TARGET_PKG_DIR):$(shell pwd)/$(BUILD_TARGET_PKG_DIR) \
chaosbladeio/chaosblade-upx:3.96 \
--best \
blade $(shell pwd)/$(BUILD_TARGET_PKG_DIR)/bin/*
test: ## Test
$(GO) test -race -coverprofile=coverage.txt -covermode=atomic ./...
# clean all build result
clean: ## Clean
$(GO) clean ./...
rm -rf $(BUILD_TARGET)
rm -rf $(BUILD_IMAGE_PATH)/$(BUILD_TARGET_DIR_NAME)
package: ## Generate the tar packages
tar zcvf $(BUILD_TARGET_PKG_FILE_PATH) -C $(BUILD_TARGET) $(BUILD_TARGET_DIR_NAME)
## Select scenario build linux version by docker image
build_linux_with_arg:
docker run --rm \
-v $(shell echo -n ${GOPATH}):/go \
-w /go/src/github.com/chaosblade-io/chaosblade \
-v ~/.m2/repository:/root/.m2/repository \
-v $(shell pwd):/go/src/github.com/chaosblade-io/chaosblade \
chaosbladeio/chaosblade-build-musl:latest build_with $$ARGS
## Select scenario build linux arm version by docker image
build_linux_arm_with_arg:
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run --rm \
-v $(shell echo -n ${GOPATH}):/go \
-w /go/src/github.com/chaosblade-io/chaosblade \
-v ~/.m2/repository:/root/.m2/repository \
-v $(shell pwd):/go/src/github.com/chaosblade-io/chaosblade \
chaosbladeio/chaosblade-build-arm:latest build_with $$ARGS
# create cache dir
mkdir_build_target:
ifneq ($(BUILD_TARGET_CACHE), $(wildcard $(BUILD_TARGET_CACHE)))
mkdir -p $(BUILD_TARGET_CACHE)
endif
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。