-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
231 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <stdio.h> | ||
#include <limits.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <filesystem> | ||
#include <fstream> | ||
#include <sstream> | ||
#include <regex> | ||
|
||
static int version = -1; | ||
|
||
int getNdkVersion(const char *path) { | ||
if (version != -1) { | ||
return version; | ||
} | ||
|
||
std::filesystem::path abs_path = std::filesystem::canonical(path); | ||
std::filesystem::path root_path = abs_path.root_directory(); | ||
|
||
for (std::filesystem::path dir = abs_path.parent_path(); dir.compare(root_path) != 0; dir = dir.parent_path()) { | ||
for (const std::filesystem::directory_entry& file : std::filesystem::directory_iterator(dir)) { | ||
if (file.is_regular_file()) { | ||
if (file.path().filename().compare("source.properties") == 0) { | ||
std::ifstream version_file(file.path(), std::ios::in); | ||
std::string line; | ||
while (std::getline(version_file, line)) { | ||
std::stringstream ss(line); | ||
std::string key; | ||
while (std::getline(ss, key, '=')) { | ||
key = std::regex_replace(key, std::regex("^ *"), ""); | ||
key = std::regex_replace(key, std::regex(" *$"), ""); | ||
if (key == "Pkg.Revision") { | ||
std::string value; | ||
std::getline(ss, value, '='); | ||
value = std::regex_replace(value, std::regex("^ *"), ""); | ||
value = std::regex_replace(value, std::regex(" *$"), ""); | ||
std::smatch m; | ||
if (std::regex_match(value, m, std::regex(R"(^(\d+).+)"))) { | ||
version = stoi(m[1].str()); | ||
goto DONE; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
DONE: | ||
return version; | ||
} | ||
|
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DECLANGANDROIDNDK_H | ||
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DECLANGANDROIDNDK_H | ||
|
||
|
||
extern int getNdkVersion(const char *path); | ||
|
||
|
||
#endif |
This file contains 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 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 |
---|---|---|
|
@@ -72,4 +72,5 @@ add_llvm_component_library(LLVMipo | |
Vectorize | ||
Instrumentation | ||
Scalar | ||
AntiHack | ||
) |
Oops, something went wrong.