|
@@ -34,79 +34,6 @@ package("libvpx")
|
|
add_deps("which")
|
|
add_deps("which")
|
|
end
|
|
end
|
|
|
|
|
|
- -- array utils
|
|
|
|
- function filter(array, filter)
|
|
|
|
- local result = {}
|
|
|
|
- for idx, val in ipairs(array) do
|
|
|
|
- if filter(val, idx, array) then
|
|
|
|
- table.insert(result, val)
|
|
|
|
- end
|
|
|
|
- end
|
|
|
|
- return result
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- function find(array, filter)
|
|
|
|
- for idx, val in ipairs(array) do
|
|
|
|
- if filter(val, idx, array) then
|
|
|
|
- return val
|
|
|
|
- end
|
|
|
|
- end
|
|
|
|
- return nil
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- function get_target(package)
|
|
|
|
- import("core.tool.compiler")
|
|
|
|
- local default_plat = "generic-gnu"
|
|
|
|
-
|
|
|
|
- local platforms = {}
|
|
|
|
- for plat in io.readfile("configure"):gmatch("all_platforms=\"%${all_platforms} ([%a%d-]-)\"") do
|
|
|
|
- table.insert(targets, plat:split("-", {plain = true}))
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- local arch = package:targetarch()
|
|
|
|
- if arch:startswith("arm64") then
|
|
|
|
- arch = "arm64"
|
|
|
|
- elseif arch == "armeabi-v7a" then
|
|
|
|
- arch = "armv7"
|
|
|
|
- elseif arch == "x64" then
|
|
|
|
- arch = "x86_64"
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- local os
|
|
|
|
- if package:is_targetos("iphoneos") then
|
|
|
|
- if package:is_targetarch("x64", "x86", "x86_64") then
|
|
|
|
- os = "iphonesimulator"
|
|
|
|
- else
|
|
|
|
- os = "darwin"
|
|
|
|
- end
|
|
|
|
- elseif package:is_targetos("macosx", "watchos") then
|
|
|
|
- os = "darwin"
|
|
|
|
- elseif package:is_targetos("cygwin", "mingw", "windows") then
|
|
|
|
- os = "win"
|
|
|
|
- else
|
|
|
|
- os = package:targetos()
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- local cc = path.basename(compiler.compcmd("foo.c")):split(" ", {plain = true})[1]:lower()
|
|
|
|
- if cc == "clang" or cc == "emcc" then
|
|
|
|
- cc = "gcc"
|
|
|
|
- elseif cc == "cl" then
|
|
|
|
- cc = "vs"
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
- local matched_plats
|
|
|
|
- matched_plats = filter(platforms, function (p) return p[1] == arch end)
|
|
|
|
- local tmp = filter(matched_plats, function (p) return p[2] == os end)
|
|
|
|
- matched_plats = #tmp == 0 and filter(matched_plats, function (p) return p[2]:startswith(plat) end) or tmp
|
|
|
|
- tmp = nil
|
|
|
|
- if #matched_plats == 0 then
|
|
|
|
- cprint("${yellow}warning: ${clear}no matching platform for " .. os .. "-" .. arch " " .. cc .. ", use " .. default_plat)
|
|
|
|
- end
|
|
|
|
- local result = find(platforms, function(p) return p[3] == cc end) or find(platforms, function(p) return p[3]:startswith(cc) end) or platforms[1]
|
|
|
|
- cprint("${green}info: ${clear}use target platform ${blue}" .. result .. "${clear}")
|
|
|
|
- return result
|
|
|
|
- end
|
|
|
|
-
|
|
|
|
on_load(function (package)
|
|
on_load(function (package)
|
|
if package:is_targetarch("x64", "x86_64") then
|
|
if package:is_targetarch("x64", "x86_64") then
|
|
if package:is_plat("freebsd") then
|
|
if package:is_plat("freebsd") then
|
|
@@ -129,7 +56,8 @@ package("libvpx")
|
|
if package:is_plat("wasm") then
|
|
if package:is_plat("wasm") then
|
|
table.join2(configs, {"--target=generic-gnu", "--disable-install-bins"})
|
|
table.join2(configs, {"--target=generic-gnu", "--disable-install-bins"})
|
|
elseif package:is_cross() then
|
|
elseif package:is_cross() then
|
|
- table.insert(configs, "--target=" .. get_target(package))
|
|
|
|
|
|
+ import("utils")
|
|
|
|
+ table.insert(configs, "--target=" .. utils.get_target(package))
|
|
end
|
|
end
|
|
|
|
|
|
local source_dir = os.curdir()
|
|
local source_dir = os.curdir()
|