Commit 60a89ccb02

60a89ccb02de0b065440bdd805e5408dbf603c80

parent: 8356b2b726

Unsigned

Ilkay Alakay <ilkay@exherbo.domain.foo> · 2026-10-02 14:38 UTC

ilkay/imake: update imake

Layout: unified · split

imake +38 −14
@@ -3,30 +3,54 @@
33
44DIR="$(pwd)"
55IMAKEFILE="$DIR/IMakefile"
6TARGET="${1:-compile}"
67
78if [[ ! -f "$IMAKEFILE" ]]; then
89 echo "imake: IMakefile not found in $DIR" >&2
910 exit 1
1011fi
1112
12while IFS= read -r line || [[ -n "$line" ]]; do
13 [[ -z "$line" ]] && continue
13if ! grep -qE "^${TARGET}:" "$IMAKEFILE"; then
14 echo "imake: *** no rule to make target '$TARGET'. stop." >&2
15 exit 1
16fi
1417
15 printf '%s:\n' "$line"
18in_target=0
1619
17 output=$(bash -c "$line" 2>&1)
18 status=$?
20while IFS= read -r line || [[ -n "$line" ]]; do
21 [[ "$line" =~ ^[[:space:]]*$ ]] && continue
22 [[ "$line" =~ ^[[:space:]]*# ]] && continue
1923
20 if [[ -n "$output" ]]; then
21 while IFS= read -r output_line || [[ -n "$output_line" ]]; do
22 printf ' %s\n' "$output_line"
23 done <<< "$output"
24 else
25 printf ' \n'
24 if [[ "$line" =~ ^([a-zA-Z0-9_-]+):[[:space:]]*$ ]]; then
25 current_target="${BASH_REMATCH[1]}"
26 if [[ "$current_target" == "$TARGET" ]]; then
27 in_target=1
28 else
29 in_target=0
30 fi
31 continue
2632 fi
2733
28 if [[ $status -ne 0 ]]; then
29 printf ' Command failed with exit code %d\n' "$status"
30 exit "$status"
34 if [[ $in_target -eq 1 ]]; then
35 [[ "$line" =~ ^[[:space:]]*(.*)$ ]]
36 cmd_print="${BASH_REMATCH[1]}"
37
38 printf '%s:\n' "$cmd_print"
39
40 output=$(bash -c "$line" 2>&1)
41 status=$?
42
43 if [[ -n "$output" ]]; then
44 while IFS= read -r output_line || [[ -n "$output_line" ]]; do
45 printf ' %s\n' "$output_line"
46 done <<< "$output"
47 else
48 printf ' \n'
49 fi
50
51 if [[ $status -ne 0 ]]; then
52 printf ' command failed with exit code %d\n' "$status"
53 exit "$status"
54 fi
3155 fi
3256done < "$IMAKEFILE"