|
| 1 | +-- Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +-- You may not use this file except in compliance with the License. |
| 3 | +-- You may obtain a copy of the License at |
| 4 | +-- |
| 5 | +-- http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +-- |
| 7 | +-- Unless required by applicable law or agreed to in writing, software |
| 8 | +-- distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +-- See the License for the specific language governing permissions and |
| 11 | +-- limitations under the License. |
| 12 | +-- |
| 13 | +-- Copyright (C) 2023-2023 RT-Thread Development Team |
| 14 | +-- |
| 15 | +-- @author xqyjlj |
| 16 | +-- @file xmake.lua |
| 17 | +-- |
| 18 | +-- Change Logs: |
| 19 | +-- Date Author Notes |
| 20 | +-- ------------ ---------- ----------------------------------------------- |
| 21 | +-- 2023-05-06 xqyjlj initial version |
| 22 | +-- |
| 23 | +package("ffmpeg") |
| 24 | +do |
| 25 | + set_homepage("https://www.ffmpeg.org") |
| 26 | + set_description( |
| 27 | + "A collection of libraries to process multimedia content such as audio, video, subtitles and related metadata.") |
| 28 | + |
| 29 | + add_urls("https://ffmpeg.org/releases/ffmpeg-$(version).tar.bz2") |
| 30 | + |
| 31 | + add_versions("5.1.2", "39a0bcc8d98549f16c570624678246a6ac736c066cebdb409f9502e915b22f2b") |
| 32 | + |
| 33 | + add_configs("shared", {description = "Build shared library.", default = true, type = "boolean"}) |
| 34 | + |
| 35 | + on_install("cross@linux", function(package) |
| 36 | + import("rt.private.build.rtflags") |
| 37 | + local info = rtflags.get_package_info(package) |
| 38 | + local host = info.host |
| 39 | + local configs = {host = ""} |
| 40 | + local cc = info.cc |
| 41 | + local cxx = info.cxx |
| 42 | + local arch = info.arch |
| 43 | + local cpu = info.cpu |
| 44 | + local ldflags = {} |
| 45 | + local packagedeps = {} |
| 46 | + os.setenv("PATH", info.toolchainsdir .. ":" .. os.getenv("PATH")) |
| 47 | + |
| 48 | + if host == "aarch64-linux-musleabi" then |
| 49 | + arch = "aarch64" |
| 50 | + cpu = "armv8-a" |
| 51 | + end |
| 52 | + |
| 53 | + table.insert(configs, "--cross-prefix=" .. host .. "-") |
| 54 | + table.insert(configs, "--enable-cross-compile") |
| 55 | + table.insert(configs, "--target-os=none") |
| 56 | + table.insert(configs, "--cc=" .. cc) |
| 57 | + table.insert(configs, "--cxx=" .. cxx) |
| 58 | + table.insert(configs, "--arch=" .. arch) |
| 59 | + table.insert(configs, "--cpu=" .. cpu) |
| 60 | + if package:config("shared") then |
| 61 | + table.insert(configs, "--enable-shared") |
| 62 | + end |
| 63 | + |
| 64 | + -- table.insert(configs, "$ADDITIONAL_CONFIGURE_FLAG") |
| 65 | + |
| 66 | + local buildenvs = import("package.tools.autoconf").buildenvs(package, |
| 67 | + {ldflags = ldflags, packagedeps = packagedeps}) |
| 68 | + import("package.tools.autoconf").configure(package, configs, {envs = buildenvs}) |
| 69 | + import("package.tools.make").install(package, {}, {envs = buildenvs}) |
| 70 | + for _, suffix in ipairs({".a", ".so"}) do |
| 71 | + if os.isfile(path.join(package:installdir("lib"), "libavdevice" .. suffix)) then |
| 72 | + package:add("links", "avdevice") -- avdevice first |
| 73 | + end |
| 74 | + if os.isfile(path.join(package:installdir("lib"), "libavfilter" .. suffix)) then |
| 75 | + package:add("links", "avfilter") |
| 76 | + end |
| 77 | + if os.isfile(path.join(package:installdir("lib"), "libavformat" .. suffix)) then |
| 78 | + package:add("links", "avformat") |
| 79 | + end |
| 80 | + if os.isfile(path.join(package:installdir("lib"), "libavcodec" .. suffix)) then |
| 81 | + package:add("links", "avcodec") |
| 82 | + end |
| 83 | + if os.isfile(path.join(package:installdir("lib"), "libswresample" .. suffix)) then |
| 84 | + package:add("links", "swresample") |
| 85 | + end |
| 86 | + if os.isfile(path.join(package:installdir("lib"), "libswscale" .. suffix)) then |
| 87 | + package:add("links", "swscale") |
| 88 | + end |
| 89 | + if os.isfile(path.join(package:installdir("lib"), "libavutil" .. suffix)) then |
| 90 | + package:add("links", "avutil") |
| 91 | + end |
| 92 | + end |
| 93 | + end) |
| 94 | + |
| 95 | + on_test(function(package) |
| 96 | + assert(package:has_cfuncs("avformat_open_input", {includes = "libavformat/avformat.h"})) |
| 97 | + end) |
| 98 | +end |
0 commit comments