build: separate package identity from storage paths
This commit is contained in:
@@ -22,6 +22,18 @@ slurp(const char *path, char **outbuf, u64 *outlen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
export_owner_matches(const char *buf, u64 len, const char *path)
|
||||
{
|
||||
static const char prefix[] = "//ww:module ";
|
||||
size_t pn = strlen(path);
|
||||
size_t need = sizeof prefix - 1 + pn + 1;
|
||||
return len >= need
|
||||
&& memcmp(buf, prefix, sizeof prefix - 1) == 0
|
||||
&& memcmp(buf + sizeof prefix - 1, path, pn) == 0
|
||||
&& buf[need - 1] == '\n';
|
||||
}
|
||||
|
||||
struct importin {
|
||||
const char *path;
|
||||
const char *file;
|
||||
@@ -164,6 +176,13 @@ main(int argc, char **argv)
|
||||
imports[i].path, imports[i].file);
|
||||
return 1;
|
||||
}
|
||||
if (!export_owner_matches(imports[i].buf, imports[i].len,
|
||||
imports[i].path)) {
|
||||
fprintf(stderr,
|
||||
"w6c: import %s: export owner mismatch in %s\n",
|
||||
imports[i].path, imports[i].file);
|
||||
return 1;
|
||||
}
|
||||
int bad = 0;
|
||||
Node *f = parseinput(a, imports[i].file, imports[i].buf,
|
||||
imports[i].len, imports[i].path, testsupport, 0, &bad);
|
||||
|
||||
Reference in New Issue
Block a user