From cb39eadaeea00b1fc6800c241badf28bd01a1b5e Mon Sep 17 00:00:00 2001 From: xqyjlj Date: Fri, 15 Dec 2023 17:09:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(sdl2=5Fimage):=20fix=20sdl2?= =?UTF-8?q?=5Fimage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/RT-Thread/userapps/issues/42 --- repo/packages/s/sdl2_image/xmake.lua | 51 ++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/repo/packages/s/sdl2_image/xmake.lua b/repo/packages/s/sdl2_image/xmake.lua index b78035c..19b2a82 100644 --- a/repo/packages/s/sdl2_image/xmake.lua +++ b/repo/packages/s/sdl2_image/xmake.lua @@ -35,11 +35,38 @@ do type = "boolean" }) + local features = { + bmp = {boolean = true, package = nil}, + gif = {boolean = false, package = "unsupport!!!"}, + jpg = {boolean = true, package = "libjpeg"}, + lbm = {boolean = false, package = "unsupport!!!"}, + pcx = {boolean = false, package = "unsupport!!!"}, + png = {boolean = true, package = "libpng"}, + pnm = {boolean = false, package = "unsupport!!!"}, + svg = {boolean = false, package = "unsupport!!!"}, + tga = {boolean = false, package = "unsupport!!!"}, + tif = {boolean = false, package = "unsupport!!!"}, + xcf = {boolean = false, package = "unsupport!!!"}, + xpm = {boolean = false, package = "unsupport!!!"}, + xv = {boolean = false, package = "unsupport!!!"}, + webp = {boolean = false, package = "unsupport!!!"} + } + + for feature, cfg in pairs(features) do + add_configs(feature, + {description = "enable " .. feature .. " support.", default = cfg.boolean, type = "boolean"}) + end + on_load(function(package) package:add("deps", "zlib", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) - package:add("deps", "libpng", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) - package:add("deps", "libjpeg", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) package:add("deps", "sdl2", {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + for feature, cfg in pairs(features) do + if package:config(feature) and cfg.package then + package:add("deps", cfg.package, + {debug = package:config("debug"), configs = {shared = package:config("shared")}}) + end + end + end) on_install("cross@linux", function(package) @@ -51,6 +78,7 @@ do local ldflags = {} os.setenv("PATH", path.directory(cc) .. ":" .. os.getenv("PATH")) local sdl2 = package:dep("sdl2") + local packagedeps = {"sdl2", "zlib"} if package:config("shared") then table.insert(configs, "--enable-shared=yes") @@ -60,12 +88,23 @@ do table.insert(configs, "--enable-static=yes") end + table.insert(configs, "--enable-jpg-shared=no") + table.insert(configs, "--enable-png-shared=no") + table.insert(configs, "--enable-tif-shared=no") + table.insert(configs, "--enable-webp-shared=no") + + for feature, cfg in pairs(features) do + if package:config(feature) and cfg.package then + table.insert(packagedeps, cfg.package) + end + table.insert(configs, string.format("--enable-%s=%s", feature, package:config(feature) and "yes" or "no")) + end + table.insert(configs, "--build=i686-pc-linux-gnu") table.insert(configs, "--with-sdl-prefix=" .. sdl2:installdir()) - local buildenvs = import("package.tools.autoconf").buildenvs(package, { - ldflags = ldflags, - packagedeps = {"libpng", "libjpeg", "sdl2", "zlib"} - }) + + local buildenvs = import("package.tools.autoconf").buildenvs(package, + {ldflags = ldflags, packagedeps = packagedeps}) -- os.vrun("autoreconf -fiv || true", {envs = buildenvs}) import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) import("package.tools.make").install(package, {}, {envs = buildenvs})