cmd: invoke package tools with exact arguments
This commit is contained in:
@@ -43,15 +43,6 @@ toolpath(const char *envvar, const char *name)
|
|||||||
return strdup(buf);
|
return strdup(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
run(const char *cmd)
|
|
||||||
{
|
|
||||||
int rc = system(cmd);
|
|
||||||
if (rc == -1) return -1;
|
|
||||||
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
run_argv(const char *prog, char *const argv[])
|
run_argv(const char *prog, char *const argv[])
|
||||||
{
|
{
|
||||||
@@ -1949,7 +1940,7 @@ build_one_sep_impl(const char *src, int entry_is_dir,
|
|||||||
char asmf[SEP_ARTIFACT_MAX], obj[SEP_ARTIFACT_MAX];
|
char asmf[SEP_ARTIFACT_MAX], obj[SEP_ARTIFACT_MAX];
|
||||||
char apath[SEP_ARTIFACT_MAX], unitnew[SEP_ARTIFACT_MAX];
|
char apath[SEP_ARTIFACT_MAX], unitnew[SEP_ARTIFACT_MAX];
|
||||||
char wwinew[SEP_ARTIFACT_MAX], asmnew[SEP_ARTIFACT_MAX];
|
char wwinew[SEP_ARTIFACT_MAX], asmnew[SEP_ARTIFACT_MAX];
|
||||||
char objnew[SEP_ARTIFACT_MAX], anew[SEP_ARTIFACT_MAX], cmd[8192];
|
char objnew[SEP_ARTIFACT_MAX], anew[SEP_ARTIFACT_MAX];
|
||||||
sep_fname(g, pi, scratch, ".unit.ww", unitf, sizeof unitf);
|
sep_fname(g, pi, scratch, ".unit.ww", unitf, sizeof unitf);
|
||||||
sep_fname(g, pi, scratch, ".wwi", wwi, sizeof wwi);
|
sep_fname(g, pi, scratch, ".wwi", wwi, sizeof wwi);
|
||||||
sep_fname(g, pi, scratch, ".s", asmf, sizeof asmf);
|
sep_fname(g, pi, scratch, ".s", asmf, sizeof asmf);
|
||||||
@@ -1994,25 +1985,30 @@ build_one_sep_impl(const char *src, int entry_is_dir,
|
|||||||
* LOCAL type (the root is never imported), which the
|
* LOCAL type (the root is never imported), which the
|
||||||
* export-check rejects. Skip -I for the root; its `.wwi`
|
* export-check rejects. Skip -I for the root; its `.wwi`
|
||||||
* is never consumed. */
|
* is never consumed. */
|
||||||
if (!needs_export) {
|
char *cargv[12];
|
||||||
|
int cpos = 0;
|
||||||
|
cargv[cpos++] = "w6c";
|
||||||
|
if (!needs_export && is_test && g->pkg[pi].root) {
|
||||||
/* #79: the root carries -T under `ww test`
|
/* #79: the root carries -T under `ww test`
|
||||||
* so w6c synthesizes the test main. Deps never
|
* so w6c synthesizes the test main. Deps never
|
||||||
* get -T. */
|
* get -T. */
|
||||||
if (is_test && g->pkg[pi].root)
|
cargv[cpos++] = "-T";
|
||||||
snprintf(cmd, sizeof cmd,
|
cargv[cpos++] = "--test-support-module";
|
||||||
"%s -T --test-support-module %s -c -o %s %s",
|
cargv[cpos++] = (char *)test_support_module;
|
||||||
c6, test_support_module, cs, cu);
|
} else if (needs_export && g->pkg[pi].test_support) {
|
||||||
else
|
cargv[cpos++] = "--test-support-module";
|
||||||
snprintf(cmd, sizeof cmd, "%s -c -o %s %s",
|
cargv[cpos++] = (char *)test_support_module;
|
||||||
c6, cs, cu);
|
}
|
||||||
} else
|
cargv[cpos++] = "-c";
|
||||||
snprintf(cmd, sizeof cmd, "%s %s%s%s-c -I %s -o %s %s",
|
if (needs_export) {
|
||||||
c6, g->pkg[pi].test_support
|
cargv[cpos++] = "-I";
|
||||||
? "--test-support-module " : "",
|
cargv[cpos++] = (char *)cw;
|
||||||
g->pkg[pi].test_support ? test_support_module : "",
|
}
|
||||||
g->pkg[pi].test_support ? " " : "",
|
cargv[cpos++] = "-o";
|
||||||
cw, cs, cu);
|
cargv[cpos++] = (char *)cs;
|
||||||
if (run(cmd) != 0) {
|
cargv[cpos++] = (char *)cu;
|
||||||
|
cargv[cpos] = NULL;
|
||||||
|
if (run_argv(c6, cargv) != 0) {
|
||||||
fprintf(stderr, "ww: w6c failed for %s\n",
|
fprintf(stderr, "ww: w6c failed for %s\n",
|
||||||
g->pkg[pi].path[0] ? g->pkg[pi].path : "(root)");
|
g->pkg[pi].path[0] ? g->pkg[pi].path : "(root)");
|
||||||
g->pkg[pi].failed = 1;
|
g->pkg[pi].failed = 1;
|
||||||
@@ -2020,8 +2016,9 @@ build_one_sep_impl(const char *src, int entry_is_dir,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!emit_asm) {
|
if (!emit_asm) {
|
||||||
snprintf(cmd, sizeof cmd, "%s -o %s %s", a6, co, cs);
|
char *aargv[] = {"w6a", "-o", (char *)co,
|
||||||
if (run(cmd) != 0) {
|
(char *)cs, NULL};
|
||||||
|
if (run_argv(a6, aargv) != 0) {
|
||||||
fprintf(stderr, "ww: w6a failed for %s\n",
|
fprintf(stderr, "ww: w6a failed for %s\n",
|
||||||
g->pkg[pi].path[0] ? g->pkg[pi].path : "(root)");
|
g->pkg[pi].path[0] ? g->pkg[pi].path : "(root)");
|
||||||
g->pkg[pi].failed = 1;
|
g->pkg[pi].failed = 1;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
// ww version → print version
|
// ww version → print version
|
||||||
//
|
//
|
||||||
// Tool paths default to siblings of $0 so a fresh build runs out of
|
// Tool paths default to siblings of $0 so a fresh build runs out of
|
||||||
// out/bin/. Env-var overrides (WW_W6C / WW_W6A / WW_W6L / WW_LIB) are
|
// out/bin/. WW_W6C / WW_W6A / WW_W6L select exact executable paths.
|
||||||
// not yet supported in this port; the bootstrap doesn't need them.
|
// Source-library and runtime-library overrides are not yet supported.
|
||||||
|
|
||||||
package main;
|
package main;
|
||||||
|
|
||||||
@@ -162,6 +162,16 @@ fn owncstr(s: str) *u8 = {
|
|||||||
return b.ptr;
|
return b.ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fn toolpath(selfdir: *u8, envvar: str, name: str) *u8 = {
|
||||||
|
match (os.getenv(envvar)) {
|
||||||
|
case let p: str => {
|
||||||
|
if (p.len != 0) { return owncstr(p); };
|
||||||
|
};
|
||||||
|
case void => void;
|
||||||
|
};
|
||||||
|
return joinpathlit(selfdir, name);
|
||||||
|
};
|
||||||
|
|
||||||
// execpackagetests — replace the driver with the native WW package
|
// execpackagetests — replace the driver with the native WW package
|
||||||
// coordinator for directory/default invocations. Explicit generated
|
// coordinator for directory/default invocations. Explicit generated
|
||||||
// package.ww roots stay on runsingletest, which is the recursion boundary when
|
// package.ww roots stay on runsingletest, which is the recursion boundary when
|
||||||
@@ -2018,9 +2028,9 @@ fn buildonesepimpl(selfdir: *u8, src: *u8, entryisdir: i32,
|
|||||||
};
|
};
|
||||||
statusi += 1;
|
statusi += 1;
|
||||||
};
|
};
|
||||||
let c6: *u8 = joinpathlit(selfdir, "w6c_ww");
|
let c6: *u8 = toolpath(selfdir, "WW_W6C", "w6c_ww");
|
||||||
let a6: *u8 = joinpathlit(selfdir, "w6a_ww");
|
let a6: *u8 = toolpath(selfdir, "WW_W6A", "w6a_ww");
|
||||||
let l6: *u8 = joinpathlit(selfdir, "w6l_ww");
|
let l6: *u8 = toolpath(selfdir, "WW_W6L", "w6l_ww");
|
||||||
|
|
||||||
let dotdotlib: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
let dotdotlib: []u8 = alloc([], (os.PATH_MAX: u64))!;
|
||||||
dotdotlib.len = os.PATH_MAX;
|
dotdotlib.len = os.PATH_MAX;
|
||||||
|
|||||||
Reference in New Issue
Block a user