logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git
commit: f4c50108da9e4674516112ace7f0097d264fe7e4
parent b5d6c2aaedeb6f1dd760da9461739328666e18b7
Author: Michael Forney <mforney@mforney.org>
Date:   Sat, 30 Dec 2017 22:43:47 -0800

Add raw mode for iterlines

Diffstat:

Mninja.lua14+++++++++-----
Mpkg/ffmpeg/gen.lua8++------
Mpkg/mpv/gen.lua5++---
Mpkg/nginx/gen.lua25++++++++++---------------
Mpkg/nsd/gen.lua3+--
Mpkg/python/gen.lua7+++----
6 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/ninja.lua b/ninja.lua @@ -131,20 +131,24 @@ end -- yields non-empty non-comment lines in a file local function linesgen(file) - table.insert(pkg.inputs.gen, '$dir/'..file) - for line in io.lines(pkg.dir..'/'..file) do + for line in io.lines(file) do if #line > 0 and not line:hasprefix('#') then coroutine.yield(line) end end end -function iterlines(file) +function iterlines(file, raw) + table.insert(pkg.inputs.gen, '$dir/'..file) + file = string.format('%s/%s', pkg.dir, file) + if raw then + return io.lines(file) + end return coroutine.wrap(linesgen), file end -function lines(file) - return collect(iterlines(file)) +function lines(file, raw) + return collect(iterlines(file, raw)) end -- diff --git a/pkg/ffmpeg/gen.lua b/pkg/ffmpeg/gen.lua @@ -52,7 +52,7 @@ pkg.deps = { } local options = {} -for line in io.lines(pkg.dir..'/options.h') do +for line in iterlines('options.h', 1) do local cfg, val = line:match('^#define ([^ ]+) ([^ ]+)') if cfg then options[cfg] = val == '1' @@ -67,7 +67,7 @@ local sources = { libswresample={}, libswscale={}, } -for line in io.lines(pkg.dir..'/sources.txt') do +for line in iterlines('sources.txt', 1) do local i = line:find(' ', 1, true) local cfg = line:sub(1, i and i - 1) if options[cfg] then @@ -89,10 +89,6 @@ end for lib, srcs in pairs(sources) do sources[lib] = table.keys(srcs) end -table.insert(pkg.inputs.gen, { - '$dir/sources.txt', - '$dir/options.h', -}) cc('libavcodec/bitstream_filters.c', {'$outdir/internal/libavcodec/bsf_list.c'}) lib('libavcodec.a', { diff --git a/pkg/mpv/gen.lua b/pkg/mpv/gen.lua @@ -46,14 +46,14 @@ for _, f in ipairs{'assdraw', 'defaults', 'options', 'osc', 'ytdl_hook'} do end local options = {} -for line in io.lines(pkg.dir..'/config.h') do +for line in iterlines('config.h', 1) do local var, val = line:match('^#define ([^ ]+) ([^ ]+)') if var and val == '1' then options[var] = true end end local sources = {} -for line in io.lines(pkg.dir..'/sources.txt') do +for line in iterlines('sources.txt', 1) do local i = line:find(' ', 1, true) local add = true if i then @@ -69,7 +69,6 @@ for line in io.lines(pkg.dir..'/sources.txt') do end end sources = table.keys(sources) -table.insert(pkg.inputs.gen, {'$dir/config.h', '$dir/sources.txt'}) if options['HAVE_ALSA'] then cflags{'-I $builddir/pkg/alsa-lib/include'} diff --git a/pkg/nginx/gen.lua b/pkg/nginx/gen.lua @@ -8,10 +8,8 @@ local libs = {} pkg.deps = {} local modules = {} -for line in io.lines(pkg.dir..'/modules.txt') do - if #line > 0 then - modules[line] = true - end +for line in iterlines('modules.txt') do + modules[line] = true end if modules['openssl'] then @@ -28,7 +26,7 @@ if modules['regex'] then table.insert(pkg.deps, 'pkg/pcre/headers') end local zlib = modules['http_gzip_filter'] or modules['http_gunzip_filter'] -for line in io.lines(pkg.dir..'/ngx_auto_config.h') do +for line in iterlines('ngx_auto_config.h', 1) do if line == 'NGX_ZLIB 1' then zlib = true break @@ -130,15 +128,13 @@ local sources = paths[[src/( ngx_linux_sendfile_chain.c ) )]] -for line in io.lines(pkg.dir..'/sources.txt') do - if #line > 0 and not line:hasprefix('#') then - local i = line:find(' ', 1, true) - if modules[line:sub(1, i and i - 1)] then - while i do - local j = line:find(' ', i + 1, true) - table.insert(sources, 'src/'..line:sub(i + 1, j and j - 1)) - i = j - end +for line in iterlines('sources.txt') do + local i = line:find(' ', 1, true) + if modules[line:sub(1, i and i - 1)] then + while i do + local j = line:find(' ', i + 1, true) + table.insert(sources, 'src/'..line:sub(i + 1, j and j - 1)) + i = j end end end @@ -158,4 +154,3 @@ build('sed', '$outdir/nginx.8', '$srcdir/docs/man/nginx.8', { man{'$outdir/nginx.8'} fetch 'git' -table.insert(pkg.inputs.gen, {'$dir/sources.txt', '$dir/modules.txt', '$dir/ngx_auto_config.h'}) diff --git a/pkg/nsd/gen.lua b/pkg/nsd/gen.lua @@ -28,8 +28,7 @@ local cfg = { chrootdir='', ratelimit_default='on', } -table.insert(pkg.inputs.gen, '$dir/config.h') -for line in io.lines(pkg.dir..'/config.h') do +for line in iterlines('config.h', 1) do local var, val = line:match('^#define (%g+) "(%g+)"$') if var then cfg[var:lower()] = val diff --git a/pkg/python/gen.lua b/pkg/python/gen.lua @@ -9,8 +9,8 @@ cflags{ local sources = {} local modules = {} -for line in io.lines(pkg.dir..'/Setup') do - if #line > 0 and not line:find('^[*#]') then +for line in iterlines('Setup') do + if not line:hasprefix('*') then local i = line:find(' ', 1, true) modules[line:sub(1, i and i - 1)] = true while i do @@ -70,7 +70,7 @@ cc('Modules/getpath.c', nil, { local platform = 'linux' local abiflags = '' -for line in io.lines(pkg.dir..'/pyconfig.h') do +for line in iterlines('pyconfig.h', 1) do if line == '#define WITH_PYMALLOC 1' then abiflags = abiflags..'m' elseif line == '#define Py_DEBUG 1' then @@ -211,5 +211,4 @@ file('lib/python3.6/_sysconfigdata_'..abiflags..'_'..platform..'_.py', '644', '$ file('lib/python3.6/Makefile', '644', '$dir/lib/Makefile') dir('lib/python3.6/lib-dynload', '755') -table.insert(pkg.inputs.gen, {'$dir/Setup', '$dir/pyconfig.h'}) fetch 'curl'