setup-sdl: Add support for SDL satellite libraries

From f8f5ba76e5d1acf7dee68b71c49996d2a06f3e67 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 11 Jan 2024 15:27:55 +0100
Subject: [PATCH] Add support for SDL satellite libraries

---
 README.md           |   24 +-
 action.yml          |   19 +-
 packed/index.js     | 1672 ++++++++++++++++++++++++++++---------------
 src/constants.ts    |    2 -
 src/linuxpm.ts      |  144 ----
 src/main.ts         |  730 +++++++++++--------
 src/platform.ts     |   32 +-
 src/pm.ts           |  226 ++++++
 src/repo.ts         |   46 ++
 src/version.test.ts |  118 +--
 src/version.ts      |  401 ++++++++---
 11 files changed, 2200 insertions(+), 1214 deletions(-)
 delete mode 100644 src/linuxpm.ts
 create mode 100644 src/pm.ts
 create mode 100644 src/repo.ts

diff --git a/README.md b/README.md
index f08e6a9..83c4237 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # setup-sdl
 
-This GitHub action downloads, builds and installs SDL from source. 
+This GitHub action downloads, builds and installs SDL and its satellite libraries from source. 
 
 By caching the result, subsequent workflow runs will be fast(er).
 
@@ -18,7 +18,8 @@ jobs:
         id: sdl
         with:
           install-linux-dependencies: true
-          version: sdl2-latest
+          version: 2-latest
+          version-sdl-image: 2-latest
           
       - name: 'Configure and build your project'
         run: |
@@ -32,16 +33,19 @@ This action will build SDL using the default c/c++ toolchain, with CMake configu
 
 An alternative build toolchain can be configured by using a [CMake toolchain file](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html).
 
-## SDL versions
+## versions
 
 Using the `version` option, a SDL release can be used or the latest git tag:
