|
|
|
@ -10,13 +10,68 @@ package("libvorbis") |
|
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
local configs = {} |
|
|
|
|
table.insert(configs, "-DBUILD_TESTING=OFF") |
|
|
|
|
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")) |
|
|
|
|
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) |
|
|
|
|
local libogg = package:dep("libogg"):fetch() |
|
|
|
|
if libogg then |
|
|
|
@ -35,4 +90,10 @@ package("libvorbis") |
|
|
|
|
|
|
|
|
|
on_test(function (package) |
|
|
|
|
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) |
|
|
|
|