mirror of
https://github.com/darlinghq/xcbuild.git
synced 2025-02-22 09:22:34 +00:00
Allow specifying per-user developer root.
Currently the developer root is resolved through the following steps: 1. DEVELOPER_DIR environment variable 2. /var/db/xcode_select_link 3. /usr/share/xcode-select/xcode_dir_path (1) suffers from having to configure this environment varirable every time. (2) and (3) suffers from needing to be root to configure on most systems. This change adds another symlink, checked first: 1. ~/.xcsdk/xcode_select_link Test Plan: 1. Create symlink ~/.xcsdk/xcode_dir_path 2. xcrun -v -l --sdk test-sdk -f test-script
This commit is contained in:
parent
96ed319dcc
commit
ea56053160
@ -82,7 +82,7 @@ public:
|
||||
/*
|
||||
* The home directory from the environment.
|
||||
*/
|
||||
std::string userHomeDirectory() const;
|
||||
virtual ext::optional<std::string> userHomeDirectory() const;
|
||||
|
||||
public:
|
||||
/*
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
virtual int32_t groupID() const;
|
||||
virtual std::string const &userName() const;
|
||||
virtual std::string const &groupName() const;
|
||||
|
||||
public:
|
||||
virtual ext::optional<std::string> userHomeDirectory() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,12 @@ executableSearchPaths() const
|
||||
return paths;
|
||||
}
|
||||
|
||||
ext::optional<std::string> Context::
|
||||
userHomeDirectory() const
|
||||
{
|
||||
return environmentVariable("HOME");
|
||||
}
|
||||
|
||||
#include <process/DefaultContext.h>
|
||||
|
||||
using process::DefaultContext;
|
||||
|
@ -240,3 +240,13 @@ groupID() const
|
||||
return ::getgid();
|
||||
}
|
||||
|
||||
ext::optional<std::string> DefaultContext::
|
||||
userHomeDirectory() const
|
||||
{
|
||||
if (ext::optional<std::string> value = Context::userHomeDirectory()) {
|
||||
return value;
|
||||
} else {
|
||||
char *home = getpwuid(getuid())->pw_dir;
|
||||
return std::string(home);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,12 @@ using xcsdk::Environment;
|
||||
using libutil::Filesystem;
|
||||
using libutil::FSUtil;
|
||||
|
||||
static std::string
|
||||
UserDeveloperRootLink(std::string const &userHomeDirectory)
|
||||
{
|
||||
return userHomeDirectory + "/.xcsdk/xcode_select_link";
|
||||
}
|
||||
|
||||
static std::string
|
||||
PrimaryDeveloperRootLink()
|
||||
{
|
||||
@ -50,6 +56,12 @@ DeveloperRoot(process::Context const *processContext, Filesystem const *filesyst
|
||||
return ResolveDeveloperRoot(filesystem, *path);
|
||||
}
|
||||
|
||||
if (ext::optional<std::string> userHomeDirectory = processContext->userHomeDirectory()) {
|
||||
if (auto path = filesystem->readSymbolicLink(UserDeveloperRootLink(*userHomeDirectory))) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto path = filesystem->readSymbolicLink(PrimaryDeveloperRootLink())) {
|
||||
return path;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user