shithub: mc

Download patch

ref: 93b64d4d7b2dd6251adb3c14d2f371c896f34b9a
parent: 330b77e1df403fdfcbc6b49534571a76b1b525b5
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Sep 26 17:22:06 EDT 2014

Build the usefile for a library.

    This was forgotten. Oops.

--- a/bldfile
+++ b/bldfile
@@ -13,5 +13,19 @@
 	util.myr
 ;
 
+lib testlib =
+	build.myr
+	clean.myr
+	config.myr
+	deps.myr
+	install.myr
+	main.myr
+	opts.myr
+	parse.myr
+	subdir.myr
+        types.myr
+	util.myr
+;
+
 man = mbld.1;
 
--- a/build.myr
+++ b/build.myr
@@ -104,6 +104,7 @@
 			;;
 		;;
 		if built
+			mergeuse(&dg, lib, inputs)
 			archivelib(&dg, lib, inputs)
 		;;
 	| `std.None:
@@ -194,7 +195,7 @@
 	var obj
 
 	cmd = [][:]
-	cmd = std.slpush(cmd, std.sldup("ar"))
+	cmd = std.slpush(cmd, std.sldup(opt_ar))
 	cmd = std.slpush(cmd, std.sldup("-rcs"))
 	cmd = std.slpush(cmd, std.fmt("lib%s.a", lib))
 	for f in files
@@ -210,6 +211,25 @@
 	run(cmd, "")
 	strlistfree(cmd)
 }
+
+const mergeuse = {dg, lib, files
+	var cmd
+
+	cmd = [][:]
+	cmd = std.slpush(cmd, std.sldup(opt_muse))
+	cmd = std.slpush(cmd, std.sldup("-mo"))
+	cmd = std.slpush(cmd, std.sldup(lib))
+	for f in files
+		if std.hassuffix(f, ".myr")
+			cmd = std.slpush(cmd, swapsuffix(f, ".myr", ".use"))
+		elif !std.hassuffix(f, ".s")
+			std.fatal(1, "unknown file type for %s\n", f)
+		;;
+	;;
+	run(cmd, "")
+	strlistfree(cmd)
+}
+
 
 
 
--- a/opts.myr
+++ b/opts.myr
@@ -68,7 +68,7 @@
 	opt_ld = std.getenvv("MYR_LD", "ld")
 	opt_ar = std.getenvv("MYR_AR", "ar")
 	opt_muse = std.getenvv("MYR_MUSE", "muse")
-	opt_runtime = std.pathcat(config.Instroot, "/lib/myr/_myrrt.o")
+	opt_runtime = std.strcat(config.Instroot, "/lib/myr/_myrrt.o")
 }
 
 const cstr2myr = {cstr
--- a/parse.myr
+++ b/parse.myr
@@ -89,6 +89,7 @@
 	| `std.Some wl: inputs = wl
 	| `std.None: failparse(p, "expected list of file names after '%s %s'\n", targ, name)
 	;;
+
 	skipspace(p)
 	if !matchc(p, ';')
 		failparse(p, "expected ';' terminating input list, got %c\n", peekc(p))
@@ -120,6 +121,7 @@
 const anontarget = {p, targ
 	var inputs
 
+	inputs = [][:]
 	skipspace(p)
 	if !matchc(p, '=')
 		failparse(p, "expected '=' after '%s' target", targ)