build+core: Add printing of version number in daemons and tools
This commit also changes how version number is handled. Version is now
fully controlled from top-level wscript. In addition to that, a new
NFD_VERSION_BUILD_STRING macro is set to include more detailed
information, including commit ID (e.g., "0.1.0-rc1-1-g5c86570").
Change-Id: I448eb627e0c42dc814de1107cf7bb0dc94fa2a89
Refs: #1575
diff --git a/tools/nfdc.cpp b/tools/nfdc.cpp
index 729dcb8..1b3499b 100644
--- a/tools/nfdc.cpp
+++ b/tools/nfdc.cpp
@@ -22,7 +22,10 @@
* You should have received a copy of the GNU General Public License along with
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
+
#include "nfdc.hpp"
+#include "version.hpp"
+
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/regex_find_format.hpp>
@@ -31,8 +34,9 @@
void
usage(const char* programName)
{
- std::cout << "Usage:\n" << programName << " [-h] COMMAND [<Command Options>]\n"
+ std::cout << "Usage:\n" << programName << " [-h] [-V] COMMAND [<Command Options>]\n"
" -h print usage and exit\n"
+ " -V print version and exit\n"
"\n"
" COMMAND can be one of the following:\n"
" register [-I] [-C] [-c cost] name <faceId | faceUri>\n"
@@ -402,6 +406,11 @@
return 0;
}
+ if (!strcmp(argv[1], "-V")) {
+ std::cout << NFD_VERSION_BUILD_STRING << std::endl;
+ return 0;
+ }
+
::optind = 2; //start reading options from 2nd argument i.e. Command
int opt;
while ((opt = ::getopt(argc, argv, "ICc:")) != -1) {