diff --git a/include/spdk/version.h b/include/spdk/version.h index f36b76c7f..f46052f82 100644 --- a/include/spdk/version.h +++ b/include/spdk/version.h @@ -1,8 +1,8 @@ /*- * 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 diff --git a/lib/rpc/rpc.c b/lib/rpc/rpc.c index 192d85986..5ce732eb0 100644 --- a/lib/rpc/rpc.c +++ b/lib/rpc/rpc.c @@ -1,8 +1,8 @@ /*- * 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); diff --git a/mk/spdk.common.mk b/mk/spdk.common.mk index e14c41903..d821190d7 100644 --- a/mk/spdk.common.mk +++ b/mk/spdk.common.mk @@ -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