diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-10-04 17:10:08 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-10-04 17:10:08 +0200 |
commit | 8531a023f0a3db50897ea77f38a5d59909a97825 (patch) | |
tree | d317a69c0bb844b86b4a0a2f16651adc20482144 | |
parent | df4e9faf60be8039af715c60a1fd7b21da8b99c5 (diff) |
makefile build instead of janky shell scripts
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | common.mk | 29 | ||||
l--------- | opdracht-1/build | 1 | ||||
-rw-r--r-- | opdracht-1/makefile | 3 | ||||
-rwxr-xr-x | opdracht-2/build | 3 | ||||
-rw-r--r-- | opdracht-2/makefile | 9 | ||||
-rw-r--r-- | opdracht-2/reset-2.sql | 2 | ||||
-rw-r--r-- | opdracht-2/reset.sql | 2 | ||||
-rwxr-xr-x | render-opdracht | 12 |
9 files changed, 44 insertions, 18 deletions
@@ -1,3 +1,4 @@ opdracht-*/*.md +opdracht-*/.tmp.sql opdracht-*/opdracht.pdf opdracht-*/opdracht-*.md diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..8a0327d --- /dev/null +++ b/common.mk @@ -0,0 +1,29 @@ +RM = rm -f +MYSQL = mysql -Hu root mysql +M4 = m4 + +RESET_SQL += reset.sql +QUERY_SQL += $(wildcard q*.sql) +TESTS_SQL += $(wildcard t*.sql) + +TESTS_MD = $(patsubst %.sql,%.md, $(TESTS_SQL)) + +.PHONY: $(TARGET).m4 $(TESTS_SQL) .tmp.sql clean reset + +all: $(TARGET).md + +.tmp.sql: $(RESET_SQL) $(QUERY_SQL) + cat $(RESET_SQL) $(QUERY_SQL) > .tmp.sql + +reset: .tmp.sql + $(MYSQL) < .tmp.sql + +%.md: %.sql reset + $(MYSQL) < $< &> $@ + +$(TARGET).md: $(TESTS_MD) $(TARGET).m4 + $(M4) $(TARGET).m4 > $(TARGET).md + +clean: + $(RM) $(wildcard *.md) .tmp.sql + diff --git a/opdracht-1/build b/opdracht-1/build deleted file mode 120000 index 1fb5c6e..0000000 --- a/opdracht-1/build +++ /dev/null @@ -1 +0,0 @@ -../render-opdracht
\ No newline at end of file diff --git a/opdracht-1/makefile b/opdracht-1/makefile new file mode 100644 index 0000000..b91dfe8 --- /dev/null +++ b/opdracht-1/makefile @@ -0,0 +1,3 @@ +TARGET := opdracht-1 + +include ../common.mk diff --git a/opdracht-2/build b/opdracht-2/build deleted file mode 100755 index 6f370cb..0000000 --- a/opdracht-2/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cat ../opdracht-1/reset.sql ../opdracht-1/q*.sql reset-2.sql > reset.sql -source ../render-opdracht diff --git a/opdracht-2/makefile b/opdracht-2/makefile new file mode 100644 index 0000000..19a0072 --- /dev/null +++ b/opdracht-2/makefile @@ -0,0 +1,9 @@ +TARGET = opdracht-2 +RESET_SQL += ../opdracht-1/.tmp.sql + +all: $(TARGET).md + +../opdracht-1/.tmp.sql: + make -C ../opdracht-1 + +include ../common.mk diff --git a/opdracht-2/reset-2.sql b/opdracht-2/reset-2.sql deleted file mode 100644 index 08ec0f3..0000000 --- a/opdracht-2/reset-2.sql +++ /dev/null @@ -1,2 +0,0 @@ -drop table Status; - diff --git a/opdracht-2/reset.sql b/opdracht-2/reset.sql index e69de29..3e90143 100644 --- a/opdracht-2/reset.sql +++ b/opdracht-2/reset.sql @@ -0,0 +1,2 @@ +drop table if exists Status; + diff --git a/render-opdracht b/render-opdracht deleted file mode 100755 index cc4fa48..0000000 --- a/render-opdracht +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -bye () { - echo "run me as root!" - exit 1 -} - -[ $(id -g) -ne 0 ] && bye -cat reset.sql q*.sql | mysql -u root mysql -for file in t*.sql; do - mysql -Hu root mysql < "$file" &> "${file/%.sql}.md" -done -m4 `basename $PWD`.m4 > `basename $PWD`.md |