Commit 2ad75733 authored by Alexey Marchuk's avatar Alexey Marchuk Committed by Tomasz Zawadzki
Browse files

build/rpc: Add git sha1 to SPDK version macro



Retrieve git sha1 during SPKD build, add sha1 to SPDK_VERSION_STRING
macro and to spdk_get_version RPC method
This might be useful for issues reporting/investigation

Change-Id: I2bfed752839036bf914b546066ed4d23ef4c99b8
Signed-off-by: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Signed-off-by: default avatarSasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: default avatarEvgeniy Kochetov <evgeniik@mellanox.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474004


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent e4aee795
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
/*-
 *   BSD LICENSE
 *
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *   Copyright (c) Intel Corporation. All rights reserved.
 *   Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
@@ -97,6 +97,14 @@
#define SPDK_VERSION_PATCH_STRING	""
#endif

#ifdef SPDK_GIT_COMMIT
#define SPDK_GIT_COMMIT_STRING SPDK_VERSION_STRINGIFY(SPDK_GIT_COMMIT)
#define SPDK_GIT_COMMIT_STRING_SHA1 " git sha1 " SPDK_GIT_COMMIT_STRING
#else
#define SPDK_GIT_COMMIT_STRING ""
#define SPDK_GIT_COMMIT_STRING_SHA1 ""
#endif

/**
 * Human-readable version string.
 */
@@ -105,6 +113,7 @@
	SPDK_VERSION_MAJOR_STRING \
	SPDK_VERSION_MINOR_STRING \
	SPDK_VERSION_PATCH_STRING \
	SPDK_VERSION_SUFFIX
	SPDK_VERSION_SUFFIX \
	SPDK_GIT_COMMIT_STRING_SHA1

#endif
+5 −2
Original line number Diff line number Diff line
/*-
 *   BSD LICENSE
 *
 *   Copyright (c) Intel Corporation.
 *   All rights reserved.
 *   Copyright (c) Intel Corporation. All rights reserved.
 *   Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved.
 *
 *   Redistribution and use in source and binary forms, with or without
 *   modification, are permitted provided that the following conditions
@@ -415,6 +415,9 @@ spdk_rpc_spdk_get_version(struct spdk_jsonrpc_request *request, const struct spd
	spdk_json_write_named_uint32(w, "minor", SPDK_VERSION_MINOR);
	spdk_json_write_named_uint32(w, "patch", SPDK_VERSION_PATCH);
	spdk_json_write_named_string_fmt(w, "suffix", "%s", SPDK_VERSION_SUFFIX);
#ifdef SPDK_GIT_COMMIT
	spdk_json_write_named_string_fmt(w, "commit", "%s", SPDK_GIT_COMMIT_STRING);
#endif
	spdk_json_write_object_end(w);

	spdk_json_write_object_end(w);
+5 −0
Original line number Diff line number Diff line
@@ -212,6 +212,11 @@ COMMON_CFLAGS += -fsanitize=thread
LDFLAGS += -fsanitize=thread
endif

SPDK_GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
ifneq (, $(SPDK_GIT_COMMIT))
COMMON_CFLAGS += -DSPDK_GIT_COMMIT=$(SPDK_GIT_COMMIT)
endif

COMMON_CFLAGS += -pthread
LDFLAGS += -pthread