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 {
|
||||
|
||||
int unittest = 0;
|
||||
|
||||
//
|
||||
// detectTarget():
|
||||
// detect target and setup invocation command
|
||||
@ -66,15 +68,19 @@ void checkIncludePath(const char *opt, const char *path) {
|
||||
if (noinccheck)
|
||||
return;
|
||||
|
||||
#ifndef _WIN32
|
||||
char buf[PATH_MAX + 1];
|
||||
const char *rpath = realpath(path, buf);
|
||||
|
||||
if (!rpath)
|
||||
rpath = path;
|
||||
#else
|
||||
const char *rpath = path;
|
||||
#endif
|
||||
|
||||
for (const char *dpath : DangerousIncludePaths) {
|
||||
if (!strncmp(rpath, dpath, strlen(dpath))) {
|
||||
warn << "possible dangerous include path specified: '" << opt << " "
|
||||
warn << "possibly dangerous include path specified: '" << opt << " "
|
||||
<< path << "'";
|
||||
|
||||
if (strcmp(path, rpath))
|
||||
@ -296,7 +302,7 @@ bool detectTarget(int argc, char **argv, Target &target) {
|
||||
|
||||
if (!strcmp(arg, "-oc-use-gcc-libs")) {
|
||||
if (target.isGCC()) {
|
||||
warn << arg << "' has no effect" << warn.endl();
|
||||
warn << "'" << arg << "' has no effect" << warn.endl();
|
||||
break;
|
||||
}
|
||||
target.stdlib = StdLib::libstdcxx;
|
||||
@ -701,8 +707,12 @@ void generateMultiArchObjectFile(int &rc, int argc, char **argv, Target &target,
|
||||
if (debug)
|
||||
dbg << "[lipo] <-- " << cmd << dbg.endl();
|
||||
|
||||
rc = system(cmd.c_str());
|
||||
rc = WEXITSTATUS(rc);
|
||||
if (unittest == 2) {
|
||||
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 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)) {
|
||||
err << "while detecting target" << err.endl();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (char *p = getenv("OCDEBUG"))
|
||||
debug = ((*p >= '1' && *p <= '9') ? *p - '0' + 0 : 0);
|
||||
|
||||
if (debug) {
|
||||
b->halt();
|
||||
|
||||
@ -786,7 +799,9 @@ int main(int argc, char **argv) {
|
||||
out += " ";
|
||||
}
|
||||
|
||||
dbg << "--> " << in << dbg.endl();
|
||||
if (!unittest)
|
||||
dbg << "--> " << in << dbg.endl();
|
||||
|
||||
dbg << "<-- " << out << dbg.endl();
|
||||
};
|
||||
|
||||
@ -813,6 +828,9 @@ int main(int argc, char **argv) {
|
||||
<< dbg.endl();
|
||||
}
|
||||
|
||||
if (unittest == 2)
|
||||
return 0;
|
||||
|
||||
if (rc == -1 && execvp(cargs[0], cargs)) {
|
||||
err << "invoking compiler failed" << err.endl();
|
||||
|
||||
|
@ -711,17 +711,16 @@ bool Target::setup() {
|
||||
case Arch::x86_64:
|
||||
case Arch::x86_64h:
|
||||
if (isGCC()) {
|
||||
if (arch == Arch::x86_64h) {
|
||||
err << "gcc does not support architecture '" << getArchName(arch)
|
||||
<< "'" << err.endl();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (targetarch.size() > 1)
|
||||
break;
|
||||
|
||||
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()) {
|
||||
if (usegcclibs && targetarch.size() > 1)
|
||||
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 execvp(const char *file, char *const argv[]) {
|
||||
(void)file;
|
||||
(void)argv;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace tools
|
||||
|
@ -280,7 +280,6 @@ typedef OSVersion ClangVersion;
|
||||
#ifdef _WIN32
|
||||
int setenv(const char *name, const char *value, int overwrite);
|
||||
int unsetenv(const char *name);
|
||||
int execvp(const char *file, char *const argv[]);
|
||||
constexpr char PATHDIV = '\\';
|
||||
#else
|
||||
constexpr char PATHDIV = '/';
|
||||
|
Loading…
Reference in New Issue
Block a user