-- `sdl2-latest`: use the latest SDL2 release
-- `sdlx.y.z`: use exactly a SDL `x.y.z` release (example: `sdl2.8.1`)
-- `sdl2-head`: use the latest SDL2 development commit
-- `sdl3-latest`: use the latest SDL3 release
-- `sdl3-head`: use the latest SDL3 development commit
+- `2-latest`: use the latest SDL2 release
+- `x.y.z`: use exactly a SDL `x.y.z` release (example: `2.8.1`)
+- `2-head`: use the latest SDL2 development commit
+- `3-latest`: use the latest SDL3 release
+- `3-head`: use the latest SDL3 development commit
 - `<git hash>`: use an exact SDL git hash (repo: https://github.com/libsdl-org/SDL.git)
 
+Using the `version-sdl-*` inputs, it is possible to install the satellite libraries.
+They accept the same kind of input as `version`.
+
 ## Options
 
 See [action.yml](action.yml) for an overview of all options, and its defaults.
@@ -64,3 +68,7 @@ Since this version, CMake will also look for packages using environment variable
 When bumping the minimum required CMake version is not desirable, here are 2 alternative methods (pick one!):
 - Add `-DCMAKE_PREFIX_PATH=${{ steps.sdl.outputs.prefix }}` to the CMake configure command (or add SDL's prefix to an already-existing `-DCMAKE_PREFIX_PATH=` argument)
 - Add `-DCMAKE_POLICY_DEFAULT_CMP0074=NEW` to the CMake configure command (this only works when the actual CMake version is >= 3.12).
+
+### `install-linux-dependencies` does things on non-Linux GitHub runners
+
+This input will be renamed to `install-dependencies`.
diff --git a/action.yml b/action.yml
index 997813b..9836ff0 100644
--- a/action.yml
+++ b/action.yml
@@ -5,6 +5,21 @@ inputs:
     description: "Required version of SDL (2.x.y, 2-any, 2-latest, 2-head, 3-head), or git hash"
     default: "2-any"
     required: true
+  version-sdl-image:
+    description: "Version of SDL_image (2.x.y, 2-any, 2-latest, 2-head, 3-head), git hash, or <empty>"
+    required: false
+  version-sdl-mixer:
+    description: "Version of SDL_mixer (2.x.y, 2-any, 2-latest, 2-head, 3-head), git hash, or <empty>"
+    required: false
+  version-sdl-net:
+    description: "Version of SDL_net (2.x.y, 2-any, 2-latest, 2-head, 3-head), git hash, or <empty>"
+    required: false
+  version-sdl-rtf:
+    description: "Version of SDL_rtf (2.x.y, 2-any, 2-latest, 2-head, 3-head), git hash, or <empty>"
+    required: false
+  version-sdl-ttf:
+    description: "Version of SDL_ttf (2.x.y, 2-any, 2-latest, 2-head, 3-head), git hash, or <empty>"
+    required: false
   pre-release:
     description: "Allow pre-releases"
     default: "true"
@@ -23,7 +38,7 @@ inputs:
   cmake-arguments:
     description: "Extra CMake arguments during configuration"
   install-linux-dependencies:
-    description: "Install Linux dependencies"
+    description: "Install dependencies (supports apt-get, dnf, brew, and msys2-pacman)"
   shell:
     description: "Run commands as `$shell $file` (with $file containing the build commands)"
   discriminator:
@@ -40,5 +55,5 @@ outputs:
   version:
     description: "SDL version"
 runs:
-  using: "node16"
+  using: "node20"
   main: "packed/index.js"
diff --git a/packed/index.js b/packed/index.js
index cd76c5c..214d95c 100644
--- a/packed/index.js
+++ b/packed/index.js
@@ -1,201 +1,6 @@
 /******/ (() => { // webpackBootstrap
 /******/ 	var __webpack_modules__ = ({
 
-/***/ 7077:
-/***/ ((__unused_webpack_module, exports) => {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-exports.SDL_GIT_REPO = exports.NINJA_VERSION = void 0;
-exports.NINJA_VERSION = "1.11.1";
-exports.SDL_GIT_REPO = { owner: "libsdl-org", repo: "SDL" };
-
-
-/***/ }),
-
-/***/ 3262:
-/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
-
-"use strict";
-
-var __extends = (this && this.__extends) || (function () {
-    var extendStatics = function (d, b) {
-        extendStatics = Object.setPrototypeOf ||
-            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
-            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
-        return extendStatics(d, b);
-    };
-    return function (d, b) {
-        if (typeof b !== "function" && b !== null)
-            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
-        extendStatics(d, b);
-        function __() { this.constructor = d; }
-        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-    };
-})();
-var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
-    if (k2 === undefined) k2 = k;
-    var desc = Object.getOwnPropertyDescriptor(m, k);
-    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
-      desc = { enumerable: true, get: function() { return m[k]; } };
-    }
-    Object.defineProperty(o, k2, desc);
-}) : (function(o, m, k, k2) {
-    if (k2 === undefined) k2 = k;
-    o[k2] = m[k];
-}));
-var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
-    Object.defineProperty(o, "default", { enumerable: true, value: v });
-}) : function(o, v) {
-    o["default"] = v;
-});
-var __importStar = (this && this.__importStar) || function (mod) {
-    if (mod && mod.__esModule) return mod;
-    var result = {};
-    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
-    __setModuleDefault(result, mod);
-    return result;
-};
-Object.defineProperty(exports, "__esModule", ({ value: true }));
-exports.detect_package_manager = exports.create_package_manager = exports.package_manager_type_from_string = exports.PackageManagerType = void 0;
-var child_process = __importStar(__nccwpck_require__(2081));
-var core = __importStar(__nccwpck_require__(2186));
-var util_1 = __nccwpck_require__(9731);
-var PackageManagerType;
-(function (PackageManagerType) {
-    PackageManagerType["Apk"] = "apk";
-    PackageManagerType["AptGet"] = "apt-get";
-    PackageManagerType["Dnf"] = "dnf";
-    PackageManagerType["Pacman"] = "pacman";
-})(PackageManagerType || (exports.PackageManagerType = PackageManagerType = {}));
-function package_manager_type_from_string(text) {
-    switch (text.trim().toLowerCase()) {
-        case "apk":
-        case "alpine":
-            return PackageManagerType.Apk;
-        case "aptget":
-        case "apt-get":
-        case "ubuntu":
-        case "debian":
-            return PackageManagerType.AptGet;
-        case "dnf":
-        case "fedora":
-        case "rhel":
-            return PackageManagerType.Dnf;
-        case "pacman":
-        case "arch":
-            return PackageManagerType.Pacman;
-    }
-    throw new util_1.SetupSdlError("Unknown package manager \"".concat(text, "\""));
-}
-exports.package_manager_type_from_string = package_manager_type_from_string;
-var PackageManager = /** @class */ (function () {
-    function PackageManager(type) {
-        this.type = type;
-        this.sudo = command_exists("sudo");
-    }
-    PackageManager.prototype.maybe_sudo_execute = function (command) {
-        command = (this.sudo ? " sudo " : "") + command;
-        core.info("Executing \"".concat(command, "\""));
-        child_process.execSync(command, { stdio: "inherit" });
-    };
-    return PackageManager;
-}());
-var AptGetPackageManager = /** @class */ (function (_super) {
-    __extends(AptGetPackageManager, _super);
-    function AptGetPackageManager() {
-        return _super.call(this, PackageManagerType.AptGet) || this;
-    }
-    AptGetPackageManager.prototype.update = function () {
-        this.maybe_sudo_execute("apt-get update -y");
-    };
-    AptGetPackageManager.prototype.install = function (packages) {
-        this.maybe_sudo_execute("apt-get install -y ".concat(packages.join(" ")));
-    };
-    return AptGetPackageManager;
-}(PackageManager));
-var DnfPackageManager = /** @class */ (function (_super) {
-    __extends(DnfPackageManager, _super);
-    function DnfPackageManager() {
-        return _super.call(this, PackageManagerType.Dnf) || this;
-    }
-    DnfPackageManager.prototype.update = function () {
-        // Not needed
-    };
-    DnfPackageManager.prototype.install = function (packages) {
-        this.maybe_sudo_execute("dnf install -y ".concat(packages.join(" ")));
-    };
-    return DnfPackageManager;
-}(PackageManager));
-var ApkPackageManager = /** @class */ (function (_super) {
-    __extends(ApkPackageManager, _super);
-    function ApkPackageManager() {
-        return _super.call(this, PackageManagerType.Apk) || this;
-    }
-    ApkPackageManager.prototype.update = function () {
-        // Not needed
-    };
-    ApkPackageManager.prototype.install = function (packages) {
-        this.maybe_sudo_execute("apk add ".concat(packages.join(" ")));
-    };
-    return ApkPackageManager;
-}(PackageManager));
-var PacmanPackageManager = /** @class */ (function (_super) {
-    __extends(PacmanPackageManager, _super);
-    function PacmanPackageManager() {
-        return _super.call(this, PackageManagerType.Pacman) || this;
-    }
-    PacmanPackageManager.prototype.update = function () {
-        // Not needed
-    };
-    PacmanPackageManager.prototype.install = function (packages) {
-        this.maybe_sudo_execute("pacman -S".concat(packages.join(" ")));
-    };
-    return PacmanPackageManager;
-}(PackageManager));
-function create_package_manager(type) {
-    switch (type) {
-        case PackageManagerType.AptGet:
-            return new AptGetPackageManager();
-        case PackageManagerType.Apk:
-            return new ApkPackageManager();
-        case PackageManagerType.Pacman:
-            return new PacmanPackageManager();
-        case PackageManagerType.Dnf:
-            return new DnfPackageManager();
-    }
-}
-exports.create_package_manager = create_package_manager;
-function command_exists(name) {
-    try {
-        child_process.execSync("command -v ".concat(name));
-        return true;
-    }
-    catch (e) {
-        return false;
-    }
-}
-function detect_package_manager() {
-    if (command_exists("apt-get")) {
-        return PackageManagerType.AptGet;
-    }
-    else if (command_exists("apk")) {
-        return PackageManagerType.Apk;
-    }
-    else if (command_exists("pacman")) {
-        return PackageManagerType.Pacman;
-    }
-    else if (command_exists("dnf")) {
-        return PackageManagerType.Dnf;
-    }
-    return undefined;
-}
-exports.detect_package_manager = detect_package_manager;
-
-
-/***/ }),
-
 /***/ 9538:
 /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
 
