shithub: mc

Download patch

ref: a4250ceb2489b320e220dbbd9a71a3523001bd50
parent: 0b7b8cf380ced404a763a81e86db439ee4915393
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Sep 8 20:23:33 EDT 2016

Add 'testdeps' option.

	This allows adding libraries (like testr) that are only
	needed by tests.

--- a/mbld/parse.myr
+++ b/mbld/parse.myr
@@ -21,6 +21,7 @@
 	/* default parameter values */
 	incpath	: byte[:][:]
 	libdeps	: byte[:][:]
+	tstdeps	: byte[:][:]
 	runtime	: byte[:]
 	ldscript: byte[:]
 	istest	: bool
@@ -97,6 +98,8 @@
 		.basedir = std.sldup(basedir),
 		.targsel = sel,
 		.incpath = [][:],
+		.libdeps = [][:],
+		.tstdeps = [][:],
 		.runtime = "",
 		.ldscript = "",
 		.istest = false,
@@ -208,6 +211,7 @@
 	/* global attributes */
 	| `std.Some "incpath":	incpath(b, p, &p.incpath, "incpath")
 	| `std.Some "libdeps":	incpath(b, p, &p.libdeps, "libdeps")
+	| `std.Some "testdeps":	incpath(b, p, &p.tstdeps, "testdeps")
 	| `std.Some "runtime":	p.runtime = expectword(b, p, "runtime")
 	| `std.Some "ldscript":	p.runtime = expectword(b, p, "ldscript")
 	| `std.Some "noinst":	p.install = false
@@ -371,7 +375,8 @@
 */
 const myrtarget = {b, p, targ
 	var ldscript, runtime, install, incpath, tags
-	var name, inputs, libdeps, libdep, attrs
+	var libdeps, libdep, tstdeps, tstdep
+	var name, inputs, attrs
 	var istest
 	var fsel
 
@@ -423,6 +428,12 @@
 		std.slpush(&libdeps, libdep)
 	;;
 
+	tstdeps = [][:]
+	for l in p.tstdeps
+		tstdep = libpath(p, l)
+		std.slpush(&tstdeps, tstdep)
+	;;
+
 	tags = [][:]
 	for elt in attrs
 		match elt
@@ -448,6 +459,7 @@
 		.name=name,
 		.inputs=inputs,
 		.libdeps=libdeps,
+		.tstdeps=tstdeps,
 		.islib=false,
 		.istest=istest,
 		/* attrs */
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -118,7 +118,7 @@
 }
 
 const buildtests = {b, targ
-	var tt, bin, tests, incpath
+	var tt, bin, tests, incpath, libdeps
 	var cmd
 
 	tests = [][:]
@@ -129,12 +129,14 @@
 		| `std.Some path:
 			bin = srcswapsuffix(path, "")
 			incpath = std.sldup(targ.incpath)
+			libdeps = std.sldup(targ.libdeps)
+			std.sljoin(&libdeps, targ.tstdeps)
 			tt = [
 				.name = bin,
 				.dir = targ.dir,
 				.inputs = [path][:],
 				.install = false,
-				.libdeps = std.sldup(targ.libdeps),
+				.libdeps = libdeps,
 				.incpath = std.slput(&incpath, 0, "."),
 			]
 
--- a/mbld/types.myr
+++ b/mbld/types.myr
@@ -38,6 +38,7 @@
 		name	: byte[:]
 		inputs	: byte[:][:]
 		libdeps	: (byte[:], byte[:], byte[:])[:]	/* dir, lib, targname */
+		tstdeps	: (byte[:], byte[:], byte[:])[:]	/* dir, lib, targname */
 		install	: bool
 		runtime	: byte[:]
 		incpath	: byte[:][:]