Skip to content

Commit

Permalink
fix(libvpx): fix wasm build
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamOfIce committed Sep 17, 2023
1 parent b6fae4d commit 4db7399
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 37 deletions.
65 changes: 33 additions & 32 deletions packages/l/libvpx/port/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,36 @@ includes("check_csnippets.lua")
add_moduledirs("xmake/scripts")
add_imports("core.project.project", "lib.detect.find_tool", "rtcd", "utils")
add_rules("asm", "mode.debug", "mode.release")
set_languages("gnu89")
set_config("buildir", "xmake_build")

local arch, fullarch
if is_arch("x86") then
arch = "x86"
fullarch = "x86"
elseif is_arch("x64", "x86_64") then
arch = "x86"
fullarch = "x86_64"
elseif is_arch("aarch64.*", "armv8.*") then
arch = "arm"
fullarch = "aarch64"
elseif is_arch("arm.*") then
arch = "arm"
fullarch = "arm"
elseif is_arch("loongarch.*") then
arch = "loongarch"
fullarch = "loongarch"
elseif is_arch("mips.*") then
arch = "mips"
fullarch = "mips"
elseif is_arch("ppc.*", "powerpc.*") then
arch = "ppc"
fullarch = "ppc"
else
arch = "unknown"
fullarch = ""
end

option("vp8", function()
add_deps("vp8-encoder", "vp8-decoder")
set_description("VP8 codec support")
Expand Down Expand Up @@ -151,6 +179,11 @@ end)
option("runtime-cpu-detect", function()
set_description("runtime cpu detection")
set_default(true)
after_check(function(opt)
if arch == "unknown" then
opt:enable(false)
end
end)
end)

option("multi-res-encoding", function()
Expand Down Expand Up @@ -179,34 +212,6 @@ option("libyuv", function()
set_default(false)
end)

-- platform extendtions
local arch, fullarch

if is_arch("x86") then
arch = "x86"
fullarch = "x86"
elseif is_arch("x64", "x86_64") then
arch = "x86"
fullarch = "x86_64"
elseif is_arch("aarch64.*", "armv8.*") then
arch = "arm"
fullarch = "aarch64"
elseif is_arch("arm.*") then
arch = "arm"
fullarch = "arm"
elseif is_arch("loongarch.*") then
arch = "loongarch"
fullarch = "loongarch"
elseif is_arch("mips.*") then
arch = "mips"
fullarch = "mips"
elseif is_arch("ppc.*", "powerpc.*") then
arch = "ppc"
fullarch = "ppc"
else
arch = "unknown"
end

local exts = {
x86 = {{
name = "mmx",
Expand Down Expand Up @@ -309,10 +314,6 @@ on_load(function(target)
target:add("cxflags", "-mfloat-abi=soft")
end
end

if project.option("pic") or vformat("$(kind)") == "shared" then
-- target:add("cxflags", "-fPIC")
end
end
end)

Expand Down
14 changes: 14 additions & 0 deletions packages/l/libvpx/port/xmake/scripts/rtcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ static void setup_rtcd_internal(void)
suffix = [[
}
#endif
]]
},
unknown = {
prefix = [[
#include "vpx_config.h"
#ifdef RTCD_C
static void setup_rtcd_internal(void)
{
]],
suffix = [[
}
#endif
]]
}
}
Expand Down Expand Up @@ -275,6 +288,7 @@ function _write_header(output, arch, all_exts, functions, aliases, decls)
file:write(setup[arch].prefix)
file:write(rtcd_content)
file:write(setup[arch].suffix)
file:write("void " .. path.basename(output):gsub("%-", "_") .. "();\n") -- avoid emscripten/emscripten-core#2175
file:write(common_buttom)
file:close()
end
Expand Down
11 changes: 6 additions & 5 deletions packages/l/libvpx/port/xmake/scripts/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ function add_arch_files(target, prefix, arch, fullarch, all_exts)
end
end
for _, ext in ipairs(exts) do
for _, file in ipairs(table.join(os.files(path.join(prefix, arch, "**_" .. ext .. ".*|*.h")),
os.files(path.join(prefix, arch, "**_" .. arch .. ".*|*.h")),
os.files(path.join(prefix, arch, "**_" .. fullarch .. ".*|*.h")),
os.files(path.join(prefix, "generic", "*.*|*.h")))) do
target:add("files", file)
for _, file in ipairs(table.join(os.files(path.join(prefix, arch, "**_" .. ext .. ".*")),
os.files(path.join(prefix, arch, "**_" .. arch .. ".*")),
os.files(path.join(prefix, arch, "**_" .. fullarch .. ".*")), os.files(path.join(prefix, "generic", "*")))) do
if path.extension(file) ~= ".h" then
target:add("files", file)
end
end
end
end
Expand Down

0 comments on commit 4db7399

Please sign in to comment.