Skip to content

Commit 791e386

Browse files
authored
Get version from project environment (#310)
Signed-off-by: yhmo <yihua.mo@zilliz.com>
1 parent cb7010b commit 791e386

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ logs/
1111
build/
1212
code_coverage/
1313

14+
# this file is auto-generated
15+
src/impl/version.h
16+
1417

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ define_option(MILVUS_BUILD_COVERAGE "Build with coverage" OFF)
5353
define_option_string(MILVUS_SDK_VERSION
5454
"Version for sdk"
5555
"2.0.0")
56-
define_option_string(MILVUS_SDK_RELEASE
57-
"Release number for sdk"
58-
"1")
56+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/impl/version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/impl/version.h @ONLY)
5957

6058
set_option_category("Thirdparty")
6159
# use thirdparty from:

src/impl/MilvusConnection.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include "MilvusInterceptor.h"
2727
#include "grpcpp/security/credentials.h"
28+
#include "version.h"
2829

2930
using grpc::Channel;
3031
using grpc::ClientContext;
@@ -109,7 +110,7 @@ MilvusConnection::Connect(const ConnectParam& param) {
109110
auto client_info = rpc_request.mutable_client_info();
110111
client_info->set_sdk_type("CPP");
111112
client_info->set_user(param.Username());
112-
client_info->set_sdk_version("2.4.0"); // TODO: automatically get this version
113+
client_info->set_sdk_version(MILVUS_SDK_VERSION);
113114
client_info->set_host(param.Host());
114115

115116
auto now = std::chrono::system_clock::now();

src/impl/version.h.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Licensed to the LF AI & Data foundation under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
#cmakedefine MILVUS_SDK_VERSION "@MILVUS_SDK_VERSION@"

0 commit comments

Comments
 (0)