mirror of
https://github.com/darlinghq/xcbuild.git
synced 2024-11-27 05:50:27 +00:00
Fix usage of GCC 4.8 on Travis.
This commit is contained in:
parent
3be46625c4
commit
f697ef0e87
@ -11,6 +11,9 @@ matrix:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: gcc48
|
||||
env:
|
||||
- CC=gcc-4.8
|
||||
- CXX=g++-4.8
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
|
@ -15,15 +15,21 @@ set(CMAKE_MACOSX_RPATH 1)
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
#set(CMAKE_BUILD_TYPE "Release")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||
|
||||
# Enable all warnings.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
|
||||
endif ()
|
||||
|
||||
# Enable color diagnostics.
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "5.0")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color")
|
||||
endif ()
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||
|
||||
find_library(CORE_FOUNDATION CoreFoundation)
|
||||
if ("${CORE_FOUNDATION}" STREQUAL "CORE_FOUNDATION-NOTFOUND")
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <unistd.h>
|
||||
@ -20,9 +22,11 @@
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <mach-o/dyld.h>
|
||||
#elif defined(__linux__) && defined(__GLIBC__)
|
||||
#include <sys/auxv.h>
|
||||
#elif defined(__linux__)
|
||||
#include <linux/limits.h>
|
||||
#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 16
|
||||
#include <sys/auxv.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern char **environ;
|
||||
@ -47,15 +51,19 @@ EnvironmentVariables()
|
||||
return environment;
|
||||
}
|
||||
|
||||
#if defined(__linux__) && defined(__GLIBC__)
|
||||
char initialWorkingDirectory[PATH_MAX] = { 0 };
|
||||
#if defined(__linux__)
|
||||
#if defined(__GLIBC__)
|
||||
static char initialWorkingDirectory[PATH_MAX] = { 0 };
|
||||
static char initialExecutablePath[PATH_MAX] = { 0 };
|
||||
|
||||
__attribute__((constructor))
|
||||
static void GetExecutablePathInitialize()
|
||||
static void GetExecutablePathInitialize(int argc, char **argv)
|
||||
{
|
||||
getcwd(initialWorkingDirectory, sizeof(initialWorkingDirectory));
|
||||
strncpy(initialExecutablePath, argv[0], sizeof(initialExecutablePath));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
std::string SysUtil::
|
||||
GetExecutablePath()
|
||||
@ -73,12 +81,18 @@ GetExecutablePath()
|
||||
}
|
||||
|
||||
return FSUtil::NormalizePath(buffer);
|
||||
#elif defined(__linux__) && defined(__GLIBC__)
|
||||
#elif defined(__linux__)
|
||||
#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 16
|
||||
char const *path = reinterpret_cast<char const *>(getauxval(AT_EXECFN));
|
||||
if (path == NULL) {
|
||||
assert(false);
|
||||
abort();
|
||||
}
|
||||
#elif defined(__GLIBC__)
|
||||
char const *path = reinterpret_cast<char const *>(initialExecutablePath);
|
||||
#else
|
||||
#error Unsupported platform.
|
||||
#endif
|
||||
|
||||
std::string absolutePath = FSUtil::ResolveRelativePath(std::string(path), std::string(initialWorkingDirectory));
|
||||
return FSUtil::NormalizePath(absolutePath);
|
||||
|
Loading…
Reference in New Issue
Block a user