Skip to content

Commit

Permalink
Merge pull request #51 from xqyjlj/xq/sdl2_image-dev
Browse files Browse the repository at this point in the history
🐞 fix(sdl2_image): fix sdl2_image
  • Loading branch information
BernardXiong authored Feb 16, 2024
2 parents d365787 + cb39ead commit 1ad52ff
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions repo/packages/s/sdl2_image/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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})
Expand Down

0 comments on commit 1ad52ff

Please sign in to comment.