internal/rosa/make: split build and check
All checks were successful
Test / Create distribution (push) Successful in 59s
Test / Sandbox (push) Successful in 2m41s
Test / Hakurei (push) Successful in 3m53s
Test / ShareFS (push) Successful in 3m57s
Test / Hpkg (push) Successful in 4m28s
Test / Sandbox (race detector) (push) Successful in 5m5s
Test / Hakurei (race detector) (push) Successful in 6m9s
Test / Flake checks (push) Successful in 2m26s

Doing these together breaks far too many buggy makefiles.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-03-01 12:11:41 +09:00
parent 1d0fcf3a75
commit 51d3df2419
19 changed files with 119 additions and 145 deletions

View File

@@ -24,14 +24,13 @@ func (t Toolchain) newCMake() pkg.Artifact {
), &MakeAttr{ ), &MakeAttr{
OmitDefaults: true, OmitDefaults: true,
SkipConfigure: true, ConfigureName: "/usr/src/cmake/bootstrap",
ScriptConfigured: ` Configure: [][2]string{
/usr/src/cmake/bootstrap \ {"prefix", "/system"},
--prefix=/system \ {"parallel", `"$(nproc)"`},
--parallel="$(nproc)" \ {"--"},
-- \ {"-DCMAKE_USE_OPENSSL", "OFF"},
-DCMAKE_USE_OPENSSL=OFF },
`,
SkipCheck: true, SkipCheck: true,
}, },
t.Load(KernelHeaders), t.Load(KernelHeaders),

View File

@@ -19,9 +19,6 @@ func (t Toolchain) newCurl() pkg.Artifact {
{"with-openssl"}, {"with-openssl"},
{"with-ca-bundle", "/system/etc/ssl/certs/ca-bundle.crt"}, {"with-ca-bundle", "/system/etc/ssl/certs/ca-bundle.crt"},
}, },
ScriptConfigured: `
make "-j$(nproc)"
`,
}, },
t.Load(Perl), t.Load(Perl),

View File

@@ -1,8 +1,6 @@
package rosa package rosa
import ( import "hakurei.app/internal/pkg"
"hakurei.app/internal/pkg"
)
func (t Toolchain) newGit() pkg.Artifact { func (t Toolchain) newGit() pkg.Artifact {
const ( const (
@@ -21,20 +19,14 @@ func (t Toolchain) newGit() pkg.Artifact {
Writable: true, Writable: true,
InPlace: true, InPlace: true,
// test suite in subdirectory
SkipCheck: true,
Make: []string{"all"},
ScriptEarly: ` ScriptEarly: `
cd /usr/src/git cd /usr/src/git
make configure make configure
`,
Script: `
ln -s ../../system/bin/perl /usr/bin/ || true ln -s ../../system/bin/perl /usr/bin/ || true
function disable_test { function disable_test {
local test=$1 pattern=$2 local test=$1 pattern=${2:-''}
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
rm "t/${test}.sh" rm "t/${test}.sh"
else else
@@ -56,12 +48,12 @@ disable_test t9300-fast-import
disable_test t0211-trace2-perf disable_test t0211-trace2-perf
disable_test t1517-outside-repo disable_test t1517-outside-repo
disable_test t2200-add-update disable_test t2200-add-update
make \
-C t \
GIT_PROVE_OPTS="--jobs 32 --failures" \
prove
`, `,
Check: []string{
"-C t",
`GIT_PROVE_OPTS="--jobs 32 --failures"`,
"prove",
},
}, },
t.Load(Perl), t.Load(Perl),
t.Load(Diffutils), t.Load(Diffutils),

View File

@@ -65,8 +65,9 @@ func (t Toolchain) newAutoconf() pkg.Artifact {
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), &MakeAttr{ ), &MakeAttr{
Make: []string{ Check: []string{
`TESTSUITEFLAGS="-j$(nproc)"`, `TESTSUITEFLAGS="-j$(nproc)"`,
"check",
}, },
Flag: TExclusive, Flag: TExclusive,
}, },
@@ -122,8 +123,9 @@ func (t Toolchain) newLibtool() pkg.Artifact {
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), &MakeAttr{ ), &MakeAttr{
Make: []string{ Check: []string{
`TESTSUITEFLAGS=32`, `TESTSUITEFLAGS="-j$(nproc)"`,
"check",
}, },
}, },
t.Load(M4), t.Load(M4),
@@ -442,8 +444,9 @@ func (t Toolchain) newTar() pkg.Artifact {
{"without-posix-acls"}, {"without-posix-acls"},
{"without-xattrs"}, {"without-xattrs"},
}, },
Make: []string{ Check: []string{
`TESTSUITEFLAGS="-j$(nproc)"`, `TESTSUITEFLAGS="-j$(nproc)"`,
"check",
}, },
}, },
t.Load(Diffutils), t.Load(Diffutils),
@@ -464,11 +467,7 @@ func (t Toolchain) newBinutils() pkg.Artifact {
nil, "https://ftpmirror.gnu.org/gnu/binutils/binutils-"+version+".tar.bz2", nil, "https://ftpmirror.gnu.org/gnu/binutils/binutils-"+version+".tar.bz2",
mustDecode(checksum), mustDecode(checksum),
pkg.TarBzip2, pkg.TarBzip2,
), &MakeAttr{ ), nil,
ScriptConfigured: `
make "-j$(nproc)"
`,
},
t.Load(Bash), t.Load(Bash),
) )
} }
@@ -484,11 +483,7 @@ func (t Toolchain) newGMP() pkg.Artifact {
"gmp-"+version+".tar.bz2", "gmp-"+version+".tar.bz2",
mustDecode(checksum), mustDecode(checksum),
pkg.TarBzip2, pkg.TarBzip2,
), &MakeAttr{ ), nil,
ScriptConfigured: `
make "-j$(nproc)"
`,
},
t.Load(M4), t.Load(M4),
) )
} }

