Skip to content

Commit

Permalink
F OpenNebula#3016: Add git version into oned -v (OpenNebula#3071)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tino Vázquez authored and Ruben S. Montero committed Mar 12, 2019
1 parent 3869ac6 commit acc8750
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
# #
Expand All @@ -19,6 +20,14 @@ import sys
import shutil
sys.path.append("./share/scons")
from lex_bison import *
from subprocess import Popen,PIPE,STDOUT

# Get git version
try:
out = Popen(["git", "describe", "--dirty", "--always", "--abbrev=8"],stdout=PIPE)
git_version = out.communicate()[0].rstrip()
except OSError:
git_version = "not known"

# This is the absolute path where the project is located
cwd = os.getcwd()
Expand All @@ -27,6 +36,8 @@ cwd = os.getcwd()
main_env = Environment()
main_env['ENV']['PATH'] = os.environ['PATH']

main_env['CXXFLAGS'] = " -DGITVERSION=\'\"" + git_version + "\"\'"

# snippet borrowed from http://dev.gentoo.org/~vapier/scons-blows.txt
# makes scons aware of build related environment variables
if os.environ.has_key('CC'):
Expand Down
6 changes: 5 additions & 1 deletion include/Nebula.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@ class Nebula
*/
static string version()
{
return "OpenNebula " + code_version();
ostringstream os;
os << "OpenNebula " << code_version();
os << " (" << GITVERSION << ")";

return os.str();
};

/**
Expand Down

0 comments on commit acc8750

Please sign in to comment.