diff --git a/docs/articles/en/built-in-modules.md b/docs/articles/en/built-in-modules.md index f39bb28..d0c7ef8 100644 --- a/docs/articles/en/built-in-modules.md +++ b/docs/articles/en/built-in-modules.md @@ -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 @@ -258,4 +263,4 @@ The following specific fields are available: - "org.gnome.Epiphany" remove: - "org.gnome.Epiphany" -``` \ No newline at end of file +``` diff --git a/plugins/make.go b/plugins/make.go index b93f412..fa47e92 100644 --- a/plugins/make.go +++ b/plugins/make.go @@ -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 @@ -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) }