зеркало из https://github.com/mozilla/gecko-dev.git
Bug 542053: Set LD_LIBRARY_PATH=[GRE dir] for mozilla-runtime on linux. r=bsmedberg
This commit is contained in:
Родитель
9f2f035eda
Коммит
03f2b0ee31
|
@ -19,6 +19,7 @@
|
|||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -132,6 +133,14 @@ typedef std::vector<std::pair<int, int> > file_handle_mapping_vector;
|
|||
bool LaunchApp(const std::vector<std::string>& argv,
|
||||
const file_handle_mapping_vector& fds_to_remap,
|
||||
bool wait, ProcessHandle* process_handle);
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD) && defined(OS_LINUX)
|
||||
typedef std::map<std::string, std::string> environment_map;
|
||||
bool LaunchApp(const std::vector<std::string>& argv,
|
||||
const file_handle_mapping_vector& fds_to_remap,
|
||||
const environment_map& env_vars_to_set,
|
||||
bool wait, ProcessHandle* process_handle);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Executes the application specified by cl. This function delegates to one
|
||||
|
|
|
@ -32,9 +32,21 @@ static mozilla::EnvironmentLog gProcessLog("MOZ_PROCESS_LOG");
|
|||
|
||||
namespace base {
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
bool LaunchApp(const std::vector<std::string>& argv,
|
||||
const file_handle_mapping_vector& fds_to_remap,
|
||||
bool wait, ProcessHandle* process_handle) {
|
||||
return LaunchApp(argv, fds_to_remap, environment_map(),
|
||||
wait, process_handle);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool LaunchApp(const std::vector<std::string>& argv,
|
||||
const file_handle_mapping_vector& fds_to_remap,
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
const environment_map& env_vars_to_set,
|
||||
#endif
|
||||
bool wait, ProcessHandle* process_handle) {
|
||||
pid_t pid = fork();
|
||||
if (pid < 0)
|
||||
return false;
|
||||
|
@ -51,6 +63,14 @@ bool LaunchApp(const std::vector<std::string>& argv,
|
|||
|
||||
CloseSuperfluousFds(fd_shuffle);
|
||||
|
||||
#if defined(CHROMIUM_MOZILLA_BUILD)
|
||||
for (environment_map::const_iterator it = env_vars_to_set.begin();
|
||||
it != env_vars_to_set.end(); ++it) {
|
||||
if (setenv(it->first.c_str(), it->second.c_str(), 1/*overwrite*/))
|
||||
exit(127);
|
||||
}
|
||||
#endif
|
||||
|
||||
scoped_array<char*> argv_cstr(new char*[argv.size() + 1]);
|
||||
for (size_t i = 0; i < argv.size(); i++)
|
||||
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
|
||||
|
|
|
@ -51,8 +51,13 @@
|
|||
#endif
|
||||
#include "nsExceptionHandler.h"
|
||||
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
#include "mozilla/ipc/BrowserProcessSubThread.h"
|
||||
|
||||
using base::environment_map;
|
||||
|
||||
using mozilla::MonitorAutoEnter;
|
||||
using mozilla::ipc::GeckoChildProcessHost;
|
||||
|
||||
|
@ -180,18 +185,20 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts)
|
|||
// we split the logic here.
|
||||
|
||||
FilePath exePath;
|
||||
environment_map newEnvVars;
|
||||
|
||||
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
|
||||
nsCOMPtr<nsIFile> greDir;
|
||||
nsresult rv = directoryService->Get(NS_GRE_DIR, NS_GET_IID(nsIFile), getter_AddRefs(greDir));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCString path;
|
||||
greDir->GetNativePath(path);
|
||||
exePath = FilePath(path.get());
|
||||
#ifdef OS_LINUX
|
||||
newEnvVars["LD_LIBRARY_PATH"] = path.get();
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
exePath = FilePath(CommandLine::ForCurrentProcess()->argv()[0]);
|
||||
exePath = exePath.DirName();
|
||||
}
|
||||
|
@ -231,7 +238,11 @@ GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts)
|
|||
}
|
||||
#endif
|
||||
|
||||
base::LaunchApp(childArgv, mFileMap, false, &process);
|
||||
base::LaunchApp(childArgv, mFileMap,
|
||||
#ifdef OS_LINUX
|
||||
newEnvVars,
|
||||
#endif
|
||||
false, &process);
|
||||
|
||||
//--------------------------------------------------
|
||||
#elif defined(OS_WIN)
|
||||
|
|
|
@ -47,9 +47,6 @@
|
|||
|
||||
#include "nsXULAppAPI.h" // for GeckoProcessType
|
||||
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIFile.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче