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

feat: add support for extra buildflags in the make plugin #114

Merged
merged 1 commit into from
Sep 27, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/articles/en/built-in-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,19 @@ The Make module automates the build process for projects that use GNU Make.

The following specific fields are available:

- `buildFlags`: Additional flags for the `make` command.
- `buildCommand`: What command different command for the build, defaults to `make build`
- `intermediateSteps`: Extra commands to run between the build and install command
- `installCommand`: What command to run for installing, defaults to `make install`

### Example

```yaml
- name: example-make-project
type: make
buildflags: "all"
buildCommand: "make PREFIX=/custompath build"
intermediateSteps:
- "make docs-all -j4"
installCommand: "make DESTDIR=/root install"
source:
url: "https://example.com/make-project-source.tar.gz"
type: tar
Expand Down Expand Up @@ -258,4 +263,4 @@ The following specific fields are available:
- "org.gnome.Epiphany"
remove:
- "org.gnome.Epiphany"
```
```
28 changes: 24 additions & 4 deletions plugins/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ import (

"github.com/vanilla-os/vib/api"
)
import "strings"

type MakeModule struct {
Name string `json:"name"`
Type string `json:"type"`
Source api.Source
Name string `json:"name"`
Type string `json:"type"`
BuildCommand string `json:"buildcommand"`
InstallCommand string `json:"installcommand"`
IntermediateSteps []string `json:"intermediatesteps"`
Source api.Source
}

//export PlugInfo
Expand Down Expand Up @@ -50,7 +54,23 @@ func BuildModule(moduleInterface *C.char, recipeInterface *C.char) *C.char {
return C.CString(fmt.Sprintf("ERROR: %s", err.Error()))
}

cmd := "cd /sources/" + api.GetSourcePath(module.Source, module.Name) + " && make && make install"
buildCommand := "make"
installCommand := "make install"
intermediateSteps := " && "

if len(strings.TrimSpace(module.BuildCommand)) != 0 {
buildCommand = module.BuildCommand
}

if len(strings.TrimSpace(module.InstallCommand)) != 0 {
installCommand = module.InstallCommand
}

if len(module.IntermediateSteps) != 0 {
intermediateSteps = " && " + strings.Join(module.IntermediateSteps, " && ") + " && "
}

cmd := "cd /sources/" + api.GetSourcePath(module.Source, module.Name) + " && " + buildCommand + intermediateSteps + installCommand
return C.CString(cmd)
}

Expand Down
Loading