add 'osxcross-man' - man page tool

This commit is contained in:
Thomas Pöchtrager 2015-06-21 14:07:19 +02:00
parent 4450f62e1a
commit 3e46f6cc32
10 changed files with 86 additions and 18 deletions

View File

@ -4,6 +4,7 @@ changed:
* improved and colorized wrapper error/warning/debug/info messages
added:
* 'osxcross-man' man page tool
* p7zip sdk packaging script
* a minimalistic xcrun tool
* support for ccache symlinks

View File

@ -98,6 +98,9 @@ LIBCXXDIR1="Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v
# Xcode 6
LIBCXXDIR2="Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1"
# Manual directory
MANDIR="Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man"
for SDK in $SDKS; do
echo -n "packaging $(echo "$SDK" | sed -E "s/(.sdk|.pkg)//g") SDK "
echo "(this may take several minutes) ..."
@ -119,6 +122,11 @@ for SDK in $SDKS; do
cp -rf $LIBCXXDIR2 "$TMP/$SDK/usr/include/c++"
fi
if [ -d $MANDIR ]; then
mkdir -p $TMP/$SDK/usr/share/man
cp -rf $MANDIR/* $TMP/$SDK/usr/share/man
fi
popd &>/dev/null
pushd $TMP &>/dev/null

View File

@ -44,6 +44,7 @@ SRCS= \
programs/osxcross-env.cpp \
programs/osxcross-conf.cpp \
programs/osxcross-cmp.cpp \
programs/osxcross-man.cpp \
programs/sw_vers.cpp \
programs/pkg-config.cpp \
programs/xcrun.cpp

View File

@ -144,6 +144,7 @@ create_wrapper_link osxcross 1
create_wrapper_link osxcross-conf 1
create_wrapper_link osxcross-env 1
create_wrapper_link osxcross-cmp 1
create_wrapper_link osxcross-man 1
create_wrapper_link pkg-config
if [ "$PLATFORM" != "Darwin" ]; then

View File

@ -32,11 +32,8 @@ int conf(Target &target) {
OSVersion OSXVersionMin = getDefaultMinTarget();
const char *ltopath = getLibLTOPath();
if (!target.getSDKPath(SDKPath)) {
err << "cannot find Mac OS X SDK (expected in: " << SDKPath << ")"
<< err.endl();
if (!target.getSDKPath(SDKPath))
return 1;
}
if (!OSXVersionMin.Num())
OSXVersionMin = target.getSDKOSNum();

View File

@ -0,0 +1,61 @@
/***********************************************************************
* 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;
using namespace target;
namespace program {
namespace osxcross {
int man(int argc, char **argv, Target &target) {
std::string SDKPath;
target.getSDKPath(SDKPath);
std::string manpath = SDKPath + "/usr/share/man";
if (!dirExists(manpath)) {
err << "directory '" << manpath << "' does not exist" << err.endl();
return 1;
}
std::vector<char *> args;
args.push_back(const_cast<char *>("man"));
args.push_back(const_cast<char *>("--manpath"));
args.push_back(const_cast<char *>(manpath.c_str()));
for (int i = 1; i < argc; ++i)
args.push_back(argv[i]);
args.push_back(nullptr);
execvp(args[0], args.data());
err << "cannot execute '" << args[0] << "'" << err.endl();
return 1;
}
} // namespace osxcross
} // namespace program

View File

@ -32,14 +32,6 @@ namespace program {
static bool showCommand = false;
bool getSDKPath(Target &target, std::string &SDKPath) {
if (!target.getSDKPath(SDKPath)) {
err << "xcrun: cannot find MacOSX SDK" << err.endl();
return false;
}
return true;
}
bool getToolPath(Target &target, std::string &toolpath, const char *tool) {
toolpath = target.execpath;
toolpath += "/";
@ -127,7 +119,7 @@ int run(Target &target, char **argv) {
int showSDKPath(Target &target, char **) {
std::string SDKPath;
if (!getSDKPath(target, SDKPath))
if (!target.getSDKPath(SDKPath))
return 1;
std::cout << SDKPath << std::endl;
return 0;

View File

@ -82,6 +82,7 @@ int version();
int env(int argc, char **argv);
int conf(Target &target);
int cmp(int argc, char **argv);
int man(int argc, char **argv, Target &target);
int pkg_config(int argc, char **argv, Target &target);
} // namespace osxcross
@ -94,6 +95,7 @@ constexpr prog programs[] = { { "sw_vers", sw_vers },
{ "osxcross-env", osxcross::env },
{ "osxcross-conf", osxcross::conf },
{ "osxcross-cmp", osxcross::cmp },
{ "osxcross-man", osxcross::man },
{ "pkg-config", osxcross::pkg_config },
{ "wrapper", dummy } };

View File

@ -56,7 +56,14 @@ bool Target::getSDKPath(std::string &path) const {
path += "u";
path += ".sdk";
return dirExists(path);
if (!dirExists(path)) {
err << "cannot find Mac OS X SDK (expected in: " << path << ")"
<< err.endl();
return false;
}
return true;
}
bool Target::getMacPortsDir(std::string &path) const {
@ -429,11 +436,8 @@ bool Target::setup() {
if (!isKnownCompiler())
warn << "unknown compiler '" << compilername << "'" << warn.endl();
if (!getSDKPath(SDKPath)) {
err << "cannot find Mac OS X SDK (expected in: " << SDKPath << ")"
<< err.endl();
if (!getSDKPath(SDKPath))
return false;
}
if (targetarch.empty())
targetarch.push_back(arch);

View File

@ -36,6 +36,7 @@
<File Name="programs/osxcross-conf.cpp"/>
<File Name="programs/osxcross-cmp.cpp"/>
<File Name="programs/xcrun.cpp"/>
<File Name="programs/osxcross-man.cpp"/>
</VirtualDirectory>
<File Name="Makefile"/>
<File Name="build.sh"/>