From 24753b81783d3c6ce718a23c9d525cc6b24c382e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20P=C3=B6chtrager?= Date: Sun, 4 Oct 2015 18:02:07 +0200 Subject: [PATCH] Cleanup: Remove the native Windows bits. There will be no *native* Windows port of OSXCross anyway. This does not affect Cygwin. --- wrapper/build.sh | 12 +--- wrapper/main.cpp | 7 -- wrapper/programs/dsymutil.cpp | 7 +- wrapper/programs/osxcross-man.cpp | 4 -- wrapper/programs/pkg-config.cpp | 4 -- wrapper/programs/proginc.h | 1 + wrapper/programs/xcrun.cpp | 4 -- wrapper/tools.cpp | 115 ------------------------------ wrapper/tools.h | 14 +--- wrapper/wrapper.workspace | 2 +- 10 files changed, 7 insertions(+), 163 deletions(-) diff --git a/wrapper/build.sh b/wrapper/build.sh index fdf31e3..0292d95 100755 --- a/wrapper/build.sh +++ b/wrapper/build.sh @@ -76,8 +76,8 @@ if [ -n "$BWPLATFORM" ]; then PLATFORM=$BWPLATFORM if [ $PLATFORM = "Darwin" -a $(uname -s) != "Darwin" ]; then - CXX=o32-clang++ - #CXX=o32-g++ + CXX=$(xcrun -f clang++) + #CXX=$(xcrun -f g++) FLAGS+="-fvisibility-inlines-hidden " elif [ $PLATFORM = "FreeBSD" -a $(uname -s) != "FreeBSD" ]; then CXX=amd64-pc-freebsd10.1-clang++ @@ -85,14 +85,6 @@ if [ -n "$BWPLATFORM" ]; then elif [ $PLATFORM = "NetBSD" -a $(uname -s) != "NetBSD" ]; then CXX=amd64-pc-netbsd6.1.3-clang++ #CXX=amd64-pc-netbsd6.1.3-g++ - elif [ $PLATFORM = "Windows" ]; then - CXX=w32-clang++ - FLAGS+="-wc-static-runtime -g " - EXESUFFIX=".exe" - elif [ $PLATFORM = "MWindows" ]; then - CXX=i686-w64-mingw32-g++ - FLAGS+="-static-libgcc -static-libstdc++ -g " - EXESUFFIX=".exe" fi [ -z "$BWCOMPILEONLY" ] && BWCOMPILEONLY=1 diff --git a/wrapper/main.cpp b/wrapper/main.cpp index 4f90da5..b779cfc 100644 --- a/wrapper/main.cpp +++ b/wrapper/main.cpp @@ -34,11 +34,8 @@ #include #include #include - -#ifndef _WIN32 #include #include -#endif #include "tools.h" #include "target.h" @@ -196,15 +193,11 @@ bool checkincludepath(Target &, const char *opt, const char *path, char **) { if (noinccheck) return true; -#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))) { diff --git a/wrapper/programs/dsymutil.cpp b/wrapper/programs/dsymutil.cpp index 31bc597..44f34f6 100644 --- a/wrapper/programs/dsymutil.cpp +++ b/wrapper/programs/dsymutil.cpp @@ -21,12 +21,9 @@ #include "proginc.h" -#ifndef _WIN32 -#include #include #include #include -#endif using namespace tools; @@ -140,7 +137,6 @@ int dsymutil(int argc, char **argv, Target &target) { return 0; } -#ifndef _WIN32 // // A glorious workaround to make the vanilla llvm-dsymutil find lipo. // @@ -148,7 +144,7 @@ int dsymutil(int argc, char **argv, Target &target) { // 2. Store a lipo symlink there. // 3. Append to PATH. // 4. Fork the process and wait until the child process exited. - // 5. Remove the temporary directory and return the llvm-dsymutil. + // 5. Remove the temporary directory and return the llvm-dsymutil // exit code. // @@ -209,7 +205,6 @@ int dsymutil(int argc, char **argv, Target &target) { removeTemporaryDirectory(); } } -#endif } if (execvp(dsymutil.c_str(), argv)) diff --git a/wrapper/programs/osxcross-man.cpp b/wrapper/programs/osxcross-man.cpp index 26659f6..a2e4c3b 100644 --- a/wrapper/programs/osxcross-man.cpp +++ b/wrapper/programs/osxcross-man.cpp @@ -21,10 +21,6 @@ #include "proginc.h" -#ifndef _WIN32 -#include -#endif - using namespace tools; using namespace target; diff --git a/wrapper/programs/pkg-config.cpp b/wrapper/programs/pkg-config.cpp index 48bc126..71cd84f 100644 --- a/wrapper/programs/pkg-config.cpp +++ b/wrapper/programs/pkg-config.cpp @@ -21,10 +21,6 @@ #include "proginc.h" -#ifndef _WIN32 -#include -#endif - extern char **environ; using namespace tools; diff --git a/wrapper/programs/proginc.h b/wrapper/programs/proginc.h index 7df7fc4..99fbc39 100644 --- a/wrapper/programs/proginc.h +++ b/wrapper/programs/proginc.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "tools.h" #include "target.h" diff --git a/wrapper/programs/xcrun.cpp b/wrapper/programs/xcrun.cpp index 9485001..29ddd94 100644 --- a/wrapper/programs/xcrun.cpp +++ b/wrapper/programs/xcrun.cpp @@ -21,10 +21,6 @@ #include "proginc.h" -#ifndef _WIN32 -#include -#endif - using namespace tools; using namespace target; diff --git a/wrapper/tools.cpp b/wrapper/tools.cpp index faea75e..f7b8b04 100644 --- a/wrapper/tools.cpp +++ b/wrapper/tools.cpp @@ -35,15 +35,10 @@ #include #include -#ifndef _WIN32 #include #include #include #include -#else -#include -#include -#endif #ifdef __APPLE__ #include @@ -72,7 +67,6 @@ namespace tools { // bool isTerminal() { -#ifndef _WIN32 static bool first = false; static bool val; @@ -82,9 +76,6 @@ bool isTerminal() { } return val; -#else - return false; -#endif } // @@ -143,8 +134,6 @@ char *getExecutablePath(char *buf, size_t len) { else l = 0; delete[] argv; -#elif defined(_WIN32) - size_t l = GetModuleFileName(nullptr, buf, (DWORD)len); #else ssize_t l = readlink("/proc/self/exe", buf, len); assert(l > 0 && "/proc not mounted?"); @@ -160,58 +149,6 @@ char *getExecutablePath(char *buf, size_t len) { const std::string &getParentProcessName() { static std::string name; -#ifdef _WIN32 - HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - PROCESSENTRY32 pe; - - auto zerope = [&]() { - memset(&pe, 0, sizeof(pe)); - pe.dwSize = sizeof(PROCESSENTRY32); - }; - - zerope(); - - auto pid = GetCurrentProcessId(); - decltype(pid) ppid = -1; - - if (Process32First(h, &pe)) { - do { - if (pe.th32ProcessID == pid) { - ppid = pe.th32ParentProcessID; - break; - } - } while (Process32Next(h, &pe)); - } - - if (ppid != static_cast(-1)) { - PROCESSENTRY32 *ppe = nullptr; - zerope(); - - if (Process32First(h, &pe)) { - do { - if (pe.th32ProcessID == ppid) { - ppe = &pe; - break; - } - } while (Process32Next(h, &pe)); - } - - if (ppe) { - char *p = strrchr(ppe->szExeFile, '\\'); - if (p) { - name = p + 1; - } else { - name = ppe->szExeFile; - } - } - } - - CloseHandle(h); - - if (!name.empty()) { - return name; - } -#else auto getName = [](const char * path)->const char * { if (const char *p = strrchr(path, '/')) { return p + 1; @@ -250,22 +187,11 @@ const std::string &getParentProcessName() { return name; } } -#endif #endif name = "unknown"; return name; } -#ifdef _WIN32 -std::string &fixPathDiv(std::string &path) { - for (auto &c : path) { - if (c == '/') - c = '\\'; - } - return path; -} -#endif - // // Environment // @@ -389,7 +315,6 @@ bool isDirectory(const char *file, const char *prefix) { bool listFiles(const char *dir, std::vector *files, listfilescallback cmp) { -#ifndef _WIN32 DIR *d = opendir(dir); dirent *de; @@ -404,25 +329,6 @@ bool listFiles(const char *dir, std::vector *files, closedir(d); return true; -#else - WIN32_FIND_DATA fdata; - HANDLE handle; - - handle = FindFirstFile(dir, &fdata); - - if (handle == INVALID_HANDLE_VALUE) - return false; - - do { - if ((!cmp || cmp(fdata.cFileName)) && files) { - files->push_back(fdata.cFileName); - } - } while (FindNextFile(handle, &fdata)); - - FindClose(handle); - - return true; -#endif } typedef bool (*realpathcmp)(const char *file, const struct stat &st); @@ -455,7 +361,6 @@ bool realPath(const char *file, std::string &result, result += file; if (!stat(result.c_str(), &st)) { -#ifndef _WIN32 char buf[PATH_MAX + 1]; if (realpath(result.c_str(), buf)) { @@ -492,7 +397,6 @@ bool realPath(const char *file, std::string &result, } } } -#endif if ((!cmp1 || cmp1(result.c_str(), st)) && (!cmp2 || cmp2(result.c_str(), st))) @@ -621,23 +525,4 @@ OSVersion parseOSVersion(const char *OSVer) { return OSNum; } -// -// OS Compat -// - -#ifdef _WIN32 -int setenv(const char *name, const char *value, int overwrite) { - std::string buf; - (void)overwrite; // TODO - - buf = name; - buf += '='; - buf += value; - - return putenv(buf.c_str()); -} - -int unsetenv(const char *name) { return setenv(name, "", 1); } -#endif - } // namespace tools diff --git a/wrapper/tools.h b/wrapper/tools.h index 0472305..ae86f2c 100644 --- a/wrapper/tools.h +++ b/wrapper/tools.h @@ -145,6 +145,8 @@ bool hasPath(const std::vector &path, const char *find); // Files and directories // +constexpr char PATHDIV = '/'; + std::string *getFileContent(const std::string &file, std::string &content); bool writeFileContent(const std::string &file, const std::string &content); @@ -341,18 +343,6 @@ static const auto &parseClangVersion = parseOSVersion; typedef OSVersion LLVMVersion; static const auto &parseLLVMVersion = parseOSVersion; -// -// OS Compat -// - -#ifdef _WIN32 -int setenv(const char *name, const char *value, int overwrite); -int unsetenv(const char *name); -constexpr char PATHDIV = '\\'; -#else -constexpr char PATHDIV = '/'; -#endif - // // Arch // diff --git a/wrapper/wrapper.workspace b/wrapper/wrapper.workspace index e32a680..782cb19 100644 --- a/wrapper/wrapper.workspace +++ b/wrapper/wrapper.workspace @@ -1,5 +1,5 @@ - +