View File

@@ -66,6 +66,7 @@ echo '# Building hakurei.'
go generate -v ./... go generate -v ./...
go build -trimpath -v -o /work/system/libexec/hakurei -ldflags="-s -w go build -trimpath -v -o /work/system/libexec/hakurei -ldflags="-s -w
-buildid= -buildid=
-linkmode external
-extldflags=-static -extldflags=-static
-X hakurei.app/internal/info.buildVersion="$HAKUREI_VERSION" -X hakurei.app/internal/info.buildVersion="$HAKUREI_VERSION"
-X hakurei.app/internal/info.hakureiPath=/system/bin/hakurei -X hakurei.app/internal/info.hakureiPath=/system/bin/hakurei

View File

@@ -29,7 +29,7 @@ func (t Toolchain) newKernelHeaders() pkg.Artifact {
"-f /usr/src/kernel-headers/Makefile", "-f /usr/src/kernel-headers/Makefile",
"O=/tmp/kbuild", "O=/tmp/kbuild",
"LLVM=1", "LLVM=1",
`HOSTLDFLAGS="${LDFLAGS}"`, `HOSTLDFLAGS="${LDFLAGS:-''}"`,
"INSTALL_HDR_PATH=/work/system", "INSTALL_HDR_PATH=/work/system",
"headers_install", "headers_install",
}, },

View File

@@ -31,7 +31,7 @@ cd /usr/src/libcap
"CC=cc", "CC=cc",
"all", "all",
}, },
CheckName: "test", Check: []string{"test"},
}, },
t.Load(Bash), t.Load(Bash),
t.Load(Diffutils), t.Load(Diffutils),

View File

@@ -20,9 +20,6 @@ func (t Toolchain) newLibgd() pkg.Artifact {
ScriptEarly: ` ScriptEarly: `
mkdir /dev/shm/gd mkdir /dev/shm/gd
`, `,
Configure: [][2]string{
{"enable-static"},
},
}, },
t.Load(Zlib), t.Load(Zlib),
) )

View File

@@ -19,9 +19,6 @@ func (t Toolchain) newLibseccomp() pkg.Artifact {
ScriptEarly: ` ScriptEarly: `
ln -s ../system/bin/bash /bin/ ln -s ../system/bin/bash /bin/
`, `,
Configure: [][2]string{
{"enable-static"},
},
}, },
t.Load(Bash), t.Load(Bash),
t.Load(Diffutils), t.Load(Diffutils),

View File

