ww: group lex.ww + tok.ww into lib/ww/lex/ submodule

This commit is contained in:
2026-05-11 16:42:13 +09:00
parent 97ca76d2bb
commit 72dfb6ac8d
8 changed files with 47 additions and 35 deletions

View File

@@ -171,8 +171,8 @@ probe_dump_diff(const char *bin)
const char *tok_inputs[] = {
"selfhost/cmd/wcc/mem.ww",
"selfhost/cmd/wcc/err.ww",
"lib/ww/lex.ww",
"lib/ww/tok.ww",
"lib/ww/lex/lex.ww",
"lib/ww/lex/tok.ww",
"lib/ww/ast.ww",
"lib/ww/parse.ww",
"selfhost/cmd/wwdump/main.ww",
@@ -188,8 +188,8 @@ probe_dump_diff(const char *bin)
"selfhost/test/uses.ww",
"selfhost/cmd/wcc/err.ww",
"selfhost/cmd/wcc/mem.ww",
"lib/ww/lex.ww",
"lib/ww/tok.ww",
"lib/ww/lex/lex.ww",
"lib/ww/lex/tok.ww",
"lib/ww/ast.ww",
"lib/ww/parse.ww",
"lib/ww/typ.ww",
@@ -435,7 +435,7 @@ probe_resolve(const char *bin)
const char *complete[] = {
"selfhost/cmd/wcc/err.ww",
"selfhost/cmd/wcc/mem.ww",
"lib/ww/tok.ww",
"lib/ww/lex/tok.ww",
"selfhost/test/smoke.ww",
NULL,
};
@@ -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/selfhost/cmd/wcc %s >/dev/null 2>&1",
tmpdir, bin, cwd, cwd, tmpsrc);
"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);
if (runwait(cmd) != 0) {
fprintf(stderr, "ww-links FAIL: ww build %s\n", fix);
fail++;
@@ -717,7 +717,7 @@ probe_cgen_match(const char *bin)
const char *files[] = {
"selfhost/cmd/wcc/mem.ww",
"selfhost/cmd/wcc/err.ww",
"lib/ww/tok.ww",
"lib/ww/lex/tok.ww",
"selfhost/test/smoke.ww",
NULL,
};

View File

@@ -59,10 +59,15 @@ slurp_eq(const char *a, const char *b)
* the build directory. 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 *workdir, const char *includes_a, const char *includes_b,
const char *includes_c)
{
char cmd[4096];
if (includes_b && includes_b[0]) {
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);
@@ -81,7 +86,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_a, const char *inc_b, const char *inc_c)
{
char dc[64], dw[64];
snprintf(dc, sizeof dc, "/tmp/ww_d_%d_c", getpid());
@@ -91,11 +96,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) != 0) {
if (build_via(bin, "ww", src, dc, inc_a, inc_b, inc_c) != 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) != 0) {
if (build_via(bin, "ww_ww", src, dw, inc_a, inc_b, inc_c) != 0) {
fprintf(stderr, "ww_ww FAIL: ww ww errored on %s\n", label);
return -1;
}
@@ -142,27 +147,31 @@ main(void)
const char *out; /* basename of expected output */
const char *inc_a;
const char *inc_b;
const char *inc_c;
} cases[] = {
{ "hello", "/tmp/ww_d_hello.ww", "ww_d_hello", "", "" },
{ "wwdump", NULL, "main", NULL, NULL }, /* filled in below */
{ NULL, NULL, NULL, NULL, NULL },
{ "hello", "/tmp/ww_d_hello.ww", "ww_d_hello", "", "", "" },
{ "wwdump", NULL, "main", NULL, NULL, NULL }, /* filled in below */
{ NULL, NULL, 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];
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/selfhost/cmd/wcc", 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;
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) != 0)
cases[i].out, cases[i].inc_a, cases[i].inc_b,
cases[i].inc_c) != 0)
fail++;
n++;
}

View File

@@ -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/selfhost/cmd/wcc "
"cd %s && %s/ww_ww build -I %s/%s -I %s/lib/ww -I %s/lib/ww/lex -I %s/selfhost/cmd/wcc "
"%s/%s >/dev/null 2>&1",
workdir, bin, cwd, inc_local, cwd, cwd, cwd, src_rel);
workdir, bin, cwd, inc_local, cwd, cwd, cwd, cwd, src_rel);
} else {
snprintf(cmd, sizeof cmd,
"cd %s && %s/ww_ww build -I %s/lib/ww -I %s/selfhost/cmd/wcc "
"cd %s && %s/ww_ww build -I %s/lib/ww -I %s/lib/ww/lex -I %s/selfhost/cmd/wcc "
"%s/%s >/dev/null 2>&1",
workdir, bin, cwd, cwd, cwd, src_rel);
workdir, bin, cwd, cwd, cwd, cwd, src_rel);
}
if (runwait(cmd) != 0) {
fprintf(stderr, "self-rebuild FAIL: ww_ww build errored on %s\n", tool);