logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

gen.lua (11471B)


  1. local arch = 'x86'
  2. cflags{
  3. '-Wno-deprecated-declarations',
  4. '-Wno-discarded-qualifiers',
  5. '-Wno-stringop-overflow',
  6. '-I $dir/include',
  7. '-I $outdir',
  8. '-I $outdir/include',
  9. '-I $outdir/internal',
  10. '-I $srcdir',
  11. '-I $srcdir/libavcodec',
  12. '-isystem $builddir/pkg/linux-headers/include',
  13. }
  14. nasmflags{
  15. '-i $srcdir/',
  16. '-i $srcdir/libavcodec/'..arch..'/',
  17. '-i $srcdir/libavutil/'..arch..'/',
  18. '-f elf64',
  19. '-P $outdir/config.asm',
  20. }
  21. -- TODO: Copy the rest of the headers.
  22. pkg.hdrs = {
  23. '$outdir/include/libavutil/avconfig.h',
  24. '$outdir/include/libavutil/ffversion.h',
  25. }
  26. pkg.deps = {
  27. '$outdir/config.asm',
  28. '$outdir/config.h',
  29. '$outdir/config_components.h',
  30. '$gendir/headers',
  31. 'pkg/linux-headers/headers',
  32. }
  33. local probe = {
  34. '$builddir/probe/PIC',
  35. '$builddir/probe/HAVE_INLINE_ASM',
  36. '$builddir/probe/HAVE_MMINTRIN_H',
  37. }
  38. build('cat', '$outdir/config.h', {'$dir/config-head.h', probe, '$dir/config.h', '$dir/config-tail.h'})
  39. build('copy', '$outdir/config_components.h', '$dir/config_components.h')
  40. build('sed', '$outdir/config.asm', {probe, '$dir/config.h'}, {
  41. expr=[[-n -e 's,^# *,%,p']],
  42. })
  43. build('awk', '$outdir/config.texi', '$dir/config.h', {
  44. expr=[['$$3 == "1" {gsub("_", "-", $$2); print "@set", tolower($$2), "yes"}']],
  45. })
  46. build('awk', '$outdir/include/libavutil/avconfig.h', {'$dir/config.h', '|', '$dir/avconfig.awk'}, {
  47. expr='-f $dir/avconfig.awk',
  48. })
  49. rule('genlist', 'lua $dir/list.lua $dir/config_components.h $type $var <$in >$out')
  50. local function genlist(out, src, type, var)
  51. build('genlist', out, {src, '|', '$dir/list.lua', '$dir/config_components.h'}, {type=type, var=var})
  52. table.insert(pkg.deps, out)
  53. end
  54. genlist('$outdir/internal/libavfilter/filter_list.c', '$srcdir/libavfilter/allfilters.c', 'AVFilter', 'filter_list')
  55. genlist('$outdir/internal/libavcodec/codec_list.c', '$srcdir/libavcodec/allcodecs.c', 'FFCodec', 'codec_list')
  56. genlist('$outdir/internal/libavcodec/parser_list.c', '$srcdir/libavcodec/parsers.c', 'AVCodecParser', 'parser_list')
  57. genlist('$outdir/internal/libavcodec/bsf_list.c', '$srcdir/libavcodec/bitstream_filters.c', 'FFBitStreamFilter', 'bitstream_filters')
  58. genlist('$outdir/internal/libavformat/demuxer_list.c', '$srcdir/libavformat/allformats.c', 'FFInputFormat', 'demuxer_list')
  59. genlist('$outdir/internal/libavformat/muxer_list.c', '$srcdir/libavformat/allformats.c', 'FFOutputFormat', 'muxer_list')
  60. genlist('$outdir/internal/libavdevice/indev_list.c', '$srcdir/libavdevice/alldevices.c', 'FFInputFormat', 'indev_list')
  61. genlist('$outdir/internal/libavdevice/outdev_list.c', '$srcdir/libavdevice/alldevices.c', 'FFOutputFormat', 'outdev_list')
  62. genlist('$outdir/internal/libavformat/protocol_list.c', '$srcdir/libavformat/protocols.c', 'URLProtocol', 'url_protocols')
  63. build('awk', '$outdir/include/libavutil/ffversion.h', {'$dir/ver'}, {
  64. expr=[['{printf "#define FFMPEG_VERSION \"%s\"\n", $$1}']],
  65. })
  66. local options = {}
  67. for _, file in ipairs{'config.h', 'config_components.h'} do
  68. for line in iterlines(file, 1) do
  69. local cfg, val = line:match('^#define ([^ ]+) ([^ ]+)')
  70. if cfg then
  71. options[cfg] = val == '1'
  72. end
  73. end
  74. end
  75. local sources = {
  76. libavcodec={},
  77. libavdevice={},
  78. libavfilter={},
  79. libavformat={},
  80. libavutil={},
  81. libswresample={},
  82. libswscale={},
  83. }
  84. local archs = {
  85. ['aarch64']=true,
  86. ['alpha']=true,
  87. ['arm']=true,
  88. ['avr32']=true,
  89. ['avr32_ap']=true,
  90. ['avr32_uc']=true,
  91. ['bfin']=true,
  92. ['ia64']=true,
  93. ['loongarch']=true,
  94. ['m68k']=true,
  95. ['mips']=true,
  96. ['parisc']=true,
  97. ['ppc']=true,
  98. ['riscv']=true,
  99. ['s390']=true,
  100. ['sh4']=true,
  101. ['sparc']=true,
  102. ['tilegx']=true,
  103. ['tilepro']=true,
  104. ['x86']=true,
  105. }
  106. for line in iterlines('sources.txt', 1) do
  107. local i = line:find(' ', 1, true)
  108. if i and options[line:sub(1, i - 1)] then
  109. for src, lib, dir in line:gmatch('(([%w_-]+)/?([%w_-]*)[%w_/-]*/[%w_.-]+)', i + 1) do
  110. if not archs[dir] or dir == arch then
  111. sources[lib][src] = true
  112. end
  113. end
  114. end
  115. end
  116. -- combination option in libavutil/x86/Makefile
  117. if not options.HAVE_MMX_INLINE and options.HAVE_MMX_EXTERNAL and not options.HAVE_MM_EMPTY then
  118. sources.libavutil['libavutil/x86/emms.asm'] = true
  119. end
  120. for lib, srcs in pairs(sources) do
  121. sources[lib] = table.keys(srcs)
  122. end
  123. if options.CONFIG_ALSA_INDEV or options.config_ALSA_OUTDEV then
  124. cflags{'-isystem $builddir/pkg/alsa-lib/include'}
  125. table.insert(pkg.deps, 'pkg/alsa-lib/headers')
  126. table.insert(sources.libavdevice, '$builddir/pkg/alsa-lib/libasound.a')
  127. end
  128. if options.CONFIG_LIBDAV1D_DECODER then
  129. cflags{'-isystem $builddir/pkg/dav1d/include'}
  130. table.insert(pkg.deps, 'pkg/dav1d/headers')
  131. table.insert(sources.libavcodec, '$builddir/pkg/dav1d/libdav1d.a')
  132. end
  133. if options.CONFIG_TLS_PROTOCOL and options.CONFIG_LIBTLS then
  134. cflags{'-isystem $builddir/pkg/libtls-bearssl/include'}
  135. table.insert(pkg.deps, 'pkg/libtls-bearssl/headers')
  136. table.insert(sources.libavformat, '$builddir/pkg/libtls-bearssl/libtls.a.d')
  137. end
  138. if options.CONFIG_TLS_PROTOCOL and options.CONFIG_OPENSSL then
  139. cflags{'-isystem $builddir/pkg/libressl/include'}
  140. table.insert(pkg.deps, 'pkg/libressl/headers')
  141. table.insert(sources.libavformat, '$builddir/pkg/libressl/libssl.a.d')
  142. end
  143. if options.CONFIG_LIBOPUS_ENCODER or options.CONFIG_LIBOPUS_DECODER then
  144. cflags{'-isystem $builddir/pkg/opus/include'}
  145. table.insert(pkg.deps, 'pkg/opus/headers')
  146. table.insert(sources.libavcodec, '$builddir/pkg/opus/libopus.a')
  147. end
  148. if options.CONFIG_ZLIB then
  149. cflags{'-isystem $builddir/pkg/zlib/include'}
  150. table.insert(pkg.deps, 'pkg/zlib/headers')
  151. table.insert(sources.libavcodec, '$builddir/pkg/zlib/libz.a')
  152. table.insert(sources.libavformat, '$builddir/pkg/zlib/libz.a')
  153. end
  154. if options.CONFIG_BLURAY_PROTOCOL then
  155. cflags{'-isystem $builddir/pkg/libbluray/include'}
  156. table.insert(pkg.deps, 'pkg/libbluray/headers')
  157. table.insert(sources.libavcodec, '$builddir/pkg/libbluray/libbluray.a.d')
  158. end
  159. sub('lib.ninja', function()
  160. cflags{'-D HAVE_AV_CONFIG_H'}
  161. lib('libavcodec.a', {
  162. expand{'libavcodec/', {
  163. 'ac3_parser.c',
  164. 'adts_parser.c',
  165. 'allcodecs.c',
  166. 'avcodec.c',
  167. 'avdct.c',
  168. 'avfft.c',
  169. 'avpacket.c',
  170. 'bitstream.c',
  171. 'bitstream_filters.c',
  172. 'bsf.c',
  173. 'codec_desc.c',
  174. 'codec_par.c',
  175. 'd3d11va.c',
  176. 'decode.c',
  177. 'dirac.c',
  178. 'dv_profile.c',
  179. 'encode.c',
  180. 'get_buffer.c',
  181. 'imgconvert.c',
  182. 'jni.c',
  183. 'mathtables.c',
  184. 'mediacodec.c',
  185. 'mpeg12framerate.c',
  186. 'options.c',
  187. 'parser.c',
  188. 'parsers.c',
  189. 'profiles.c',
  190. 'qsv_api.c',
  191. 'raw.c',
  192. 'refstruct.c',
  193. 'utils.c',
  194. 'version.c',
  195. 'vlc.c',
  196. 'vorbis_parser.c',
  197. 'xiph.c',
  198. 'x86/constants.c',
  199. }},
  200. sources.libavcodec,
  201. 'libavutil.a',
  202. })
  203. lib('libavdevice.a', {
  204. expand{'libavdevice/', {
  205. 'alldevices.c',
  206. 'avdevice.c',
  207. 'utils.c',
  208. 'version.c',
  209. }},
  210. sources.libavdevice,
  211. 'libavcodec.a.d',
  212. 'libavformat.a.d',
  213. 'libavutil.a',
  214. })
  215. lib('libavfilter.a', {
  216. expand{'libavfilter/', {
  217. 'allfilters.c',
  218. 'audio.c',
  219. 'avfilter.c',
  220. 'avfiltergraph.c',
  221. 'buffersink.c',
  222. 'buffersrc.c',
  223. 'colorspace.c',
  224. 'ccfifo.c',
  225. 'drawutils.c',
  226. 'formats.c',
  227. 'framepool.c',
  228. 'framequeue.c',
  229. 'graphdump.c',
  230. 'graphparser.c',
  231. 'version.c',
  232. 'video.c',
  233. }},
  234. sources.libavfilter,
  235. 'libavutil.a',
  236. })
  237. cc('libavformat/protocols.c', {'$gendir/deps', '$outdir/internal/libavformat/protocol_list.c'})
  238. lib('libavformat.a', {
  239. expand{'libavformat/', {
  240. 'allformats.c',
  241. 'avformat.c',
  242. 'avio.c',
  243. 'aviobuf.c',
  244. 'demux.c',
  245. 'demux_utils.c',
  246. 'dump.c',
  247. 'dv.c',
  248. 'format.c',
  249. 'id3v1.c',
  250. 'id3v2.c',
  251. 'isom_tags.c',
  252. 'metadata.c',
  253. 'mux.c',
  254. 'mux_utils.c',
  255. 'options.c',
  256. 'os_support.c',
  257. 'protocols.c.o',
  258. 'riff.c',
  259. 'sdp.c',
  260. 'seek.c',
  261. 'url.c',
  262. 'utils.c',
  263. 'version.c',
  264. }},
  265. sources.libavformat,
  266. 'libavcodec.a.d',
  267. 'libavutil.a',
  268. })
  269. lib('libavutil.a', {
  270. expand{'libavutil/', {
  271. 'adler32.c',
  272. 'aes.c',
  273. 'aes_ctr.c',
  274. 'ambient_viewing_environment.c',
  275. 'audio_fifo.c',
  276. 'avstring.c',
  277. 'avsscanf.c',
  278. 'base64.c',
  279. 'blowfish.c',
  280. 'bprint.c',
  281. 'buffer.c',
  282. 'cast5.c',
  283. 'camellia.c',
  284. 'channel_layout.c',
  285. 'cpu.c',
  286. 'crc.c',
  287. 'csp.c',
  288. 'des.c',
  289. 'detection_bbox.c',
  290. 'dict.c',
  291. 'display.c',
  292. 'dovi_meta.c',
  293. 'downmix_info.c',
  294. 'encryption_info.c',
  295. 'error.c',
  296. 'eval.c',
  297. 'executor.c',
  298. 'fifo.c',
  299. 'file.c',
  300. 'file_open.c',
  301. 'float_dsp.c',
  302. 'fixed_dsp.c',
  303. 'frame.c',
  304. 'hash.c',
  305. 'hdr_dynamic_metadata.c',
  306. 'hdr_dynamic_vivid_metadata.c',
  307. 'hmac.c',
  308. 'hwcontext.c',
  309. 'iamf.c',
  310. 'imgutils.c',
  311. 'integer.c',
  312. 'intmath.c',
  313. 'lfg.c',
  314. 'lls.c',
  315. 'log.c',
  316. 'log2_tab.c',
  317. 'lzo.c',
  318. 'mathematics.c',
  319. 'mastering_display_metadata.c',
  320. 'md5.c',
  321. 'mem.c',
  322. 'murmur3.c',
  323. 'opt.c',
  324. 'parseutils.c',
  325. 'pixdesc.c',
  326. 'pixelutils.c',
  327. 'random_seed.c',
  328. 'rational.c',
  329. 'reverse.c',
  330. 'rc4.c',
  331. 'ripemd.c',
  332. 'samplefmt.c',
  333. 'sha.c',
  334. 'sha512.c',
  335. 'slicethread.c',
  336. 'spherical.c',
  337. 'stereo3d.c',
  338. 'threadmessage.c',
  339. 'time.c',
  340. 'timecode.c',
  341. 'timestamp.c',
  342. 'tree.c',
  343. 'twofish.c',
  344. 'utils.c',
  345. 'xga_font_data.c',
  346. 'xtea.c',
  347. 'tea.c',
  348. 'tx.c',
  349. 'tx_float.c',
  350. 'tx_double.c',
  351. 'tx_int32.c',
  352. 'uuid.c',
  353. 'version.c',
  354. 'video_enc_params.c',
  355. 'video_hint.c',
  356. 'film_grain_params.c',
  357. 'x86/cpu.c',
  358. 'x86/fixed_dsp_init.c',
  359. 'x86/float_dsp_init.c',
  360. 'x86/imgutils_init.c',
  361. 'x86/lls_init.c',
  362. 'x86/cpuid.asm',
  363. 'x86/fixed_dsp.asm',
  364. 'x86/float_dsp.asm',
  365. 'x86/imgutils.asm',
  366. 'x86/lls.asm',
  367. 'x86/tx_float.asm',
  368. }},
  369. sources.libavutil,
  370. })
  371. lib('libswresample.a', {
  372. expand{'libswresample/', {
  373. 'audioconvert.c',
  374. 'dither.c',
  375. 'options.c',
  376. 'rematrix.c',
  377. 'resample.c',
  378. 'resample_dsp.c',
  379. 'swresample.c',
  380. 'swresample_frame.c',
  381. 'version.c',
  382. 'x86/audio_convert.asm',
  383. 'x86/rematrix.asm',
  384. 'x86/resample.asm',
  385. 'x86/audio_convert_init.c',
  386. 'x86/rematrix_init.c',
  387. 'x86/resample_init.c',
  388. }},
  389. sources.libswresample,
  390. 'libavutil.a',
  391. })
  392. lib('libswscale.a', {
  393. expand{'libswscale/', {
  394. 'alphablend.c',
  395. 'hscale.c',
  396. 'hscale_fast_bilinear.c',
  397. 'gamma.c',
  398. 'half2float.c',
  399. 'input.c',
  400. 'options.c',
  401. 'output.c',
  402. 'rgb2rgb.c',
  403. 'slice.c',
  404. 'swscale.c',
  405. 'swscale_unscaled.c',
  406. 'utils.c',
  407. 'version.c',
  408. 'yuv2rgb.c',
  409. 'vscale.c',
  410. 'x86/rgb2rgb.c',
  411. 'x86/swscale.c',
  412. 'x86/yuv2rgb.c',
  413. 'x86/hscale_fast_bilinear_simd.c',
  414. 'x86/input.asm',
  415. 'x86/output.asm',
  416. 'x86/scale.asm',
  417. 'x86/scale_avx2.asm',
  418. 'x86/rgb_2_rgb.asm',
  419. 'x86/yuv_2_rgb.asm',
  420. 'x86/yuv2yuvX.asm',
  421. }},
  422. sources.libswscale,
  423. 'libavutil.a',
  424. })
  425. end)
  426. local libs = {
  427. 'libavcodec.a.d',
  428. 'libavdevice.a.d',
  429. 'libavfilter.a.d',
  430. 'libavformat.a.d',
  431. 'libavutil.a',
  432. 'libswresample.a.d',
  433. 'libswscale.a.d',
  434. }
  435. cc('fftools/cmdutils.c', {'$gendir/deps'})
  436. cc('fftools/opt_common.c', {'$gendir/deps'})
  437. exe('ffprobe', {paths[[fftools/(ffprobe.c cmdutils.c.o opt_common.c.o)]], libs})
  438. file('bin/ffprobe', '755', '$outdir/ffprobe')
  439. exe('ffmpeg', {paths[[
  440. fftools/(
  441. ffmpeg.c
  442. ffmpeg_dec.c
  443. ffmpeg_demux.c
  444. ffmpeg_enc.c
  445. ffmpeg_filter.c
  446. ffmpeg_hw.c
  447. ffmpeg_mux.c
  448. ffmpeg_mux_init.c
  449. ffmpeg_opt.c
  450. ffmpeg_sched.c
  451. objpool.c
  452. sync_queue.c
  453. thread_queue.c
  454. cmdutils.c.o
  455. opt_common.c.o
  456. )
  457. ]], libs})
  458. file('bin/ffmpeg', '755', '$outdir/ffmpeg')
  459. rule('texi2mdoc', [[$builddir/pkg/texi2mdoc/host/texi2mdoc -d 'August 2, 2024' -I $outdir $in >$out]])
  460. build('texi2mdoc', '$outdir/ffprobe.1', {'$srcdir/doc/ffprobe.texi', '|', '$outdir/config.texi', '$builddir/pkg/texi2mdoc/host/texi2mdoc'})
  461. build('texi2mdoc', '$outdir/ffmpeg.1', {'$srcdir/doc/ffmpeg.texi', '|', '$outdir/config.texi', '$builddir/pkg/texi2mdoc/host/texi2mdoc'})
  462. man{'$outdir/ffprobe.1', '$outdir/ffmpeg.1'}
  463. fetch 'git'