ww: unify directory package-test products
This commit is contained in:
@@ -327,6 +327,11 @@ fn allocimportptrs(count: i32) ([]*u8 | nomem) = {
|
||||
return value;
|
||||
};
|
||||
|
||||
fn allocimportstrs(count: i32) ([]str | nomem) = {
|
||||
let value: []str = alloc([], count: u64)?;
|
||||
return value;
|
||||
};
|
||||
|
||||
fn allocnodeptrs(count: i32) ([]*syntax.node | nomem) = {
|
||||
let value: []*syntax.node = alloc([], count: u64)?;
|
||||
return value;
|
||||
@@ -457,7 +462,6 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
let out: *u8 = nil;
|
||||
let wwiout: *u8 = nil; // -I <out.wwi>: M2 export-data producer
|
||||
let testsupport: *u8 = nil;
|
||||
let testtarget: *u8 = nil;
|
||||
let testmode: i32 = 0i32; // #15: `-T` test-mode
|
||||
let testpackage: i32 = 0i32;
|
||||
let commandpackage: i32 = 0i32;
|
||||
@@ -469,8 +473,10 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
// only; treat `.wwi` deps as external)
|
||||
let pathallocation: ([]*u8 | nomem) = allocimportptrs(argc);
|
||||
let fileallocation: ([]*u8 | nomem) = allocimportptrs(argc);
|
||||
let targetallocation: ([]str | nomem) = allocimportstrs(argc);
|
||||
let importpaths: []*u8;
|
||||
let importfiles: []*u8;
|
||||
let testtargets: []str;
|
||||
let astallocation: ([]*syntax.node | nomem) = allocnodeptrs(argc);
|
||||
let importasts: []*syntax.node;
|
||||
match (pathallocation) {
|
||||
@@ -491,6 +497,15 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
};
|
||||
importpaths.len = argc;
|
||||
importfiles.len = argc;
|
||||
match (targetallocation) {
|
||||
case let value: []str => testtargets = value;
|
||||
case nomem => {
|
||||
let m: str = "w6c: out of memory\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 1;
|
||||
};
|
||||
};
|
||||
testtargets.len = argc;
|
||||
match (astallocation) {
|
||||
case let value: []*syntax.node => importasts = value;
|
||||
case nomem => {
|
||||
@@ -501,6 +516,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
};
|
||||
importasts.len = argc;
|
||||
let nimports: i32 = 0;
|
||||
let ntesttargets: i32 = 0;
|
||||
let mapallocation: ([]importmap | nomem) = allocimportmaps(argc);
|
||||
let importmaps: []importmap;
|
||||
match (mapallocation) {
|
||||
@@ -572,7 +588,8 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
testtarget = argv[i];
|
||||
testtargets[ntesttargets] = pathstr(argv[i]);
|
||||
ntesttargets += 1;
|
||||
} else { if (cstreq(a, "-c")) {
|
||||
sepmode = 1i32;
|
||||
} else { if (cstreq(a, "--import")) {
|
||||
@@ -711,17 +728,24 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
if (testtarget != nil && (sepmode == 0 || testmode == 0
|
||||
|| testtarget[0u64] == 0u8)) {
|
||||
let m: str = "w6c: invalid --test-target-package\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
if (testtarget != nil) {
|
||||
let targeti: i32 = 0;
|
||||
for (targeti < ntesttargets) {
|
||||
let testtarget: str = testtargets[targeti];
|
||||
if (sepmode == 0 || testmode == 0 || testtarget.len == 0) {
|
||||
let m: str = "w6c: invalid --test-target-package\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
if (targeti > 0
|
||||
&& strings.compare(testtargets[targeti - 1], testtarget) >= 0) {
|
||||
let m: str = "w6c: --test-target-package paths must be sorted and unique\n";
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
let direct: bool = false;
|
||||
importi = 0;
|
||||
for (importi < nimports) {
|
||||
if (cstreq(importpaths[importi], pathstr(testtarget))) {
|
||||
if (syntax.streq(pathstr(importpaths[importi]), testtarget)) {
|
||||
direct = true;
|
||||
};
|
||||
importi += 1;
|
||||
@@ -731,6 +755,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
targeti += 1;
|
||||
};
|
||||
|
||||
let importhead: *syntax.node = nil;
|
||||
@@ -848,13 +873,14 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
testsupport)) {
|
||||
return 1;
|
||||
};
|
||||
if (testtarget != nil) {
|
||||
targeti = 0;
|
||||
for (targeti < ntesttargets) {
|
||||
let seen: i32 = 0;
|
||||
let targetuse: *syntax.node = f.list;
|
||||
for (targetuse != nil) {
|
||||
if (targetuse.kind == syntax.nkind.N_USE
|
||||
&& targetuse.imported == 0
|
||||
&& syntax.streq(targetuse.usepath, pathstr(testtarget))) {
|
||||
&& syntax.streq(targetuse.usepath, testtargets[targeti])) {
|
||||
targetuse.str = targetuse.usepath;
|
||||
seen += 1;
|
||||
};
|
||||
@@ -865,6 +891,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
return 2;
|
||||
};
|
||||
targeti += 1;
|
||||
};
|
||||
if (importhead != nil) {
|
||||
importtail.next = f.list;
|
||||
@@ -896,8 +923,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
|
||||
let testmodule: str;
|
||||
if (testsupport != nil) { testmodule = pathstr(testsupport); };
|
||||
let testtargetmodule: str;
|
||||
if (testtarget != nil) { testtargetmodule = pathstr(testtarget); };
|
||||
testtargets.len = ntesttargets;
|
||||
let packageinitsymbol: str;
|
||||
if (packageinit != nil) { packageinitsymbol = pathstr(packageinit); };
|
||||
let initdispatchsymbol: str;
|
||||
@@ -905,7 +931,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
|
||||
let haswwi: i32 = 0;
|
||||
if (wwiout != nil) { haswwi = 1; };
|
||||
let compilerc: i32 = wcc.compilefile(f, testmode, testpackage, testmodule,
|
||||
testtargetmodule, sepmode, wwifd, haswwi, entrymode,
|
||||
testtargets, sepmode, wwifd, haswwi, entrymode,
|
||||
packageinitsymbol, initdispatchsymbol);
|
||||
if (out != nil) { os.close(1i32); };
|
||||
if (compilerc != 0) {
|
||||
|
||||
Reference in New Issue
Block a user