aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/meson.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/rosa/meson.go')
-rw-r--r--internal/rosa/meson.go105
1 files changed, 53 insertions, 52 deletions
diff --git a/internal/rosa/meson.go b/internal/rosa/meson.go
index fbdb3637..317b102d 100644
--- a/internal/rosa/meson.go
+++ b/internal/rosa/meson.go
@@ -31,49 +31,59 @@ python3 setup.py \
}
func init() { artifactsF[Meson] = Toolchain.newMeson }
-// MesonAttr holds the project-specific attributes that will be applied to a new
-// [pkg.Artifact] compiled via [Meson].
-type MesonAttr struct {
- // Mount the source tree writable.
- Writable bool
-
- // Additional environment variables.
- Env []string
- // Runs before setup.
- ScriptEarly string
- // Runs after configure.
+// MesonHelper is the [Meson] build system helper.
+type MesonHelper struct {
+ // Runs after setup.
+ ScriptCompileEarly string
+ // Runs after compile.
ScriptCompiled string
// Runs after install.
Script string
// Flags passed to the setup command.
- Configure [][2]string
+ Setup [][2]string
// Whether to skip meson test.
- SkipCheck bool
- // Appended after the test command.
- AppendTest string
+ SkipTest bool
+}
- // Suffix appended to the source pathname.
- SourceSuffix string
+var _ Helper = new(MesonHelper)
- // Passed through to [Toolchain.New], before source.
- Paths []pkg.ExecPath
- // Passed through to [Toolchain.New].
- Flag int
+// name returns its arguments joined with '-'.
+func (*MesonHelper) name(name, version string) string {
+ return name + "-" + version
}
-// NewViaMeson returns a [pkg.Artifact] for compiling and installing via [Meson].
-func (t Toolchain) NewViaMeson(
- name, version string,
- source pkg.Artifact,
- attr *MesonAttr,
- extra ...pkg.Artifact,
-) pkg.Artifact {
- if name == "" || version == "" {
- panic("names must be non-empty")
+// extra returns hardcoded meson runtime dependencies.
+func (*MesonHelper) extra(int) []PArtifact {
+ return []PArtifact{
+ Python,
+ Meson,
+ Ninja,
+
+ PkgConfig,
+ CMake,
}
+}
+
+// wantsChmod returns false.
+func (*MesonHelper) wantsChmod() bool { return false }
+
+// wantsWrite returns false.
+func (*MesonHelper) wantsWrite() bool { return false }
+
+// scriptEarly returns the zero value.
+func (*MesonHelper) scriptEarly() string { return "" }
+
+// createDir returns false.
+func (*MesonHelper) createDir() bool { return false }
+
+// wantsDir requests a new directory in TMPDIR.
+func (*MesonHelper) wantsDir() string { return `"$(mktemp -d)"` }
+
+// script generates the cure script.
+func (attr *MesonHelper) script(name string) string {
if attr == nil {
- attr = new(MesonAttr)
+ attr = new(MesonHelper)
}
scriptCompiled := attr.ScriptCompiled
@@ -81,26 +91,21 @@ func (t Toolchain) NewViaMeson(
scriptCompiled = "\n" + scriptCompiled
}
- var check string
- if !attr.SkipCheck {
- check = "\nmeson test \\\n\t--print-errorlogs" + attr.AppendTest
+ var scriptTest string
+ if !attr.SkipTest {
+ scriptTest = `
+meson test \
+ --print-errorlogs`
}
- return t.New(name+"-"+version, attr.Flag, slices.Concat([]pkg.Artifact{
- t.Load(Python),
- t.Load(Meson),
- t.Load(Ninja),
-
- t.Load(PkgConfig),
- t.Load(CMake),
- }, extra), nil, attr.Env, attr.ScriptEarly+`
+ return `
cd "$(mktemp -d)"
meson setup \
- `+strings.Join(slices.Collect(func(yield func(string) bool) {
+ ` + strings.Join(slices.Collect(func(yield func(string) bool) {
for _, v := range append([][2]string{
{"prefix", "/system"},
{"buildtype", "release"},
- }, attr.Configure...) {
+ }, attr.Setup...) {
s := "-" + v[0]
if len(v[0]) > 0 && v[0][0] != 'D' {
s = "-" + s
@@ -112,14 +117,10 @@ meson setup \
return
}
}
- }), " \\\n\t")+` \
- . /usr/src/`+name+`
-meson compile`+scriptCompiled+check+`
+ }), " \\\n\t") + ` \
+ . '/usr/src/` + name + `'
+meson compile` + scriptCompiled + scriptTest + `
meson install \
--destdir=/work
-`+attr.Script, slices.Concat(attr.Paths, []pkg.ExecPath{
- pkg.Path(AbsUsrSrc.Append(
- name+attr.SourceSuffix,
- ), attr.Writable, source),
- })...)
+` + attr.Script
}