mirror of
https://github.com/Relintai/osxcross.git
synced 2025-02-03 22:45:56 +01:00
add pkg-config wrapper
This commit is contained in:
parent
e7b643d9bd
commit
a8fdaa3ab2
@ -42,7 +42,8 @@ SRCS= \
|
|||||||
programs/osxcross-env.cpp \
|
programs/osxcross-env.cpp \
|
||||||
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
|
||||||
|
|
||||||
OBJS=$(subst .cpp,.o,$(SRCS))
|
OBJS=$(subst .cpp,.o,$(SRCS))
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@ create_wrapper_link osxcross 1
|
|||||||
create_wrapper_link osxcross-conf 1
|
create_wrapper_link osxcross-conf 1
|
||||||
create_wrapper_link osxcross-env 1
|
create_wrapper_link osxcross-env 1
|
||||||
create_wrapper_link osxcross-cmp 1
|
create_wrapper_link osxcross-cmp 1
|
||||||
|
create_wrapper_link pkg-config 1
|
||||||
|
|
||||||
if [ "$PLATFORM" != "Darwin" ]; then
|
if [ "$PLATFORM" != "Darwin" ]; then
|
||||||
create_wrapper_link sw_vers 1
|
create_wrapper_link sw_vers 1
|
||||||
|
@ -27,7 +27,7 @@ using namespace target;
|
|||||||
namespace program {
|
namespace program {
|
||||||
namespace osxcross {
|
namespace osxcross {
|
||||||
|
|
||||||
int conf(const Target &target) {
|
int conf(Target &target) {
|
||||||
std::string sdkpath;
|
std::string sdkpath;
|
||||||
OSVersion OSXVersionMin = getDefaultMinTarget();
|
OSVersion OSXVersionMin = getDefaultMinTarget();
|
||||||
const char *ltopath = getLibLTOPath();
|
const char *ltopath = getLibLTOPath();
|
||||||
|
63
wrapper/programs/pkg-config.cpp
Normal file
63
wrapper/programs/pkg-config.cpp
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
* OSXCross Compiler Wrapper *
|
||||||
|
* Copyright (C) 2014 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
|
||||||
|
|
||||||
|
extern char **environ;
|
||||||
|
|
||||||
|
using namespace tools;
|
||||||
|
using namespace target;
|
||||||
|
|
||||||
|
namespace program {
|
||||||
|
namespace osxcross {
|
||||||
|
|
||||||
|
int pkg_config(int argc, char **argv) {
|
||||||
|
(void)argc;
|
||||||
|
|
||||||
|
bool execute = false;
|
||||||
|
std::string varname;
|
||||||
|
const char *val;
|
||||||
|
|
||||||
|
// Map OSXCROSS_PKG_* to PKG_*
|
||||||
|
for (char **env = environ; *env; ++env) {
|
||||||
|
char *p = *env;
|
||||||
|
|
||||||
|
if (!strncmp(p, "OSXCROSS_PKG", 12)) {
|
||||||
|
execute = true;
|
||||||
|
p += 9; // skip OSXCROSS_
|
||||||
|
val = strchr(p, '=') + 1; // find value offset
|
||||||
|
varname.assign(p, val - p - 1);
|
||||||
|
setenv(varname.c_str(), val, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (execute && execvp("pkg-config", argv))
|
||||||
|
std::cerr << "cannot find or execute pkg-config" << std::endl;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace osxcross
|
||||||
|
} // namespace program
|
@ -26,7 +26,7 @@ using namespace target;
|
|||||||
|
|
||||||
namespace program {
|
namespace program {
|
||||||
|
|
||||||
int sw_vers(int argc, char **argv, const Target &target) {
|
int sw_vers(int argc, char **argv, Target &target) {
|
||||||
|
|
||||||
auto genFakeBuildVer = [](std::string & build)->std::string & {
|
auto genFakeBuildVer = [](std::string & build)->std::string & {
|
||||||
std::stringstream tmp;
|
std::stringstream tmp;
|
||||||
|
@ -31,8 +31,8 @@ class prog {
|
|||||||
public:
|
public:
|
||||||
typedef int (*f1)();
|
typedef int (*f1)();
|
||||||
typedef int (*f2)(int, char **);
|
typedef int (*f2)(int, char **);
|
||||||
typedef int (*f3)(int, char **, const target::Target &);
|
typedef int (*f3)(int, char **, Target &);
|
||||||
typedef int (*f4)(const target::Target &);
|
typedef int (*f4)(Target &);
|
||||||
|
|
||||||
constexpr prog(const char *name, f1 fun)
|
constexpr prog(const char *name, f1 fun)
|
||||||
: name(name), fun1(fun), fun2(), fun3(), fun4(), type(1) {}
|
: name(name), fun1(fun), fun2(), fun3(), fun4(), type(1) {}
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
constexpr prog(const char *name, f4 fun)
|
constexpr prog(const char *name, f4 fun)
|
||||||
: name(name), fun1(), fun2(), fun3(), fun4(fun), type(4) {}
|
: name(name), fun1(), fun2(), fun3(), fun4(fun), type(4) {}
|
||||||
|
|
||||||
void operator()(int argc, char **argv, const Target &target) const {
|
void operator()(int argc, char **argv, Target &target) const {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 1:
|
case 1:
|
||||||
exit(fun1());
|
exit(fun1());
|
||||||
@ -74,13 +74,14 @@ private:
|
|||||||
int type;
|
int type;
|
||||||
};
|
};
|
||||||
|
|
||||||
int sw_vers(int argc, char **argv, const target::Target &target);
|
int sw_vers(int argc, char **argv, target::Target &target);
|
||||||
|
|
||||||
namespace osxcross {
|
namespace osxcross {
|
||||||
int version();
|
int version();
|
||||||
int env(int argc, char **argv);
|
int env(int argc, char **argv);
|
||||||
int conf(const Target &target);
|
int conf(Target &target);
|
||||||
int cmp(int argc, char **argv);
|
int cmp(int argc, char **argv);
|
||||||
|
int pkg_config(int argc, char **argv);
|
||||||
} // namespace osxcross
|
} // namespace osxcross
|
||||||
|
|
||||||
static int dummy() { return 0; }
|
static int dummy() { return 0; }
|
||||||
@ -91,6 +92,7 @@ constexpr prog programs[] = { { "sw_vers", sw_vers },
|
|||||||
{ "osxcross-env", osxcross::env },
|
{ "osxcross-env", osxcross::env },
|
||||||
{ "osxcross-conf", osxcross::conf },
|
{ "osxcross-conf", osxcross::conf },
|
||||||
{ "osxcross-cmp", osxcross::cmp },
|
{ "osxcross-cmp", osxcross::cmp },
|
||||||
|
{ "pkg-config", osxcross::pkg_config },
|
||||||
{ "wrapper", dummy } };
|
{ "wrapper", dummy } };
|
||||||
|
|
||||||
template <class T> const prog *getprog(const T &name) {
|
template <class T> const prog *getprog(const T &name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user