From 0b71f9f4fa08a9f3d331bb6cbdb4f9f41232c0e2 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Fri, 9 Mar 2018 15:59:12 +0900 Subject: [PATCH] Add compiler version -v, --version Show version information Change-Id: I95fb5147c68b92aa16f666a136693bc2622d2970 Signed-off-by: Junghoon Park --- build.sh | 3 ++- idlc/CMakeLists.txt | 2 ++ idlc/c_gen/c_proxy_body_gen.cc | 2 +- idlc/main.cc | 13 +++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index fbd6883..29b8201 100755 --- a/build.sh +++ b/build.sh @@ -22,7 +22,8 @@ cmd_build() { echo "[TIDL] Build the package" mkdir -p $SCRIPT_DIR/$BUILD_DIR cd $SCRIPT_DIR/$BUILD_DIR - cmake .. + VER=`cat ../packaging/tidl.spec | grep 'Version' | sed 's/Version://' | tr -d ' \r'` + cmake .. -DFULLVER=$VER make clean make } diff --git a/idlc/CMakeLists.txt b/idlc/CMakeLists.txt index 4e434f1..64ed7fe 100644 --- a/idlc/CMakeLists.txt +++ b/idlc/CMakeLists.txt @@ -15,6 +15,8 @@ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") +ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"") + AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/cs_gen CS_GEN_SOURCES) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/c_gen C_GEN_SOURCES) diff --git a/idlc/c_gen/c_proxy_body_gen.cc b/idlc/c_gen/c_proxy_body_gen.cc index edcef36..a159b31 100644 --- a/idlc/c_gen/c_proxy_body_gen.cc +++ b/idlc/c_gen/c_proxy_body_gen.cc @@ -485,7 +485,7 @@ void CProxyBodyGen::GenInterfaceMethods(std::ofstream& stream, " rpc_port_parcel_destroy(parcel);\n" \ "$$" \ "}\n"; - const char parcel[] = "$$($$, $$);\n"; + for (auto& i : inf.GetDeclarations().GetDecls()) { if (i->GetMethodType() == Declaration::MethodType::DELEGATE) continue; diff --git a/idlc/main.cc b/idlc/main.cc index 8088152..a3b99ba 100644 --- a/idlc/main.cc +++ b/idlc/main.cc @@ -48,6 +48,7 @@ class Options { enum Cmd { CMD_PROXY, CMD_STUB, + CMD_VERSION, CMD_MAX }; @@ -59,6 +60,7 @@ class Options { }; void PrintUsage(); + void PrintVersion(); private: bool isProxy_; @@ -72,6 +74,10 @@ void Options::PrintUsage() { std::cerr << help_ << std::endl; } +void Options::PrintVersion() { + std::cerr << "tidlc " << FULLVER << std::endl; +} + std::unique_ptr Options::Parse(int argc, char** argv) { gpointer cmd[CMD_MAX] = { 0, }; static GOptionEntry cmdEntries[] = { @@ -79,6 +85,8 @@ std::unique_ptr Options::Parse(int argc, char** argv) { "Generate proxy code", NULL }, { "stub", 's', 0, G_OPTION_ARG_NONE, &cmd[CMD_STUB], "Generate stub code", NULL }, + { "version", 'v', 0, G_OPTION_ARG_NONE, &cmd[CMD_VERSION], + "Show version information", NULL }, { NULL } }; gpointer opt[OPT_MAX] = { 0, }; @@ -125,6 +133,11 @@ std::unique_ptr Options::Parse(int argc, char** argv) { g_free(help); g_option_context_free(context); + if (cmd[CMD_VERSION]) { + options->PrintVersion(); + return std::unique_ptr(nullptr); + } + if ((!cmd[CMD_PROXY] && !cmd[CMD_STUB]) || !opt[OPT_LANGUAGE] || !opt[OPT_INPUT] || !opt[OPT_OUTPUT]) { -- 2.7.4