selfhost: migrate tool sources to directory packages
Build w6a and w6l from package-main directories and expose the wcc backend through a narrow package API so w6c and wwdump no longer import implementation files. Retarget the remaining load-bearing fixtures and example sources to directory packages; retain the one intentional flat compiler collision as an explicitly composed raw unit.
This commit is contained in:
@@ -63,18 +63,15 @@ slurp_eq(const char *a, const char *b)
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Each tool builds via `ww_ww build -I <local> -I lib/ww -I selfhost/cmd/wcc src`.
|
||||
/* Each tool builds via `ww_ww build -I lib/ww -I selfhost/cmd src`.
|
||||
* lib/ww holds the language introspection (lex/tok/ast/parse/typ/sym);
|
||||
* selfhost/cmd/wcc holds the compiler internals (mem/check/cgen*).
|
||||
* selfhost/cmd holds the compiler-internal `wcc` directory package.
|
||||
* Dotted `import encoding.utf8;` finds lib/encoding/utf8/ via the
|
||||
* driver's default srclib path post-task-#22 dir-enum.
|
||||
* Some tools have a local module dir (w6a, w6l with sibling .ww files).
|
||||
* inc_local is "" for tools without one (w6c, ww, wwdump).
|
||||
*/
|
||||
struct buildjob {
|
||||
const char *tool;
|
||||
const char *src_rel;
|
||||
const char *inc_local;
|
||||
char workdir[64];
|
||||
pid_t pid;
|
||||
};
|
||||
@@ -99,20 +96,11 @@ spawn_build(const char *bin, const char *cwd, struct buildjob *j)
|
||||
}
|
||||
|
||||
char cmd[4096];
|
||||
if (j->inc_local && j->inc_local[0]) {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/ww_ww build -o %s/main -I %s/%s "
|
||||
"-I %s/lib/ww "
|
||||
"-I %s/selfhost/cmd/wcc %s/%s >/dev/null 2>%s/build.err",
|
||||
j->workdir, bin, j->workdir, cwd, j->inc_local,
|
||||
cwd, cwd, cwd, j->src_rel, j->workdir);
|
||||
} else {
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/ww_ww build -o %s/main "
|
||||
"-I %s/lib/ww "
|
||||
"-I %s/selfhost/cmd/wcc %s/%s >/dev/null 2>%s/build.err",
|
||||
j->workdir, bin, j->workdir, cwd, cwd, cwd, j->src_rel, j->workdir);
|
||||
}
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"cd %s && timeout 180 %s/ww_ww build -o %s/main "
|
||||
"-I %s/lib/ww -I %s/selfhost/cmd "
|
||||
"%s/%s >/dev/null 2>%s/build.err",
|
||||
j->workdir, bin, j->workdir, cwd, cwd, cwd, j->src_rel, j->workdir);
|
||||
|
||||
pid_t p = fork();
|
||||
if (p < 0) {
|
||||
@@ -184,11 +172,11 @@ main(void)
|
||||
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
|
||||
|
||||
struct buildjob jobs[] = {
|
||||
{ "w6c", "selfhost/cmd/w6c/main.ww", "", {0}, 0 },
|
||||
{ "w6a", "selfhost/cmd/w6a/main.ww", "selfhost/cmd/w6a", {0}, 0 },
|
||||
{ "w6l", "selfhost/cmd/w6l/main.ww", "selfhost/cmd/w6l", {0}, 0 },
|
||||
{ "ww", "selfhost/cmd/ww/main.ww", "", {0}, 0 },
|
||||
{ "wwdump", "selfhost/cmd/wwdump/main.ww", "", {0}, 0 },
|
||||
{ "w6c", "selfhost/cmd/w6c/main.ww", {0}, 0 },
|
||||
{ "w6a", "selfhost/cmd/w6a", {0}, 0 },
|
||||
{ "w6l", "selfhost/cmd/w6l", {0}, 0 },
|
||||
{ "ww", "selfhost/cmd/ww/main.ww", {0}, 0 },
|
||||
{ "wwdump", "selfhost/cmd/wwdump/main.ww", {0}, 0 },
|
||||
};
|
||||
const int n = (int)(sizeof jobs / sizeof jobs[0]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user