mirror of
https://github.com/Relintai/osxcross.git
synced 2025-02-03 22:45:56 +01:00
wrapper:
* minor fixes * prepare for unit tests
This commit is contained in:
parent
9033b6b847
commit
8543a46c6c
34
wrapper/main.cpp
Normal file → Executable file
34
wrapper/main.cpp
Normal file → Executable file
@ -49,6 +49,8 @@ using namespace target;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
int unittest = 0;
|
||||||
|
|
||||||
//
|
//
|
||||||
// detectTarget():
|
// detectTarget():
|
||||||
// detect target and setup invocation command
|
// detect target and setup invocation command
|
||||||
@ -66,15 +68,19 @@ void checkIncludePath(const char *opt, const char *path) {
|
|||||||
if (noinccheck)
|
if (noinccheck)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
char buf[PATH_MAX + 1];
|
char buf[PATH_MAX + 1];
|
||||||
const char *rpath = realpath(path, buf);
|
const char *rpath = realpath(path, buf);
|
||||||
|
|
||||||
if (!rpath)
|
if (!rpath)
|
||||||
rpath = path;
|
rpath = path;
|
||||||
|
#else
|
||||||
|
const char *rpath = path;
|
||||||
|
#endif
|
||||||
|
|
||||||
for (const char *dpath : DangerousIncludePaths) {
|
for (const char *dpath : DangerousIncludePaths) {
|
||||||
if (!strncmp(rpath, dpath, strlen(dpath))) {
|
if (!strncmp(rpath, dpath, strlen(dpath))) {
|
||||||
warn << "possible dangerous include path specified: '" << opt << " "
|
warn << "possibly dangerous include path specified: '" << opt << " "
|
||||||
<< path << "'";
|
<< path << "'";
|
||||||
|
|
||||||
if (strcmp(path, rpath))
|
if (strcmp(path, rpath))
|
||||||
@ -296,7 +302,7 @@ bool detectTarget(int argc, char **argv, Target &target) {
|
|||||||
|
|
||||||
if (!strcmp(arg, "-oc-use-gcc-libs")) {
|
if (!strcmp(arg, "-oc-use-gcc-libs")) {
|
||||||
if (target.isGCC()) {
|
if (target.isGCC()) {
|
||||||
warn << arg << "' has no effect" << warn.endl();
|
warn << "'" << arg << "' has no effect" << warn.endl();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
target.stdlib = StdLib::libstdcxx;
|
target.stdlib = StdLib::libstdcxx;
|
||||||
@ -701,8 +707,12 @@ void generateMultiArchObjectFile(int &rc, int argc, char **argv, Target &target,
|
|||||||
if (debug)
|
if (debug)
|
||||||
dbg << "[lipo] <-- " << cmd << dbg.endl();
|
dbg << "[lipo] <-- " << cmd << dbg.endl();
|
||||||
|
|
||||||
rc = system(cmd.c_str());
|
if (unittest == 2) {
|
||||||
rc = WEXITSTATUS(rc);
|
rc = 0;
|
||||||
|
} else {
|
||||||
|
rc = system(cmd.c_str());
|
||||||
|
rc = WEXITSTATUS(rc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,14 +743,17 @@ int main(int argc, char **argv) {
|
|||||||
int debug = 0;
|
int debug = 0;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
|
if (char *p = getenv("OCDEBUG"))
|
||||||
|
debug = atoi(p);
|
||||||
|
|
||||||
|
if (char *p = getenv("OSXCROSS_UNIT_TEST"))
|
||||||
|
unittest = atoi(p);
|
||||||
|
|
||||||
if (!detectTarget(argc, argv, target)) {
|
if (!detectTarget(argc, argv, target)) {
|
||||||
err << "while detecting target" << err.endl();
|
err << "while detecting target" << err.endl();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (char *p = getenv("OCDEBUG"))
|
|
||||||
debug = ((*p >= '1' && *p <= '9') ? *p - '0' + 0 : 0);
|
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
b->halt();
|
b->halt();
|
||||||
|
|
||||||
@ -786,7 +799,9 @@ int main(int argc, char **argv) {
|
|||||||
out += " ";
|
out += " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
dbg << "--> " << in << dbg.endl();
|
if (!unittest)
|
||||||
|
dbg << "--> " << in << dbg.endl();
|
||||||
|
|
||||||
dbg << "<-- " << out << dbg.endl();
|
dbg << "<-- " << out << dbg.endl();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -813,6 +828,9 @@ int main(int argc, char **argv) {
|
|||||||
<< dbg.endl();
|
<< dbg.endl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (unittest == 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (rc == -1 && execvp(cargs[0], cargs)) {
|
if (rc == -1 && execvp(cargs[0], cargs)) {
|
||||||
err << "invoking compiler failed" << err.endl();
|
err << "invoking compiler failed" << err.endl();
|
||||||
|
|
||||||
|
@ -711,17 +711,16 @@ bool Target::setup() {
|
|||||||
case Arch::x86_64:
|
case Arch::x86_64:
|
||||||
case Arch::x86_64h:
|
case Arch::x86_64h:
|
||||||
if (isGCC()) {
|
if (isGCC()) {
|
||||||
|
if (arch == Arch::x86_64h) {
|
||||||
|
err << "gcc does not support architecture '" << getArchName(arch)
|
||||||
|
<< "'" << err.endl();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (targetarch.size() > 1)
|
if (targetarch.size() > 1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fargs.push_back(is32bit ? "-m32" : "-m64");
|
fargs.push_back(is32bit ? "-m32" : "-m64");
|
||||||
|
|
||||||
if (arch == Arch::x86_64h) {
|
|
||||||
err << "'" << getArchName(arch) << "' requires clang" << err.endl();
|
|
||||||
return false;
|
|
||||||
// fargs.push_back("-march=core-avx2");
|
|
||||||
// fargs.push_back("-Wl,-arch,x86_64h");
|
|
||||||
}
|
|
||||||
} else if (isClang()) {
|
} else if (isClang()) {
|
||||||
if (usegcclibs && targetarch.size() > 1)
|
if (usegcclibs && targetarch.size() > 1)
|
||||||
break;
|
break;
|
||||||
|
@ -475,13 +475,6 @@ int setenv(const char *name, const char *value, int overwrite) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int unsetenv(const char *name) { return setenv(name, "", 1); }
|
int unsetenv(const char *name) { return setenv(name, "", 1); }
|
||||||
|
|
||||||
int execvp(const char *file, char *const argv[]) {
|
|
||||||
(void)file;
|
|
||||||
(void)argv;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace tools
|
} // namespace tools
|
||||||
|
@ -280,7 +280,6 @@ typedef OSVersion ClangVersion;
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int setenv(const char *name, const char *value, int overwrite);
|
int setenv(const char *name, const char *value, int overwrite);
|
||||||
int unsetenv(const char *name);
|
int unsetenv(const char *name);
|
||||||
int execvp(const char *file, char *const argv[]);
|
|
||||||
constexpr char PATHDIV = '\\';
|
constexpr char PATHDIV = '\\';
|
||||||
#else
|
#else
|
||||||
constexpr char PATHDIV = '/';
|
constexpr char PATHDIV = '/';
|
||||||
|
Loading…
Reference in New Issue
Block a user