diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | stage3/shell.c | 11 |
3 files changed, 25 insertions, 2 deletions
@@ -5,3 +5,5 @@ bx_enh_dbg.ini stage3/isr.asm fs.tar +stage3/version.c +stage3/version.*.c @@ -32,7 +32,8 @@ STAGE3 = \ stage3/yield.o \ stage3/ps2.o \ stage3/thread.o \ - stage3/shell.o + stage3/shell.o \ + stage3/version.o PAD_BOUNDARY = pad() { truncate -s $$(echo "($$(du -b $$1 | cut -f1)+$$2-1)/$$2*$$2" | bc) $$1; }; pad @@ -58,6 +59,15 @@ stage3/%.o: stage3/%.asm stage3/%.o: stage3/%.c gcc $(CFLAGS) -c $< -o $@ +GIT_VERSION := $(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD) + +stage3/version.c: stage3/version.$(GIT_VERSION).c + cp $< $@ + +stage3/version.$(GIT_VERSION).c: + rm -f stage3/version.*.c + echo -e "#include \"def.h\"\nstr version = S(\"$(GIT_VERSION)\");" > $@ + stage3/isr.asm: stage3/isr.lua lua stage3/isr.lua > stage3/isr.asm @@ -76,7 +86,7 @@ qemu: cuddles.img run: qemu clean: - rm -rf stage3/*.o *.bin *.img *.map stage3/isr.asm fs.tar + rm -rf stage3/*.o *.bin *.img *.map stage3/{isr.asm,version.c,version.*.c} fs.tar flash: cuddles.img dd if=cuddles.img of=$(DEV) diff --git a/stage3/shell.c b/stage3/shell.c index 244a247..b0e1fce 100644 --- a/stage3/shell.c +++ b/stage3/shell.c @@ -158,6 +158,16 @@ static void cmd_love(str arg) } } +extern str version; + +static void cmd_uname(str arg) +{ + (void) arg; + print(S("cuddles ")); + print(version); + print(S("\n")); +} + typedef struct { str name; void (*fn)(str arg); @@ -174,6 +184,7 @@ static command registry[] = { { S("loadkeys"), &cmd_loadkeys }, { S("clear"), &cmd_clear }, { S("love"), &cmd_love }, + { S("uname"), &cmd_uname }, }; void shell_run_cmd(str cmd) |