1
0
mirror of https://git.lain.church/bake/bake.git synced 2025-06-08 23:06:43 +00:00

Document and break.

This commit is contained in:
Emil Williams 2025-01-04 15:10:15 -07:00
parent 03123a69d3
commit f829ecdb77
Signed by: Emil Williams
GPG Key ID: 9489B46C65132B52
6 changed files with 52 additions and 18 deletions

48
README
View File

@ -1,10 +1,11 @@
--- README --- README
A tool to run embedded scripts. Run embedded scripts.
Bootstrap with ./shake bake.l Bootstrap with ./awake bake.l
then compile further with ./bake, then compile further with ./bake,
install by running ./install.sh
or JUST install by running ./install.sh (has --help)
--- ---
@ -17,12 +18,11 @@ of @STOP. All @BAKE ... @STOP statements must become before any @BAKE
... EOLs. ... EOLs.
It expands some macros, It expands some macros,
@FILENAME @FILE @NAME - filename @FILE - filename
@SHORT - filename without suffix (abc.x.txt \-> abc.x) @SHORT - filename without suffix (abc.x.txt \-> abc.x)
@SHORT:N - removes N suffixes, so (a.b.c 2 -> a) @SHORT:N - removes N suffixes, so (a.b.c 2 -> a)
@ARGS - other arguments to the program @ARGS - other arguments to the program
@ARGS:N - Provides the Nth argument, starting from @ARGS:N - Provides the Nth argument, starting from 0
0
@ARGS:N+ - All arguments at and after Nth @ARGS:N+ - All arguments at and after Nth
@RECURS - the full path name to the executable @RECURS - the full path name to the executable
@LINE - line number at the selected @BAKE @LINE - line number at the selected @BAKE
@ -31,10 +31,10 @@ All macros can be exempted by prefixing them with a backslash,
which'll be subtracted in the expansion. commands may be spanned over which'll be subtracted in the expansion. commands may be spanned over
several lines with a leading backslash. several lines with a leading backslash.
-h --help | Help message -h --help | Help message
-n --dry-run | don't execute or remove anything -n --dry-run | don't execute or remove anything
-c --color | disables color -c --color | disables color
-l --list | lists available Bake blocks -l --list | lists available Bake blocks
-s --select <n> | selects Nth Bake block -s --select <n> | selects Nth Bake block
-x --expunge | Removes the file specified in the expunge block -x --expunge | Removes the file specified in the expunge block
@ -59,6 +59,16 @@ Changelog
Bake was created on 2023/09/13, and complete as of 2024/03/02. Bake was created on 2023/09/13, and complete as of 2024/03/02.
2024-03-02
Initial relaase
2024-04-04
Expunge & color.
2024-04 - 2024-08 - 3 Tags of bump -> minor fixes and improvements
2024-09-27 2024-09-27
Lex. As adviced by the original creator, I learned and implemented Lex. As adviced by the original creator, I learned and implemented
@ -75,3 +85,23 @@ to the BSDs.
cd /dir/of/file; awake file cd /dir/of/file; awake file
See --help See --help
2025-01-04
Introducing some breaking changes.
Remove @FILENAME @NAME, and @FILE_NAME (heyo) leaving only @FILE.
Upgraded ./install.sh to have options.
s/@(FILE_?NAME|NAME)/@FILE/g
I'm finished with tool for the rest of time and have put zero effort
into it this time. If I use it and it breaks, I'll fix it or replace
it with something better.
Anonson, the original creator made a ebuild for Gentoo a few months
ago, and I will link it here when I receive that link from him. I may
one day dare to package Bake as a deb. I would likely have to rename
bake to ebake, which is somehow worse than the original name of eMake.
ebuild: <PENDING>
debian: <PENDING> (perhaps forever)

2
awake
View File

