Lines Matching full:local
3 local require=function(modname)if package.loaded[modname]==nil then
11 local _ENV=require'std.normalize'{}local function fatal(...)local msg=(...)if select('#',...)>1 then
19 local _ENV=require'std.normalize'{'luke._base','luke.lukefile','luke.platforms','std.functional',}l…
29 local function help()print[[
49 local function opterr(...)local msg=(...)if select('#',...)>1 then
52 local function display(...)return stdout:write(concat{...})end
53 local function dump(...)local s=concat(map(list(...),str))if len(s)>0 then
56 local function interpolate_to_substitute(s)return(gsub(s,'%$([%w_]+)','@%1@'))end
57 return{parse_arguments=function(args)local r={clidefs={},valreqs={},fname='lukefile',install={},log…
66 end,validate_arguments=function(parsed)local luke,err=loadluke(parsed.fname)diagnose(luke~=nil,'bad…
68 local targets=call(function()if isempty(parsed.targets)or contains(parsed.targets,'all')then
70 local r=filter(parsed.targets,function(target)if target~='install'and luke.modules[target]==nil then
74 end)local install
75 local build=pluck(targets,luke.modules)if contains(targets,'install')then
85 local _ENV=require'std.normalize'{'luke._base','luke.environment','std.functional','type.context-ma…
86 local function run(L,env,command)L.write(interpolate(env,concat(command,' ')),'\n')local status,err…
92 local function defines(env,deftables)return zip_with(merge({},unpack(deftables)),function(name,valu…
93 local function incdirs(...)return map(flatten(...),function(v)return'-I'..v
95 local function libdirs(...)return map(flatten(...),function(v)return'-L'..v
97 local function c_module_path(objdir,name)return format('%s/%s.$LIB_EXTENSION',objdir,gsub(name,'%.'…
98 local function c_source(module,objdir)local path=gsub(module,'%.','/')local src=c_module_path(objdi…
99 local function lua_source(module,src)local abspath='$INST_LUADIR/'..gsub(module,'%.','/')if match(s…
102 local function module_to_path(module,sources,objdir)return dropuntil(sources,function(source)return…
103 …ke,name)local rules=luke.modules[name]local c_module=c_module_path(luke.variables.objdir,name)loca…
106 local src,dir=module_to_path(name,modules[name].sources,luke.variables.objdir)if not exists(interpo…
115 local _ENV=require'std.normalize'{'luke._base','luke.compile','luke.environment','std.functional','…
119 local function checking(L,...)L.verbose('checking ',concat({...},' '),'... ')end
120 local function found_library(L,x)if x==nil or x==''then
126 local function found_prog(L,x)L.verbose(x and'yes\n'or'no\n')return x
128 local function found_result(L,x)L.verbose(x==0 and'yes\n'or'no\n')return x~=0 and 0 or 1
130 local function bindirs(...)return map(flatten(...),function(v)return v..':'end)end
131 local function compile_command(L,env,config,filename)local command=flatten('$CC','-c','$CFLAGS',inc…
132 local function link_command(L,env,config,a_out,source,lib)local command=flatten('$CC','$CFLAGS',inc…
133 local function check_executable_in_path(L,env,config,prog)local PATH=concat(bindirs(config.bindir))…
137 local function check_header_compile(L,env,config,header,extra_hdrs)return with(CTest(),function(con…
138 local function check_struct_member_compile(L,env,config,structname,member,extra_hdrs)return with(CT…
147 local function try_link(L,env,config,lib,symbol)return with(CTest(),TmpFile(),function(conftest,a_o…
156 local function try_compile(L,env,config,headers)return with(CTest(),TmpFile(),function(conftest,a_o…
167 local function check_func_decl(L,env,config,fname,extra_hdrs)return with(CTest(),function(conftest)…
178 local function check_func_link(L,env,config,fname)return with(CTest(),TmpFile(),function(conftest,a…
212 local function add_external_deps(env,config,prefix)if prefix~=nil then
214 local envvar=interpolate(env,format(v,prefix))if envvar~=''then
220 local function format_includes(includes)return map(includes or{},function(include)return format('#i…
221 local configure=setmetatable(OrderedDict({checkprog=function(L,env,config)return dropuntil(config.p…
224 …local extra_hdrs=concat(format_includes(config.includes),'\n')return found_result(L,check_header_c…
225 local headers=concat(format_includes(config.includes),'\n')if try_compile(L,env,config,headers)~=0 …
228 local libraries,symbol=config.libraries,config.checksymbol
229 local trylibs=reduce(libraries,{''},function(r,lib)append(r,'-l'..lib)end)return dropuntil(trylibs,…
237 …)local extra_hdrs=concat(format_includes(config.includes),'\n')local i=find(config.checkmember,'%.…
240 …pported configure type '%s'",type)end,})end,})return{config_compiler=function(L,env)local CC=env.CC
243 checking(L,interpolate(env,'whether $CC works'))local cm=CTest()local works,err=with(cm,function(co…
248 end,config_ldoc=function(L,env)local LDOC=env.LDOC
255 local _ENV=require'std.normalize'{'luke.platforms','std.functional',LUAVERSION=string.gsub(_VERSION…
259 end)end,}local function interpolate_with(pattern,env,s)local r=''while r~=s do
264 local function isenv(t)return getmetatable(t)==env_mt
266 …local',INST_LIBDIR='$PREFIX/lib/lua/$LUAVERSION',INST_LUADIR='$PREFIX/share/lua/$LUAVERSION',LIB_E…
272 local _ENV=require'std.normalize'{'luke.cli','luke.compile','luke.configure','luke.environment','lu…
273 local function build_modules(L,env)local conf=makeenv(CONFIGENV,env)if not isempty(L.luke.ldocs or{…
275 local c=c_modules(L.luke.modules)if not isempty(c)then
277 …configs(L,conf,L.luke)local substitute=makeenv(L.clidefs,L.luke.substitute,SHELLENV)L.luke=run_tem…
282 …in=function(args)local L=validate_arguments(parse_arguments(args))local env=makeenv(L.clidefs,L.lu…
293 local _ENV=require'std.normalize'{'luke._base','luke.configure','luke.environment','luke.platforms'…
295 local function isconfig(x)return istable(x)and has_anykey(x,configure)end
296 local function collect_configs(luke,modulename,configs)configs=configs or{}for k,v in next,luke do
308 local function deepcopy(t)return mapvalues(t,function(v)return case(type(v),{['table']=function()re…
309 local weighting=setmetatable(copy(configure),{__call=function(self,config)local t=config.t[config.k…
314 end})local function config_cmp(a,b)return weighting(a)<weighting(b)end
315 local function fill_templates(env,src,dest)with(File(dest,'w'),function(cm)for line in lines(src)do
319 local function rewrite_template_files(L,env,source)return case(source,{['(.+)%.in']=function(r)L.wr…
320 local function collect_variables(luke,variables)for k,v in next,luke do
322 map(keys(v),function(name)local rootdir=concat{'$',name,'_DIR'}variables[name..'_DIR']='/usr'variab…
327 local function normalize_configs(config)return cond({[not istable(config)]=config,},{[not isconfig(…
328 local function normalize_rules(rules)return case(type(rules),{['nil']=nop,['string']=function()retu…
332 local function unwrap_external_dependencies(luke)if istable(luke.external_dependencies)then
341 return{loadluke=function(filename)local content,err=slurp(File(filename))if content==nil then
344 local r={}local chunk,err=loadstring(content,filename,r)if chunk==nil then
347 local ok,err=pcall(chunk)if not ok then
351 …local r=deepcopy(luke)local all_configs=collect_configs(r)sort(all_configs,config_cmp)map(all_conf…
357 local _ENV=require'std.normalize'{'std.functional',}local CANON={['AIX']=list('aix','unix'),['FreeB…
358 end)end)local function match_uname(canon,uname,x)return match(uname,x)and canon[x]end
359 local function toplatforms(canon,uname)local literalkeys,patternkeys=partition(keys(canon),function…
360 local supported=toplatforms(CANON,popen('uname -s'):read'*l')local function isplatform(x)return ALL…
362 local function filter_platforms(t,using,predicate)local r,supported,isplatform={},using or supporte…
365 local matches=filter(supported,bind(get,{v}))local default=except(keys(v),isplatform)merge(r,hoist(…
375 local _ENV=require'std.normalize'{destructure=next,isfile=function(x)return io.type(x)=='file'end,w…
379 local function call(fn,...)assert(fn~=nil,'cannot call nil-valued function')if iscallable(fn)then
383 local function wrapnonnil(iterator)return function(...)local r=list(iterator(...))if r[1]~=nil then
388 local function each(seq)if type(seq)=='function'then
390 local i,n=0,int(seq.n)or len(seq)return function()if i<n then
395 local function eq(x)return function(y)return x==y
398 local function isnonnil(x)return x~=nil
400 local function mkpredicate(x)return type(x)=='function'and x or eq(x)end
401 local function except(seq,predicate)predicate=mkpredicate(predicate)local r={}for valu in each(seq)…
407 local function visit(x)if type(x)=='table'then
413 local function flatten(...)local r={}for v in wrap(visit),except(list(...),nil)do
424 …apply,bind=function(fn,bound)local n=bound.n or maxn(bound)return function(...)local argu,unbound=…
435 local DEFAULT=1
438 local argu=list(match(s,'^'..pattern..'$'))if argu[1]~=nil then
442 local default=branches[DEFAULT]if iscallable(default)then
446 local expr,consequence=destructure(unpack(clauseu))if expr then
461 local r=list(block(unpack(valu)))if predicate(unpack(r))then
470 end,except=except,filter=function(seq,predicate)predicate=mkpredicate(predicate)local r={}for valu …
475 end,flatten=flatten,foldkeys=function(keymap,dict,combinator)local r={}for k,v in next,dict or{}do
476 local key=keymap[k]if key then
482 end,get=function(dict,key)return(dict or{})[key]end,hoist=function(keylist,dict)local r={}for keyu …
487 end,keys=function(iterable)local r=list()for k in next,iterable or{}do
490 end,map=function(seq,block)local r=list()for valu in each(seq)do
493 end,mapvalues=function(iterable,block)local r={}for k,v in next,iterable or{}do
497 end,nop=function()end,partition=function(seq,block)local r,s=list(),list()for valu in each(seq)do
500 end,pluck=function(keylist,dict)local r={}for keyu in each(keylist)do
501 local key=unpack(keyu)r[key]=dict[key]end
510 end,values=function(iterable)local r=list()for _,v in next,iterable or{}do
513 end,zip_with=function(iterable,block)local r=list()for k,v in next,iterable or{}do
519 local ceil=math.ceil
520 local concat=table.concat
521 local config=package.config
522 local getmetatable=getmetatable
523 local loadstring=loadstring
524 local match=string.match
525 local next=next
526 local pack=table.pack or function(...)return{n=select('#',...),...}end
527 local setfenv=setfenv
528 local sort=table.sort
529 local tointeger=math.tointeger
530 local tonumber=tonumber
531 local tostring=tostring
532 local type=type
533 local unpack=table.unpack or unpack
534 local dirsep,pathsep,pathmark,execdir,igmark=match(config,'^([^\n]+)\n([^\n]+)\n([^\n]+)\n([^\n]+)\…
539 local int=(function(f)if f==nil then
550 end)(tointeger)local function iscallable(x)return type(x)=='function'and x or(getmetatable(x)or{}).…
552 local function getmetamethod(x,n)return iscallable((getmetatable(x)or{})[tostring(n)])end
553 local function rawlen(x)if type(x)~='table'then
556 local n=#x
564 local function len(x)local m=getmetamethod(x,'__len')return m and m(x)or rawlen(x)end
566 local _loadstring=loadstring
575 local function keysort(a,b)if int(a)then
580 local function str(x,roots)roots=roots or{}local function stop_roots(x)return roots[x]or str(x,copy…
583 local buf={'{'}roots[x]=tostring(x)local n,keys=1,{}for k in next,x do
586 sort(keys,keysort)local kp
597 return setmetatable({append=function(seq,v)local n=(int(seq.n)or len(seq))+1
600 …,lines=io.lines,list=pack,loadstring=loadstring,match=string.match,maxn=function(iterable)local n=0
602 local i=int(k)if i and i>n then
607 end,merge=function(r,...)local argu=pack(...)for i=1,argu.n do
613 end,next=next,open=io.open,pack=pack,pcall=pcall,pop=function(seq)local n,r=seq.n or len(seq)r,seq[…
617 …nt(seq.n)or len(seq))end,write=io.write,},{__call=function(self,env,level)local userenv,level=copy…
631 local _ENV=require'std.normalize'{'std.functional',}local contextmanager_mt={__index=function(self,…
636 end,}local function ContextManager(release,acquire,...)local fh,err=acquire(...)if not fh then
639 local cm={context=fh,release=release,n=select("#",...),...}if cm.context~=nil then
643 local function context_close(cm)return isfile(cm.context)and close(cm.context)end
644 local function with(...)local argu=list(...)local block=pop(argu)local r=list(apply(block,argu))map…
647 return{ContextManager=ContextManager,CTest=function()local conftest=tmpname()return ContextManager(…
658 local _ENV=require'std.normalize'{destructure=next,}return{OrderedDict=function(...)local r,argu={}…
659 local k,v=destructure(argu[i])append(r,k)r[k]=v
665 local _ENV=require'std.normalize'{}local BASENAMEPAT='.*'..dirsep
666 local DIRNAMEPAT=dirsep..'[^'..dirsep..']*$'return{basename=function(path)return(gsub(path,BASENAME…