Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 5763321

Browse files
geeknoidistio-testing
authored andcommitted
Update common files. (#229)
1 parent 954cb2b commit 5763321

12 files changed

+235
-61
lines changed

.commonfiles.sha

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# common-files repo, make the change there and check it in. Then come back to this repo and run
66
# "make update-common".
77

8-
# Copyright 2019 Istio Authors
8+
# Copyright Istio Authors
99
#
1010
# Licensed under the Apache License, Version 2.0 (the "License");
1111
# you may not use this file except in compliance with the License.
@@ -22,19 +22,18 @@
2222
# allow optional per-repo overrides
2323
-include Makefile.overrides.mk
2424

25-
RUN =
26-
2725
# Set the environment variable BUILD_WITH_CONTAINER to use a container
2826
# to build the repo. The only dependencies in this mode are to have make and
2927
# docker. If you'd rather build with a local tool chain instead, you'll need to
3028
# figure out all the tools you need in your environment to make that work.
3129
export BUILD_WITH_CONTAINER ?= 0
30+
3231
ifeq ($(BUILD_WITH_CONTAINER),1)
33-
IMG = gcr.io/istio-testing/build-tools:2019-08-21T08-35-40
32+
IMG = gcr.io/istio-testing/build-tools:2019-08-25T20-37-02
3433
UID = $(shell id -u)
3534
PWD = $(shell pwd)
3635
GOBIN_SOURCE ?= $(GOPATH)/bin
37-
export GOBIN ?= /work/out/bin
36+
GOBIN ?= /work/out/bin
3837

3938
LOCAL_ARCH := $(shell uname -m)
4039
ifeq ($(LOCAL_ARCH),x86_64)
@@ -46,23 +45,25 @@ GOARCH_LOCAL := arm
4645
else
4746
GOARCH_LOCAL := $(LOCAL_ARCH)
4847
endif
49-
export GOARCH ?= $(GOARCH_LOCAL)
48+
49+
GOARCH ?= $(GOARCH_LOCAL)
5050

5151
LOCAL_OS := $(shell uname)
5252
ifeq ($(LOCAL_OS),Linux)
53-
export GOOS_LOCAL = linux
53+
GOOS_LOCAL = linux
5454
else ifeq ($(LOCAL_OS),Darwin)
55-
export GOOS_LOCAL = darwin
55+
GOOS_LOCAL = darwin
5656
else
5757
$(error "This system's OS $(LOCAL_OS) isn't recognized/supported")
5858
endif
5959

60-
export GOOS ?= $(GOOS_LOCAL)
60+
GOOS ?= $(GOOS_LOCAL)
6161

6262
RUN = docker run -t -i --sig-proxy=true -u $(UID) --rm \
6363
-e GOOS="$(GOOS)" \
6464
-e GOARCH="$(GOARCH)" \
6565
-e GOBIN="$(GOBIN)" \
66+
-e BUILD_WITH_CONTAINER="$(BUILD_WITH_CONTAINER)" \
6667
-v /etc/passwd:/etc/passwd:ro \
6768
-v $(readlink /etc/localtime):/etc/localtime:ro \
6869
$(CONTAINER_OPTIONS) \
@@ -73,6 +74,7 @@ RUN = docker run -t -i --sig-proxy=true -u $(UID) --rm \
7374
-w /work $(IMG)
7475
else
7576
export GOBIN ?= ./out/bin
77+
RUN =
7678
endif
7779

7880
MAKE = $(RUN) make --no-print-directory -e -f Makefile.core.mk
@@ -82,3 +84,5 @@ MAKE = $(RUN) make --no-print-directory -e -f Makefile.core.mk
8284

8385
default:
8486
@$(MAKE)
87+
88+
.PHONY: default

Makefile.common.mk

Lines changed: 0 additions & 50 deletions
This file was deleted.

Makefile.core.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ generate-values: $(values_v1alpha2_pb_gos) $(values_v1alpha2_pb_docs) $(values_v
105105
clean-values:
106106
@rm -fr $(values_v1alpha2_pb_gos) $(values_v1alpha2_pb_docs) $(values_v1alpha2_pb_pythons)
107107

108-
include Makefile.common.mk
108+
include common/Makefile.common.mk

common/.commonfiles.sha

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
924cf1256448b0869bf55646525e1439ec11f85c

common/Makefile.common.mk

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# WARNING: DO NOT EDIT, THIS FILE IS PROBABLY A COPY
2+
#
3+
# The original version of this file is located in the https://github.com/istio/common-files repo.
4+
# If you're looking at this file in a different repo and want to make a change, please go to the
5+
# common-files repo, make the change there and check it in. Then come back to this repo and run
6+
# "make update-common".
7+
8+
# Copyright Istio Authors
9+
#
10+
# Licensed under the Apache License, Version 2.0 (the "License");
11+
# you may not use this file except in compliance with the License.
12+
# You may obtain a copy of the License at
13+
#
14+
# http://www.apache.org/licenses/LICENSE-2.0
15+
#
16+
# Unless required by applicable law or agreed to in writing, software
17+
# distributed under the License is distributed on an "AS IS" BASIS,
18+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
# See the License for the specific language governing permissions and
20+
# limitations under the License.
21+
22+
FINDFILES=find . \( -path ./vendor -o -path ./.git \) -prune -o -type f
23+
XARGS = xargs -0 -r
24+
25+
lint-dockerfiles:
26+
@${FINDFILES} -name 'Dockerfile*' -print0 | ${XARGS} hadolint -c ./common/config/.hadolint.yml
27+
28+
lint-scripts:
29+
@${FINDFILES} -name '*.sh' -print0 | ${XARGS} shellcheck
30+
31+
lint-yaml:
32+
@${FINDFILES} \( -name '*.yml' -o -name '*.yaml' \) -print0 | ${XARGS} grep -L -e "{{" | xargs -r yamllint -c ./common/config/.yamllint.yml
33+
34+
lint-helm:
35+
@${FINDFILES} -name 'Chart.yaml' -print0 | ${XARGS} -L 1 dirname | xargs -r helm lint --strict
36+
37+
lint-copyright-banner:
38+
@${FINDFILES} \( -name '*.go' -o -name '*.cc' -o -name '*.h' -o -name '*.proto' -o -name '*.py' -o -name '*.sh' \) \( ! \( -name '*.gen.go' -o -name '*.pb.go' -o -name '*_pb2.py' \) \) -print0 |\
39+
${XARGS} common/scripts/lint_copyright_banner.sh
40+
41+
lint-go:
42+
@golangci-lint run -j 8 -c ./common/config/.golangci.yml
43+
44+
lint-python:
45+
@${FINDFILES} -name '*.py' -print0 | ${XARGS} autopep8 --max-line-length 160 --exit-code -d
46+
47+
format-go:
48+
@${FINDFILES} -name '*.go' \( ! \( -name '*.gen.go' -o -name '*.pb.go' \) \) -print0 | ${XARGS} goimports -w -local "istio.io"
49+
50+
format-python:
51+
@${FINDFILES} -name '*.py' -print0 | ${XARGS} autopep8 --max-line-length 160 --aggressive --aggressive -i
52+
53+
update-common:
54+
@git clone --depth 1 --single-branch --branch master https://github.com/istio/common-files
55+
@cd common-files ; git rev-parse HEAD >files/common/.commonfiles.sha
56+
@rm -fr common
57+
@cp -r common-files/files/* .
58+
@rm -fr common-files
59+
60+
.PHONY: lint-dockerfiles lint-scripts lint-yaml lint-copyright-banner lint-go lint-pyhton lint-helm format-go format-python update-common
File renamed without changes.
File renamed without changes.
File renamed without changes.

common/scripts/gobuild.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
#
3+
# Copyright Istio Authors. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# This script builds and version stamps the output
18+
19+
VERBOSE=${VERBOSE:-"0"}
20+
V=""
21+
if [[ "${VERBOSE}" == "1" ]];then
22+
V="-x"
23+
set -x
24+
fi
25+
26+
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
27+
28+
OUT=${1:?"output path"}
29+
BUILDPATH=${2:?"path to build"}
30+
31+
set -e
32+
33+
BUILD_GOOS=${GOOS:-linux}
34+
BUILD_GOARCH=${GOARCH:-amd64}
35+
GOBINARY=${GOBINARY:-go}
36+
BUILDINFO=${BUILDINFO:-""}
37+
STATIC=${STATIC:-1}
38+
LDFLAGS="-extldflags -static"
39+
GOBUILDFLAGS=${GOBUILDFLAGS:-""}
40+
# Split GOBUILDFLAGS by spaces into an array called GOBUILDFLAGS_ARRAY.
41+
IFS=' ' read -r -a GOBUILDFLAGS_ARRAY <<< "$GOBUILDFLAGS"
42+
43+
GCFLAGS=${GCFLAGS:-}
44+
export CGO_ENABLED=0
45+
46+
if [[ "${STATIC}" != "1" ]];then
47+
LDFLAGS=""
48+
fi
49+
50+
# gather buildinfo if not already provided
51+
# For a release build BUILDINFO should be produced
52+
# at the beginning of the build and used throughout
53+
if [[ -z ${BUILDINFO} ]];then
54+
BUILDINFO=$(mktemp)
55+
"${SCRIPTPATH}/report_build_info.sh" > "${BUILDINFO}"
56+
fi
57+
58+
# BUILD LD_EXTRAFLAGS
59+
LD_EXTRAFLAGS=""
60+
while read -r line; do
61+
LD_EXTRAFLAGS="${LD_EXTRAFLAGS} -X ${line}"
62+
done < "${BUILDINFO}"
63+
64+
time GOOS=${BUILD_GOOS} GOARCH=${BUILD_GOARCH} ${GOBINARY} build \
65+
${V} "${GOBUILDFLAGS_ARRAY[@]}" ${GCFLAGS:+-gcflags "${GCFLAGS}"} \
66+
-o "${OUT}" \
67+
-ldflags "${LDFLAGS} ${LD_EXTRAFLAGS}" "${BUILDPATH}"

0 commit comments

Comments
 (0)