shithub: mc

Download patch

ref: f5761a93a98d27b6f05a31f4bdc3338ae244c86c
parent: e3068fa21bebe67d64694e91497e0c02ee39d293
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Sep 24 11:53:34 EDT 2014

Remove debug dumps and compiler workarounds.

--- a/bldfile
+++ b/bldfile
@@ -1,5 +1,5 @@
 # comment
-bin mbld2 {ldscript = link.ld} =
+bin mbld2 =
 	build.myr
 	clean.myr
 	config.myr
--- a/build.myr
+++ b/build.myr
@@ -4,6 +4,7 @@
 use "deps.use"
 use "opts.use"
 use "parse.use"
+use "types.use"
 use "util.use"
 
 pkg bld =
@@ -17,7 +18,7 @@
 const buildall = {p
 	for t in p.targs
 		match t
-		| `Bin [.name=bin, .inputs=leaves, .install=_, .ldscript=lds, .runtime=rt]:
+		| `Bin [.name=bin, .inputs=leaves, .ldscript=lds, .runtime=rt]:
 			buildbin(bin, leaves, lds, rt)
 		| `Lib [.name=lib, .inputs=leaves]:
 			buildlib(lib, leaves)
@@ -43,7 +44,7 @@
 	built = false
 	for t in p.targs
 		match t
-		| `Bin [.name=bin, .inputs=leaves, .install=_, .ldscript=lds, .runtime=rt]:
+		| `Bin [.name=bin, .inputs=leaves, .ldscript=lds, .runtime=rt]:
 			if std.sleq(bin, targ)
 				buildbin(bin, leaves, lds, rt)
 				built = true
@@ -72,17 +73,22 @@
 
 const buildbin = {bin, inputs, ldscript, rt
 	var dg
+	var built
 
-	std.put("LD SCRIPT: %s\n", ldscript)
 	if !myrdeps(&dg, bin, inputs, false)
 		std.fatal(1, "Could not load dependencies for %s\n", bin)
 	;;
 	match std.htget(dg.deps, bin)
 	| `std.Some deps:
+		built = false
 		for d in deps
-			builddep(&dg, d, bin)
+			if builddep(&dg, d, bin)
+				built = true
+			;;
 		;;
-		linkbin(&dg, bin, inputs, ldscript, rt)
+		if built
+			linkbin(&dg, bin, inputs, ldscript, rt)
+		;;
 	| `std.None:
 		std.fatal(1, "No such binary %s\n", bin)
 	;;
@@ -90,6 +96,7 @@
 
 const buildlib = {lib, inputs
 	var dg
+	var built
 
 	if !myrdeps(&dg, lib, inputs, true)
 		std.fatal(1, "Could not load dependencies for %s\n", lib)
@@ -96,10 +103,15 @@
 	;;
 	match std.htget(dg.deps, lib)
 	| `std.Some deps:
+		built = false
 		for d in deps
-			builddep(&dg, d, lib)
+			if builddep(&dg, d, lib)
+				built = true
+			;;
 		;;
-		archivelib(&dg, lib, inputs)
+		if built
+			archivelib(&dg, lib, inputs)
+		;;
 	| `std.None:
 		std.fatal(1, "No such library %s\n", lib)
 	;;
@@ -119,11 +131,12 @@
 	;;
 
 	if isfresh(dep, out)
-		->
+		-> false
 	;;
 	if std.hassuffix(dep, ".myr")
 		run(["6m", dep][:])
 	;;
+	-> true
 }
 
 const linkbin = {dg, bin, srcfiles, ldscript, rt
@@ -138,7 +151,6 @@
 	cmd = std.slpush(cmd, std.sldup(bin))
 
 	/* [-T script] */
-	std.put("ldscript = %s\n", ldscript)
 	if ldscript.len > 0
 		cmd = std.slpush(cmd, std.sldup("-T"))
 		cmd = std.slpush(cmd, std.sldup(ldscript))
--- a/clean.myr
+++ b/clean.myr
@@ -4,6 +4,7 @@
 use "deps.use"
 use "opts.use"
 use "parse.use"
+use "types.use"
 
 pkg bld =
 	const cleanall	: (p : parser# -> bool)
--- a/deps.myr
+++ b/deps.myr
@@ -4,14 +4,9 @@
 
 use "config.use"
 use "opts.use"
+use "types.use"
 
 pkg bld =
-	type depgraph = struct
-		roots	: byte[:][:]
-		deps	: std.htab(byte[:], byte[:][:])#
-		libs	: std.htab(byte[:], byte[:][:])#
-	;;
-
 	const myrdeps	: (dg : depgraph#, targ : byte[:], leaves : byte[:][:], islib : bool	-> bool)
 ;;
 
@@ -33,6 +28,7 @@
 
 	dg.deps = std.mkht(std.strhash, std.streq)
 	dg.libs = std.mkht(std.strhash, std.streq)
+	dg.updated = std.mkht(std.strhash, std.streq)
 	seentab = std.mkht(std.strhash, std.streq)
 	donetab = std.mkht(std.strhash, std.streq)
 	/* direct dependencies of binary */
--- a/install.myr
+++ b/install.myr
@@ -5,6 +5,7 @@
 use "opts.use"
 use "parse.use"
 use "util.use"
+use "types.use"
 
 pkg bld =
 	const install	: (p : parser#	-> bool)
--- a/main.myr
+++ b/main.myr
@@ -6,12 +6,13 @@
 use "install.use"
 use "opts.use"
 use "parse.use"
+use "types.use"
 
 const main = {args : byte[:][:]
 	var p : bld.parser#
 	var optctx
 
-	optctx = std.optinit("hb:l:s:r:I:C:A:M:L:R:", args)
+	optctx = std.optinit("hb:l:s:r:I:C:A:M:L:R:d", args)
 	bld.initopts()
 	while !std.optdone(optctx)
 		match std.optnext(optctx)
@@ -42,7 +43,7 @@
 	;;
 
 	if bld.opt_binname.len != 0
-		bld.buildbin(bld.opt_binname, optctx.args, bld.opt_ldscript)
+		bld.buildbin(bld.opt_binname, optctx.args, bld.opt_ldscript, bld.opt_runtime)
 	elif bld.opt_libname.len != 0
 		bld.buildlib(bld.opt_libname, optctx.args)
 	else
--- a/parse.myr
+++ b/parse.myr
@@ -1,35 +1,8 @@
 use std
 
-pkg bld =
-	type parser = struct
-		/* parse input */
-		data	: byte[:]
-		rest	: byte[:]
-		fname	: byte[:]
-		line	: int
+use "types.use"
 
-		/* build params */
-		targs	: target[:]
-		prefix	: byte[:]
-		system	: byte[:]
-		arch	: byte[:]
-	;;
-
-	type myrtarg = struct
-		name	: byte[:]
-		inputs	: byte[:][:]
-		install	: bool
-		ldscript	: byte[:]
-		runtime	: byte[:]
-	;;
-
-	type target = union
-		`Bin	myrtarg
-		`Lib	myrtarg
-		`Sub	byte[:][:]
-		`Man	byte[:][:]
-	;;
-
+pkg bld =
 	const parse	: (p : parser#	-> bool)
 ;;
 
@@ -74,10 +47,6 @@
 
 const bintarget = {p
 	p.targs = std.slpush(p.targs, `Bin myrtarget(p, "bin"))
