diff --git a/core/relinker/cli/include/Cli.hpp b/core/relinker/cli/include/Cli.hpp index 6348d38b5..9e44a1d9a 100644 --- a/core/relinker/cli/include/Cli.hpp +++ b/core/relinker/cli/include/Cli.hpp @@ -22,7 +22,7 @@ struct Args { std::uint32_t unusedFilterLevel = 0; std::string inputPath; std::string outputPath; - std::string sceModulePath = "."; + std::string sceModulePath; std::string runPath = "$ORIGIN/libs"; std::set excludedSceModules; }; diff --git a/core/relinker/cli/src/CliArgs.cpp b/core/relinker/cli/src/CliArgs.cpp index 2c5873abd..8fcda4b31 100644 --- a/core/relinker/cli/src/CliArgs.cpp +++ b/core/relinker/cli/src/CliArgs.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -86,6 +87,8 @@ Args ParseArgs(int argc, char* argv[]) { throw std::runtime_error(Usage()); + if (!sceModulePathSpecified && !args.skipSceModule && !args.inputPath.empty()) args.sceModulePath = std::filesystem::absolute(args.inputPath).parent_path().string(); + return args; } diff --git a/core/relinker/relinker/tests/test_sce_module_path.py b/core/relinker/relinker/tests/test_sce_module_path.py index 8458d41d7..987c9e619 100644 --- a/core/relinker/relinker/tests/test_sce_module_path.py +++ b/core/relinker/relinker/tests/test_sce_module_path.py @@ -34,7 +34,12 @@ def main(): run("absolute", ["--sce-module-path", str(parent)], artifact=True) run("relative", ["--sce-module-path", "module root"], artifact=True) - run("default", [], cwd=parent, artifact=True) + inputModules = source.parent / "sce_module" + inputModules.mkdir() + (inputModules / "needed.prx").write_bytes(guest_fixture(PLAIN_SITE)) + run("default", [], artifact=True) + (inputModules / "needed.prx").unlink() + inputModules.rmdir() run("explicit-dot", ["--sce-module-path", "."], cwd=parent, artifact=True) run("skip", ["--skip-sce-module"]) run("conflict", ["--sce-module-path", str(parent), "--skip-sce-module"], error="conflicts with --skip-sce-module") @@ -46,7 +51,7 @@ def main(): run("missing-parent", ["--sce-module-path", "absent"], error="parent directory does not exist") run("file-parent", ["--sce-module-path", str(source)], error="parent path is not a directory") run("wrong-level", ["--sce-module-path", str(modules)], error="--skip-sce-module") - run("module-directory-is-file", [], error="Guest module path is not a directory") + run("module-directory-is-file", ["--sce-module-path", "."], error="Guest module path is not a directory") (parent / "sce_modules").mkdir() run("ambiguous", ["--sce-module-path", str(parent)], error="Both sce_module and sce_modules") (parent / "sce_modules").rmdir() diff --git a/docs/user/USAGE.md b/docs/user/USAGE.md index b2f364aca..a987b28e8 100644 --- a/docs/user/USAGE.md +++ b/docs/user/USAGE.md @@ -2,7 +2,7 @@ ## Input and conversion -Use a clean ELF executable. Place its bundled ELF modules in `sce_module/`, `sce_modules/`, or `prx/` under the current working directory, or under the parent directory selected with `--sce-module-path `. The option accepts absolute paths and paths relative to the current working directory; do not include the `sce_module` directory itself. Only files directly inside the module directories are processed. A bundled module in a SELF container is an error, as the executable is. `prx/` can coexist with either `sce_module/` or `sce_modules/`. Both `sce_module/` and `sce_modules/` present, or all three absent, is an error. +Use a clean ELF executable. Place its bundled ELF modules in `sce_module/`, `sce_modules/`, or `prx/` beside the input executable, or under the parent directory selected with `--sce-module-path `. The option accepts absolute paths and paths relative to the current working directory; do not include the `sce_module` directory itself. Only files directly inside the module directories are processed. A bundled module in a SELF container is an error, as the executable is. `prx/` can coexist with either `sce_module/` or `sce_modules/`. Both `sce_module/` and `sce_modules/` present, or all three absent, is an error. ```text source/ @@ -54,7 +54,7 @@ All switches are disabled by default. `unused-filter` defaults to `0`; `--rpath` | `--registry` | Write `.registry.json` beside the output executable, and `..registry.json` for each converted bundled module. | | `--rpath ` | Set the system library search path. Quote `$ORIGIN` to prevent shell expansion, for example `--rpath '$ORIGIN/libs'` in Bash or PowerShell. Linux guest modules require an absolute path or a path beginning with `$ORIGIN`. Windows requires a nonempty ASCII path and supports `$ORIGIN` as the executable directory. | | `--autorun` | Run the output after conversion, print its exit code, and wait for Enter. Adds executable permissions for Linux output. Requires the target OS and prepared runtime layout. | -| `--sce-module-path ` | Set the parent directory of bundled module directories (default: current working directory). Conflicts with `--skip-sce-module`. | +| `--sce-module-path ` | Set the parent directory of bundled module directories (default: the input ELF parent directory). Conflicts with `--skip-sce-module`. | | `--skip-sce-module` | Deprecated. Skip all bundled module processing. | | `--exclude-sce-module ` | Deprecated. Exclude a bundled module by exact filename, not path. Repeat for multiple files; a missing filename is an error. Conflicts with `--skip-sce-module`. | | `--skip-syscall-check` | Deprecated. Disable syscall scanning in the executable and bundled modules. |