diff options
author | Ori Bernstein <ori@eigenstate.org> | 2017-07-24 00:31:54 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2017-07-25 22:23:05 -0700 |
commit | 254640059611d64a97b82cc8b20bf759eccc6806 (patch) | |
tree | 35e126e33cd5cde6dd96ebf9471d3ebcc2b9aaf5 | |
parent | a2ff9547b25b4c44d8e9095659bd282a2b4e160e (diff) | |
download | mc-254640059611d64a97b82cc8b20bf759eccc6806.tar.gz |
Add support for obj/ directory.
Currently, it's unconditional.
-rw-r--r-- | lib/std/fmt.myr | 3 | ||||
-rw-r--r-- | mbld/deps.myr | 47 | ||||
-rw-r--r-- | mbld/main.myr | 1 | ||||
-rw-r--r-- | mbld/types.myr | 1 |
4 files changed, 35 insertions, 17 deletions
diff --git a/lib/std/fmt.myr b/lib/std/fmt.myr index e405075..11268e4 100644 --- a/lib/std/fmt.myr +++ b/lib/std/fmt.myr @@ -248,7 +248,8 @@ const parseparams = {paramstr, optdesc for (opt, hasarg) : optdesc std.put("\t'{}', hasarg={}\n", opt, hasarg) ;; - std.fatal("invalid option '{}' ", o) + std.put("invalid option '{}' ", o) + std.die("dying") ;; ;; slfree(params) diff --git a/mbld/deps.myr b/mbld/deps.myr index dafe2bc..471180b 100644 --- a/mbld/deps.myr +++ b/mbld/deps.myr @@ -58,7 +58,7 @@ const testdeps = {b } const myrdeps = {b, name, mt - var p, o, u, n, to, tu + var t, p, o, u, n, to, tu var libs, dynlibs var cflags, ll var g, a, deps @@ -68,8 +68,8 @@ const myrdeps = {b, name, mt if mt.islib u = std.fmt("lib{}.use", mt.name) o = std.fmt("lib{}.a", mt.name) - tu = std.pathcat(mt.dir, u) - to = std.pathcat(mt.dir, o) + tu = std.pathjoin([b.objdir, mt.dir, u][:]) + to = std.pathjoin([b.objdir, mt.dir, o][:]) gu = node(g, tu) go = node(g, to) @@ -90,8 +90,8 @@ const myrdeps = {b, name, mt std.slfree(u) else u = std.fmt("{}.use", mt.name) - tu = std.pathcat(mt.dir, u) - to = std.pathcat(mt.dir, mt.name) + tu = std.pathjoin([b.objdir, mt.dir, u][:]) + to = std.pathjoin([b.objdir, mt.dir, mt.name][:]) go = node(g, to) gu = node(g, tu) @@ -120,8 +120,14 @@ const myrdeps = {b, name, mt p = std.pathcat(mt.dir, f) leaf(g, p) if std.hassuffix(f, ".myr") - o = changesuffix(p, config.Objsuffix) - u = changesuffix(p, ".use") + t = changesuffix(p, config.Objsuffix) + o = std.pathcat(b.objdir, t) + std.slfree(t) + + t = changesuffix(p, ".use") + u = std.pathcat(b.objdir, t) + std.slfree(t) + depends(g, go, o) depends(g, gu, u) @@ -142,16 +148,21 @@ const myrdeps = {b, name, mt myrcmd(b, n, mt, p, false) std.slfree(deps) elif std.hassuffix(f, ".s") - o = changesuffix(p, config.Objsuffix) + t = changesuffix(p, config.Objsuffix) + o = std.pathcat(b.objdir, t) + std.slfree(t) + depends(g, go, o) n = node(g, o) generates(g, n, o) depends(g, n, p) ascmd(b, n, mt, o, p) elif std.hassuffix(f, ".glue.c") + t = changesuffix(p, config.Objsuffix) + o = std.pathcat(b.objdir, t) + std.slfree(t) + (cflags, ll) = scrapecflags(b, mt, p) - std.put("cflags: {}, ll: {}\n", cflags, ll) - o = changesuffix(p, config.Objsuffix) depends(g, go, o) n = node(g, o) generates(g, n, o) @@ -429,17 +440,20 @@ const linkcmd = {b, n, mt, bin, libs, dynlibs, istest const myrcmd = {b, n, mt, src, istest std.slpush(&n.cmd, opt_mc) + if b.objdir.len > 0 + pushopt(&n.cmd, "-O", b.objdir) + ;; for inc : mt.incpath[:mt.incpath.len - 1] - pushinc(&n.cmd, "-I", inc) + pushopt(&n.cmd, "-I", inc) ;; if istest for (dir, _, _) : mt.tstdeps - pushinc(&n.cmd, "-I", dir) + pushopt(&n.cmd, "-I", dir) ;; - pushinc(&n.cmd, "-I", mt.dir) + pushopt(&n.cmd, "-I", mt.dir) ;; for (dir, _, _) : mt.libdeps - pushinc(&n.cmd, "-I", dir) + pushopt(&n.cmd, "-I", dir) ;; if opt_genasm std.slpush(&n.cmd, "-S") @@ -486,7 +500,7 @@ const scrapedeps = {b : build#, mt, path std.slpush(&l, `Xdep p) else /* internal library */ - p = std.pathcat(mt.dir, uses[3]) + p = std.pathjoin([b.objdir, mt.dir, uses[3]][:]) std.sljoin(&p, ".use") std.slpush(&l, `Ldep p) ;; @@ -531,6 +545,7 @@ const scrapecflags = {b, mt, path } const generates = {g, n, dep + std.mkpath(std.dirname(dep)) std.slpush(&n.gen, dep) std.htput(g.gen, dep, n) } @@ -575,7 +590,7 @@ const addnode = {g, targ, n std.htput(g.targs, targ, nl) } -const pushinc = {lst, pfx, dir +const pushopt = {lst, pfx, dir std.slpush(lst, std.sldup(pfx)) std.slpush(lst, std.pathnorm(dir)) } diff --git a/mbld/main.myr b/mbld/main.myr index 2d80fc1..fde3808 100644 --- a/mbld/main.myr +++ b/mbld/main.myr @@ -152,6 +152,7 @@ const mkbuild = {tags var b b = std.zalloc() + b.objdir = "obj" b.libs = std.mkht(std.strhash, std.streq) b.proc = std.mkht(std.inthash, std.inteq) b.targs = std.mkht(std.strhash, std.streq) diff --git a/mbld/types.myr b/mbld/types.myr index d29bd72..c898aaf 100644 --- a/mbld/types.myr +++ b/mbld/types.myr @@ -4,6 +4,7 @@ pkg bld = type build = struct /* build state */ basedir : byte[:] + objdir : byte[:] tags : std.htab(byte[:], (int, int, int))# libs : std.htab(byte[:], libdep#)# deps : depgraph# |