Skip to content

Commit

Permalink
feat: add support for extra buildflags in the make plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
axtloss committed Sep 27, 2024
1 parent 3fb55c0 commit 0ce393b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
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,12 +7,16 @@ import (

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

// Configuration for building a project using Make
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
}

// Provide plugin information as a JSON string
Expand Down Expand Up @@ -55,7 +59,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

0 comments on commit 0ce393b

Please sign in to comment.