1/** 2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef ARK_VERSION_H 17#define ARK_VERSION_H 18 19#include <string> 20#include <sstream> 21#include <iostream> 22 23namespace panda { 24 25constexpr std::string_view ARK_VERSION_GIT_HASH = "${ARK_VERSION_GIT_HASH}"; 26 27constexpr uint32_t ARK_VERSION_MAJOR = 0; 28constexpr uint32_t ARK_VERSION_MINOR = 0; 29constexpr uint32_t ARK_VERSION_PATCH = 0; 30 31inline void PrintPandaVersion() 32{ 33 std::stringstream ss; 34 35 ss << "Ark version " << ARK_VERSION_MAJOR << '.' << ARK_VERSION_MINOR << '.' << ARK_VERSION_PATCH << '\n'; 36 37 if (ARK_VERSION_GIT_HASH.empty()) { 38 ss << "Built from gitless source tree\n"; 39 } else { 40 ss << "Built from git commit " << ARK_VERSION_GIT_HASH << '\n'; 41 } 42 43 std::cout << ss.str() << std::endl; 44} 45 46inline std::string_view GetPandaVersion() 47{ 48 return ARK_VERSION_GIT_HASH; 49} 50 51} // namespace panda 52 53#endif // ARK_VERSION_H 54