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