summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-19 22:20:53 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-19 22:22:26 -0700
commitec311388a2880c4f836bd1108245cd4c2ab5630e (patch)
tree1b34660d9b7c26eec6c2510bf189c79c9ebedcf5
parent80e1f20064f435fba7b4c7be70fd6b19c5218cc3 (diff)
downloadmc-ec311388a2880c4f836bd1108245cd4c2ab5630e.tar.gz
Only use the filename itself for __init__
This sucks, but it's *extremely* unlikely that a file will share a namespace, filename, and __init__. This makes builds directory-independent, so that linking the same file compiled with a different compiler cwd will work.
-rw-r--r--mbld/deps.myr1
-rw-r--r--parse/gram.y11
2 files changed, 9 insertions, 3 deletions
diff --git a/mbld/deps.myr b/mbld/deps.myr
index e501983..fa92de4 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -58,6 +58,7 @@ const myrdeps = {b, mt, doclean, addsrc
.extlibs = [][:],
.dynamic = false,
])
+
/* direct dependencies of binary */
if mt.islib
out = std.fmt("lib{}.a", mt.name)
diff --git a/parse/gram.y b/parse/gram.y
index 02b3399..dc91cb8 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -1053,10 +1053,15 @@ label : Tcolon Tident {
static void setupinit(Node *n)
{
char name[1024];
- char *p;
+ char *p, *s;
bprintf(name, sizeof name, "%s$__init__", file->file.files[0]);
- p = name;
+ s = strrchr(name, '/');
+ if (s)
+ s++;
+ else
+ s = name;
+ p = s;
while (*p) {
if (!isalnum(*p) && *p != '_')
*p = '$';
@@ -1064,7 +1069,7 @@ static void setupinit(Node *n)
}
n->decl.isinit = 1;
n->decl.vis = Vishidden;
- n->decl.name->name.name = strdup(name);
+ n->decl.name->name.name = strdup(s);
}
static void addtrait(Type *t, char *str)