@@ -22,9 +22,6 @@ cd /usr/src/
tar xf libxml2.tar.xz tar xf libxml2.tar.xz
mv libxml2-` + version + ` libxml2 mv libxml2-` + version + ` libxml2
`, `,
Configure: [][2]string{
{"enable-static"},
},
SourceSuffix: ".tar.xz", SourceSuffix: ".tar.xz",
}, },
t.Load(Diffutils), t.Load(Diffutils),

View File

@@ -22,9 +22,6 @@ cd /usr/src/
tar xf libxslt.tar.xz tar xf libxslt.tar.xz
mv libxslt-` + version + ` libxslt mv libxslt-` + version + ` libxslt
`, `,
Configure: [][2]string{
{"enable-static"},
},
SourceSuffix: ".tar.xz", SourceSuffix: ".tar.xz",
// python libxml2 cyclic dependency // python libxml2 cyclic dependency

View File

@@ -45,6 +45,8 @@ type MakeAttr struct {
ScriptEarly string ScriptEarly string
// Runs after configure. // Runs after configure.
ScriptConfigured string ScriptConfigured string
// Runs before check.
ScriptCheckEarly string
// Runs after install. // Runs after install.
Script string Script string
@@ -66,7 +68,7 @@ type MakeAttr struct {
// Whether to skip the check target. // Whether to skip the check target.
SkipCheck bool SkipCheck bool
// Name of the check target, zero value is equivalent to "check". // Name of the check target, zero value is equivalent to "check".
CheckName string Check []string
// Replaces the default install command. // Replaces the default install command.
ScriptInstall string ScriptInstall string
@@ -93,31 +95,30 @@ func (t Toolchain) NewViaMake(
attr = new(MakeAttr) attr = new(MakeAttr)
} }
host := `"${ROSA_TRIPLE}"`
if attr.Host != "" {
host = attr.Host
}
build := `"${ROSA_TRIPLE}"`
if attr.Build != "" {
build = attr.Build
}
var configure string var configure string
if !attr.SkipConfigure { if !attr.SkipConfigure {
configure = attr.ConfigureName configure = attr.ConfigureName
if configure == "" { if configure == "" {
configure += ` configure += `/usr/src/` + name + `/configure \
/usr/src/` + name + `/configure \
--prefix=/system` --prefix=/system`
}
if attr.Host != `""` { host := `"${ROSA_TRIPLE}"`
configure += ` \ if attr.Host != "" {
host = attr.Host
}
if attr.Host != `""` {
configure += ` \
--host=` + host --host=` + host
} }
if attr.Build != `""` {
configure += ` \ build := `"${ROSA_TRIPLE}"`
if attr.Build != "" {
build = attr.Build
}
if attr.Build != `""` {
configure += ` \
--build=` + build --build=` + build
}
} }
if len(attr.Configure) > 0 { if len(attr.Configure) > 0 {
@@ -149,17 +150,25 @@ func (t Toolchain) NewViaMake(
} }
} }
makeTargets := make([]string, 1, 2+len(attr.Make)) scriptMake := `
if !attr.SkipCheck { make \
if attr.CheckName == "" { "-j$(nproc)"`
makeTargets = append(makeTargets, "check") if len(attr.Make) > 0 {
} else { scriptMake += " \\\n\t" + strings.Join(attr.Make, " \\\n\t")
makeTargets = append(makeTargets, attr.CheckName)
}
} }
makeTargets = append(makeTargets, attr.Make...) scriptMake += "\n"
if len(makeTargets) == 1 {
makeTargets = nil if !attr.SkipCheck {
scriptMake += attr.ScriptCheckEarly + `
make \
"-j$(nproc)" \
`
if len(attr.Check) > 0 {
scriptMake += strings.Join(attr.Check, " \\\n\t")
} else {
scriptMake += "check"
}
scriptMake += "\n"
} }
var finalExtra []pkg.Artifact var finalExtra []pkg.Artifact
@@ -176,7 +185,9 @@ func (t Toolchain) NewViaMake(
scriptEarly := attr.ScriptEarly scriptEarly := attr.ScriptEarly
if !attr.InPlace { if !attr.InPlace {
scriptEarly += "\ncd \"$(mktemp -d)\"" scriptEarly += `
cd "$(mktemp -d)"
`
} else if scriptEarly == "" { } else if scriptEarly == "" {
panic("cannot remain in root") panic("cannot remain in root")
} }
@@ -187,14 +198,25 @@ func (t Toolchain) NewViaMake(
} }
scriptInstall += "\n" scriptInstall += "\n"
return t.New(name+"-"+version, attr.Flag, stage0Concat(t, return t.New(
attr.NonStage0, name+"-"+version,
finalExtra..., attr.Flag,
), nil, attr.Env, scriptEarly+configure+attr.ScriptConfigured+` stage0Concat(t,
make "-j$(nproc)"`+strings.Join(makeTargets, " ")+` attr.NonStage0,
`+scriptInstall+attr.Script, slices.Concat(attr.Paths, []pkg.ExecPath{ finalExtra...,
pkg.Path(AbsUsrSrc.Append( ),
name+attr.SourceSuffix, nil,
), attr.Writable, source), 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),
})...,
)
} }

