File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
Tools/EcsactUnrealCodegen Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,33 @@ constexpr auto HELP_MSG =
3131 // clang-format on
3232 " See https://ecsact.dev/start/unreal for more details\n\n " ;
3333
34- auto find_ecsact_exe () -> std::optional<fs::path> {
34+ constexpr auto platform_exec_ext () -> std::string {
35+ #ifdef _WIN32
36+ return " .exe" ;
37+ #else
38+ return " " ;
39+ #endif
40+ }
41+
42+ /* *
43+ * Find ecsact executable in priority order
44+ * 1. the executable in the same parent directory as this one
45+ * 2. the executable found in PATH
46+ * 3. (windows only workaround) in LocalAppData/Microsoft/WindowsApps
47+ */
48+ auto find_ecsact_exe (const char * argv0) -> std::optional<fs::path> {
49+ auto ec = std::error_code{};
50+ auto argv0_canon = fs::canonical (argv0, ec);
51+ if (!ec) {
52+ if (argv0_canon.has_parent_path ()) {
53+ auto exe_neighbour =
54+ argv0_canon.parent_path () / (" ecsact" + platform_exec_ext ());
55+ if (fs::exists (exe_neighbour)) {
56+ return exe_neighbour;
57+ }
58+ }
59+ }
60+
3561 auto found_exe = bp::search_path (" ecsact" ).generic_string ();
3662 if (!found_exe.empty ()) {
3763 return found_exe;
@@ -255,7 +281,7 @@ auto main(int argc, char* argv[]) -> int {
255281 assert (!project_file.empty ());
256282
257283 auto env = boost::process::native_environment{};
258- auto ecsact_cli = find_ecsact_exe ();
284+ auto ecsact_cli = find_ecsact_exe (argv[ 0 ] );
259285 if (!ecsact_cli) {
260286 std::cerr << " ERROR: Cannot find 'ecsact' in PATH " SDK_PLEASE;
261287 return -1 ;
You can’t perform that action at this time.
0 commit comments