diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-03-01 12:11:41 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-03-01 14:41:34 +0900 |
| commit | 51d3df2419e26f15d780c98629a357473855ebd4 (patch) | |
| tree | e5c0e3810156d3f706ed732b67bd5e12b3dfa8f5 /internal/rosa/make.go | |
| parent | 1d0fcf3a75bbdbeac24c34f5d55cb5ba347f1782 (diff) | |
internal/rosa/make: split build and check
Doing these together breaks far too many buggy makefiles.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/make.go')
| -rw-r--r-- | internal/rosa/make.go | 96 |
1 files changed, 59 insertions, 37 deletions
diff --git a/internal/rosa/make.go b/internal/rosa/make.go index 4d45f32c..fb74039c 100644 --- a/internal/rosa/make.go +++ b/internal/rosa/make.go @@ -45,6 +45,8 @@ type MakeAttr struct { ScriptEarly string // Runs after configure. ScriptConfigured string + // Runs before check. + ScriptCheckEarly string // Runs after install. Script string @@ -66,7 +68,7 @@ type MakeAttr struct { // Whether to skip the check target. SkipCheck bool // Name of the check target, zero value is equivalent to "check". - CheckName string + Check []string // Replaces the default install command. ScriptInstall string @@ -93,31 +95,30 @@ func (t Toolchain) NewViaMake( attr = new(MakeAttr) } - host := `"${ROSA_TRIPLE}"` - if attr.Host != "" { - host = attr.Host - } - build := `"${ROSA_TRIPLE}"` - if attr.Build != "" { - build = attr.Build - } - var configure string if !attr.SkipConfigure { configure = attr.ConfigureName if configure == "" { - configure += ` -/usr/src/` + name + `/configure \ + configure += `/usr/src/` + name + `/configure \ --prefix=/system` - } - if attr.Host != `""` { - configure += ` \ + host := `"${ROSA_TRIPLE}"` + if attr.Host != "" { + host = attr.Host + } + if attr.Host != `""` { + configure += ` \ --host=` + host - } - if attr.Build != `""` { - configure += ` \ + } + + build := `"${ROSA_TRIPLE}"` + if attr.Build != "" { + build = attr.Build + } + if attr.Build != `""` { + configure += ` \ --build=` + build + } } if len(attr.Configure) > 0 { @@ -149,17 +150,25 @@ func (t Toolchain) NewViaMake( } } - makeTargets := make([]string, 1, 2+len(attr.Make)) + scriptMake := ` +make \ + "-j$(nproc)"` + if len(attr.Make) > 0 { + scriptMake += " \\\n\t" + strings.Join(attr.Make, " \\\n\t") + } + scriptMake += "\n" + if !attr.SkipCheck { - if attr.CheckName == "" { - makeTargets = append(makeTargets, "check") + scriptMake += attr.ScriptCheckEarly + ` +make \ + "-j$(nproc)" \ + ` + if len(attr.Check) > 0 { + scriptMake += strings.Join(attr.Check, " \\\n\t") } else { - makeTargets = append(makeTargets, attr.CheckName) + scriptMake += "check" } - } - makeTargets = append(makeTargets, attr.Make...) - if len(makeTargets) == 1 { - makeTargets = nil + scriptMake += "\n" } var finalExtra []pkg.Artifact @@ -176,7 +185,9 @@ func (t Toolchain) NewViaMake( scriptEarly := attr.ScriptEarly if !attr.InPlace { - scriptEarly += "\ncd \"$(mktemp -d)\"" + scriptEarly += ` +cd "$(mktemp -d)" +` } else if scriptEarly == "" { panic("cannot remain in root") } @@ -187,14 +198,25 @@ func (t Toolchain) NewViaMake( } scriptInstall += "\n" - return t.New(name+"-"+version, attr.Flag, stage0Concat(t, - attr.NonStage0, - finalExtra..., - ), nil, attr.Env, scriptEarly+configure+attr.ScriptConfigured+` -make "-j$(nproc)"`+strings.Join(makeTargets, " ")+` -`+scriptInstall+attr.Script, slices.Concat(attr.Paths, []pkg.ExecPath{ - pkg.Path(AbsUsrSrc.Append( - name+attr.SourceSuffix, - ), attr.Writable, source), - })...) + return t.New( + name+"-"+version, + attr.Flag, + stage0Concat(t, + attr.NonStage0, + finalExtra..., + ), + nil, + attr.Env, + scriptEarly+ + configure+ + attr.ScriptConfigured+ + scriptMake+ + scriptInstall+ + attr.Script, + slices.Concat(attr.Paths, []pkg.ExecPath{ + pkg.Path(AbsUsrSrc.Append( + name+attr.SourceSuffix, + ), attr.Writable, source), + })..., + ) } |
