2014-05-17 23:15:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* OSXCross Compiler Wrapper *
|
2015-02-08 10:27:26 +01:00
|
|
|
* Copyright (C) 2014, 2015 by Thomas Poechtrager *
|
2014-05-17 23:15:15 +02:00
|
|
|
* t.poechtrager@gmail.com *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software *
|
|
|
|
* Foundation, Inc., *
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
namespace target {
|
|
|
|
|
|
|
|
using namespace tools;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Default values for the Target struct
|
|
|
|
//
|
|
|
|
|
|
|
|
constexpr const char *getDefaultVendor() { return "apple"; }
|
|
|
|
constexpr const char *getDefaultTarget() { return OSXCROSS_TARGET; }
|
|
|
|
constexpr const char *getDefaultCompiler() { return "clang"; }
|
|
|
|
constexpr const char *getDefaultCXXCompiler() { return "clang++"; }
|
|
|
|
constexpr const char *getLinkerVersion() { return OSXCROSS_LINKER_VERSION; }
|
2015-08-21 23:32:37 +02:00
|
|
|
constexpr const char *getBuildDir() { return OSXCROSS_BUILD_DIR; }
|
2014-05-17 23:15:15 +02:00
|
|
|
|
|
|
|
constexpr const char *getLibLTOPath() {
|
|
|
|
#ifdef OSXCROSS_LIBLTO_PATH
|
|
|
|
return OSXCROSS_LIBLTO_PATH;
|
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr const char *getOSXCrossVersion() {
|
|
|
|
#ifdef OSXCROSS_VERSION
|
|
|
|
return OSXCROSS_VERSION[0] ? OSXCROSS_VERSION : "unknown";
|
|
|
|
#else
|
|
|
|
return "unknown";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef OSXCROSS_OSX_VERSION_MIN
|
|
|
|
inline OSVersion getDefaultMinTarget() {
|
|
|
|
if (!strcmp(OSXCROSS_OSX_VERSION_MIN, "default"))
|
|
|
|
return OSVersion();
|
|
|
|
|
|
|
|
return parseOSVersion(OSXCROSS_OSX_VERSION_MIN);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
constexpr OSVersion getDefaultMinTarget() { return OSVersion(); }
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// Target
|
|
|
|
//
|
|
|
|
|
|
|
|
struct Target {
|
|
|
|
Target()
|
2015-06-27 19:01:56 +02:00
|
|
|
: vendor(getDefaultVendor()), SDK(getenv("OSXCROSS_SDKROOT")),
|
|
|
|
arch(Arch::x86_64), target(getDefaultTarget()), stdlib(StdLib::unset),
|
2015-08-22 23:15:27 +02:00
|
|
|
usegcclibs(), nocodegen(), compilername(getDefaultCompiler()),
|
2015-08-23 22:45:53 +02:00
|
|
|
language() {
|
2014-05-17 23:15:15 +02:00
|
|
|
if (!getExecutablePath(execpath, sizeof(execpath)))
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
OSVersion getSDKOSNum() const;
|
|
|
|
bool getSDKPath(std::string &path) const;
|
|
|
|
|
2014-12-24 10:52:24 +01:00
|
|
|
bool getMacPortsDir(std::string &path) const;
|
|
|
|
bool getMacPortsSysRootDir(std::string &path) const;
|
|
|
|
bool getMacPortsPkgConfigDir(std::string &path) const;
|
|
|
|
bool getMacPortsIncludeDir(std::string &path) const;
|
|
|
|
bool getMacPortsLibDir(std::string &path) const;
|
|
|
|
bool getMacPortsFrameworksDir(std::string &path) const;
|
|
|
|
|
2014-05-17 23:15:15 +02:00
|
|
|
void addArch(const Arch arch);
|
|
|
|
bool haveArch(const Arch arch);
|
|
|
|
|
|
|
|
bool hasLibCXX() const;
|
|
|
|
bool libCXXIsDefaultCXXLib() const;
|
|
|
|
bool isLibCXX() const;
|
|
|
|
bool isLibSTDCXX() const;
|
|
|
|
|
|
|
|
bool isCXX();
|
2015-08-23 22:45:53 +02:00
|
|
|
bool isGCH();
|
2014-05-17 23:15:15 +02:00
|
|
|
|
2015-08-23 22:45:53 +02:00
|
|
|
bool isClang() const;
|
|
|
|
bool isGCC() const;
|
2014-05-17 23:15:15 +02:00
|
|
|
|
|
|
|
bool isKnownCompiler() const { return isClang() || isGCC(); }
|
|
|
|
|
2015-06-21 11:46:01 +02:00
|
|
|
const std::string &getDefaultTriple(std::string &triple) const;
|
2014-05-17 23:15:15 +02:00
|
|
|
const std::string &getTriple() const { return triple; }
|
|
|
|
|
2015-05-30 21:04:51 +02:00
|
|
|
void setCompilerPath();
|
2015-02-17 19:51:17 +01:00
|
|
|
bool findClangIntrinsicHeaders(std::string &path);
|
2014-05-17 23:15:15 +02:00
|
|
|
|
|
|
|
void setupGCCLibs(Arch arch);
|
|
|
|
bool setup();
|
|
|
|
|
|
|
|
const char *vendor;
|
2015-06-27 19:01:56 +02:00
|
|
|
const char *SDK;
|
2014-05-17 23:15:15 +02:00
|
|
|
Arch arch;
|
|
|
|
std::vector<Arch> targetarch;
|
|
|
|
std::string target;
|
|
|
|
OSVersion OSNum;
|
|
|
|
StdLib stdlib;
|
2015-02-17 19:51:17 +01:00
|
|
|
ClangVersion clangversion;
|
2014-05-17 23:15:15 +02:00
|
|
|
GCCVersion gccversion;
|
2015-02-17 19:51:17 +01:00
|
|
|
bool usegcclibs;
|
2014-05-17 23:15:15 +02:00
|
|
|
bool nocodegen;
|
2015-05-30 21:04:51 +02:00
|
|
|
std::string compilerpath; // /usr/bin/clang | [...]/target/bin/*-gcc
|
|
|
|
std::string compilername; // clang | gcc
|
|
|
|
std::string compilerexecname; // clang | *-apple-darwin-gcc
|
2014-05-17 23:15:15 +02:00
|
|
|
std::string triple;
|
|
|
|
std::string otriple;
|
|
|
|
string_vector fargs;
|
|
|
|
string_vector args;
|
2015-08-23 22:45:53 +02:00
|
|
|
const char *language;
|
2014-05-17 23:15:15 +02:00
|
|
|
char execpath[PATH_MAX + 1];
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace target
|