libvorbis: Add vorbisenc and vorbisfile support (#441)

* libvorbis: Add vorbisenc and vorbisfile support

* libvorbis: remove with_ prefix for configs

* libvorbis: handle external

* libvorbis: fix MinGW

* libvorbis: this isn't required

* libvorbis: use package:find_package

* libvorbis: fix MinGW static

* libvorbis: replace sysincludedirs by includedirs

* libvorbis: rework on_fetch
pull/444/head
Jérôme Leclercq 4 years ago committed by GitHub
parent 349e5e6dae
commit 56a833a76f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 61
      packages/l/libvorbis/xmake.lua

@ -10,13 +10,68 @@ package("libvorbis")
add_versions("1.3.7", "0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab") add_versions("1.3.7", "0e982409a9c3fc82ee06e08205b1355e5c6aa4c36bca58146ef399621b0ce5ab")
add_configs("vorbisenc", {description = "Includes vorbisenc", default = true, type = "boolean"})
add_configs("vorbisfile", {description = "Includes vorbisfile", default = true, type = "boolean"})
add_deps("cmake", "libogg") add_deps("cmake", "libogg")
on_fetch(function (package, opt)
if opt.system then
local libs = {"vorbis"}
-- vorbisenc and vorbisfile depends on vorbis, put them first to fix link order
if package:config("vorbisenc") then
table.insert(libs, 1, "vorbisenc")
end
if package:config("vorbisfile") then
table.insert(libs, 1, "vorbisfile")
end
local result
for _, name in ipairs(libs) do
local pkginfo = package:find_package(name, opt)
if not pkginfo then
return -- we must find all wanted libraries
end
if not result then
result = table.copy(pkginfo)
else
local includedirs = pkginfo.sysincludedirs or pkginfo.includedirs
result.links = table.wrap(result.links)
result.linkdirs = table.wrap(result.linkdirs)
result.includedirs = table.wrap(result.includedirs)
table.join2(result.includedirs, includedirs)
table.join2(result.linkdirs, pkginfo.linkdirs)
table.join2(result.links, pkginfo.links)
end
end
return result
end
end)
on_load(function (package)
local ext = (package:is_plat("mingw") and package:config("shared")) and ".dll" or ""
if package:config("vorbisenc") then
package:add("links", "vorbisenc" .. ext)
end
if package:config("vorbisfile") then
package:add("links", "vorbisfile" .. ext)
end
package:add("links", "vorbis" .. ext)
end)
on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package) on_install("windows", "linux", "macosx", "iphoneos", "mingw", "android", function (package)
local configs = {} local configs = {}
table.insert(configs, "-DBUILD_TESTING=OFF") table.insert(configs, "-DBUILD_TESTING=OFF")
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release")) table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF")) table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
if not package:config("vorbisenc") then
io.replace("CMakeLists.txt", "${CMAKE_CURRENT_BINARY_DIR}/vorbisenc.pc", "", {plain = true})
end
if not package:config("vorbisfile") then
io.replace("CMakeLists.txt", "${CMAKE_CURRENT_BINARY_DIR}/vorbisfile.pc", "", {plain = true})
end
-- we pass libogg as packagedeps instead of findOgg.cmake (it does not work) -- we pass libogg as packagedeps instead of findOgg.cmake (it does not work)
local libogg = package:dep("libogg"):fetch() local libogg = package:dep("libogg"):fetch()
if libogg then if libogg then
@ -35,4 +90,10 @@ package("libvorbis")
on_test(function (package) on_test(function (package)
assert(package:has_cfuncs("vorbis_info_init", {includes = "vorbis/codec.h"})) assert(package:has_cfuncs("vorbis_info_init", {includes = "vorbis/codec.h"}))
if package:config("vorbisenc") then
assert(package:has_cfuncs("vorbis_encode_init", {includes = "vorbis/vorbisenc.h"}))
end
if package:config("vorbisfile") then
assert(package:has_cfuncs("ov_open_callbacks", {includes = "vorbis/vorbisfile.h"}))
end
end) end)

Loading…
Cancel
Save