compiler: separate package exports from entry roots
This commit is contained in:
@@ -65,6 +65,8 @@ main(int argc, char **argv)
|
||||
const char *wwiout = NULL; /* -I <out.wwi>: M2 export-data producer */
|
||||
const char *testsupport = NULL;
|
||||
int testmode = 0;
|
||||
int testpackage = 0;
|
||||
int entrymode = 0;
|
||||
int sepmode = 0; /* -c: #22 M3 separate-compile / primary-
|
||||
* only codegen (emit imported==0 decls
|
||||
* only; treat `.wwi` deps as external) */
|
||||
@@ -82,6 +84,10 @@ main(int argc, char **argv)
|
||||
wwiout = argv[++i];
|
||||
} else if (strcmp(a, "-T") == 0) {
|
||||
testmode = 1;
|
||||
} else if (strcmp(a, "--test-package") == 0) {
|
||||
testpackage = 1;
|
||||
} else if (strcmp(a, "--entry") == 0) {
|
||||
entrymode = 1;
|
||||
} else if (strcmp(a, "--test-support-module") == 0) {
|
||||
if (i + 1 >= argc) {
|
||||
fputs("w6c: --test-support-module requires arg\n", stderr);
|
||||
@@ -109,7 +115,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
if (src == NULL) {
|
||||
fputs("usage: w6c [-T] [-c] [-I out.wwi] "
|
||||
fputs("usage: w6c [-T|--test-package] [--entry] [-c] [-I out.wwi] "
|
||||
"[--import path dep.wwi]... [-o out.s] file.ww\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
@@ -117,6 +123,14 @@ main(int argc, char **argv)
|
||||
fputs("w6c: --import requires -c\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
if ((entrymode || testpackage) && !sepmode) {
|
||||
fputs("w6c: --entry and --test-package require -c\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
if (testmode && testpackage) {
|
||||
fputs("w6c: -T and --test-package are mutually exclusive\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
for (int i = 0; i < nimports; i++) {
|
||||
if (imports[i].path[0] == '\0') {
|
||||
fputs("w6c: --import path is empty\n", stderr);
|
||||
@@ -169,6 +183,7 @@ main(int argc, char **argv)
|
||||
|
||||
check_init(&c, a);
|
||||
c.is_test = testmode;
|
||||
c.is_test_package = testpackage;
|
||||
if (testsupport != NULL) c.test_module = testsupport;
|
||||
c.sep_mode = sepmode;
|
||||
check_file(&c, file);
|
||||
@@ -198,10 +213,10 @@ main(int argc, char **argv)
|
||||
|
||||
cg_init(&cg, a);
|
||||
cg.sep_mode = sepmode;
|
||||
/* #99: wwiout != NULL <=> this is a sep DEP unit (the producer passes
|
||||
* -I to deps only; the root's .wwi is stripped per #69). Gates the
|
||||
* bare-`main` carve-out so only the root/link-entry main stays bare. */
|
||||
cg.sep_isdep = (wwiout != NULL);
|
||||
/* Export production and entry identity are independent package-action
|
||||
* properties. Legacy raw invocations without -I remain entry-like; every
|
||||
* driver package now supplies -I, and only link roots add --entry. */
|
||||
cg.sep_isdep = (wwiout != NULL && !entrymode);
|
||||
cg_file(&cg, of, file);
|
||||
|
||||
if (of != stdout) fclose(of);
|
||||
|
||||
Reference in New Issue
Block a user