-	match p.targs[p.targs.len - 1]
-	| `Bin b:
-		std.put("ldscript in targ = %s\n", b.ldscript)
-	;;
 }
 
 const libtarget = {p
@@ -130,9 +99,7 @@
 	runtime = ""
 	for elt in attrs
 		match elt
-		| ("ldscript", lds):
-			std.put("ldscript attr = %s\n", lds)
-			ldscript = std.sldup(lds)
+		| ("ldscript", lds):	ldscript = std.sldup(lds)
 		| ("runtime", rt):	runtime = std.sldup(rt)
 		| ("noinst", val):
 			if val.len != 0
@@ -141,7 +108,6 @@
 			inst = false
 		;;
 	;;
-	std.put("ldscript = %s\n", ldscript)
 	-> [
 		.name=name,
 		.inputs=inputs,
--- /dev/null
+++ b/types.myr
@@ -1,0 +1,38 @@
+use std
+
+pkg bld =
+	type parser = struct
+		/* parse input */
+		data	: byte[:]
+		rest	: byte[:]
+		fname	: byte[:]
+		line	: int
+
+		/* build params */
+		targs	: target[:]
+		prefix	: byte[:]
+		system	: byte[:]
+		arch	: byte[:]
+	;;
+
+	type depgraph = struct
+		roots	: byte[:][:]
+		deps	: std.htab(byte[:], byte[:][:])#
+		libs	: std.htab(byte[:], byte[:][:])#
+	;;
+
+	type myrtarg = struct
+		name	: byte[:]
+		inputs	: byte[:][:]
+		install	: bool
+		ldscript	: byte[:]
+		runtime	: byte[:]
+	;;
+
+	type target = union
+		`Bin	myrtarg
+		`Lib	myrtarg
+		`Sub	byte[:][:]
+		`Man	byte[:][:]
+	;;
+;;