Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Makefile to ease debugging #26159

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 41 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ debug: all
include Makefile.defs

SUBDIRS_CILIUM_CONTAINER := proxylib envoy bpf cilium daemon cilium-health bugtool tools/mount tools/sysctlfix
SUBDIRS := $(SUBDIRS_CILIUM_CONTAINER) operator plugins tools hubble-relay
SUBDIR_OPERATOR_CONTAINER := operator

# Add the ability to override variables
-include Makefile.override

SUBDIRS := $(SUBDIRS_CILIUM_CONTAINER) $(SUBDIR_OPERATOR_CONTAINER) plugins tools hubble-relay

SUBDIRS_CILIUM_CONTAINER += plugins/cilium-cni
ifdef LIBNETWORK_PLUGIN
Expand Down Expand Up @@ -55,6 +60,21 @@ build: check-sources $(SUBDIRS) ## Builds all the components for Cilium by execu
build-container: check-sources ## Builds components required for cilium-agent container.
for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i all; done

build-container-operator: ## Builds components required for cilium-operator container.
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) all

build-container-operator-generic: ## Builds components required for a cilium-operator generic variant container.
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-generic

build-container-operator-aws: ## Builds components required for a cilium-operator aws variant container.
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-aws

build-container-operator-azure: ## Builds components required for a cilium-operator azure variant container.
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-azure

build-container-operator-alibabacloud: ## Builds components required for a cilium-operator alibabacloud variant container.
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-alibabacloud

$(SUBDIRS): force ## Execute default make target(make all) for the provided subdirectory.
@ $(MAKE) $(SUBMAKEOPTS) -C $@ all

Expand Down Expand Up @@ -175,6 +195,26 @@ install-bash-completion: ## Install bash completion for all components required
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i install-bash-completion; done

install-container-binary-operator: ## Install binaries for all components required for cilium-operator container.
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install

install-container-binary-operator-generic: ## Install binaries for all components required for cilium-operator generic variant container.
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-generic

install-container-binary-operator-aws: ## Install binaries for all components required for cilium-operator aws variant container.
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-aws

install-container-binary-operator-azure: ## Install binaries for all components required for cilium-operator azure variant container.
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-azure

install-container-binary-operator-alibabacloud: ## Install binaries for all components required for cilium-operator alibabacloud variant container.
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-alibabacloud

# Workaround for not having git in the build environment
# Touch the file only if needed
GIT_VERSION: force
Expand Down
6 changes: 4 additions & 2 deletions daemon/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Copyright Authors of Cilium
# SPDX-License-Identifier: Apache-2.0

include ../Makefile.defs
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

include ${ROOT_DIR}/../Makefile.defs

TARGET := cilium-agent

all: $(TARGET)

.PHONY: all $(TARGET)

$(TARGET): ../Makefile ../Makefile.defs Makefile
$(TARGET):
@$(ECHO_GO)
$(QUIET)$(GO_BUILD) -o $(TARGET)

Expand Down
7 changes: 3 additions & 4 deletions images/operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ ARG LOCKDEBUG
ARG RACE
ARG OPERATOR_VARIANT

WORKDIR /go/src/github.com/cilium/cilium/operator
WORKDIR /go/src/github.com/cilium/cilium

RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg \
make GOARCH=${TARGETARCH} RACE=${RACE} NOSTRIP=${NOSTRIP} NOOPT=${NOOPT} LOCKDEBUG=${LOCKDEBUG} cilium-${OPERATOR_VARIANT} \
&& mkdir -p /out/${TARGETOS}/${TARGETARCH}/usr/bin && mv cilium-${OPERATOR_VARIANT} /out/${TARGETOS}/${TARGETARCH}/usr/bin
make GOARCH=${TARGETARCH} RACE=${RACE} NOSTRIP=${NOSTRIP} NOOPT=${NOOPT} LOCKDEBUG=${LOCKDEBUG} \
DESTDIR=/out/${TARGETOS}/${TARGETARCH} build-container-${OPERATOR_VARIANT} install-container-binary-${OPERATOR_VARIANT}

WORKDIR /go/src/github.com/cilium/cilium
# licenses-all is a "script" that executes "go run" so its ARCH should be set
# to the same ARCH specified in the base image of this Docker stage (BUILDARCH)
RUN --mount=type=bind,readwrite,target=/go/src/github.com/cilium/cilium \
Expand Down
20 changes: 19 additions & 1 deletion operator/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright Authors of Cilium
# SPDX-License-Identifier: Apache-2.0

include ../Makefile.defs
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

include ${ROOT_DIR}/../Makefile.defs

TARGETS := cilium-operator cilium-operator-generic cilium-operator-aws cilium-operator-azure cilium-operator-alibabacloud

Expand Down Expand Up @@ -31,3 +33,19 @@ clean:
install:
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(foreach target,$(TARGETS), $(QUIET)$(INSTALL) -m 0755 $(target) $(DESTDIR)$(BINDIR);)

install-generic:
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(QUIET)$(INSTALL) -m 0755 cilium-operator-generic $(DESTDIR)$(BINDIR)

install-aws:
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(QUIET)$(INSTALL) -m 0755 cilium-operator-aws $(DESTDIR)$(BINDIR)

install-azure:
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(QUIET)$(INSTALL) -m 0755 cilium-operator-azure $(DESTDIR)$(BINDIR)

install-alibabacloud:
$(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR)
$(QUIET)$(INSTALL) -m 0755 cilium-operator-alibabacloud $(DESTDIR)$(BINDIR)