master hovercats/oakiss / pkg / dav1d / gen.lua
  1cflags{
  2	'-Wall', '-Wno-maybe-uninitialized',
  3	'-D _XOPEN_SOURCE=700',
  4	'-I $srcdir',
  5	'-I $srcdir/include',
  6	'-I $srcdir/tools',
  7	'-I $outdir',
  8	'-I $outdir/include/dav1d',
  9	'-I $dir',
 10}
 11nasmflags{
 12	'-i $srcdir/src/',
 13	'-i $outdir/',
 14	'-f elf64',
 15}
 16
 17pkg.hdrs = {
 18	copy('$outdir/include/dav1d', '$srcdir/include/dav1d', {
 19		'common.h',
 20		'data.h',
 21		'dav1d.h',
 22		'headers.h',
 23		'picture.h',
 24	}),
 25	'$outdir/include/dav1d/version.h',
 26}
 27pkg.deps = {
 28	'$gendir/headers',
 29	'$outdir/cli_config.h',
 30	'$outdir/vcs_version.h',
 31	'$outdir/config.asm',
 32}
 33
 34build('sed', '$outdir/include/dav1d/version.h', '$srcdir/include/dav1d/version.h.in', {
 35	expr={
 36		'-e s,@DAV1D_API_VERSION_MAJOR@,5,',
 37		'-e s,@DAV1D_API_VERSION_MINOR@,0,',
 38		'-e s,@DAV1D_API_VERSION_PATCH@,0,',
 39	},
 40})
 41build('awk', '$outdir/vcs_version.h', '$dir/ver', {
 42	expr=[['{printf "#define DAV1D_VERSION \"%s\"\n", $$1}']],
 43})
 44build('awk', '$outdir/config.asm', '$dir/config.h', {
 45	expr=[['$$1 == "#define" {print "%define " substr($$0, length("#define ") + 1)} END {print "%define private_prefix dav1d"}']],
 46})
 47build('touch', '$outdir/cli_config.h')
 48
 49local srcs = paths[[
 50	src/(
 51		cdf.c
 52		cpu.c
 53		data.c
 54		decode.c
 55		dequant_tables.c
 56		getbits.c
 57		intra_edge.c
 58		itx_1d.c
 59		lf_mask.c
 60		log.c
 61		mem.c
 62		msac.c
 63		obu.c
 64		picture.c
 65		qm.c
 66		ref.c
 67		refmvs.c
 68		scan.c
 69		tables.c
 70		warpmv.c
 71		wedge.c
 72
 73		lib.c
 74		thread_task.c
 75
 76		@x86_64 x86/(
 77			cpu.c msac_init.c refmvs_init.c
 78			cpuid.asm msac.asm refmvs.asm cdef_avx2.asm itx_avx2.asm
 79			looprestoration_avx2.asm cdef_sse.asm itx_sse.asm
 80
 81			cdef_avx512.asm
 82			mc_avx512.asm
 83			mc_avx2.asm
 84			film_grain_avx2.asm
 85			ipred_avx2.asm
 86			loopfilter_avx2.asm
 87			film_grain_sse.asm
 88			ipred_sse.asm
 89			loopfilter_sse.asm
 90			looprestoration_sse.asm
 91			mc_sse.asm
 92
 93			cdef16_avx2.asm
 94			film_grain16_avx2.asm
 95			ipred16_avx2.asm
 96			itx16_avx2.asm
 97			loopfilter16_avx2.asm
 98			looprestoration16_avx2.asm
 99			mc16_avx2.asm
100			cdef16_sse.asm
101			film_grain16_sse.asm
102			ipred16_sse.asm
103			itx16_sse.asm
104			loopfilter16_sse.asm
105			looprestoration16_sse.asm
106			mc16_sse.asm
107		)
108	)
109]]
110
111local tmpl = paths[[
112	cdef_apply_tmpl.c
113	cdef_tmpl.c
114	fg_apply_tmpl.c
115	film_grain_tmpl.c
116	ipred_prepare_tmpl.c
117	ipred_tmpl.c
118	itx_tmpl.c
119	lf_apply_tmpl.c
120	loopfilter_tmpl.c
121	looprestoration_tmpl.c
122	lr_apply_tmpl.c
123	mc_tmpl.c
124	recon_tmpl.c
125
126	@x86_64 x86/(
127		cdef_init_tmpl.c
128		film_grain_init_tmpl.c
129		ipred_init_tmpl.c
130		itx_init_tmpl.c
131		loopfilter_init_tmpl.c
132		looprestoration_init_tmpl.c
133		mc_init_tmpl.c
134	)
135]]
136for _, bit in ipairs{'8', '16'} do
137	for _, src in ipairs(tmpl) do
138		local obj = ('$outdir/%s/%s.o'):format(bit, src)
139		build('cc', obj, {'$srcdir/src/'..src, '||', '$gendir/deps'}, {cflags='$cflags -D BITDEPTH='..bit})
140		table.insert(srcs, obj)
141	end
142end
143
144lib('libdav1d.a', srcs)
145
146exe('dav1d', [[
147	tools/(
148		dav1d.c
149		dav1d_cli_parse.c
150		input/(input.c annexb.c ivf.c section5.c)
151		output/(md5.c null.c output.c y4m2.c yuv.c)
152	)
153	libdav1d.a
154]])
155file('bin/dav1d', '755', '$outdir/dav1d')
156
157fetch 'git'