summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgy95 <guoyao17@huawei.com>2022-03-30 14:51:00 +0800
committergy95 <guoyao17@huawei.com>2022-04-06 10:59:42 +0800
commit0bd2d508040b774f5678e318fe7747dadc7d3599 (patch)
tree481e001e5766d146d5aee04955f65889da482224
parentMerge pull request #3750 from vincentgoat/optimize_sendobj (diff)
downloadkubeedge-0bd2d508040b774f5678e318fe7747dadc7d3599.tar.gz
support compile binaries with golang images
Signed-off-by: gy95 <guoyao17@huawei.com>
-rw-r--r--Makefile10
-rwxr-xr-xhack/make-rules/build_with_container.sh29
2 files changed, 39 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 4ec131fc5..784cd140e 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,8 @@ COMPONENTS=cloud \
.EXPORT_ALL_VARIABLES:
OUT_DIR ?= _output/local
+RUN = hack/make-rules/build_with_container.sh
+
define ALL_HELP_INFO
# Build code.
#
@@ -40,12 +42,20 @@ define ALL_HELP_INFO
# to "-N -l" to disable optimizations and inlining, this will be helpful when you want to
# use the debugging tools like delve. When GOLDFLAGS is unspecified, it defaults to "-s -w" which strips
# debug information, see https://golang.org/cmd/link for other flags.
+#
+# Set the environment variable or arg BUILD_WITH_CONTAINER to build inside container,
+# only docker and make are required in this mode.
+# 1) make all WHAT=cloudcore BUILD_WITH_CONTAINER=true
+# 2) export BUILD_WITH_CONTAINER=true && make all WHAT=cloudcore
endef
.PHONY: all
ifeq ($(HELP),y)
all: clean
@echo "$$ALL_HELP_INFO"
+else ifeq ($(BUILD_WITH_CONTAINER),true)
+all:
+ $(RUN) hack/make-rules/build.sh $(WHAT)
else
all:
KUBEEDGE_OUTPUT_SUBPATH=$(OUT_DIR) hack/make-rules/build.sh $(WHAT)
diff --git a/hack/make-rules/build_with_container.sh b/hack/make-rules/build_with_container.sh
new file mode 100755
index 000000000..80fb3fb03
--- /dev/null
+++ b/hack/make-rules/build_with_container.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+###
+#Copyright 2022 The KubeEdge Authors.
+#
+#Licensed under the Apache License, Version 2.0 (the "License");
+#you may not use this file except in compliance with the License.
+#You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing, software
+#distributed under the License is distributed on an "AS IS" BASIS,
+#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#See the License for the specific language governing permissions and
+#limitations under the License.
+###
+
+set -o errexit
+set -o nounset
+set -o pipefail
+
+KUBEEDGE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
+MOUNTPATH="${MOUNTPATH:-/kubeedge}"
+KUBEEDGE_BUILD_IMAGE=${KUBEEDGE_BUILD_IMAGE:-"kubeedge/build-tools"}
+
+set -x
+docker run --rm -v ${KUBEEDGE_ROOT}:${MOUNTPATH} -w ${MOUNTPATH} ${KUBEEDGE_BUILD_IMAGE} "$@"
+set +x