@ -69,7 +69,7 @@ BEGIN {
if (list) { if (list) {
print bakenum": "$0 print bakenum": "$0
} else if (select == bakenum) { } else if (select == bakenum) {
gsub(/\$@|@(FILE_NAME|FILENAME|FILE|NAME)/, filename) gsub(/\$@|@FILE/, filename)
gsub(/\$\*|@SHORT/, shortname) gsub(/\$\*|@SHORT/, shortname)
gsub(/\$\+|@ARGS/, extraargs) gsub(/\$\+|@ARGS/, extraargs)
gsub(/@RECURS/, ARGV[0]) gsub(/@RECURS/, ARGV[0])

2
bake.1
View File

@ -35,7 +35,7 @@ extend a command over several lines.
These macros will expand to their counterpart before execution. These macros will expand to their counterpart before execution.
.TP .TP
.B @FILENAME, @FILE, @NAME, $@ .B @NAME, $@
returns target\-file (abc.x.txt) returns target\-file (abc.x.txt)
.TP .TP
.B @SHORT, $* .B @SHORT, $*

4
bake.l
View File

@ -28,8 +28,8 @@ extern void shorten(char * filename, int n);
SPACE [ \t\r\v\f] SPACE [ \t\r\v\f]
/* Everything that can be backslashed */ /* Everything that can be backslashed */
FILENAME (@FILE_NAME|@FILENAME|@FILE|@NAME) FILENAME @FILE
CMD @BAKE[[:space:]] CMD @BAKE[[:space:]]
MACROS ({CMD}|@STOP|{FILENAME}|@SHORT|@ARGS|@LINE|@RECURS|$@|$*|$+|@\{) MACROS ({CMD}|@STOP|{FILENAME}|@SHORT|@ARGS|@LINE|@RECURS|$@|$*|$+|@\{)
%x FOUND PADDING STOP %x FOUND PADDING STOP

View File

@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
# source install # source install
cd "$(dirname "$(readlink -f $0)")" || exit
TARGET="${TARGET:-/usr/local}" TARGET="${TARGET:-/usr/local}"
INSTALL="bake" INSTALL="bake"
@ -9,6 +11,7 @@ usage() {
echo "" echo ""
echo "--alternatives Includes awake and shake into the build" echo "--alternatives Includes awake and shake into the build"
echo "--target=DIRECTORY Target directory like /usr or /usr/local" echo "--target=DIRECTORY Target directory like /usr or /usr/local"
echo "--prebuilt Program is prebuilt"
echo "" echo ""
exit 1 exit 1
} }
@ -24,6 +27,9 @@ while [ ! -z $1 ]; do
"--help") "--help")
usage usage
;; ;;
"--prebuilt")
BUILD=1
;;
*) *)
echo "Unknown option: " $1 echo "Unknown option: " $1
usage usage
@ -32,9 +38,10 @@ while [ ! -z $1 ]; do
shift shift
done done
cd "$(dirname "$(readlink -f $0)")" if [ -z $BUILD ]; then
./awake bake.l
fi
./awake bake.l
mkdir -p "$TARGET/bin" "$TARGET/man/man1" mkdir -p "$TARGET/bin" "$TARGET/man/man1"
install -m 755 $INSTALL "$TARGET/bin" install -m 755 $INSTALL "$TARGET/bin"
gzip -c bake.1 > "$TARGET/man/man1/bake.1.gz" gzip -c bake.1 > "$TARGET/man/man1/bake.1.gz"

3
shake
View File

@ -76,12 +76,9 @@ if [[ -n $line ]]; then
line=${line//\$@/$input_file} line=${line//\$@/$input_file}
line=${line//\$\*/${input_file%.*}} line=${line//\$\*/${input_file%.*}}
line=${line//\$+/$@} line=${line//\$+/$@}
line=${line//@FILE_NAME/$input_file}
line=${line//@FILENAME/$input_file} line=${line//@FILENAME/$input_file}
line=${line//@SHORT/${input_file%.*}} line=${line//@SHORT/${input_file%.*}}
line=${line//@ARGS/$@} line=${line//@ARGS/$@}
line=${line//@NAME/$input_file}
line=${line//@FILE/$input_file}
line=$(echo "$line" | sed 's/@STOP.*//') line=$(echo "$line" | sed 's/@STOP.*//')
echo -e "${BOLD}${GREEN}$0${NORMAL}: ${line#*${MARK}}" echo -e "${BOLD}${GREEN}$0${NORMAL}: ${line#*${MARK}}"