View File

@@ -13,24 +13,24 @@ func (t Toolchain) newOpenSSL() pkg.Artifact {
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), &MakeAttr{ ), &MakeAttr{
OmitDefaults: true, OmitDefaults: true,
SkipConfigure: true,
Env: []string{ Env: []string{
"CC=cc", "CC=cc",
}, },
ScriptConfigured: ` ConfigureName: "/usr/src/openssl/Configure",
/usr/src/openssl/Configure \ Configure: [][2]string{
--prefix=/system \ {"prefix", "/system"},
--libdir=lib \ {"libdir", "lib"},
--openssldir=etc/ssl {"openssldir", "etc/ssl"},
`, },
CheckName: "test", Check: []string{
Make: []string{
`HARNESS_JOBS="$(expr "$(nproc)" '*' 2)"`, `HARNESS_JOBS="$(expr "$(nproc)" '*' 2)"`,
"test",
}, },
}, },
t.Load(Perl), t.Load(Perl),
t.Load(Coreutils),
t.Load(Zlib), t.Load(Zlib),
t.Load(KernelHeaders), t.Load(KernelHeaders),

View File

@@ -29,8 +29,6 @@ echo 'print STDOUT "1..0 # Skip broken test\n";' > ext/Pod-Html/t/htmldir3.t
rm -f /system/bin/ps # perl does not like toybox ps rm -f /system/bin/ps # perl does not like toybox ps
`, `,
ConfigureName: "./Configure", ConfigureName: "./Configure",
Host: `""`,
Build: `""`,
Configure: [][2]string{ Configure: [][2]string{
{"-des"}, {"-des"},
{"Dprefix", "/system"}, {"Dprefix", "/system"},
@@ -40,7 +38,10 @@ rm -f /system/bin/ps # perl does not like toybox ps
{"Doptimize", "'-O2 -fno-strict-aliasing'"}, {"Doptimize", "'-O2 -fno-strict-aliasing'"},
{"Duseithreads"}, {"Duseithreads"},
}, },
CheckName: "TEST_JOBS=256 test_harness", Check: []string{
"TEST_JOBS=256",
"test_harness",
},
ScriptInstall: "./perl -Ilib -I. installperl --destdir=/work", ScriptInstall: "./perl -Ilib -I. installperl --destdir=/work",
Flag: TEarly, Flag: TEarly,
@@ -95,16 +96,18 @@ func (t Toolchain) newViaPerlMakeMaker(
return t.NewViaMake("perl-"+name, version, t.NewPatchedSource( return t.NewViaMake("perl-"+name, version, t.NewPatchedSource(
"perl-"+name, version, source, false, patches..., "perl-"+name, version, source, false, patches...,
), &MakeAttr{ ), &MakeAttr{
Writable: true, Writable: true,
OmitDefaults: true, OmitDefaults: true,
SkipConfigure: true, InPlace: true,
InPlace: true,
ScriptEarly: ` ScriptEarly: `
cd /usr/src/perl-` + name + ` cd /usr/src/perl-` + name + `
perl Makefile.PL PREFIX=/system
`, `,
CheckName: "test", ConfigureName: "perl Makefile.PL",
Configure: [][2]string{
{"PREFIX", "/system"},
},
Check: []string{"test"},
}, slices.Concat(extra, []pkg.Artifact{ }, slices.Concat(extra, []pkg.Artifact{
t.Load(Perl), t.Load(Perl),
})...) })...)

View File

@@ -48,12 +48,7 @@ func (t Toolchain) newPython() pkg.Artifact {
"LDFLAGS=-Wl,--dynamic-linker=/system/lib/" + "LDFLAGS=-Wl,--dynamic-linker=/system/lib/" +
"ld-musl-" + linuxArch() + ".so.1", "ld-musl-" + linuxArch() + ".so.1",
}, },
Check: []string{"test"},
ScriptEarly: `
export HOME="$(mktemp -d)"
`,
CheckName: "test",
}, },
t.Load(Zlib), t.Load(Zlib),
t.Load(Libffi), t.Load(Libffi),

