mirror of
https://github.com/Relintai/osxcross.git
synced 2025-04-28 09:44:58 +02:00
wrap dsymutil to llvm-dsymutil (#1)
This commit is contained in:
parent
bdb734909e
commit
7e9f856e6a
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
changed:
|
changed:
|
||||||
* improved and colorized wrapper error/warning/debug/info messages
|
* improved and colorized wrapper error/warning/debug/info messages
|
||||||
|
* dsymutil is now wrapped to llvm-dsymutil (LLVM >= 3.7 only)
|
||||||
|
|
||||||
added:
|
added:
|
||||||
* support for ccache symlinks
|
* support for ccache symlinks
|
||||||
|
@ -43,7 +43,8 @@ SRCS= \
|
|||||||
programs/osxcross-conf.cpp \
|
programs/osxcross-conf.cpp \
|
||||||
programs/osxcross-cmp.cpp \
|
programs/osxcross-cmp.cpp \
|
||||||
programs/sw_vers.cpp \
|
programs/sw_vers.cpp \
|
||||||
programs/pkg-config.cpp
|
programs/pkg-config.cpp \
|
||||||
|
programs/dsymutil.cpp
|
||||||
|
|
||||||
OBJS=$(subst .cpp,.o,$(SRCS))
|
OBJS=$(subst .cpp,.o,$(SRCS))
|
||||||
|
|
||||||
|
68
wrapper/programs/dsymutil.cpp
Normal file
68
wrapper/programs/dsymutil.cpp
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* OSXCross Compiler Wrapper *
|
||||||
|
* Copyright (C) 2014, 2015 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"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace tools;
|
||||||
|
|
||||||
|
namespace program {
|
||||||
|
|
||||||
|
int dsymutil(int argc, char **argv) {
|
||||||
|
(void)argc;
|
||||||
|
|
||||||
|
std::string dsymutil;
|
||||||
|
char llvmveroutput[1024];
|
||||||
|
const char *verstr;
|
||||||
|
LLVMVersion llvmver;
|
||||||
|
|
||||||
|
if (!realPath("llvm-dsymutil", dsymutil))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
std::string command = dsymutil + " -version";
|
||||||
|
|
||||||
|
if (runcommand(command.c_str(), llvmveroutput, sizeof(llvmveroutput)) ==
|
||||||
|
RUNCOMMAND_ERROR)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
verstr = strstr(llvmveroutput, "LLVM version ");
|
||||||
|
|
||||||
|
if (!verstr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
verstr += 13; // strlen("LLVM version ");
|
||||||
|
|
||||||
|
llvmver = parseLLVMVersion(verstr);
|
||||||
|
|
||||||
|
// LLVM <= 3.6 is too old
|
||||||
|
if (llvmver <= LLVMVersion(3, 6))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (execvp(dsymutil.c_str(), argv))
|
||||||
|
err << "cannot execute '" << dsymutil << "'" << err.endl();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace program
|
@ -75,6 +75,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
int sw_vers(int argc, char **argv, target::Target &target);
|
int sw_vers(int argc, char **argv, target::Target &target);
|
||||||
|
int dsymutil(int argc, char **argv);
|
||||||
|
|
||||||
namespace osxcross {
|
namespace osxcross {
|
||||||
int version();
|
int version();
|
||||||
@ -87,7 +88,7 @@ int pkg_config(int argc, char **argv, Target &target);
|
|||||||
static int dummy() { return 0; }
|
static int dummy() { return 0; }
|
||||||
|
|
||||||
constexpr prog programs[] = { { "sw_vers", sw_vers },
|
constexpr prog programs[] = { { "sw_vers", sw_vers },
|
||||||
{ "dsymutil", dummy },
|
{ "dsymutil", dsymutil },
|
||||||
{ "osxcross", osxcross::version },
|
{ "osxcross", osxcross::version },
|
||||||
{ "osxcross-env", osxcross::env },
|
{ "osxcross-env", osxcross::env },
|
||||||
{ "osxcross-conf", osxcross::conf },
|
{ "osxcross-conf", osxcross::conf },
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@ -443,6 +444,36 @@ const char *getFileExtension(const char *file) {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Shell Commands
|
||||||
|
//
|
||||||
|
|
||||||
|
size_t runcommand(const char *command, char *buf, size_t len) {
|
||||||
|
#define RETURN(v) \
|
||||||
|
do { \
|
||||||
|
if (p) \
|
||||||
|
pclose(p); \
|
||||||
|
return (v); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
if (!len)
|
||||||
|
return RUNCOMMAND_ERROR;
|
||||||
|
|
||||||
|
FILE *p;
|
||||||
|
size_t outputlen;
|
||||||
|
|
||||||
|
if (!(p = popen(command, "r")))
|
||||||
|
RETURN(RUNCOMMAND_ERROR);
|
||||||
|
|
||||||
|
if (!(outputlen = fread(buf, sizeof(char), len - 1, p)))
|
||||||
|
RETURN(RUNCOMMAND_ERROR);
|
||||||
|
|
||||||
|
buf[outputlen] = '\0';
|
||||||
|
|
||||||
|
RETURN(outputlen);
|
||||||
|
#undef RETURN
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Time
|
// Time
|
||||||
//
|
//
|
||||||
|
@ -163,6 +163,14 @@ inline const char *getFileExtension(const std::string &file) {
|
|||||||
return getFileExtension(file.c_str());
|
return getFileExtension(file.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Shell Commands
|
||||||
|
//
|
||||||
|
|
||||||
|
constexpr size_t RUNCOMMAND_ERROR = -1;
|
||||||
|
|
||||||
|
size_t runcommand(const char *command, char *buf, size_t len);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Time
|
// Time
|
||||||
//
|
//
|
||||||
@ -275,10 +283,13 @@ static_assert(OSVersion(10, 6) != OSVersion(10, 5), "");
|
|||||||
OSVersion parseOSVersion(const char *OSVer);
|
OSVersion parseOSVersion(const char *OSVer);
|
||||||
|
|
||||||
typedef OSVersion GCCVersion;
|
typedef OSVersion GCCVersion;
|
||||||
#define parseGCCVersion parseOSVersion
|
static const auto &parseGCCVersion = parseOSVersion;
|
||||||
|
|
||||||
typedef OSVersion ClangVersion;
|
typedef OSVersion ClangVersion;
|
||||||
#define parseClangVersion parseOSVersion
|
static const auto &parseClangVersion = parseOSVersion;
|
||||||
|
|
||||||
|
typedef OSVersion LLVMVersion;
|
||||||
|
static const auto &parseLLVMVersion = parseOSVersion;
|
||||||
|
|
||||||
//
|
//
|
||||||
// OS Compat
|
// OS Compat
|
||||||
|
Loading…
Reference in New Issue
Block a user