aboutsummaryrefslogtreecommitdiff
path: root/internal/build/build.go
blob: 37587298ddac86efd0d6265689201e7e4dd4d256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package build

import (
	"github.com/yuin/gopher-lua"
)

type Kiirofile struct {
	Path string
}

func (k *Kiirofile) Load(L *lua.LState) error {
	if err := L.DoFile(k.Path); err != nil {
		// just return it, they can do the err detection
		return err
	}
	return nil
}

func (k *Kiirofile) RunBuild(L *lua.LState) error {
	// just return it because if its an error notmyfault they detect it
	// notmyfault you forgot to Kiirofile.Load()
	// or that the Kiirofile maintainer typed it wrong
	return L.CallByParam(lua.P{
		Fn: L.GetGlobal("build"),
		NRet: 0,
		Protect: true,
	})
}

func (k *Kiirofile) RunPackage(L *lua.LState) error {
	// just return it because if its an error notmyfault they detect it
	// notmyfault you forgot to Kiirofile.Load()
	// or that the Kiirofile maintainer typed it wrong
	return L.CallByParam(lua.P{
		Fn: L.GetGlobal("package"),
		NRet: 0,
		Protect: true,
	})
}

// TODO: Add auto-detection and methods for MakeBuild, CargoBuild, CMakeBuild, etc for the projects that don't have a Kiirofile
// That's probably for later because right now we need basic package manager with Kiirofile parsing working