mirror of
https://github.com/Relintai/osxcross.git
synced 2025-02-03 22:45:56 +01:00
osxcross-man:
* use MANPATH environment variable instead of --manpath for more portability * add (build_gcc.sh) gcc man pages
This commit is contained in:
parent
226435ef4e
commit
54d6ae9172
@ -33,22 +33,54 @@ namespace osxcross {
|
|||||||
|
|
||||||
int man(int argc, char **argv, Target &target) {
|
int man(int argc, char **argv, Target &target) {
|
||||||
std::string SDKPath;
|
std::string SDKPath;
|
||||||
target.getSDKPath(SDKPath);
|
|
||||||
std::string manpath = SDKPath + "/usr/share/man";
|
|
||||||
|
|
||||||
if (!dirExists(manpath)) {
|
if (!target.getSDKPath(SDKPath))
|
||||||
err << "directory '" << manpath << "' does not exist" << err.endl();
|
return 1;
|
||||||
|
|
||||||
|
std::vector<std::string> manpaths;
|
||||||
|
|
||||||
|
manpaths.push_back(SDKPath + "/usr/share/man");
|
||||||
|
manpaths.push_back(std::string(target.execpath) + "/../share/man");
|
||||||
|
|
||||||
|
unsetenv("MANPATH");
|
||||||
|
|
||||||
|
for (const std::string &manpath : manpaths)
|
||||||
|
if (dirExists(manpath))
|
||||||
|
concatEnvVariable("MANPATH", manpath);
|
||||||
|
|
||||||
|
if (!getenv("MANPATH")) {
|
||||||
|
err << "cannot find man pages!" << err.endl();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<char *> args;
|
std::vector<char *> args;
|
||||||
|
|
||||||
args.push_back(const_cast<char *>("man"));
|
// All the const violation here doesn't matter,
|
||||||
args.push_back(const_cast<char *>("--manpath"));
|
// the arguments won't be modified
|
||||||
args.push_back(const_cast<char *>(manpath.c_str()));
|
|
||||||
|
|
||||||
for (int i = 1; i < argc; ++i)
|
args.push_back(const_cast<char *>("man"));
|
||||||
args.push_back(argv[i]);
|
|
||||||
|
for (int i = 1; i < argc; ++i) {
|
||||||
|
char *arg = argv[i];
|
||||||
|
|
||||||
|
// Rewrite gcc to <triple>-gcc for compatibility
|
||||||
|
// with other man pages
|
||||||
|
|
||||||
|
constexpr const char *GCCManPages[] = { "gcc", "g++", "cpp", "gcov" };
|
||||||
|
|
||||||
|
for (const char *mp : GCCManPages) {
|
||||||
|
if (!strcmp(mp, arg)) {
|
||||||
|
std::string *str = new std::string; // Intentionally "leaked"
|
||||||
|
target.getDefaultTriple(*str);
|
||||||
|
str->append("-");
|
||||||
|
str->append(arg);
|
||||||
|
arg = const_cast<char *>(str->c_str());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
args.push_back(arg);
|
||||||
|
}
|
||||||
|
|
||||||
args.push_back(nullptr);
|
args.push_back(nullptr);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user