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

Refactor Makefile #2638

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

norio-nomura
Copy link
Contributor

@norio-nomura norio-nomura commented Sep 19, 2024

refactored and added targets:

  • guestagents builds lima-guestagent for archs enabled by CONFIG_GUESTAGENT_ARCHS_*
  • native-guestagent builds lima-guestagent for native arch
  • additional-guestagents builds lima-guestagent for archs other than native arch
  • <arch>-guestagent builds lima-guestagent for : aarch64 armv7l riscv64 x86_64
  • limactl builds limactl, codesign, and lima
  • lima copy lima, and lima$(bat)
  • helpers copy nerdctl.lima, apptainer.lima, docker.lima, podman.lima, kubectl.lima
  • default_template copy examples/default.yaml
  • templates copy examples/*.yaml
  • template_experimentals copy examples/experimental/*.yaml
  • create-examples-link create link at, or copy to _output/share/lima/examples
  • documents copy *.md, LICENSE, SECURITY.md, and VERSION
  • create-links-in-documents create link at, or copy to _output/share/doc/lima/{templates,examples}

With this change, running make clean limactl native-guestagent templates install will allow you to install limactl, the native linux-guestagent, and all templates.

This is my solution to #2426 (comment)

EDIT: added <arch>-guestagent targets

…stagents` targets

refactored and added targets to build `lima-guestagent` for archs:
- `guestagents` builds for archs enabled by `CONFIG_GUESTAGENT_ARCHS_*`
- `native-guestagent` builds for native arch
- `additional-guestagents` builds for archs other than native arch

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
refactored and added targets:
- `limactl` builds `limactl`, `codesign`, and `lima`
- `lima` copy `lima`, and `lima$(bat)`
- `helpers` copy `nerdctl.lima`, `apptainer.lima`, `docker.lima`, `podman.lima`, `kubectl.lima`

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
…s`, and `create-examples-link` targets

refactored and added targets:
- `default_template` copy `examples/default.yaml`
- `templates` copy `examples/*.yaml`
- `template_experimentals` copy `examples/experimental/*.yaml`
- `create-examples-link` create link at, or copy to `_output/share/lima/examples`

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
- `documents` copy `*.md`, `LICENSE`, `SECURITY.md`, and `VERSION`
- `create-links-in-documents` create link at, or copy to `_output/share/doc/lima/{templates,examples}`

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
also changed `artifacts-misc` to depends `_artifacts`

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
It seems that variable expansion in Makefile targets is not done recursively.

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
Makefile Outdated Show resolved Hide resolved
Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
@norio-nomura norio-nomura marked this pull request as ready for review September 19, 2024 23:24
Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use plain cp?

@norio-nomura
Copy link
Contributor Author

Why not just use plain cp?

By having make recognize each file, it can copy only those that have been modified.
e.g.

~09:57:10 09:57:15~ (refactor-makefile) make templates
mkdir -p _output/share/lima/templates
cp -aL examples/README.md _output/share/lima/templates/README.md
cp -aL examples/almalinux-8.yaml _output/share/lima/templates/almalinux-8.yaml
cp -aL examples/almalinux-9.yaml _output/share/lima/templates/almalinux-9.yaml
cp -aL examples/almalinux.yaml _output/share/lima/templates/almalinux.yaml
cp -aL examples/alpine-image.yaml _output/share/lima/templates/alpine-image.yaml
cp -aL examples/alpine.yaml _output/share/lima/templates/alpine.yaml
cp -aL examples/apptainer-rootful.yaml _output/share/lima/templates/apptainer-rootful.yaml
cp -aL examples/apptainer.yaml _output/share/lima/templates/apptainer.yaml
cp -aL examples/archlinux.yaml _output/share/lima/templates/archlinux.yaml
cp -aL examples/buildkit.yaml _output/share/lima/templates/buildkit.yaml
cp -aL examples/centos-stream-9.yaml _output/share/lima/templates/centos-stream-9.yaml
cp -aL examples/centos-stream.yaml _output/share/lima/templates/centos-stream.yaml
cp -aL examples/debian-11.yaml _output/share/lima/templates/debian-11.yaml
cp -aL examples/debian-12.yaml _output/share/lima/templates/debian-12.yaml
cp -aL examples/debian.yaml _output/share/lima/templates/debian.yaml
cp -aL examples/default.yaml _output/share/lima/templates/default.yaml
cp -aL examples/docker-rootful.yaml _output/share/lima/templates/docker-rootful.yaml
cp -aL examples/docker.yaml _output/share/lima/templates/docker.yaml
cp -aL examples/faasd.yaml _output/share/lima/templates/faasd.yaml
cp -aL examples/fedora.yaml _output/share/lima/templates/fedora.yaml
cp -aL examples/k3s.yaml _output/share/lima/templates/k3s.yaml
cp -aL examples/k8s.yaml _output/share/lima/templates/k8s.yaml
cp -aL examples/opensuse-leap.yaml _output/share/lima/templates/opensuse-leap.yaml
cp -aL examples/opensuse.yaml _output/share/lima/templates/opensuse.yaml
cp -aL examples/oraclelinux-8.yaml _output/share/lima/templates/oraclelinux-8.yaml
cp -aL examples/oraclelinux-9.yaml _output/share/lima/templates/oraclelinux-9.yaml
cp -aL examples/oraclelinux.yaml _output/share/lima/templates/oraclelinux.yaml
cp -aL examples/podman-rootful.yaml _output/share/lima/templates/podman-rootful.yaml
cp -aL examples/podman.yaml _output/share/lima/templates/podman.yaml
cp -aL examples/rocky-8.yaml _output/share/lima/templates/rocky-8.yaml
cp -aL examples/rocky-9.yaml _output/share/lima/templates/rocky-9.yaml
cp -aL examples/rocky.yaml _output/share/lima/templates/rocky.yaml
cp -aL examples/ubuntu-lts.yaml _output/share/lima/templates/ubuntu-lts.yaml
cp -aL examples/ubuntu.yaml _output/share/lima/templates/ubuntu.yaml
cp -aL examples/vmnet.yaml _output/share/lima/templates/vmnet.yaml~09:57:15 09:57:18~ (refactor-makefile) limactl edit templates/docker.yaml --memory 8~09:57:18 09:57:20~ (refactor-makefile) make templates
cp -aL examples/docker.yaml _output/share/lima/templates/docker.yaml~09:57:20 09:57:20~ (refactor-makefile)

@AkihiroSuda AkihiroSuda added this to the v1.0 milestone Sep 20, 2024
AkihiroSuda
AkihiroSuda previously approved these changes Sep 20, 2024
…evious

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
```
- <arch>-guestagent         : Build guestagent for <arch>: aarch64 armv7l riscv64 x86_64
```

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
@norio-nomura
Copy link
Contributor Author

Sorry, I added <arch>-guestagent targets.
e.g.

~10:56:10 13:20:12~ (refactor-makefile) make armv7l-guestagent
GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=0 go build -ldflags="-s -w -X github.com/lima-vm/lima/pkg/version.Version=v1.0.0-alpha.0-95-g1efc42e1.m" -tags "" -o _output/share/lima/lima-guestagent.Linux-armv7l ./cmd/lima-guestagent
chmod 644 _output/share/lima/lima-guestagent.Linux-armv7l

@norio-nomura
Copy link
Contributor Author

The artifacts-* targets rely on the binaries target, which is affected by .config. Given the nature of these targets, I’m wondering if they should be rewritten to avoid using the binaries target, so they won’t be influenced by .config. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants