Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add version information #35

Merged
merged 1 commit into from
Jan 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ target_link_libraries(l3roamd ${LIBNL_LIBRARIES} ${LIBNL_GENL_LIBRARIES})
set_target_properties(l3roamd PROPERTIES COMPILE_FLAGS "-std=gnu11 -Wall" LINK_FLAGS "")

install(TARGETS l3roamd RUNTIME DESTINATION bin)

# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

configure_file(
${CMAKE_SOURCE_DIR}/src/version.h.in
${CMAKE_BINARY_DIR}/src/version.h
)
11 changes: 10 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

// TODO EPOLLOUT beim schreiben auf den tunfd

#include "version.h"
#include "vector.h"
#include "ipmgr.h"
#include "error.h"
Expand Down Expand Up @@ -154,6 +155,7 @@ void usage() {
puts(" -m <meshif> mesh interface. may be specified multiple times");
puts(" -t <export table> export routes to this table");
puts(" -4 <prefix> IPv4 translation prefix");
puts(" -V show version information");
puts(" -h this help\n\n");
puts("The socket will accept the following commands:");
puts("get_clients The daemon will reply with a json structure, currently providing client count.");
Expand Down Expand Up @@ -226,8 +228,15 @@ int main(int argc, char *argv[]) {
l3ctx.debug = false;

int c;
while ((c = getopt(argc, argv, "dha:b:p:i:m:t:c:4:n:s:d")) != -1)
while ((c = getopt(argc, argv, "dha:b:p:i:m:t:c:4:n:s:d:V")) != -1)
switch (c) {
case 'V':
printf("l3roamd %s\n", SOURCE_VERSION);
#if defined(GIT_BRANCH) && defined(GIT_COMMIT_HASH)
printf("branch: %s\n", GIT_BRANCH);
printf("commit: %s\n", GIT_COMMIT_HASH);
#endif
exit(EXIT_SUCCESS);
case 'b':
free(l3ctx.routemgr_ctx.client_bridge);
l3ctx.routemgr_ctx.client_bridge = strdupa(optarg);
Expand Down
33 changes: 33 additions & 0 deletions src/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright (c) 2015, Nils Schneider <[email protected]>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef VERSION_H
#define VERSION_H

#define SOURCE_VERSION "0.0.1"
#define GIT_BRANCH "@GIT_BRANCH@"
#define GIT_COMMIT_HASH "@GIT_COMMIT_HASH@"

#endif