-
Notifications
You must be signed in to change notification settings - Fork 3
docs: add script and make target to auto-generate project structure #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,10 +7,10 @@ BIN_DIR ?= $(PREFIX)/bin | |||||||||||||||||||||||||||||||||||||||
| SHARE_DIR ?= $(PREFIX)/share/mako | ||||||||||||||||||||||||||||||||||||||||
| RUNTIME_DST ?= $(SHARE_DIR)/runtime | ||||||||||||||||||||||||||||||||||||||||
| CARGO ?= cargo | ||||||||||||||||||||||||||||||||||||||||
| TARGET_DIR ?= $(shell $(CARGO) metadata --format-version 1 --no-deps 2>/dev/null | python3 -c 'import json,sys; print(json.load(sys.stdin)["target_directory"])' 2>/dev/null || echo target) | ||||||||||||||||||||||||||||||||||||||||
| TARGET_DIR ?= $(shell$(CARGO) metadata --format-version 1 --no-deps 2>/dev/null | python3 -c 'import json,sys; print(json.load(sys.stdin)["target_directory"])' 2>/dev/null || echo target) | ||||||||||||||||||||||||||||||||||||||||
| MAKO_BIN := $(TARGET_DIR)/release/mako | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| .PHONY: all release build install uninstall test help clean version | ||||||||||||||||||||||||||||||||||||||||
| .PHONY: all release build install uninstall test help clean version structure | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| all: release | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
|
@@ -31,18 +31,11 @@ install: release | |||||||||||||||||||||||||||||||||||||||
| install -m 644 runtime/third_party/README.md "$(RUNTIME_DST)/third_party/"; \ | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| @if [ -d std ]; then \ | ||||||||||||||||||||||||||||||||||||||||
| rm -rf "$(SHARE_DIR)/std"; mkdir -p "$(SHARE_DIR)/std"; cp -R std/. "$(SHARE_DIR)/std/"; \ | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| @VER=$$("$(BIN_DIR)/mako" version 2>/dev/null || true); \ | ||||||||||||||||||||||||||||||||||||||||
| rm -rf "$(SHARE_DIR)/std"; mkdir -p "$(SHARE_DIR)/std"; cp -R std/. "$(SHARE_DIR)/std/"; \ fi @VER=$$("$(BIN_DIR)/mako" version 2>/dev/null || true); \ | ||||||||||||||||||||||||||||||||||||||||
| HOST=$$(uname -s 2>/dev/null)-$$(uname -m 2>/dev/null); \ | ||||||||||||||||||||||||||||||||||||||||
| TS=$$(date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date); \ | ||||||||||||||||||||||||||||||||||||||||
| printf '%s\n' \ | ||||||||||||||||||||||||||||||||||||||||
| '{' \ | ||||||||||||||||||||||||||||||||||||||||
| ' "schema": "mako.install.v1",' \ | ||||||||||||||||||||||||||||||||||||||||
| " \"version\": \"$$VER\"," \ | ||||||||||||||||||||||||||||||||||||||||
| TS=$$(date -u +\%Y-\%m-\%dT\%H:\%M:\%SZ 2>/dev/null \vert{}\vert{} date); \ printf '\%s\n' \ '{' \ ' "schema": "mako.install.v1",' \ " \"version\": \"$$VER\"," \ | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: make -n install | sed -n '/rm -rf.*std/,/install-manifest.json/p' | cat -vetRepository: loreste/mako Length of output: 188 🏁 Script executed: #!/bin/bash
set -u
if ! command -v make >/dev/null 2>&1; then
echo "make not available"
fi
sed -n '20,45p' Makefile | cat -vet
printf '\n--- parse Makefile recipe continuation check ---\n'
python3 - <<'PY'
from pathlib import Path
p = Path("Makefile")
text = p.read_text()
lines = text.splitlines()
for i, line in enumerate(lines, 1):
if 'TS=$$(date -u +\\%Y' in line or '`@VER`=$$' in line or 'cp -R std/.' in line:
before = ''
if 1 <= i-1 <= len(lines):
before = repr(lines[i-1])
print(f"line {i}: {line!r} (ends_backslash={line.endswith(chr(92))}) prev={before}")
PYRepository: loreste/mako Length of output: 2388 🏁 Script executed: #!/bin/bash
set -u
python3 - <<'PY'
from pathlib import Path
p = Path("/tmp/makefile-probe.txt")
# Only preserve the Makefile recipe lines of interest as literal bytes.
p.write_text(bytes([
ord('\t'), ord('@'), ord('i'), ord('f'), ord(' '), ord('['), ord(' '), ord('d'), ord(' '),
ord('s'), ord('t'), ord('d'), ord(']'), ord(';'), ord(' '), ord('\\ ')
ord('d') # duplicate 'd' from original snippet, but this is intentionally wrong so continuation fails
]) , "utf-8"))
PY
# Show the exact line endings and continuation characters for the affected Makefile lines.
python3 - <<'PY'
from pathlib import Path
p = Path("Makefile")
text = p.read_text()
for index, line in enumerate(text.splitlines(keepends=True), 1):
if 33 <= index <= 38:
print(f"--- line {index} ---")
print(repr(line))
PYRepository: loreste/mako Length of output: 935 🌐 Web query:
💡 Result: In GNU Make, a backslash () is used to split a long logical line in a recipe into multiple physical lines. It is critical that the backslash is the very last character on the line, immediately followed by the newline [1][2]. If you place any whitespace—such as spaces or tabs—after the backslash on the same line, GNU Make will not recognize the backslash as a line continuation character [3]. Instead, the backslash and the subsequent whitespace will be treated as part of the command line itself and passed directly to the shell [1][3]. This often results in unexpected behavior, such as a "command not found" error or syntax errors, because the shell receives the trailing backslash as a literal character in the command [3]. Key behavior regarding recipe line splitting: - Preservation: Unlike how backslash/newline pairs are treated elsewhere in a makefile, GNU Make does not remove the backslash and newline characters in a recipe [1][2]. They are preserved and passed to the shell [1][2]. - Shell Interpretation: Because the backslash and newline are passed to the shell, the actual behavior depends on how your chosen shell (e.g., /bin/sh or /bin/bash) interprets them [1][2]. - Recipe Prefix: When a recipe is split, if the first character of the next physical line is the recipe prefix character (a tab by default), GNU Make removes that prefix character before passing the line to the shell [1][2]. No additional whitespace is added by GNU Make during this process [1][2]. Citations:
🌐 Web query:
💡 Result: In GNU Make, a backslash immediately followed by a newline is used to split a single logical recipe line into multiple physical lines in the makefile [1][2]. Crucially, in the context of recipe lines (the commands executed by the shell), the backslash/newline pair is not removed by make [1][2]. Instead, both the backslash and the newline characters are preserved and passed directly to the shell [1][2]. Consequently, whether whitespace (such as a space) is permitted after the backslash depends entirely on how your shell interprets that sequence [1][2]. If you place a space after the backslash and before the newline: 1. The backslash is no longer immediately followed by the newline. 2. The sequence is not recognized by GNU Make as a line continuation directive for the recipe [1][2]. 3. The shell will receive the space, the backslash, and the newline as part of the command line, which will likely result in a syntax error or unintended behavior depending on the shell [1][2]. For splitting recipe lines, you must place the backslash at the very end of the line, immediately before the newline character [1][2]. If the first character of the next physical line is the recipe prefix character (a tab by default), GNU Make will remove only that tab character; it does not add any whitespace to the recipe [1][2]. If you need to include a newline in a quoted string passed to the shell, it is often safer to store the command in a GNU Make variable, where standard makefile line-continuation rules apply and backslash/newline sequences are stripped [1][2]. Citations:
🌐 Web query:
💡 Result: In GNU Make (including version 4.4.1), you can split long lines in your Makefile for better readability by using the backslash ( Citations:
🌐 Web query:
💡 Result: In GNU make, a backslash-newline in a recipe line is not removed; both characters are preserved and passed to the shell. If the next line starts with the recipe prefix (a tab by default), that one character is removed, and no whitespace is added. (gnu.org) Citations: Fix the malformed GNU Make continuations before running Lines 34 and 36 leave whitespace after recipe 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| " \"prefix\": \"$(PREFIX)\"," \ | ||||||||||||||||||||||||||||||||||||||||
| " \"host\": \"$$HOST\"," \ | ||||||||||||||||||||||||||||||||||||||||
| " \"installedAt\": \"$$TS\"," \ | ||||||||||||||||||||||||||||||||||||||||
| " \"host\": \"$$HOST\"," \ " \"installedAt\": \"$$TS\"," \ | ||||||||||||||||||||||||||||||||||||||||
| " \"runtime\": \"$(RUNTIME_DST)\"," \ | ||||||||||||||||||||||||||||||||||||||||
| " \"std\": \"$(SHARE_DIR)/std\"" \ | ||||||||||||||||||||||||||||||||||||||||
| '}' > "$(SHARE_DIR)/install-manifest.json" | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+36
to
41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: tmp="$(mktemp)"
printf '\%s\n' '{' ' "schema": "mako.install.v1",' '}' > "$tmp"
python3 -m json.tool "$tmp"Repository: loreste/mako Length of output: 192 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '--- Makefile relevant section ---\n'
sed -n '30,50p' Makefile | cat -n
printf '\n--- behavioral probes ---\n'
tmp="$(mktemp)"
printf '%s\n' '{' '{"a":1}' > "$tmp"
printf -- 'single printf output:\n'
sed -n '1,5p' "$tmp"
printf '\nprintf \"\\%%s\\n\":\n'
printf '\%s\n' '{' ' "schema": "mako.install.v1",' '}' > "$tmp"
sed -n '1,5p' "$tmp"
python3 -m json.tool "$tmp" || true
printf '\nprintf \"%%%%s\\n\":\n'
printf '%s\n' '{' ' "schema": "mako.install.v1",' '}' > "$tmp"
sed -n '1,5p' "$tmp"
printf '\nmanifold printf behavior check:\n'
for line in 'printf '\''\%s\n'\'' '\''{'\''' 'printf '\''%s\n'\'' '\''{'\'''; do
tmp="$(mktemp)"
(eval "$line" 'a' 'b') > "$tmp"
printf '%s ->' "$line"
sed -n '1p' "$tmp" | od -c | tr '\n' ' '
printf '\n'
doneRepository: loreste/mako Length of output: 241 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- Makefile relevant section ---'
sed -n '30,50p' Makefile | cat -n
printf '%s\n' ''
printf '%s\n' '--- behavioral probes ---'
tmp="$(mktemp)"
printf '%s\n' '{' '{"a":1}' > "$tmp"
printf 'single printf output:\n'
sed -n '1,5p' "$tmp"
printf '%s\n' ''
printf 'printf with literal backslash format:\n'
printf '\%s\n' '{' ' "schema": "mako.install.v1",' '}' > "$tmp"
sed -n '1,5p' "$tmp"
python3 -m json.tool "$tmp" || true
printf '%s\n' ''
printf 'printf with escaped backslash format:\n'
printf '%s\n' '{' ' "schema": "mako.install.v1",' '}' > "$tmp"
sed -n '1,5p' "$tmp"
printf '%s\n' ''
printf 'printf with escaped backslash format plus newline, if supported:\n'
printf '%s\n' '{' ' "schema": "mako.install.v1",' '}' > "$tmp"
sed -n '1,5p' "$tmp"Repository: loreste/mako Length of output: 1731 Emit the manifest with The literal Proposed fix- printf '\%s\n' \
+ printf '%s\n' \📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
|
|
@@ -63,8 +56,11 @@ version: | |||||||||||||||||||||||||||||||||||||||
| $(CARGO) run --quiet --release -- --version | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| help: | ||||||||||||||||||||||||||||||||||||||||
| @echo "Targets: release install uninstall test version help" | ||||||||||||||||||||||||||||||||||||||||
| @echo "Targets: release install uninstall test version help structure" | ||||||||||||||||||||||||||||||||||||||||
| @echo "PREFIX=$(PREFIX) RUNTIME_DST=$(RUNTIME_DST)" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| clean: | ||||||||||||||||||||||||||||||||||||||||
| $(CARGO) clean | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| structure: | ||||||||||||||||||||||||||||||||||||||||
| @bash scripts/update_structure.sh | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: loreste/mako
Length of output: 872
🏁 Script executed:
Repository: loreste/mako
Length of output: 3134
🏁 Script executed:
Repository: loreste/mako
Length of output: 1555
🏁 Script executed:
Repository: loreste/mako
Length of output: 512
🏁 Script executed:
Repository: loreste/mako
Length of output: 624
🏁 Script executed:
Repository: loreste/mako
Length of output: 199
🌐 Web query:
GNU make Function invocation syntax $(function arguments) whitespace after function name $(shell command)💡 Result:
In GNU make, the syntax for a function invocation is$(function arguments) or $ {function arguments} [1][2]. Regarding whitespace: 1. Function Name and Arguments: The function name must be separated from the first argument by one or more spaces or tabs [1][3]. This whitespace is considered a separator and is not included as part of the first argument's value [1][2]. 2. Leading Whitespace in Arguments: Leading whitespace in the first argument is not preserved as part of the argument's text [1][3]. However, whitespace contained within subsequent arguments is generally preserved [1][4]. 3. Shell Function: The $(shell command) function follows these same rules [5]. The command string provided to the shell function is the text following the initial separator whitespace [1][5]. Because make uses whitespace to separate the function name from its arguments, extra or unexpected whitespace can sometimes lead to issues if not handled carefully [6]. For example, if you intend to pass a string that begins with spaces as the first argument, you cannot simply write it directly because the leading spaces will be stripped [1][3]. Instead, you must use techniques like defining a variable that contains the required space character (e.g., space:= $(empty) $(empty)) and using it to construct the argument [1][3].
Citations:
Fix the malformed
$(shell ...)invocation.Make function arguments must be delimited from the function name, so add whitespace after
shell:$(shell $(CARGO) metadata --format-version 1 --no-deps 2>/dev/null | python3 -c ...). As written, this is not parsed as Make’sshellfunction and causesMAKO_BINto expand from the fallbacktarget.🤖 Prompt for AI Agents