Permalink
Browse files

print version (git revision) and exit with arg "-v" or "--version"

  • Loading branch information...
hoijui committed Dec 27, 2017
1 parent 2ff6de1 commit 4b63d765c499abe951c03d3edf2eb14d50f98574
Showing with 26 additions and 1 deletion.
  1. +19 −1 makefile
  2. +7 −0 src/App.cpp
@@ -1,7 +1,25 @@
APP := numptyphysics
ifneq ($(shell echo),)
CMD_EXE = 1
endif
ifdef CMD_EXE
NULLDEV = nul:
else
NULLDEV = /dev/null
endif
ifndef VERSION
VERSION := $(shell git describe --tags HEAD 2> $(NULLDEV) )
ifneq ($(words $(VERSION)),1)
VERSION := "N/A"
endif
endif
$(info VERSION: $(VERSION))
SOURCES := $(wildcard src/*.cpp)
CXXFLAGS += -std=c++11 -Isrc -Wall -Wno-sign-compare
CXXFLAGS += -std=c++11 -Isrc -Wall -Wno-sign-compare -DAPP=\"$(APP)\" -DVERSION=\"$(VERSION)\"
all: app
@@ -153,6 +153,13 @@ class App : private Container, public MainLoop
MainLoop *
npmain(int argc, char **argv)
{
if (argc == 2) {
const std::string arg0 = argv[1];
if (arg0 == "-v" || arg0 == "--version") {
printf("%s %s\n", APP, VERSION);
exit(0);
}
}
OS->init(argc, argv);
return new App(argc, argv);
}

0 comments on commit 4b63d76

Please sign in to comment.