View File

@@ -1,8 +1,6 @@
package rosa package rosa
import ( import "hakurei.app/internal/pkg"
"hakurei.app/internal/pkg"
)
func (t Toolchain) newQEMU() pkg.Artifact { func (t Toolchain) newQEMU() pkg.Artifact {
const ( const (
@@ -57,7 +55,6 @@ _notrun 'appears to spuriously fail on zfs'
EOF EOF
) )
`, `,
Configure: [][2]string{ Configure: [][2]string{
{"disable-download"}, {"disable-download"},
{"disable-docs"}, {"disable-docs"},
@@ -70,10 +67,6 @@ EOF
"ppc-softmmu," + "ppc-softmmu," +
"ppc64-softmmu"}, "ppc64-softmmu"},
}, },
ScriptConfigured: `
make "-j$(nproc)"
`,
}, },
t.Load(Bash), t.Load(Bash),
t.Load(Python), t.Load(Python),

View File

@@ -19,7 +19,7 @@ func (t Toolchain) newToybox(suffix, script string) pkg.Artifact {
SkipConfigure: true, SkipConfigure: true,
ScriptEarly: ` ScriptEarly: `
LDFLAGS="${LDFLAGS} -static" LDFLAGS="${LDFLAGS:-''} -static"
chmod +w /bin/ chmod +w /bin/
ln -rs "$(which bash)" /bin/ || true ln -rs "$(which bash)" /bin/ || true
@@ -37,13 +37,14 @@ make defconfig
sed -i \ sed -i \
's/^CONFIG_TOYBOX_ZHELP=y$/CONFIG_TOYBOX_ZHELP=0/' \ 's/^CONFIG_TOYBOX_ZHELP=y$/CONFIG_TOYBOX_ZHELP=0/' \
.config .config
make "-j$(nproc)"
`, `,
ScriptConfigured: script, ScriptConfigured: script,
CheckName: "USER=cure tests",
SkipCheck: t.isStage0(), SkipCheck: t.isStage0(),
ScriptInstall: "PREFIX=/work/system/bin make install_flat", Check: []string{
"USER=cure",
"tests",
},
ScriptInstall: "PREFIX=/work/system/bin make install_flat",
Script: ` Script: `
mkdir -p /work/usr/bin mkdir -p /work/usr/bin
ln -s ../../system/bin/env /work/usr/bin ln -s ../../system/bin/env /work/usr/bin

View File

@@ -64,10 +64,6 @@ func (t Toolchain) newLibXau() pkg.Artifact {
cd /usr/src/libXau cd /usr/src/libXau
autoreconf -if autoreconf -if
`, `,
Configure: [][2]string{
{"enable-static"},
},
}, },
t.Load(M4), t.Load(M4),
t.Load(Perl), t.Load(Perl),

View File

@@ -11,11 +11,7 @@ func (t Toolchain) newXCBProto() pkg.Artifact {
nil, "https://xcb.freedesktop.org/dist/xcb-proto-"+version+".tar.gz", nil, "https://xcb.freedesktop.org/dist/xcb-proto-"+version+".tar.gz",
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), &MakeAttr{ ), nil,
Configure: [][2]string{
{"enable-static"},
},
},
t.Load(Python), t.Load(Python),
) )
} }
@@ -30,11 +26,7 @@ func (t Toolchain) newXCB() pkg.Artifact {
nil, "https://xcb.freedesktop.org/dist/libxcb-"+version+".tar.gz", nil, "https://xcb.freedesktop.org/dist/libxcb-"+version+".tar.gz",
mustDecode(checksum), mustDecode(checksum),
pkg.TarGzip, pkg.TarGzip,
), &MakeAttr{ ), nil,
Configure: [][2]string{
{"enable-static"},
},
},
t.Load(Python), t.Load(Python),
t.Load(PkgConfig), t.Load(PkgConfig),