mirror of
https://github.com/Relintai/osxcross.git
synced 2025-02-03 22:45:56 +01:00
Fixes for #187
This commit is contained in:
parent
88cb6e8d0d
commit
16efae8992
@ -74,7 +74,7 @@ bool getToolPath(Target &target, std::string &toolpath, const char *tool) {
|
|||||||
|
|
||||||
if (!fileExists(toolpath.c_str())) {
|
if (!fileExists(toolpath.c_str())) {
|
||||||
// Fall back to system executables so 'xcrun git status' etc. works.
|
// Fall back to system executables so 'xcrun git status' etc. works.
|
||||||
if (!isxcodetool && realPath(tool, toolpath))
|
if (!isxcodetool && realPath(tool, toolpath, nullptr, nullptr, 0))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
err << "xcrun: cannot find '" << tool << "' executable" << err.endl();
|
err << "xcrun: cannot find '" << tool << "' executable" << err.endl();
|
||||||
@ -200,6 +200,7 @@ int xcrun(int argc, char **argv, Target &target) {
|
|||||||
if (getenv("xcrun_log"))
|
if (getenv("xcrun_log"))
|
||||||
showCommand = true;
|
showCommand = true;
|
||||||
|
|
||||||
|
if (!getenv("OSXCROSS_XCRUN_NO_ENV_WARNING")) {
|
||||||
constexpr const char *ENVVARS[] = {
|
constexpr const char *ENVVARS[] = {
|
||||||
"DEVELOPER_DIR", "TOOLCHAINS", "xcrun_verbose"
|
"DEVELOPER_DIR", "TOOLCHAINS", "xcrun_verbose"
|
||||||
};
|
};
|
||||||
@ -210,6 +211,7 @@ int xcrun(int argc, char **argv, Target &target) {
|
|||||||
<< "'" << evar << "'" << warn.endl();
|
<< "'" << evar << "'" << warn.endl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (char *SDK = getenv("SDKROOT")) {
|
if (char *SDK = getenv("SDKROOT")) {
|
||||||
unsetenv("OSXCROSS_SDKROOT");
|
unsetenv("OSXCROSS_SDKROOT");
|
||||||
|
@ -344,7 +344,8 @@ bool ignoreCCACHE(const char *f, const struct stat &) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool realPath(const char *file, std::string &result,
|
bool realPath(const char *file, std::string &result,
|
||||||
realpathcmp cmp1, realpathcmp cmp2) {
|
realpathcmp cmp1, realpathcmp cmp2,
|
||||||
|
const size_t maxSymbolicLinkDepth) {
|
||||||
char *PATH = getenv("PATH");
|
char *PATH = getenv("PATH");
|
||||||
const char *p = PATH ? PATH : "";
|
const char *p = PATH ? PATH : "";
|
||||||
struct stat st;
|
struct stat st;
|
||||||
@ -362,6 +363,9 @@ bool realPath(const char *file, std::string &result,
|
|||||||
result += file;
|
result += file;
|
||||||
|
|
||||||
if (!stat(result.c_str(), &st)) {
|
if (!stat(result.c_str(), &st)) {
|
||||||
|
if (maxSymbolicLinkDepth == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
char buf[PATH_MAX + 1];
|
char buf[PATH_MAX + 1];
|
||||||
|
|
||||||
if (realpath(result.c_str(), buf)) {
|
if (realpath(result.c_str(), buf)) {
|
||||||
@ -379,6 +383,7 @@ bool realPath(const char *file, std::string &result,
|
|||||||
else
|
else
|
||||||
++pathlen; // PATHDIV
|
++pathlen; // PATHDIV
|
||||||
|
|
||||||
|
|
||||||
memcpy(path, result.c_str(), pathlen); // not null terminated
|
memcpy(path, result.c_str(), pathlen); // not null terminated
|
||||||
|
|
||||||
while ((len = readlink(result.c_str(), buf, PATH_MAX)) != -1) {
|
while ((len = readlink(result.c_str(), buf, PATH_MAX)) != -1) {
|
||||||
@ -390,7 +395,7 @@ bool realPath(const char *file, std::string &result,
|
|||||||
pathlen = strrchr(buf, PATHDIV) - buf + 1; // + 1: PATHDIV
|
pathlen = strrchr(buf, PATHDIV) - buf + 1; // + 1: PATHDIV
|
||||||
memcpy(path, buf, pathlen);
|
memcpy(path, buf, pathlen);
|
||||||
}
|
}
|
||||||
if (++n >= 1000) {
|
if (++n >= maxSymbolicLinkDepth) {
|
||||||
err << result << ": too many levels of symbolic links"
|
err << result << ": too many levels of symbolic links"
|
||||||
<< err.endl();
|
<< err.endl();
|
||||||
result.clear();
|
result.clear();
|
||||||
|
@ -161,7 +161,8 @@ typedef bool (*realpathcmp)(const char *file, const struct stat &st);
|
|||||||
bool isExecutable(const char *f, const struct stat &);
|
bool isExecutable(const char *f, const struct stat &);
|
||||||
bool ignoreCCACHE(const char *f, const struct stat &);
|
bool ignoreCCACHE(const char *f, const struct stat &);
|
||||||
bool realPath(const char *file, std::string &result,
|
bool realPath(const char *file, std::string &result,
|
||||||
realpathcmp cmp1 = nullptr, realpathcmp cmp2 = nullptr);
|
realpathcmp cmp1 = nullptr, realpathcmp cmp2 = nullptr,
|
||||||
|
const size_t maxSymobolicLinkDepth = 1000);
|
||||||
bool getPathOfCommand(const char *command, std::string &result,
|
bool getPathOfCommand(const char *command, std::string &result,
|
||||||
realpathcmp cmp = nullptr);
|
realpathcmp cmp = nullptr);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user