ref: a74320b380fc191353b7b938e9cb3c18f3677259
parent: 8a57984a3b3102a30ca6210f7b73dc523f620377
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Sep 17 07:31:07 EDT 2015
Add the '-T' option for custom systags.
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -21,6 +21,7 @@
var bintarg
var cmd
var libpath
+ var tags
dumponly = false
cmd = std.optparse(args, &[
@@ -27,6 +28,7 @@
.argdesc = "[inputs...]",
.opts = [
[.opt='t', .desc="list all available targets"],
+ [.opt='T', .arg="tag", .desc="build with specified systag"],
[.opt='S', .desc="generate assembly when building"],
[.opt='d', .desc="dump debugging information for mbld"],
[.opt='I', .arg="inc", .desc="add 'inc' to your include path"],
@@ -40,13 +42,15 @@
])
targname = ""
+ tags = [][:]
bld.initopts()
for opt in cmd.opts
match opt
- | ('t', ""): dumponly = true
- | ('S', ""): bld.opt_genasm = true
- | ('I', arg): bld.opt_incpaths = std.slpush(bld.opt_incpaths, arg)
- | ('R', arg): bld.opt_instroot = arg
+ | ('t', ""): dumponly = true
+ | ('S', ""): bld.opt_genasm = true
+ | ('I', arg): bld.opt_incpaths = std.slpush(bld.opt_incpaths, arg)
+ | ('R', arg): bld.opt_instroot = arg
+ | ('T', tag): tags = std.slpush(tags, tag)
| ('b', arg):
targname = arg
bintarg = true
@@ -80,7 +84,7 @@
| `std.Fail f: std.fatal("Failed to compile use pattern regex\n")
;;
- b = mkbuild()
+ b = mkbuild(tags)
if targname.len != 0
mt = [
.name=targname,
@@ -123,7 +127,7 @@
;;
}
-const mkbuild = {
+const mkbuild = {tags
var b
b = std.zalloc()
@@ -130,7 +134,8 @@
b.targs = std.mkht(std.strhash, std.streq)
b.gensrc = std.mkht(std.strhash, std.streq)
b.built = std.mkht(std.strhash, std.streq)
- bld.addsysattrs(b.sysattrs)
+ b.sysattrs = std.mkht(std.strhash, std.streq)
+ bld.addsysattrs(b.sysattrs, tags)
-> b
}
--- a/mbld/syssel.myr
+++ b/mbld/syssel.myr
@@ -17,7 +17,7 @@
generic sysseladd : (syssel : syssel(byte[:])#, file : byte[:] -> void)
generic sysseladdlist : (syssel : syssel(@a)#, base : byte[:], attrs : byte[:][:], val : @a -> void)
generic sysselfin : (syssel : syssel(@a)# -> @a[:])
- const addsysattrs : (sa : std.htab(byte[:], bool)# -> void)
+ const addsysattrs : (sa : std.htab(byte[:], bool)#, tags : byte[:][:] -> void)
;;
generic mksyssel = {b, file, line, targ
@@ -95,7 +95,7 @@
-> ret
}
-const addsysattrs = {sa
+const addsysattrs = {sa, tags
var attrs
match opt_sys
@@ -115,5 +115,8 @@
;;
for a in attrs
std.htput(sa, a, true)
+ ;;
+ for t in tags
+ std.htput(sa, t, true)
;;
}