forked from aws/aws-lambda-runtime-interface-emulator
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
45 lines (33 loc) · 1.33 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
# Golang EOL overview: https://endoflife.date/go
DOCKER_GOLANG_IMAGE ?= golang:1.21.0-bullseye
# On ARM hosts, use: make ARCH=arm64 build-init
# Check host architecture: uname -m
# x86_64 or arm64
ARCH ?= x86_64
ifeq ($(ARCH), arm64)
GOARCH=arm64
else
GOARCH=amd64
endif
# Limitation: Debugging x86_64 lambdas does not work on ARM machines due to missing ptrace implementation in qemu used by Docker
# The function aborts with "could not launch process: fork/exec /var/rapid/init: function not implemented"
# * Discussion: https://github.com/aws/aws-sam-cli/discussions/4706
# * Docker for Mac: https://github.com/docker/for-mac/issues/5191#issuecomment-834154431
all: build
# build & "package" necessary files for debugging
build build-init: build-rapid build-delve/dlv
cp ../bin/aws-lambda-rie-$(ARCH) ./init/var/rapid/init
cp ./build-delve/dlv ./init/var/rapid/dlv
build-rapid:
cd .. && GC_FLAGS="all=-N -l" make ARCH=$(ARCH) compile-lambda-linux
build-delve/dlv:
docker run --rm -v $$(pwd)/build-delve/:/app/ $(DOCKER_GOLANG_IMAGE) \
bash -c "cd /app && export GOARCH=$(GOARCH) && ./build.sh"
clean clean-init: clean-rapid clean-delve
clean-rapid:
rm -rf ../bin/aws-lambda-rie-*
rm -rf ./init/var/rapid/init
clean-delve:
rm -rf ./build-delve/dlv
rm -rf ./init/var/rapid/dlv
.PHONY: build build-rapid clean clean-rapid clean-delve