diff options
author | Chunseok Lee <chunseok.lee@samsung.com> | 2020-07-30 11:40:16 +0900 |
---|---|---|
committer | Chunseok Lee <chunseok.lee@samsung.com> | 2020-07-30 11:40:16 +0900 |
commit | 9e45ab56bd165609118989c0d1bec309c3754560 (patch) | |
tree | 4979e8674abc7d21a6471770c1355e0e6c0e8a3f /compiler/vconone | |
parent | 05e0ec30a632339a8533082476f27bda31ccde16 (diff) | |
download | nnfw-9e45ab56bd165609118989c0d1bec309c3754560.tar.gz nnfw-9e45ab56bd165609118989c0d1bec309c3754560.tar.bz2 nnfw-9e45ab56bd165609118989c0d1bec309c3754560.zip |
patch for rebase master on release/1.7.0submit/tizen/20200731.060745submit/tizen/20200730.075407submit/tizen/20200730.023729accepted/tizen/unified/20200803.122223tizen_6_m1_backup
Change-Id: Id38b617d325ef7e854995a47f032bdf482a779b3
Diffstat (limited to 'compiler/vconone')
-rw-r--r-- | compiler/vconone/CMakeLists.txt | 31 | ||||
-rw-r--r-- | compiler/vconone/README.md | 14 | ||||
-rw-r--r-- | compiler/vconone/driver/driver.cpp | 36 | ||||
-rw-r--r-- | compiler/vconone/include/vconone/vconone.h | 61 | ||||
-rw-r--r-- | compiler/vconone/src/version.cpp | 63 | ||||
-rw-r--r-- | compiler/vconone/src/version.test.cpp | 49 | ||||
-rw-r--r-- | compiler/vconone/version_cfg.h.in | 22 |
7 files changed, 276 insertions, 0 deletions
diff --git a/compiler/vconone/CMakeLists.txt b/compiler/vconone/CMakeLists.txt new file mode 100644 index 000000000..b8cb79331 --- /dev/null +++ b/compiler/vconone/CMakeLists.txt @@ -0,0 +1,31 @@ +if (NOT VCONONE_VERSION) + set(VCONONE_VERSION 0x0000000000080001) + # NOTE order is [build patch minor major] + # if VCONONE_VERSION is set with -D option, it will be cached + # you may have to remove cache file if you remove -D option +endif() + +configure_file(version_cfg.h.in version_cfg.h @ONLY) + +set(DRIVER "driver/driver.cpp") + +file(GLOB_RECURSE SOURCES "src/*.cpp") +file(GLOB_RECURSE TESTS "src/*.test.cpp") +list(REMOVE_ITEM SOURCES ${TESTS}) + +add_library(vconone STATIC ${SOURCES}) +target_include_directories(vconone PUBLIC include) +target_include_directories(vconone PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) + +add_executable(one-version ${DRIVER}) +target_link_libraries(one-version vconone) +install(TARGETS one-version DESTINATION bin) + +if(NOT ENABLE_TEST) + return() +endif(NOT ENABLE_TEST) + +nnas_find_package(GTest REQUIRED) + +GTest_AddTest(vconone_test ${TESTS}) +target_link_libraries(vconone_test vconone) diff --git a/compiler/vconone/README.md b/compiler/vconone/README.md new file mode 100644 index 000000000..c08dd63d3 --- /dev/null +++ b/compiler/vconone/README.md @@ -0,0 +1,14 @@ +# vconone + +_vconone_ provides version number and strings for one-* commands and command +line tools + +# Revise version number + +To revise version number, update `VCONONE_VERSION` in `CmakeLists.txt` +or give `-DVCONONE_VERSION=0x0000000100080001` at cmake configure step. + +Number given is four numbers `build`, `patch`, `minor` and `major` in order for +each 16bit integers. `build` is not used for now. + +`0x0000000100080001` version is interpretered as `1.8.1` diff --git a/compiler/vconone/driver/driver.cpp b/compiler/vconone/driver/driver.cpp new file mode 100644 index 000000000..12bd0eef2 --- /dev/null +++ b/compiler/vconone/driver/driver.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <vconone/vconone.h> + +#include <string> +#include <iostream> + +int main(int argc, char *argv[]) +{ + auto str = vconone::get_string(); + if (argc >= 2) + { + for (int c = 1; c < argc; ++c) + std::cout << argv[c] << " "; + std::cout << "version " << str << std::endl; + std::cout << vconone::get_copyright() << std::endl; + } + else + std::cout << str; + + return 0; +} diff --git a/compiler/vconone/include/vconone/vconone.h b/compiler/vconone/include/vconone/vconone.h new file mode 100644 index 000000000..a6a1998a5 --- /dev/null +++ b/compiler/vconone/include/vconone/vconone.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __VCON_ONE_H__ +#define __VCON_ONE_H__ + +#include <cstdint> +#include <string> + +namespace vconone +{ + +struct four +{ + uint16_t major; + uint16_t minor; + uint16_t patch; + uint16_t build; // build is not used for now +}; + +union version { + uint64_t v; + four f; +}; + +/** + * @brief get_number will return version union structure + */ +version get_number(void); + +/** + * @brief get_string will return string of major.minor.patch (without build) + */ +std::string get_string(void); + +/** + * @brief get_string4 will return string of major.minor.patch.build + */ +std::string get_string4(void); + +/** + * @brief get_copyright will return copyright string + */ +std::string get_copyright(void); + +} // namespace vconone + +#endif // __VCON_ONE_H__ diff --git a/compiler/vconone/src/version.cpp b/compiler/vconone/src/version.cpp new file mode 100644 index 000000000..9b693c621 --- /dev/null +++ b/compiler/vconone/src/version.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "vconone/vconone.h" + +#include "version_cfg.h" + +#include <sstream> + +namespace vconone +{ + +version get_number(void) +{ + version v; + v.v = VCONONE_VERSION; + return v; +} + +std::string get_string4(void) +{ + std::ostringstream ss; + + auto v = get_number(); + ss << unsigned(v.f.major) << "." << unsigned(v.f.minor) << "." << unsigned(v.f.patch) << "." + << unsigned(v.f.build); + + return ss.str(); +} + +std::string get_string(void) +{ + std::ostringstream ss; + + auto v = get_number(); + ss << unsigned(v.f.major) << "." << unsigned(v.f.minor) << "." << unsigned(v.f.patch); + + return ss.str(); +} + +std::string get_copyright(void) +{ + std::string str; + str = "Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved\r\n"; + str += "Licensed under the Apache License, Version 2.0\r\n"; + str += "https://github.com/Samsung/ONE"; + return str; +} + +} // namespace vconone diff --git a/compiler/vconone/src/version.test.cpp b/compiler/vconone/src/version.test.cpp new file mode 100644 index 000000000..35a0647c1 --- /dev/null +++ b/compiler/vconone/src/version.test.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <vconone/vconone.h> + +#include <gtest/gtest.h> + +TEST(vconone, version_number) +{ + auto v = vconone::get_number(); + + ASSERT_NE(0x0000000000000000ULL, v.v); +} + +TEST(vconone, version_string) +{ + auto str = vconone::get_string(); + + ASSERT_NE("..", str); + ASSERT_NE("", str); +} + +TEST(vconone, version_string4) +{ + auto str = vconone::get_string4(); + + ASSERT_NE("...", str); + ASSERT_NE("", str); +} + +TEST(vconone, copyright) +{ + auto str = vconone::get_copyright(); + + ASSERT_NE("", str); +} diff --git a/compiler/vconone/version_cfg.h.in b/compiler/vconone/version_cfg.h.in new file mode 100644 index 000000000..aa3ad9e70 --- /dev/null +++ b/compiler/vconone/version_cfg.h.in @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __VCON_ONE_VERSION_CFG_H__ +#define __VCON_ONE_VERSION_CFG_H__ + +#define VCONONE_VERSION @VCONONE_VERSION@ULL + +#endif // __VCON_ONE_VERSION_CFG_H__ |