Skip to content

Commit

Permalink
Add basic Kconfig support for lima-guestagent
Browse files Browse the repository at this point in the history
Make it possible to configure which guestagents to build.

Regenerating config file requires kconfig or kbuild tools.

Signed-off-by: Anders F Björklund <[email protected]>
  • Loading branch information
afbjorklund committed Sep 15, 2023
1 parent a1a0491 commit 418122f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_output/
_artifacts/
lima.REJECTED.yaml
.config
32 changes: 32 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

mainmenu "Lima"

config GUESTAGENT_OS_LINUX
bool "guestagent OS: Linux"
help
Build lima-guestagent for "Linux" OS
default y

config GUESTAGENT_ARCH_X8664
bool "guestagent Arch: x86_64"
help
Build lima-guestagent for "x86_64" Arch
default y

config GUESTAGENT_ARCH_AARCH64
bool "guestagent Arch: aarch64"
help
Build lima-guestagent for "aarch64" Arch
default y

config GUESTAGENT_ARCH_ARMV7L
bool "guestagent Arch: armv7l"
help
Build lima-guestagent for "armv7l" Arch
default y

config GUESTAGENT_ARCH_RISCV64
bool "guestagent Arch: riscv64"
help
Build lima-guestagent for "riscv64" Arch
default y
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ TAR ?= tar
ZIP ?= zip
PLANTUML ?= plantuml # may also be "java -jar plantuml.jar" if installed elsewhere

# The KCONFIG programs are only needed for re-generating the ".config" file.
KCONFIG_CONF ?= kconfig-conf
KCONFIG_MCONF ?= kconfig-mconf

GOOS ?= $(shell $(GO) env GOOS)
ifeq ($(GOOS),windows)
bat = .bat
Expand Down Expand Up @@ -45,6 +49,11 @@ GO_BUILD := $(GO) build -ldflags="-s -w -X $(PACKAGE)/pkg/version.Version=$(VERS
.PHONY: all
all: binaries manpages

.PHONY: help
help:
@echo ' binaries - Build all binaries'
@echo ' manpages - Build manual pages'

exe: _output/bin/limactl$(exe)

.PHONY: minimal
Expand All @@ -55,21 +64,44 @@ minimal: clean \
mkdir -p _output/share/lima/templates
cp -aL examples/default.yaml _output/share/lima/templates/

config: Kconfig
$(KCONFIG_CONF) $<

menuconfig: Kconfig
$(KCONFIG_MCONF) $<

# Copy the default config, if not overridden locally
# This is done to avoid a dependency on KCONFIG tools
.config: config.mk
cp $^ $@

-include .config

HELPERS = \
_output/bin/nerdctl.lima \
_output/bin/apptainer.lima \
_output/bin/docker.lima \
_output/bin/podman.lima \
_output/bin/kubectl.lima

ifeq ($(CONFIG_GUESTAGENT_OS_LINUX),y)
ifeq ($(CONFIG_GUESTAGENT_ARCH_X8664),y)
GUESTAGENT += \
_output/share/lima/lima-guestagent.Linux-x86_64
endif
ifeq ($(CONFIG_GUESTAGENT_ARCH_AARCH64),y)
GUESTAGENT += \
_output/share/lima/lima-guestagent.Linux-aarch64
endif
ifeq ($(CONFIG_GUESTAGENT_ARCH_ARMV7L),y)
GUESTAGENT += \
_output/share/lima/lima-guestagent.Linux-armv7l
endif
ifeq ($(CONFIG_GUESTAGENT_ARCH_RISCV64),y)
GUESTAGENT += \
_output/share/lima/lima-guestagent.Linux-riscv64
endif
endif

.PHONY: binaries
binaries: clean \
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,17 @@ curl -fsSL "https://github.com/lima-vm/lima/releases/download/${VERSION}/lima-${

- To install Lima from the source, run `make && make install`.

- To change the build configuration, run `make config` or `make menuconfig`.
This requires kconfig tools installed, it is also possible to edit `.config`.

> **NOTE**
> Lima is not regularly tested on ARM Mac (due to lack of CI).
##### Kconfig tools

The tools are available as either "kconfig-frontends" or "kbuild-standalone".
There is one `conf` for the text, and one `mconf` for the menu interface.

</p>
</details>

Expand Down
5 changes: 5 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIG_GUESTAGENT_OS_LINUX=y
CONFIG_GUESTAGENT_ARCH_X8664=y
CONFIG_GUESTAGENT_ARCH_AARCH64=y
CONFIG_GUESTAGENT_ARCH_ARMV7L=y
CONFIG_GUESTAGENT_ARCH_RISCV64=y

0 comments on commit 418122f

Please sign in to comment.