@@ -269,8 +74,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
     }
     return to.concat(ar || Array.prototype.slice.call(from));
 };
-var _a;
 Object.defineProperty(exports, "__esModule", ({ value: true }));
+exports.Executor = void 0;
 var child_process = __importStar(__nccwpck_require__(2081));
 var crypto = __importStar(__nccwpck_require__(6113));
 var fs = __importStar(__nccwpck_require__(7147));
@@ -280,79 +85,57 @@ var cache = __importStar(__nccwpck_require__(7799));
 var core = __importStar(__nccwpck_require__(2186));
 var rest_1 = __nccwpck_require__(5375);
 var AdmZip = __nccwpck_require__(6761);
-var constants_1 = __nccwpck_require__(7077);
+var repo_1 = __nccwpck_require__(8130);
 var util_1 = __nccwpck_require__(9731);
-var linuxpm = __importStar(__nccwpck_require__(3262));
+var pm = __importStar(__nccwpck_require__(7964));
 var version_1 = __nccwpck_require__(6970);
 var platform_1 = __nccwpck_require__(5527);
-function convert_git_branch_tag_to_hash(args) {
-    return __awaiter(this, void 0, void 0, function () {
-        var _this = this;
-        return __generator(this, function (_a) {
-            switch (_a.label) {
-                case 0: return [4 /*yield*/, core.group("Calculating git hash of ".concat(args.branch_or_hash), function () { return __awaiter(_this, void 0, void 0, function () {
-                        var response, sha, e_1, response, e_2;
-                        return __generator(this, function (_a) {
-                            switch (_a.label) {
-                                case 0:
-                                    _a.trys.push([0, 2, , 3]);
-                                    core.debug("Look for a branch named \"".concat(args.branch_or_hash, "\"..."));
-                                    return [4 /*yield*/, args.octokit.rest.repos.getBranch({
-                                            owner: constants_1.SDL_GIT_REPO.owner,
-                                            repo: constants_1.SDL_GIT_REPO.repo,
-                                            branch: args.branch_or_hash,
-                                        })];
-                                case 1:
-                                    response = _a.sent();
-                                    core.debug("It was a branch.");
-                                    sha = response.data.commit.sha;
-                                    core.info("git hash = ".concat(sha));
-                                    return [2 /*return*/, sha];
-                                case 2:
-                                    e_1 = _a.sent();
-                                    core.debug("It was not a branch.");
-                                    return [3 /*break*/, 3];
-                                case 3:
-                                    _a.trys.push([3, 5, , 6]);
-                                    core.debug("Look for a commit named \"".concat(args.branch_or_hash, "\"..."));
-                                    return [4 /*yield*/, args.octokit.rest.repos.getCommit({
-                                            owner: constants_1.SDL_GIT_REPO.owner,
-                                            repo: constants_1.SDL_GIT_REPO.repo,
-                                            ref: args.branch_or_hash,
-                                        })];
-                                case 4:
-                                    response = _a.sent();
-                                    core.debug("It was a commit.");
-                                    return [2 /*return*/, response.data.sha];
-                                case 5:
-                                    e_2 = _a.sent();
-                                    core.debug("It was not a commit.");
-                                    return [3 /*break*/, 6];
-                                case 6: throw new util_1.SetupSdlError("Unable to convert ".concat(args.branch_or_hash, " into a git hash."));
-                            }
-                        });
-                    }); })];
-                case 1: return [2 /*return*/, _a.sent()];
-            }
+function read_gitmodules(path) {
+    if (!fs.existsSync(path)) {
+        return [];
+    }
+    var submodules = [];
+    var sdl_repo_regex = /https:\/\/github\.com\/([a-zA-Z0-9_-]+)\/([0-9a-zA-Z_-]+)(\.git)?/;
+    var gitmodules_lines = fs
+        .readFileSync(path, { encoding: "utf8" })
+        .trim()
+        .split("\n");
+    for (var i = 0; 4 * i + 3 <= gitmodules_lines.length; i += 1) {
+        var path_1 = gitmodules_lines[4 * i + 1].split("=")[1].trim();
+        var url = gitmodules_lines[4 * i + 2].split("=")[1].trim();
+        var match = url.match(sdl_repo_regex);
+        if (!match) {
+            throw new util_1.SetupSdlError("Unable to extract owner/name from \"".concat(url, "\""));
+        }
+        var repo_owner = match[1];
+        var repo_name = match[2];
+        var branch = gitmodules_lines[4 * i + 3].split("=")[1].trim();
+        submodules.push({
+            path: path_1,
+            repo_owner: repo_owner,
+            repo_name: repo_name,
+            branch: branch,
         });
-    });
+    }
+    return submodules;
 }
-function download_sdl_git_hash(args) {
+function download_git_repo(args) {
     return __awaiter(this, void 0, void 0, function () {
+        var submodules, _i, submodules_1, submodule, submodule_hash, submodule_directory;
         var _this = this;
         return __generator(this, function (_a) {
             switch (_a.label) {
                 case 0:
                     fs.mkdirSync(args.directory, { recursive: true });
-                    return [4 /*yield*/, core.group("Downloading and extracting ".concat(args.git_hash, " into ").concat(args.directory), function () { return __awaiter(_this, void 0, void 0, function () {
+                    return [4 /*yield*/, core.group("Downloading and extracting ".concat(args.repo_owner, "/").concat(args.repo_name, " (").concat(args.git_hash, ") into ").concat(args.directory), function () { return __awaiter(_this, void 0, void 0, function () {
                             var response, ARCHIVE_PATH, admzip;
                             return __generator(this, function (_a) {
                                 switch (_a.label) {
                                     case 0:
                                         core.info("Downloading git zip archive...");
                                         return [4 /*yield*/, args.octokit.rest.repos.downloadZipballArchive({
-                                                owner: constants_1.SDL_GIT_REPO.owner,
-                                                repo: constants_1.SDL_GIT_REPO.repo,
+                                                owner: args.repo_owner,
+                                                repo: args.repo_name,
                                                 ref: args.git_hash,
                                             })];
                                     case 1:
@@ -384,25 +167,67 @@ function download_sdl_git_hash(args) {
                         }); })];
                 case 1:
                     _a.sent();
-                    return [2 /*return*/];
+                    if (!args.submodules) return [3 /*break*/, 6];
+                    submodules = read_gitmodules("".concat(args.directory, "/.gitmodules"));
+                    _i = 0, submodules_1 = submodules;
+                    _a.label = 2;
+                case 2:
+                    if (!(_i < submodules_1.length)) return [3 /*break*/, 6];
+                    submodule = submodules_1[_i];
+                    return [4 /*yield*/, (0, repo_1.convert_git_branch_tag_to_hash)({
+                            branch_or_hash: submodule.branch,
+                            owner: submodule.repo_owner,
+                            repo: submodule.repo_name,
+                            octokit: args.octokit,
+                        })];
+                case 3:
+                    submodule_hash = _a.sent();
+                    submodule_directory = "".concat(args.directory, "/").concat(submodule.path);
+                    return [4 /*yield*/, download_git_repo({
+                            repo_owner: submodule.repo_owner,
+                            repo_name: submodule.repo_name,
+                            submodules: false,
+                            git_hash: submodule_hash,
+                            directory: submodule_directory,
+                            octokit: args.octokit,
+                        })];
+                case 4:
+                    _a.sent();
+                    _a.label = 5;
+                case 5:
+                    _i++;
+                    return [3 /*break*/, 2];
+                case 6: return [2 /*return*/];
             }
         });
     });
 }
-function execute_child_process(command, shell) {
-    core.info("".concat(command));
-    var final_command;
-    if (shell && shell.indexOf("{0}") >= 0) {
-        var cmd_file = "".concat(os.tmpdir, "/cmd.txt");
-        fs.writeFileSync(cmd_file, command);
-        final_command = shell.replace("{0}", cmd_file);
-        core.info("-> ".concat(final_command));
-    }
-    else {
-        final_command = command;
+var Executor = /** @class */ (function () {
+    function Executor(args) {
+        this.shell = args.shell;
     }
-    child_process.execSync(final_command, { stdio: "inherit" });
-}
+    Executor.prototype.run = function (command, stdio_inherit) {
+        if (stdio_inherit === void 0) { stdio_inherit = false; }
+        core.info("".concat(command));
+        var final_command;
+        if (this.shell && this.shell.indexOf("{0}") >= 0) {
+            var cmd_file = "".concat(os.tmpdir, "/cmd.txt");
+            fs.writeFileSync(cmd_file, command);
+            final_command = this.shell.replace("{0}", cmd_file);
+            core.info("-> ".concat(final_command));
+        }
+        else {
+            final_command = command;
+        }
+        var stdio_options = {};
+        if (stdio_inherit) {
+            stdio_options.stdio = "inherit";
+        }
+        child_process.execSync(final_command, stdio_options);
+    };
+    return Executor;
+}());
+exports.Executor = Executor;
 function cmake_configure_build(args) {
     return __awaiter(this, void 0, void 0, function () {
         var configure_args, build_args, install_args;
@@ -439,31 +264,31 @@ function cmake_configure_build(args) {
                         "--config",
                         args.build_type,
                     ];
-                    return [4 /*yield*/, core.group("Configuring SDL (CMake)", function () { return __awaiter(_this, void 0, void 0, function () {
+                    return [4 /*yield*/, core.group("Configuring ".concat(args.project, " (CMake)"), function () { return __awaiter(_this, void 0, void 0, function () {
                             var configure_command;
                             return __generator(this, function (_a) {
                                 configure_command = configure_args.join(" ");
-                                execute_child_process(configure_command, args.shell);
+                                args.executor.run(configure_command, true);
                                 return [2 /*return*/];
                             });
                         }); })];
                 case 1:
                     _a.sent();
-                    return [4 /*yield*/, core.group("Building SDL (CMake)", function () { return __awaiter(_this, void 0, void 0, function () {
+                    return [4 /*yield*/, core.group("Building ".concat(args.project, " (CMake)"), function () { return __awaiter(_this, void 0, void 0, function () {
                             var build_command;
                             return __generator(this, function (_a) {
                                 build_command = build_args.join(" ");
-                                execute_child_process(build_command, args.shell);
+                                args.executor.run(build_command, true);
                                 return [2 /*return*/];
                             });
                         }); })];
                 case 2:
                     _a.sent();
-                    return [4 /*yield*/, core.group("Installing SDL (CMake)", function () { return __awaiter(_this, void 0, void 0, function () {
+                    return [4 /*yield*/, core.group("Installing ".concat(args.project, " (CMake)"), function () { return __awaiter(_this, void 0, void 0, function () {
                             var install_command;
                             return __generator(this, function (_a) {
                                 install_command = install_args.join(" ");
-                                execute_child_process(install_command, args.shell);
+                                args.executor.run(install_command, true);
                                 return [2 /*return*/];
                             });
                         }); })];
@@ -516,7 +341,7 @@ function calculate_state_hash(args) {
     var misc_state = [
         "GIT_HASH=".concat(args.git_hash),
         "build_platform=".concat(args.build_platform),
-        "shell=".concat(args.shell),
+        "shell=".concat(args.executor.shell),
     ];
     if (args.package_manager) {
         misc_state.push("package_manager=".concat(args.package_manager));
@@ -534,6 +359,9 @@ function calculate_state_hash(args) {
     if (args.cmake_configure_arguments) {
         misc_state.push("cmake_arguments=".concat(args.cmake_configure_arguments));
     }
+    for (var dep in args.dependency_hashes) {
+        misc_state.push("dependency_".concat(dep, "=").concat(args.dependency_hashes[dep]));
+    }
     var complete_state = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
         "ENVIRONMENT"
     ], env_state, true), [
@@ -577,80 +405,11 @@ function get_cmake_toolchain_path() {
     }
     return undefined;
 }
-var SDL_LINUX_DEPENDENCIES = (_a = {},
-    _a[linuxpm.PackageManagerType.AptGet] = {
-        required: [
-            "cmake",
-            "make",
-            "ninja-build",
-            "libasound2-dev",
-            "libpulse-dev",
-            "libaudio-dev",
-            "libjack-dev",
-            "libsndio-dev",
-            "libusb-1.0-0-dev",
-            "libx11-dev",
-            "libxext-dev",
-            "libxrandr-dev",
-            "libxcursor-dev",
-            "libxfixes-dev",
-            "libxi-dev",
-            "libxss-dev",
-            "libwayland-dev",
-            "libxkbcommon-dev",
-            "libdrm-dev",
-            "libgbm-dev",
-            "libgl1-mesa-dev",
-            "libgles2-mesa-dev",
-            "libegl1-mesa-dev",
-            "libdbus-1-dev",
-            "libibus-1.0-dev",
-            "libudev-dev",
-            "fcitx-libs-dev",
-        ],
-        optional: [
-            "libpipewire-0.3-dev" /* Ubuntu 22.04 */,
-            "libdecor-0-dev" /* Ubuntu 22.04 */,
-        ],
-    },
-    _a[linuxpm.PackageManagerType.Dnf] = {
-        required: [
-            "cmake",
-            "make",
-            "ninja-build",
-            "alsa-lib-devel",
-            "dbus-devel",
-            "ibus-devel",
-            "libusb1-devel",
-            "libX11-devel",
-            "libXau-devel",
-            "libXScrnSaver-devel",
-            "libXcursor-devel",
-            "libXext-devel",
-            "libXfixes-devel",
-            "libXi-devel",
-            "libXrandr-devel",
-            "libxkbcommon-devel",
-            "libdecor-devel",
-            "libglvnd-devel",
-            "pipewire-devel",
-            "pipewire-jack-audio-connection-kit-devel",
-            "pulseaudio-libs-devel",
-            "wayland-devel",
-        ],
-        optional: [],
-    },
-    _a[linuxpm.PackageManagerType.Apk] = undefined,
-    _a[linuxpm.PackageManagerType.Pacman] = undefined,
-    _a);
-function parse_linux_package_manager(input, build_platform) {
-    if (build_platform != platform_1.SdlBuildPlatform.Linux) {
-        return undefined;
-    }
-    if (!input) {
+function parse_package_manager(args) {
+    if (!args.input) {
         return undefined;
     }
-    input = input.trim().toLowerCase();
+    var input = args.input.trim().toLowerCase();
     if (input.length == 0) {
         return undefined;
     }
@@ -658,29 +417,36 @@ function parse_linux_package_manager(input, build_platform) {
         return undefined;
     }
     else if (input == "true") {
-        return linuxpm.detect_package_manager();
+        return pm.detect_package_manager({ build_platform: args.build_platform });
     }
     else {
-        return linuxpm.package_manager_type_from_string(input);
+        return pm.package_manager_type_from_string(input);
     }
 }
-function install_linux_dependencies(package_manager_type) {
+function install_dependencies(args) {
     return __awaiter(this, void 0, void 0, function () {
-        var package_manager, packages;
+        var package_manager, pm_packages;
         var _this = this;
         return __generator(this, function (_a) {
             switch (_a.label) {
                 case 0:
-                    package_manager = linuxpm.create_package_manager(package_manager_type);
-                    packages = SDL_LINUX_DEPENDENCIES[package_manager_type];
-                    if (!packages) {
-                        throw new util_1.SetupSdlError("Don't know what packages to install for ".concat(package_manager_type, ". Please create a pr."));
+                    package_manager = pm.create_package_manager({
+                        type: args.package_manager_type,
+                        executor: args.executor,
+                    });
+                    pm_packages = args.packages[args.package_manager_type];
+                    if (pm_packages && !package_manager) {
+                        core.info("Don't know how to install packages the for current platform (".concat(args.package_manager_type, "). Please create a pr."));
+                        return [2 /*return*/];
                     }
-                    return [4 /*yield*/, core.group("Installing SDL dependencies using ".concat(package_manager_type), function () { return __awaiter(_this, void 0, void 0, function () {
+                    if (!pm_packages) {
+                        return [2 /*return*/];
+                    }
+                    return [4 /*yield*/, core.group("Installing ".concat(args.project, " dependencies using ").concat(args.package_manager_type), function () { return __awaiter(_this, void 0, void 0, function () {
                             return __generator(this, function (_a) {
                                 package_manager.update();
-                                package_manager.install(packages.required);
-                                packages.optional.forEach(function (optional_package) {
+                                package_manager.install(pm_packages.required);
+                                pm_packages.optional.forEach(function 

(Patch may be truncated, please check the link at the top of this post.)