Skip to content

Commit

Permalink
added version printing
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoziara committed Jul 9, 2019
1 parent e1457db commit 659ff1c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ C_OBJS4=$(addprefix objs4/, $(C_SRC:.c=.o))
C_OBJS8=$(addprefix objs8/, $(C_SRC:.c=.o))
LIBS=-lm $(PYTHONLIB) $(HDF5LIB)

default: dirs $(ISPC_HEADERS4) $(ISPC_HEADERS8) $(CPP_OBJS4) $(CPP_OBJS8) $(C_OBJS4) $(C_OBJS8) $(EXE)4 $(EXE)8
default: dirs version $(EXE)4 $(EXE)8

.PHONY: dirs clean print

Expand Down Expand Up @@ -45,6 +45,9 @@ clean:
/bin/rm -rf objs* *~ $(EXE)4 $(EXE)8 *.dSYM
find ./ -iname "*.dump" -exec rm '{}' ';'

version:
python python/version.py

$(EXE)4: $(CPP_OBJS4) $(C_OBJS4) $(ISPC_OBJS4)
$(MPICXX) $(CFLAGS) -fopenmp -o $@ $^ $(LIBS)

Expand Down
8 changes: 8 additions & 0 deletions cpp/solfec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,18 @@ SOFTWARE.

/* Contributors: Tomasz Koziara */

#include <stdio.h>
#include <mpi.h>
#include "real.h"
#include "version.h"

int main (int argc, char *argv[])
{
if (argc == 1)
{
printf ("VERSION: 1.%s (%s)\n", VERSION_HASH, VERSION_DATE);
printf ("SYNOPSIS: solfec%d path/to/input/file.py\n", REALSIZE);
}

return 0;
}
2 changes: 2 additions & 0 deletions cpp/version.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define VERSION_HASH "e1457db"
#define VERSION_DATE "2019-07-04"
18 changes: 18 additions & 0 deletions python/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# convert git shortehand hash into version string
import subprocess

git = ["git", "log", "--pretty=format:'%h'", "-n", "1"]
p = subprocess.Popen(git, stdout=subprocess.PIPE)
commit = p.communicate()[0].replace("'",'"')
git = ["git", "show", "-s", "--format=%cd", "--date=short", commit.replace('"','')]
p = subprocess.Popen(git, stdout=subprocess.PIPE)
date = p.communicate()[0].replace('\n','')

with open('cpp/version.h') as f:
lines = f.readlines()
comm0 = lines[0].split()[2]

if comm0 != commit:
with open('cpp/version.h','w') as f:
f.write('#define VERSION_HASH %s\n' % commit)
f.write('#define VERSION_DATE "%s"' % date)

0 comments on commit 659ff1c

Please sign in to comment.