本文整理汇总了C++中TargetSP::GetExecutableSearchPaths方法的典型用法代码示例。如果您正苦于以下问题:C++ TargetSP::GetExecutableSearchPaths方法的具体用法?C++ TargetSP::GetExecutableSearchPaths怎么用?C++ TargetSP::GetExecutableSearchPaths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TargetSP
的用法示例。
在下文中一共展示了TargetSP::GetExecutableSearchPaths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: arch
Error
TargetList::CreateTarget (Debugger &debugger,
const FileSpec& file,
const char *triple_cstr,
bool get_dependent_files,
const OptionGroupPlatform *platform_options,
TargetSP &target_sp)
{
Error error;
PlatformSP platform_sp;
// This is purposely left empty unless it is specified by triple_cstr.
// If not initialized via triple_cstr, then the currently selected platform
// will set the architecture correctly.
const ArchSpec arch(triple_cstr);
if (triple_cstr && triple_cstr[0])
{
if (!arch.IsValid())
{
error.SetErrorStringWithFormat("invalid triple '%s'", triple_cstr);
return error;
}
}
ArchSpec platform_arch(arch);
CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
if (platform_options)
{
if (platform_options->PlatformWasSpecified ())
{
const bool select_platform = true;
platform_sp = platform_options->CreatePlatformWithOptions (interpreter,
arch,
select_platform,
error,
platform_arch);
if (!platform_sp)
return error;
}
}
if (!platform_sp)
{
// Get the current platform and make sure it is compatible with the
// current architecture if we have a valid architecture.
platform_sp = debugger.GetPlatformList().GetSelectedPlatform ();
if (arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, &platform_arch))
{
platform_sp = Platform::GetPlatformForArchitecture(arch, &platform_arch);
}
}
if (!platform_arch.IsValid())
platform_arch = arch;
error = TargetList::CreateTarget (debugger,
file,
platform_arch,
get_dependent_files,
platform_sp,
target_sp);
if (target_sp)
{
if (file.GetDirectory())
{
FileSpec file_dir;
file_dir.GetDirectory() = file.GetDirectory();
target_sp->GetExecutableSearchPaths ().Append (file_dir);
}
}
return error;
}
示例2: scoped_timer
//.........这里部分代码省略.........
bool user_exe_path_is_bundle = false;
char resolved_bundle_exe_path[PATH_MAX];
resolved_bundle_exe_path[0] = '\0';
if (file)
{
if (file.GetFileType() == FileSpec::eFileTypeDirectory)
user_exe_path_is_bundle = true;
if (file.IsRelativeToCurrentWorkingDirectory())
{
// Ignore paths that start with "./" and "../"
if (!((user_exe_path[0] == '.' && user_exe_path[1] == '/') ||
(user_exe_path[0] == '.' && user_exe_path[1] == '.' && user_exe_path[2] == '/')))
{
char cwd[PATH_MAX];
if (getcwd (cwd, sizeof(cwd)))
{
std::string cwd_user_exe_path (cwd);
cwd_user_exe_path += '/';
cwd_user_exe_path += user_exe_path;
FileSpec cwd_file (cwd_user_exe_path.c_str(), false);
if (cwd_file.Exists())
file = cwd_file;
}
}
}
ModuleSP exe_module_sp;
if (platform_sp)
{
FileSpecList executable_search_paths (Target::GetDefaultExecutableSearchPaths());
error = platform_sp->ResolveExecutable (file,
arch,
exe_module_sp,
executable_search_paths.GetSize() ? &executable_search_paths : NULL);
}
if (error.Success() && exe_module_sp)
{
if (exe_module_sp->GetObjectFile() == NULL)
{
if (arch.IsValid())
{
error.SetErrorStringWithFormat("\"%s\" doesn't contain architecture %s",
file.GetPath().c_str(),
arch.GetArchitectureName());
}
else
{
error.SetErrorStringWithFormat("unsupported file type \"%s\"",
file.GetPath().c_str());
}
return error;
}
target_sp.reset(new Target(debugger, arch, platform_sp));
target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
if (user_exe_path_is_bundle)
exe_module_sp->GetFileSpec().GetPath(resolved_bundle_exe_path, sizeof(resolved_bundle_exe_path));
}
}
else
{
// No file was specified, just create an empty target with any arch
// if a valid arch was specified
target_sp.reset(new Target(debugger, arch, platform_sp));
}
if (target_sp)
{
// Set argv0 with what the user typed, unless the user specified a
// directory. If the user specified a directory, then it is probably a
// bundle that was resolved and we need to use the resolved bundle path
if (user_exe_path)
{
// Use exactly what the user typed as the first argument when we exec or posix_spawn
if (user_exe_path_is_bundle && resolved_bundle_exe_path[0])
{
target_sp->SetArg0 (resolved_bundle_exe_path);
}
else
{
// Use resolved path
target_sp->SetArg0 (file.GetPath().c_str());
}
}
if (file.GetDirectory())
{
FileSpec file_dir;
file_dir.GetDirectory() = file.GetDirectory();
target_sp->GetExecutableSearchPaths ().Append (file_dir);
}
Mutex::Locker locker(m_target_list_mutex);
m_selected_target_idx = m_target_list.size();
m_target_list.push_back(target_sp);
}
return error;
}