opkg

statically linked package installer
git clone anongit@rnpnr.xyz:opkg.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

gen.lua (2269B)


      1 local arch = ({
      2 	aarch64='arm64',
      3 	x86_64='x86',
      4 })[config.target.platform:match('[^-]*')]
      5 sub('tools.ninja', function()
      6 	toolchain(config.host)
      7 	exe('unifdef', {'scripts/unifdef.c'})
      8 end)
      9 
     10 rule('header', 'sed -E -f $dir/header.sed $in >$out.tmp && { $outdir/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $out.tmp >$out; [ $$? -le 1 ]; } && rm $out.tmp')
     11 rule('wrapper', [[printf '#include <asm-generic/%s>\n' $file >$out]])
     12 
     13 local function process(outdir, srcdir, files)
     14 	local outs = {}
     15 	for i, file in ipairs(files) do
     16 		local out = outdir..'/'..file
     17 		outs[i] = out
     18 		build('header', out, {srcdir..'/'..file, '|', '$dir/header.sed', '$outdir/unifdef'})
     19 	end
     20 	return outs
     21 end
     22 
     23 local mandatory = {
     24 	-- <awk '$1 == "mandatory-y" {printf "\\t'\'%s\'',\\n", $3}' src/include/uapi/asm-generic/Kbuild
     25 	'auxvec.h',
     26 	'bitsperlong.h',
     27 	'bpf_perf_event.h',
     28 	'byteorder.h',
     29 	'errno.h',
     30 	'fcntl.h',
     31 	'ioctl.h',
     32 	'ioctls.h',
     33 	'ipcbuf.h',
     34 	'mman.h',
     35 	'msgbuf.h',
     36 	'param.h',
     37 	'poll.h',
     38 	'posix_types.h',
     39 	'ptrace.h',
     40 	'resource.h',
     41 	'sembuf.h',
     42 	'setup.h',
     43 	'shmbuf.h',
     44 	'sigcontext.h',
     45 	'siginfo.h',
     46 	'signal.h',
     47 	'socket.h',
     48 	'sockios.h',
     49 	'stat.h',
     50 	'statfs.h',
     51 	'swab.h',
     52 	'termbits.h',
     53 	'termios.h',
     54 	'types.h',
     55 	'unistd.h',
     56 }
     57 
     58 local basefiles = load('base.lua')
     59 local archfiles = load(arch..'.lua')
     60 
     61 build('awk', '$outdir/include/linux/version.h', {'$srcdir/Makefile', '|', '$dir/version.awk'}, {
     62 	expr='-f $dir/version.awk',
     63 })
     64 
     65 pkg.hdrs = {
     66 	'$outdir/include/linux/version.h',
     67 	process('$outdir/include', '$srcdir/include/uapi', basefiles),
     68 	process('$outdir/include', '$srcdir/arch/'..arch..'/include/uapi', archfiles),
     69 	install=true,
     70 }
     71 
     72 for _, file in ipairs(archfiles) do
     73 	archfiles[file] = true
     74 end
     75 for _, file in ipairs(mandatory) do
     76 	if not archfiles['asm/'..file] then
     77 		local out = '$outdir/include/asm/'..file
     78 		build('wrapper', out, nil, {file=file})
     79 		table.insert(pkg.hdrs, out)
     80 	end
     81 end
     82 
     83 for _, spec in ipairs(archfiles.unistd) do
     84 	local out = '$outdir/include/asm/'..spec.dst
     85 	build('awk', out, {'$srcdir/'..spec.src, '|', '$dir/unistd.awk'}, {
     86 		expr={
     87 			'-v arch='..arch,
     88 			'-v file='..spec.dst,
     89 			string.format([[-v abi='%s']], spec.abi),
     90 			'-v off='..(spec.off or ''),
     91 			'-f $dir/unistd.awk',
     92 		},
     93 	})
     94 	table.insert(pkg.hdrs, out)
     95 end
     96 
     97 fetch('local')