From b435a5824bf88b9bddddb81e645623caa2e334bc Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Wed, 9 Sep 2020 19:36:13 +0100 Subject: Switch to using redo --- .gitignore | 2 ++ Makefile | 9 --------- all.do | 2 ++ configure | 5 +++++ default.o.do | 5 +++++ link | 4 ++++ loadargs | 8 ++++++++ scripts/clean | 2 ++ test_gen.do | 3 +++ unpack_test.do | 3 +++ unpack_test.inc.do | 3 +++ unpack_test.o.do | 4 ++++ 12 files changed, 41 insertions(+), 9 deletions(-) delete mode 100644 Makefile create mode 100644 all.do create mode 100755 configure create mode 100644 default.o.do create mode 100644 link create mode 100644 loadargs create mode 100755 scripts/clean create mode 100644 test_gen.do create mode 100644 unpack_test.do create mode 100644 unpack_test.inc.do create mode 100644 unpack_test.o.do diff --git a/.gitignore b/.gitignore index 981c059..c29b68d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ +*.d *.o *_test *.inc *_gen +*.args diff --git a/Makefile b/Makefile deleted file mode 100644 index d8037f6..0000000 --- a/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# Copyright (C) 2020 Tomasz Kramkowski -# SPDX-License-Identifier: MIT -unpack_test: unpack_test.o unpack.o common.o trace.o -unpack_test.o: unpack_test.c pack.h trace.h common.h unpack_test.inc -trace.o: trace.c trace.h -common.o: common.c common.h -unpack_test.inc: test_gen - ./$< >$@ -test_gen: test_gen.o diff --git a/all.do b/all.do new file mode 100644 index 0000000..ff9812a --- /dev/null +++ b/all.do @@ -0,0 +1,2 @@ +#!/bin/sh +redo-ifchange "$0" "unpack_test" diff --git a/configure b/configure new file mode 100755 index 0000000..70a0698 --- /dev/null +++ b/configure @@ -0,0 +1,5 @@ +#!/bin/sh + +for f in args/"$1"/*; do + ln -sf "$f" +done diff --git a/default.o.do b/default.o.do new file mode 100644 index 0000000..9135cb8 --- /dev/null +++ b/default.o.do @@ -0,0 +1,5 @@ +#!/bin/bash +redo-ifchange "$0" "default.o.do" "$2.c" +. loadargs "compile" +gcc -std=c11 -MD -MF "$2.d" -c -o "$3" "${args[@]}" "$2.c" +redo-ifchange "$2.d" $(sed ':a;/\\$/{s/[^:]*: //;N;s/ \\\n//;ba}' <"$2.d") diff --git a/link b/link new file mode 100644 index 0000000..2b99b87 --- /dev/null +++ b/link @@ -0,0 +1,4 @@ +#/fake/bash +redo-ifchange "$0" "link" "${deps[@]}" +. loadargs "link" +gcc -o "$3" "${deps[@]}" diff --git a/loadargs b/loadargs new file mode 100644 index 0000000..3ec8b0d --- /dev/null +++ b/loadargs @@ -0,0 +1,8 @@ +#/fake/bash +if [ -r "$1.args" ]; then + redo-ifchange "$1.args" + mapfile -t args <"$1.args" +else + redo-ifcreate "$1.args" + args=() +fi diff --git a/scripts/clean b/scripts/clean new file mode 100755 index 0000000..97d7b0f --- /dev/null +++ b/scripts/clean @@ -0,0 +1,2 @@ +#!/bin/sh +find . \( -name '*.d' -o -name '*.o' -o -name '*_gen' -o -name '*.inc' \) -delete diff --git a/test_gen.do b/test_gen.do new file mode 100644 index 0000000..ed0f2e4 --- /dev/null +++ b/test_gen.do @@ -0,0 +1,3 @@ +#!/bin/bash +deps=(test_gen.o) +. ./link diff --git a/unpack_test.do b/unpack_test.do new file mode 100644 index 0000000..9c810c6 --- /dev/null +++ b/unpack_test.do @@ -0,0 +1,3 @@ +#!/bin/bash +deps=(unpack_test.o common.o unpack.o trace.o) +. ./link diff --git a/unpack_test.inc.do b/unpack_test.inc.do new file mode 100644 index 0000000..c6d5c1b --- /dev/null +++ b/unpack_test.inc.do @@ -0,0 +1,3 @@ +#!/bin/sh +redo-ifchange "$0" "test_gen" +./test_gen diff --git a/unpack_test.o.do b/unpack_test.o.do new file mode 100644 index 0000000..a7c32b8 --- /dev/null +++ b/unpack_test.o.do @@ -0,0 +1,4 @@ +#!/bin/bash +redo-ifchange "unpack_test.inc" +set -- "$1" "${2%.o}" "$3" +. ./default.o.do -- cgit v1.2.3-54-g00ecf