osxcross/wrapper/programs/osxcross-conf.cpp

77 lines
2.8 KiB
C++
Raw Permalink Normal View History

/***********************************************************************
* OSXCross Compiler Wrapper *
* Copyright (C) 2014-2016 by Thomas Poechtrager *
* 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. *
***********************************************************************/
#include "proginc.h"
using namespace tools;
using namespace target;
namespace program {
namespace osxcross {
Fix building on CentOS 7.x With C++14 the following error happens on CentOS 7.x: ================================== $ clang++ -std=c++1y -Wall -Wextra -pedantic -Wno-missing-field-initializers \ -I. -O2 -DOSXCROSS_VERSION="\"1.2\"" -DOSXCROSS_TARGET="\"darwin14\"" \ -DOSXCROSS_OSX_VERSION_MIN="\"10.6\"" -DOSXCROSS_LINKER_VERSION="\"530\"" \ -DOSXCROSS_LIBLTO_PATH="\"/usr/lib64/llvm\"" \ -DOSXCROSS_BUILD_DIR="\"/osxcross/build\"" -isystem quirks/include \ -c -o target.o target.cpp In file included from target.cpp:24: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/iostream:39: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ostream:38: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ios:42: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/ios_base.h:41: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/locale_classes.h:40: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/string:52: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/basic_string.h:2815: In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ext/string_conversions.h:43: /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdio:120:11: error: no member named 'gets' in the global namespace using ::gets; ~~^ 1 error generated. ================================== That's a known issue with older C++ headers, see https://bugs.llvm.org/show_bug.cgi?id=30277 With C++11 we then get another problem: ================================== $ clang++ -std=c++0x -Wall -Wextra -pedantic -Wno-missing-field-initializers \ -I. -O2 -DOSXCROSS_VERSION="\"1.2\"" -DOSXCROSS_TARGET="\"darwin14\"" \ -DOSXCROSS_OSX_VERSION_MIN="\"10.6\"" -DOSXCROSS_LINKER_VERSION="\"530\"" \ -DOSXCROSS_LIBLTO_PATH="\"/usr/lib64/llvm\"" \ -DOSXCROSS_BUILD_DIR="\"/osxcross/build\"" -isystem quirks/include \ -c -o programs/osxcross-conf.o programs/osxcross-conf.cpp programs/osxcross-conf.cpp:50:49: error: 'auto' not allowed in lambda parameter static auto print = [](const char *var, const auto &val) { ^~~~ programs/osxcross-conf.cpp:50:55: warning: unused parameter 'val' [-Wunused-parameter] static auto print = [](const char *var, const auto &val) { ^ programs/osxcross-conf.cpp:54:3: error: no matching function for call to object of type '<lambda at programs/osxcross-conf.cpp:50:23>' print("VERSION", getOSXCrossVersion()); ================================== That last issue requires a move from a lambda to more ugly template solution. But in the end we get all built!
2020-07-12 15:29:26 +02:00
template<typename A>
void print(const char *var, const A &val) {
std::cout << "export OSXCROSS_" << var << "=" << val << std::endl;
};
2014-09-27 19:45:49 +02:00
int conf(Target &target) {
std::string SDKPath;
OSVersion OSXVersionMin = getDefaultMinTarget();
const char *ltopath = getLibLTOPath();
std::string BuildDir = getBuildDir();
if (BuildDir.empty()) {
BuildDir += target.execpath;
BuildDir += "/../../build";
}
2015-06-21 14:07:19 +02:00
if (!target.getSDKPath(SDKPath))
return 1;
if (!OSXVersionMin.Num())
OSXVersionMin = target.getSDKOSNum();
if (!ltopath)
ltopath = "";
print("VERSION", getOSXCrossVersion());
print("OSX_VERSION_MIN", OSXVersionMin.shortStr());
print("TARGET", getDefaultTarget());
print("BASE_DIR", BuildDir + "/..");
print("SDK", SDKPath);
print("SDK_DIR", SDKPath + "/..");
print("SDK_VERSION", target.getSDKOSNum().shortStr());
print("TARBALL_DIR", BuildDir + "/../tarballs");
print("PATCH_DIR", BuildDir + "/../patches");
print("TARGET_DIR", std::string(target.execpath) + "/..");
print("DIR_SDK_TOOLS", SDKPath + "/../tools");
print("BUILD_DIR", BuildDir);
print("CCTOOLS_PATH", target.execpath);
print("LIBLTO_PATH", ltopath);
print("LINKER_VERSION", getLinkerVersion());
return 0;
}
} // namespace osxcross
} // namespace program