compiler: separate package exports from entry roots
This commit is contained in:
@@ -66,6 +66,8 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
let wwiout: *u8 = nil; // -I <out.wwi>: M2 export-data producer
|
||||
let testsupport: *u8 = nil;
|
||||
let testmode: i32 = 0i32; // #15: `-T` test-mode
|
||||
let testpackage: i32 = 0i32;
|
||||
let entrymode: i32 = 0i32;
|
||||
let sepmode: i32 = 0i32; // -c: #22 M3 separate-compile / primary-
|
||||
// only codegen (emit imported==0 decls
|
||||
// only; treat `.wwi` deps as external)
|
||||
@@ -96,6 +98,10 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
wwiout = argv[i];
|
||||
} else { if (cstreq(a, "-T")) {
|
||||
testmode = 1i32;
|
||||
} else { if (cstreq(a, "--test-package")) {
|
||||
testpackage = 1i32;
|
||||
} else { if (cstreq(a, "--entry")) {
|
||||
entrymode = 1i32;
|
||||
} else { if (cstreq(a, "--test-support-module")) {
|
||||
i += 1;
|
||||
if (i >= argc) {
|
||||
@@ -127,12 +133,12 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
return 2;
|
||||
};
|
||||
src = a;
|
||||
}; }; }; }; }; }; };
|
||||
}; }; }; }; }; }; }; }; };
|
||||
i += 1;
|
||||
};
|
||||
|
||||
if (src == nil) {
|
||||
let m: str = "usage: w6c_ww [-T] [-c] [-I out.wwi] [--import path dep.wwi]... [-o out.s] file.ww\n";
|
||||
let m: str = "usage: w6c_ww [-T|--test-package] [--entry] [-c] [-I out.wwi] [--import path dep.wwi]... [-o out.s] file.ww\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
@@ -141,6 +147,16 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
if ((entrymode != 0 || testpackage != 0) && sepmode == 0) {
|
||||
let m: str = "w6c: --entry and --test-package require -c\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
if (testmode != 0 && testpackage != 0) {
|
||||
let m: str = "w6c: -T and --test-package are mutually exclusive\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
let importi: i32 = 0;
|
||||
for (importi < nimports) {
|
||||
if (importpaths[importi][0u64] == 0u8) {
|
||||
@@ -249,5 +265,6 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
if (testsupport != nil) { testmodule = pathstr(testsupport); };
|
||||
let interfaceout: str;
|
||||
if (wwiout != nil) { interfaceout = pathstr(wwiout); };
|
||||
return wcc.compilefile(f, testmode, testmodule, sepmode, interfaceout);
|
||||
return wcc.compilefile(f, testmode, testpackage, testmodule, sepmode,
|
||||
interfaceout, entrymode);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user