| 82 | } |
| 83 | |
| 84 | DefaultPath GetDefaultExecutablePath(const std::string& executable_name) { |
| 85 | const bool is_app = ::EndsWith(executable_name, ".app"); |
| 86 | |
| 87 | DefaultPath default_path{executable_name, ""}; |
| 88 | |
| 89 | // Using VULKAN_SDK environement variable |
| 90 | const Path vulkan_sdk_bin_path(Path::BIN); |
| 91 | if (!vulkan_sdk_bin_path.Empty() && !is_app) { |
| 92 | const Path search_path(vulkan_sdk_bin_path.RelativePath() + "/" + executable_name); |
| 93 | if (search_path.Exists()) { |
| 94 | default_path.executable_path = search_path.AbsolutePath(); |
| 95 | default_path.working_folder = search_path.AbsoluteDir(); |
| 96 | return default_path; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // Search the default applications from package installation (Linux) |
| 101 | if (is_app) { |
| 102 | Path search_path(std::string("/Applications/") + executable_name); |
| 103 | if (search_path.Exists() && ExactExecutableFromAppBundle(search_path)) { |
| 104 | default_path.executable_path = search_path.AbsolutePath(); |
| 105 | default_path.working_folder = search_path.AbsoluteDir(); |
| 106 | return default_path; |
| 107 | } |
| 108 | } else { |
| 109 | const Path search_path(std::string("/usr/bin/") + executable_name); |
| 110 | if (search_path.Exists()) { |
| 111 | default_path.executable_path = search_path.AbsolutePath(); |
| 112 | default_path.working_folder = search_path.AbsoluteDir(); |
| 113 | return default_path; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // Using relative path to vkconfig in case SDK is not "installed" |
| 118 | if (VKC_PLATFORM == PLATFORM_MACOS) { |
| 119 | if (is_app) { |
| 120 | Path search_path(std::string("../../") + executable_name); |
| 121 | if (search_path.Exists() && ExactExecutableFromAppBundle(search_path)) { |
| 122 | default_path.executable_path = search_path.AbsolutePath(); |
| 123 | default_path.working_folder = search_path.AbsoluteDir(); |
| 124 | return default_path; |
| 125 | } |
| 126 | } else { |
| 127 | Path search_path(std::string("../../../../macOS/bin/") + executable_name); |
| 128 | if (search_path.Exists()) { |
| 129 | default_path.executable_path = search_path.AbsolutePath(); |
| 130 | default_path.working_folder = search_path.AbsoluteDir(); |
| 131 | return default_path; |
| 132 | } |
| 133 | } |
| 134 | } else { |
| 135 | Path search_path(std::string("./") + executable_name); |
| 136 | if (search_path.Exists()) { |
| 137 | default_path.executable_path = search_path.AbsolutePath(); |
| 138 | default_path.working_folder = search_path.AbsoluteDir(); |
| 139 | return default_path; |
| 140 | } |
| 141 | } |