This repository was archived by the owner on Jul 4, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 181
fix: dynamically get cuda toolkit version #1053
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,61 @@ | ||
| #include <trantor/utils/Logger.h> | ||
| #include <sstream> | ||
| #include <vector> | ||
|
|
||
| namespace semantic_version_utils { | ||
| inline std::vector<int> SplitVersion(const std::string& version) { | ||
| std::vector<int> parts; | ||
| std::stringstream ss(version); | ||
| std::string part; | ||
| struct SemVer { | ||
| int major; | ||
| int minor; | ||
| int patch; | ||
| }; | ||
|
|
||
| while (std::getline(ss, part, '.')) { | ||
| parts.push_back(std::stoi(part)); | ||
| inline SemVer SplitVersion(const std::string& version) { | ||
| if (version.empty()) { | ||
| LOG_WARN << "Passed in version is empty!"; | ||
| } | ||
| SemVer semVer = {0, 0, 0}; // default value | ||
| std::stringstream ss(version); | ||
| std::string part; | ||
|
|
||
| while (parts.size() < 3) { | ||
| parts.push_back(0); | ||
| int index = 0; | ||
| while (std::getline(ss, part, '.') && index < 3) { | ||
| int value = std::stoi(part); | ||
| switch (index) { | ||
| case 0: | ||
| semVer.major = value; | ||
| break; | ||
| case 1: | ||
| semVer.minor = value; | ||
| break; | ||
| case 2: | ||
| semVer.patch = value; | ||
| break; | ||
| } | ||
| ++index; | ||
| } | ||
|
|
||
| return parts; | ||
| return semVer; | ||
| } | ||
|
|
||
| inline int CompareSemanticVersion(const std::string& version1, | ||
| const std::string& version2) { | ||
| std::vector<int> v1 = SplitVersion(version1); | ||
| std::vector<int> v2 = SplitVersion(version2); | ||
|
|
||
| for (size_t i = 0; i < 3; ++i) { | ||
| if (v1[i] < v2[i]) | ||
| return -1; | ||
| if (v1[i] > v2[i]) | ||
| return 1; | ||
| } | ||
| SemVer v1 = SplitVersion(version1); | ||
| SemVer v2 = SplitVersion(version2); | ||
|
|
||
| if (v1.major < v2.major) | ||
| return -1; | ||
| if (v1.major > v2.major) | ||
| return 1; | ||
|
|
||
| if (v1.minor < v2.minor) | ||
| return -1; | ||
| if (v1.minor > v2.minor) | ||
| return 1; | ||
|
|
||
| if (v1.patch < v2.patch) | ||
| return -1; | ||
| if (v1.patch > v2.patch) | ||
| return 1; | ||
|
|
||
| return 0; | ||
| } | ||
| } // namespace semantic_version_utils | ||
| } // namespace semantic_version_utils |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.