+ if(++j==cur_names->end())
+ {
+ if(mode==BuildInfo::DYNAMIC && cur_names==&shared_names)
+ cur_names = &static_names;
+ else if(mode==BuildInfo::STATIC && cur_names==&static_names)
+ cur_names = &shared_names;
+ else
+ break;
+ j = cur_names->begin();
+ }
+ }
+
+ builder.get_logger().log("vfs", format("Library %s not found in %s", lib, p.str()));
+ }
+
+ return 0;
+}
+
+FileTarget *VirtualFileSystem::find_binary(const string &name)
+{
+ SearchPath path;
+ if(FS::Path(name).is_absolute())
+ path.push_back("/");
+ else
+ {
+ if(sys_bin_path.empty())
+ {
+ string env_path = Msp::getenv("PATH");
+ if(!env_path.empty())
+ {
+ for(const string &p: split(env_path, ':'))
+ sys_bin_path.push_back(p);
+ }
+ else
+ {
+ sys_bin_path.push_back("/bin");
+ sys_bin_path.push_back("/usr/bin");
+ }
+ }
+ path = sys_bin_path;
+ }
+
+ for(const FS::Path &p: path)
+ {
+ FS::Path filename = p/name;
+ if(FileTarget *tgt = get_target(filename))
+ {
+ builder.get_logger().log("vfs", format("Binary %s found in %s as existing %s", name, p, tgt->get_type()));
+ return tgt;
+ }
+ else if(file_exists(filename))
+ {
+ builder.get_logger().log("vfs", format("Binary %s found in %s", name, p));
+ return new Executable(builder, filename);