~autumnull/haredo-devel

Print (skipped) when a target isn't updated v1 APPLIED

Ember Sawady: 2
 Print (skipped) when a target isn't updated
 Drop echos from dofiles

 17 files changed, 24 insertions(+), 25 deletions(-)
Thanks!

~Autumn
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~autumnull/haredo-devel/patches/38316/mbox | git am -3
Learn more about email & git

[PATCH 1/2] Print (skipped) when a target isn't updated Export this patch

---
 src/main.ha | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/main.ha b/src/main.ha
index 573807c..010988a 100644
--- a/src/main.ha
+++ b/src/main.ha
@@ -136,7 +136,9 @@ export fn main() void = {
			const status = exec::wait(&child.0)!;
			defer io::write(ctx.wr, [0])!;
			match (cleanup_child(&ctx, &status, child.1, cmd.args[i])) {
			case void => log(&ctx, lvl::OK, cmd.args[i], "done")!;
			case let new: bool =>
				let msg = if (new) "done" else "skipped";
				log(&ctx, lvl::OK, cmd.args[i], msg)!;
			case let err: !str =>
				log(&ctx, lvl::ERR, cmd.args[i], err)!;
				os::exit(1);
@@ -158,7 +160,9 @@ export fn main() void = {
		defer free(tmpfile);
		defer io::write(ctx.wr, [0])!;
		match (cleanup_child(&ctx, &status, tmpfile, target)) {
		case void => log(&ctx, lvl::OK, target, "done")!;
		case let new: bool =>
			let msg = if (new) "done" else "skipped";
			log(&ctx, lvl::OK, cmd.args[i], msg)!;
		case let err: !str =>
			log(&ctx, lvl::ERR, cmd.args[i], err)!;
			os::exit(1);
@@ -268,20 +272,29 @@ fn try_do(
	return (proc, tmpfilepath);
};

// XXX: Should be (str | !str), workaround for https://todo.sr.ht/~sircmpwn/hare/788
fn cleanup_child(
	ctx: *context,
	status: *exec::status,
	tmpfile: str,
	target: str,
) (void | !str) = {
) (bool | !str) = {
	match (exec::check(status)) {
	case void => void;
	case let e: !exec::exit_status => return exec::exitstr(e);
	case let e: !exec::exit_status =>
		return exec::exitstr(e);
	};
	match (os::move(tmpfile, target)) {
	case void => void;
	case errors::noentry => void;
	case let e: fs::error => return fs::strerror(e);
	case void => return true;
	case errors::noentry =>
		match (os::access(target, os::amode::F_OK)) {
		case let e: fs::error =>
			return true;
		case let ok: bool =>
			return !ok;
		};
	case let e: fs::error =>
		return fs::strerror(e);
	};
};

-- 
2.39.1

[PATCH 2/2] Drop echos from dofiles Export this patch

---
 bin/clean.do            | 1 -
 bin/haredo.do           | 1 -
 doc/clean.do            | 1 -
 doc/haredo.1.do         | 1 -
 src/main.ha             | 6 +++---
 test.do                 | 2 +-
 test/amd64/default.o.do | 1 -
 test/arm64/default.o.do | 1 -
 test/clean-gen.do       | 1 -
 test/clean.do           | 1 -
 test/default.o.do       | 1 -
 test/install.do         | 1 -
 test/main.o.do          | 1 -
 test/qbe.do             | 1 -
 test/rv64/default.o.do  | 1 -
 test/uninstall.do       | 1 -
 16 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/bin/clean.do b/bin/clean.do
index c714ae5..cd241af 100644
--- a/bin/clean.do
@@ -1,5 +1,4 @@
if test -f haredo
then
	echo "RM\tharedo"
	rm haredo
fi
diff --git a/bin/haredo.do b/bin/haredo.do
index bcaf464..1a8fddb 100644
--- a/bin/haredo.do
@@ -1,5 +1,4 @@
if haredo ++ ../src/*
then
	echo "HARE\t$1"
	$HARE build -o $3 ../src
fi
diff --git a/doc/clean.do b/doc/clean.do
index 8d1f2a5..585ae1f 100644
--- a/doc/clean.do
+++ b/doc/clean.do
@@ -1,5 +1,4 @@
if test -f haredo.1
then
	echo "RM\tharedo.1"
	rm haredo.1
fi
diff --git a/doc/haredo.1.do b/doc/haredo.1.do
index 379562c..9a5e093 100644
--- a/doc/haredo.1.do
+++ b/doc/haredo.1.do
@@ -1,5 +1,4 @@
if haredo ++ $1.scd
then
	echo "SCDOC\t$1"
	$SCDOC < $1.scd > $3
fi
diff --git a/src/main.ha b/src/main.ha
index 010988a..f7559b5 100644
--- a/src/main.ha
+++ b/src/main.ha
@@ -287,11 +287,11 @@ fn cleanup_child(
	match (os::move(tmpfile, target)) {
	case void => return true;
	case errors::noentry =>
		match (os::access(target, os::amode::F_OK)) {
		match (os::stat(target)) {
		case let e: fs::error =>
			return true;
		case let ok: bool =>
			return !ok;
		case let fs: fs::filestat =>
			return !fs::isfile(fs.mode);
		};
	case let e: fs::error =>
		return fs::strerror(e);
diff --git a/test.do b/test.do
index a8f7fa7..5366aec 100644
--- a/test.do
+++ b/test.do
@@ -1,7 +1,7 @@
haredo bin/haredo || true
PATH=$PWD/bin:$PATH # run haredo from bin directory

haredo -q test/all || true
haredo test/all || true
touch test/rv64/all.h
haredo test/all || true
haredo test/clean-gen || true
diff --git a/test/amd64/default.o.do b/test/amd64/default.o.do
index fdbbecf..c042299 100644
--- a/test/amd64/default.o.do
+++ b/test/amd64/default.o.do
@@ -1,5 +1,4 @@
if haredo ++ ../all.h ../ops.h all.h $2.c
then
	echo "CC\t$1"
	$CC $CFLAGS -c $2.c -o $3
fi
diff --git a/test/arm64/default.o.do b/test/arm64/default.o.do
index fdbbecf..c042299 100644
--- a/test/arm64/default.o.do
+++ b/test/arm64/default.o.do
@@ -1,5 +1,4 @@
if haredo ++ ../all.h ../ops.h all.h $2.c
then
	echo "CC\t$1"
	$CC $CFLAGS -c $2.c -o $3
fi
diff --git a/test/clean-gen.do b/test/clean-gen.do
index 9b303bc..68dc9dc 100644
--- a/test/clean-gen.do
+++ b/test/clean-gen.do
@@ -2,6 +2,5 @@ haredo clean || true

if test -f config.h
then
	echo "RM\tconfig.h"
	rm config.h
fi
diff --git a/test/clean.do b/test/clean.do
index 1dee03f..2c8a4e1 100644
--- a/test/clean.do
+++ b/test/clean.do
@@ -2,6 +2,5 @@ rm -f *.o */*.o

if test -f qbe
then
	echo "RM\tqbe"
	rm qbe
fi
diff --git a/test/default.o.do b/test/default.o.do
index 9c6f0e1..e2cb5f8 100644
--- a/test/default.o.do
+++ b/test/default.o.do
@@ -1,5 +1,4 @@
if haredo ++ all.h ops.h $2.c
then
	echo "CC\t$1"
	$CC $CFLAGS -c $2.c -o $3
fi
diff --git a/test/install.do b/test/install.do
index bb50bef..fa2781d 100644
--- a/test/install.do
+++ b/test/install.do
@@ -3,7 +3,6 @@
if haredo qbe
then
	mkdir -p "$DESTDIR$BINDIR"
	echo "INSTALL\t$DESTDIR$BINDIR/qbe"
	install -m755 qbe "$DESTDIR$BINDIR/qbe"
fi

diff --git a/test/main.o.do b/test/main.o.do
index beb8dec..1ca08ec 100644
--- a/test/main.o.do
+++ b/test/main.o.do
@@ -1,5 +1,4 @@
if haredo config.h ++ all.h ops.h $2.c
then
	echo "CC\t$1"
	$CC $CFLAGS -c $2.c -o $3
fi
diff --git a/test/qbe.do b/test/qbe.do
index b538303..b062f5e 100644
--- a/test/qbe.do
+++ b/test/qbe.do
@@ -2,6 +2,5 @@

if haredo $OBJ
then
	echo "CCLD\t$1"
	$CC $LDFLAGS $OBJ -o $3
fi
diff --git a/test/rv64/default.o.do b/test/rv64/default.o.do
index fdbbecf..c042299 100644
--- a/test/rv64/default.o.do
+++ b/test/rv64/default.o.do
@@ -1,5 +1,4 @@
if haredo ++ ../all.h ../ops.h all.h $2.c
then
	echo "CC\t$1"
	$CC $CFLAGS -c $2.c -o $3
fi
diff --git a/test/uninstall.do b/test/uninstall.do
index ca9abc1..4ee85f6 100644
--- a/test/uninstall.do
+++ b/test/uninstall.do
@@ -1,5 +1,4 @@
if test -f $DESTDIR$BINDIR/qbe
then
	echo "RM\t$DESTDIR$BINDIR/qbe"
	rm "$DESTDIR$BINDIR/qbe"
fi
-- 
2.39.1
Thanks!

~Autumn