ww build: discard exact null outputs

This commit is contained in:
2026-08-20 23:17:23 +09:00
parent 84f5e68709
commit 71a9da2058
7 changed files with 751 additions and 31 deletions

View File

@@ -1844,6 +1844,8 @@ export fn packagecommand(args: []str) int = {
};
if (roots.len == 0) { append(roots, "."); };
pkgsortstrings(roots);
let buildnull: bool = buildonly && explicitout
&& strings.compare(outname, "/dev/null") == 0;
if (compileonly && !buildonly
&& (list || filters.len != 0 || timeoutarg.len != 0)) {
pkgusage();
@@ -1946,11 +1948,11 @@ export fn packagecommand(args: []str) int = {
ds.paths = pkgdedup(ds.paths);
if (ds.paths.len == 0) {
if (buildonly) {
if (explicitout && pkgoutputdir(outname)) {
if (explicitout && !buildnull && pkgoutputdir(outname)) {
pkgputln(os.STDERR_FILENO, "ww: no main packages to build");
return 1;
};
if (explicitout) {
if (explicitout && !buildnull) {
pkgputln(os.STDERR_FILENO, "ww: no packages to build");
return 1;
};
@@ -2177,11 +2179,11 @@ export fn packagecommand(args: []str) int = {
};
if (groups.len == 0) {
if (buildonly) {
if (explicitout && pkgoutputdir(outname)) {
if (explicitout && !buildnull && pkgoutputdir(outname)) {
pkgputln(os.STDERR_FILENO, "ww: no main packages to build");
return 1;
};
if (explicitout) {
if (explicitout && !buildnull) {
pkgputln(os.STDERR_FILENO, "ww: no packages to build");
return 1;
};
@@ -2192,7 +2194,7 @@ export fn packagecommand(args: []str) int = {
};
pkgsortgroups(groups);
let defaultout: bool = false;
if (buildonly && outname.len == 0 && folders.len == 1
if (buildonly && !buildnull && outname.len == 0 && folders.len == 1
&& groups.len == 1 && strings.compare(groups[0].pkg, "main") == 0) {
outname = pkgbase(groups[0].dir);
defaultout = true;
@@ -2203,7 +2205,8 @@ export fn packagecommand(args: []str) int = {
pkgputln(os.STDERR_FILENO, "\" already exists and is a directory");
return 1;
};
let outputdir: bool = buildonly && explicitout && pkgoutputdir(outname);
let outputdir: bool = buildonly && explicitout && !buildnull
&& pkgoutputdir(outname);
if (outputdir) {
let mainpackages: i32 = 0;
i = 0;
@@ -2330,7 +2333,8 @@ export fn packagecommand(args: []str) int = {
};
// A non-directory caller-owned build name cannot fan out. A directory
// build output publishes each selected command under its directory leaf.
if (buildonly && outname.len != 0 && !outputdir && groups.len > 1) {
if (buildonly && !buildnull && outname.len != 0
&& !outputdir && groups.len > 1) {
pkgputln(os.STDERR_FILENO,
"wwtest package: cannot use -o with multiple packages");
return 2;
@@ -2338,7 +2342,7 @@ export fn packagecommand(args: []str) int = {
// Recursive/multi-root -S needs a caller-owned artifact tree. Without -w
// every assembly file would otherwise live only in the coordinator's
// temporary plan and disappear on successful return.
if (buildonly && emitasm && workroot.len == 0) {
if (buildonly && emitasm && workroot.len == 0 && !buildnull) {
pkgputln(os.STDERR_FILENO,
"wwtest package: recursive -S needs -w");
return 2;
@@ -2360,7 +2364,7 @@ export fn packagecommand(args: []str) int = {
plan.end = groups.len;
plan.state = PKGQUEUED;
plan.buildonly = buildonly;
plan.publish = buildonly && explicitout && outname.len != 0
plan.publish = buildonly && explicitout && !buildnull && outname.len != 0
&& groups.len == 1
&& strings.compare(groups[0].pkg, "main") != 0;
plan.emitasm = emitasm;
@@ -2380,11 +2384,13 @@ export fn packagecommand(args: []str) int = {
};
let tmproot: str = temp.dir();
let planout: str = outname;
if (buildnull) { planout = ""; };
let failed: i32 = 0;
i = 0;
for (i < plans.len) {
if (!pkgsetplanpaths(&plans[i], groups, tmproot, i,
compileonly, buildonly, outname, outputdir, createdir,
compileonly, buildonly, planout, outputdir, createdir,
workroot)) {
if (!pkgremoveall(tmproot)) {
pkgput(os.STDERR_FILENO,