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 requires python kconfiglib or similar.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
  • Loading branch information
afbjorklund committed Sep 14, 2023
1 parent 4cc8d2c commit 17c610d
Show file tree
Hide file tree
Showing 5 changed files with 72 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
31 changes: 31 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ 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.
# You can install the python "kconfiglib", if you don't have kconfig/kbuild.
KCONFIG_CONF ?= oldconfig
KCONFIG_MCONF ?= menuconfig

GOOS ?= $(shell $(GO) env GOOS)
ifeq ($(GOOS),windows)
bat = .bat
Expand Down Expand Up @@ -45,6 +50,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 +65,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.default
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ curl -fsSL "https://github.com/lima-vm/lima/releases/download/${VERSION}/lima-${

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

- To change configuration, run `make config` or edit `.config`.

> **NOTE**
> Lima is not regularly tested on ARM Mac (due to lack of CI).
Expand Down
5 changes: 5 additions & 0 deletions config.default
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 17c610d

Please sign in to comment.