ww: split parse.ww into parse/{parse,expr,stmt,decl}.ww submodule
This commit is contained in:
@@ -174,7 +174,7 @@ probe_dump_diff(const char *bin)
|
||||
"lib/ww/lex/lex.ww",
|
||||
"lib/ww/lex/tok.ww",
|
||||
"lib/ww/ast.ww",
|
||||
"lib/ww/parse.ww",
|
||||
"lib/ww/parse/parse.ww", "lib/ww/parse/expr.ww", "lib/ww/parse/stmt.ww", "lib/ww/parse/decl.ww",
|
||||
"selfhost/cmd/wwdump/main.ww",
|
||||
"selfhost/test/smoke.ww",
|
||||
NULL,
|
||||
@@ -191,7 +191,7 @@ probe_dump_diff(const char *bin)
|
||||
"lib/ww/lex/lex.ww",
|
||||
"lib/ww/lex/tok.ww",
|
||||
"lib/ww/ast.ww",
|
||||
"lib/ww/parse.ww",
|
||||
"lib/ww/parse/parse.ww", "lib/ww/parse/expr.ww", "lib/ww/parse/stmt.ww", "lib/ww/parse/decl.ww",
|
||||
"lib/ww/typ.ww",
|
||||
"lib/ww/sym.ww",
|
||||
"selfhost/cmd/wcc/check.ww",
|
||||
@@ -656,8 +656,8 @@ probe_ww_links(const char *bin)
|
||||
runwait(cmd);
|
||||
/* ww build to get the .combined.ww as a side effect. */
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s/ww build -I %s/lib/ww -I %s/lib/ww/lex -I %s/selfhost/cmd/wcc %s >/dev/null 2>&1",
|
||||
tmpdir, bin, cwd, cwd, cwd, tmpsrc);
|
||||
"cd %s && %s/ww build -I %s/lib/ww -I %s/lib/ww/lex -I %s/lib/ww/parse -I %s/selfhost/cmd/wcc %s >/dev/null 2>&1",
|
||||
tmpdir, bin, cwd, cwd, cwd, cwd, tmpsrc);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "ww-links FAIL: ww build %s\n", fix);
|
||||
fail++;
|
||||
|
||||
@@ -56,25 +56,18 @@ slurp_eq(const char *a, const char *b)
|
||||
}
|
||||
|
||||
/* Build `src` via the named driver, expecting output binary `out` in
|
||||
* the build directory. Returns 0 on success. */
|
||||
* the build directory. `incs` may be a colon-separated list of include
|
||||
* dirs (the ww driver accepts -I path1:path2:path3). Returns 0 on
|
||||
* success. */
|
||||
static int
|
||||
build_via(const char *bin, const char *driver, const char *src,
|
||||
const char *workdir, const char *includes_a, const char *includes_b,
|
||||
const char *includes_c)
|
||||
const char *workdir, const char *incs)
|
||||
{
|
||||
char cmd[4096];
|
||||
if (includes_c && includes_c[0]) {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s/%s build -I %s -I %s -I %s %s 2>/dev/null",
|
||||
workdir, bin, driver, includes_a, includes_b, includes_c, src);
|
||||
} else if (includes_b && includes_b[0]) {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s/%s build -I %s -I %s %s 2>/dev/null",
|
||||
workdir, bin, driver, includes_a, includes_b, src);
|
||||
} else if (includes_a && includes_a[0]) {
|
||||
if (incs && incs[0]) {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s/%s build -I %s %s 2>/dev/null",
|
||||
workdir, bin, driver, includes_a, src);
|
||||
workdir, bin, driver, incs, src);
|
||||
} else {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s/%s build %s 2>/dev/null",
|
||||
@@ -86,7 +79,7 @@ build_via(const char *bin, const char *driver, const char *src,
|
||||
static int
|
||||
diff_one(const char *bin, const char *cwd, const char *label,
|
||||
const char *src, const char *out_basename,
|
||||
const char *inc_a, const char *inc_b, const char *inc_c)
|
||||
const char *incs)
|
||||
{
|
||||
char dc[64], dw[64];
|
||||
snprintf(dc, sizeof dc, "/tmp/ww_d_%d_c", getpid());
|
||||
@@ -96,11 +89,11 @@ diff_one(const char *bin, const char *cwd, const char *label,
|
||||
snprintf(cmd, sizeof cmd, "rm -rf %s %s && mkdir -p %s %s", dc, dw, dc, dw);
|
||||
if (runwait(cmd) != 0) return -1;
|
||||
|
||||
if (build_via(bin, "ww", src, dc, inc_a, inc_b, inc_c) != 0) {
|
||||
if (build_via(bin, "ww", src, dc, incs) != 0) {
|
||||
fprintf(stderr, "ww_ww FAIL: C ww errored on %s\n", label);
|
||||
return -1;
|
||||
}
|
||||
if (build_via(bin, "ww_ww", src, dw, inc_a, inc_b, inc_c) != 0) {
|
||||
if (build_via(bin, "ww_ww", src, dw, incs) != 0) {
|
||||
fprintf(stderr, "ww_ww FAIL: ww ww errored on %s\n", label);
|
||||
return -1;
|
||||
}
|
||||
@@ -145,33 +138,28 @@ main(void)
|
||||
const char *label;
|
||||
const char *src; /* may be relative to cwd */
|
||||
const char *out; /* basename of expected output */
|
||||
const char *inc_a;
|
||||
const char *inc_b;
|
||||
const char *inc_c;
|
||||
const char *incs; /* colon-separated -I list, may be NULL */
|
||||
} cases[] = {
|
||||
{ "hello", "/tmp/ww_d_hello.ww", "ww_d_hello", "", "", "" },
|
||||
{ "wwdump", NULL, "main", NULL, NULL, NULL }, /* filled in below */
|
||||
{ NULL, NULL, NULL, NULL, NULL, NULL },
|
||||
{ "hello", "/tmp/ww_d_hello.ww", "ww_d_hello", "" },
|
||||
{ "wwdump", NULL, "main", NULL }, /* filled in below */
|
||||
{ NULL, NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
/* wwdump case: absolute paths so the driver finds the imports
|
||||
* regardless of the per-driver workdir. */
|
||||
static char wwdump_src[2048], wwdump_inc_a[2048], wwdump_inc_b[2048], wwdump_inc_c[2048];
|
||||
snprintf(wwdump_src, sizeof wwdump_src, "%s/selfhost/cmd/wwdump/main.ww", cwd);
|
||||
snprintf(wwdump_inc_a, sizeof wwdump_inc_a, "%s/lib/ww", cwd);
|
||||
snprintf(wwdump_inc_b, sizeof wwdump_inc_b, "%s/lib/ww/lex", cwd);
|
||||
snprintf(wwdump_inc_c, sizeof wwdump_inc_c, "%s/selfhost/cmd/wcc", cwd);
|
||||
cases[1].src = wwdump_src;
|
||||
cases[1].inc_a = wwdump_inc_a;
|
||||
cases[1].inc_b = wwdump_inc_b;
|
||||
cases[1].inc_c = wwdump_inc_c;
|
||||
static char wwdump_src[2048], wwdump_incs[4096];
|
||||
snprintf(wwdump_src, sizeof wwdump_src, "%s/selfhost/cmd/wwdump/main.ww", cwd);
|
||||
snprintf(wwdump_incs, sizeof wwdump_incs,
|
||||
"%s/lib/ww:%s/lib/ww/lex:%s/lib/ww/parse:%s/selfhost/cmd/wcc",
|
||||
cwd, cwd, cwd, cwd);
|
||||
cases[1].src = wwdump_src;
|
||||
cases[1].incs = wwdump_incs;
|
||||
|
||||
int fail = 0;
|
||||
int n = 0;
|
||||
for (int i = 0; cases[i].label; i++) {
|
||||
if (diff_one(bin, cwd, cases[i].label, cases[i].src,
|
||||
cases[i].out, cases[i].inc_a, cases[i].inc_b,
|
||||
cases[i].inc_c) != 0)
|
||||
cases[i].out, cases[i].incs) != 0)
|
||||
fail++;
|
||||
n++;
|
||||
}
|
||||
|
||||
@@ -77,14 +77,14 @@ rebuild_one(const char *bin, const char *cwd, const char *tool,
|
||||
|
||||
if (inc_local && inc_local[0]) {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s/ww_ww build -I %s/%s -I %s/lib/ww -I %s/lib/ww/lex -I %s/selfhost/cmd/wcc "
|
||||
"cd %s && %s/ww_ww build -I %s/%s -I %s/lib/ww -I %s/lib/ww/lex -I %s/lib/ww/parse -I %s/selfhost/cmd/wcc "
|
||||
"%s/%s >/dev/null 2>&1",
|
||||
workdir, bin, cwd, inc_local, cwd, cwd, cwd, cwd, src_rel);
|
||||
workdir, bin, cwd, inc_local, cwd, cwd, cwd, cwd, cwd, src_rel);
|
||||
} else {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && %s/ww_ww build -I %s/lib/ww -I %s/lib/ww/lex -I %s/selfhost/cmd/wcc "
|
||||
"cd %s && %s/ww_ww build -I %s/lib/ww -I %s/lib/ww/lex -I %s/lib/ww/parse -I %s/selfhost/cmd/wcc "
|
||||
"%s/%s >/dev/null 2>&1",
|
||||
workdir, bin, cwd, cwd, cwd, cwd, src_rel);
|
||||
workdir, bin, cwd, cwd, cwd, cwd, cwd, src_rel);
|
||||
}
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "self-rebuild FAIL: ww_ww build errored on %s\n", tool);
|
||||
|
||||
Reference in New Issue
Block a user