This repository has been archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Makefile
93 lines (75 loc) · 3.29 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
ROOT := $(shell pwd)
all: build
SOURCEDIR := ./img2lambda
BINARY_NAME=img2lambda
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
LOCAL_BINARY := bin/local/img2lambda
LINUX_BINARY := bin/linux-amd64/img2lambda
DARWIN_BINARY := bin/darwin-amd64/img2lambda
WINDOWS_BINARY := bin/windows-amd64/img2lambda.exe
LOCAL_PATH := $(ROOT)/scripts:${PATH}
VERSION := $(shell cat VERSION)
GITFILES := $(shell find ".git/")
.PHONY: build
build: format $(LOCAL_BINARY)
$(LOCAL_BINARY): $(SOURCES) GITCOMMIT_SHA
./scripts/build_binary.sh ./bin/local img2lambda $(VERSION) $(shell cat GITCOMMIT_SHA)
@echo "Built img2lambda"
.PHONY: integration-test
integration-test: $(LOCAL_BINARY)
./scripts/build_example.sh
.PHONY: generate
generate: $(SOURCES)
PATH=$(LOCAL_PATH) go generate -x $(shell go list ./img2lambda/... | grep -v '/vendor/')
.PHONY: format
format: $(SOURCES)
PATH=$(LOCAL_PATH) go fmt -x $(shell go list ./img2lambda/... | grep -v '/vendor/')
.PHONY: install-tools
install-tools:
go get golang.org/x/tools/cmd/cover
go get github.com/golang/mock/mockgen
go get golang.org/x/tools/cmd/goimports
.PHONY: windows-build
windows-build: $(WINDOWS_BINARY)
.PHONY: docker-build
docker-build:
docker run -v $(shell pwd):/usr/src/app/src/github.com/awslabs/aws-lambda-container-image-converter \
--workdir=/usr/src/app/src/github.com/awslabs/aws-lambda-container-image-converter \
--env GOPATH=/usr/src/app \
golang:1.13 make $(LINUX_BINARY)
docker run -v $(shell pwd):/usr/src/app/src/github.com/awslabs/aws-lambda-container-image-converter \
--workdir=/usr/src/app/src/github.com/awslabs/aws-lambda-container-image-converter \
--env GOPATH=/usr/src/app \
golang:1.13 make $(DARWIN_BINARY)
docker run -v $(shell pwd):/usr/src/app/src/github.com/awslabs/aws-lambda-container-image-converter \
--workdir=/usr/src/app/src/github.com/awslabs/aws-lambda-container-image-converter \
--env GOPATH=/usr/src/app \
golang:1.13 make $(WINDOWS_BINARY)
.PHONY: docker-test
docker-test:
docker run -v $(shell pwd):/usr/src/app/src/github.com/awslabs/aws-lambda-container-image-converter \
--workdir=/usr/src/app/src/github.com/awslabs/aws-lambda-container-image-converter \
--env GOPATH=/usr/src/app \
--env IMG_TOOL_RELEASE=$(IMG_TOOL_RELEASE) \
golang:1.13 make
.PHONY: stage-release-binaries
stage-release-binaries: $(LINUX_BINARY) $(DARWIN_BINARY) $(WINDOWS_BINARY)
$(WINDOWS_BINARY): $(SOURCES) GITCOMMIT_SHA
TARGET_GOOS=windows GOARCH=amd64 ./scripts/build_binary.sh ./bin/release-$(VERSION) windows-amd64-img2lambda.exe $(VERSION) $(shell cat GITCOMMIT_SHA)
@echo "Built img2lambda.exe for windows"
$(LINUX_BINARY): $(SOURCES) GITCOMMIT_SHA
TARGET_GOOS=linux GOARCH=amd64 ./scripts/build_binary.sh ./bin/release-$(VERSION) linux-amd64-img2lambda $(VERSION) $(shell cat GITCOMMIT_SHA)
@echo "Built img2lambda for linux"
$(DARWIN_BINARY): $(SOURCES) GITCOMMIT_SHA
TARGET_GOOS=darwin GOARCH=amd64 ./scripts/build_binary.sh ./bin/release-$(VERSION) darwin-amd64-img2lambda $(VERSION) $(shell cat GITCOMMIT_SHA)
@echo "Built img2lambda for darwin"
GITCOMMIT_SHA: $(GITFILES)
git rev-parse --short=7 HEAD > GITCOMMIT_SHA
.PHONY: clean
clean:
- rm -rf ./bin
- rm -rf ./output
- rm -rf ./example/output
- rm -f GITCOMMIT_SHA