Lines Matching full:end

7 end
8 package.loaded[modname]=package.preload[modname](modname,"package.preload")end
9 return package.loaded[modname]end
12 msg=format(...)end
13 stderr:write('luke: fatal: '..msg..'\n')exit(1)end
15 fatal(...)end
16 end,fatal=fatal,}
17 end
28 ]]exit(0)end
48 Report bugs to https://github.com/gvvaughan/luke/issues.]]exit(0)end
50 msg=format(...)end
51 …e('luke: error: '..msg..'.\n')stderr:write("luke: try '"..arg[0].." --help' for help.\n")exit(2)end
52 local function display(...)return stdout:write(concat{...})end
54 …t(...),str)),'\n*$','\n'):gsub('(.-)\n',function(line)stderr:write(' DEBUG: '..line..'\n')end)end
55 end
56 local function interpolate_to_substitute(s)return(gsub(s,'%$([%w_]+)','@%1@'))end
58 end,['%-%-file=(.+)']=function(optarg)r.fname=optarg
59 end,['%-%-value=(.+)']=function(optarg)r.valreqs[#r.valreqs+1]=optarg
60 end,['--quiet']=function()r.write=nop
61 end,['--verbose']=function()r.verbose=display
62 end,['--help']=help,['--version']=version,['([^-][^=]-)=(.+)']=function(name,value)r.clidefs[name]=…
63 end,function(opt)if match(opt,'^-')~=nil then
64 opterr("unrecognized option '%s'",opt)end
65 append(r.targets,opt)end,})end)return r
66 end,validate_arguments=function(parsed)local luke,err=loadluke(parsed.fname)diagnose(luke~=nil,'bad…
67 fatal("no modules table in '%s', nothing to build",parsed.fname)end
69 return except(flatten(parsed.targets,keys(luke.modules)),'all')end
71 fatal("no rule to make target '%s'",target)end
73 end)assert(len(r)>0,"no build targets specified")return r
74 end)local install
77 end
81 end
82 …ll,log=parsed.log,luke=luke,valreqs=parsed.valreqs,verbose=parsed.verbose,write=parsed.write,}end,}
83 end
85 …f $?'}return tonumber(slurp(Pipe(pipe))),slurp(File(err.filename)),slurp(File(out.filename))end)end
88 stdout:write(concat(command,' ')..'\n')end
89 stderr:write(err..'\n')end
91 end
92 …ch(value,SHELLMETACHARS)~=nil]="-D%s='%s'"},{[true]='-D%s=%s'})return format(fmt,name,value)end)end
94 end)end
96 end)end
97 …ction c_module_path(objdir,name)return format('%s/%s.$LIB_EXTENSION',objdir,gsub(name,'%.','/'))end
98 ….','/')local src=c_module_path(objdir,path)return src,(gsub('$INST_LIBDIR/'..path,'/[^/]+$',''))end
100 abspath=abspath..'/init'end
101 abspath=abspath..'.lua'return src,(gsub(abspath,'/[^/]+%.lua$',''))end
102 ….in']=bind(lua_source,{module}),function(src)fatal("unsupported source type '%s'",src)end,})end)end
104 stdout:write(concat(command,' ')..'\n')stderr:write(err..'\n')exit(status)end
105 …s))end,c_modules=function(modules)return filter(keys(modules),function(name)return dropuntil(modul…
107 status=run(L,env,{'$MAKEDIRS',dir})end
109 status=run(L,env,{'$INSTALL',src,dir..'/'})end
110 end
112 end)end,libdirs=libdirs,run_command=run,spawn=spawn,}
113 end
116 L.log(err)end
118 end
119 local function checking(L,...)L.verbose('checking ',concat({...},' '),'... ')end
123 L.verbose(x)end
125 end
127 end
129 end
130 local function bindirs(...)return map(flatten(...),function(v)return v..':'end)end
131 …g.incdir),'$CPPFLAGS',filename)L.log(interpolate(env,concat(command,' ')))return unpack(command)end
132 …GS',lib,'$libs',CONFIGENV.libs)L.log(interpolate(env,concat(command,' ')))return unpack(command)end
135 end)end)L.log(found and'found '..found or prog..' not found')return found~=nil
136 end
137 …n',extra_hdrs,header))return logspawn(L,env,compile_command(L,env,config,conftest.filename))end)end
146 …rs,structname,member))return logspawn(L,env,compile_command(L,env,config,conftest.filename))end)end
155 …mbol))return logspawn(L,env,link_command(L,env,config,a_out.filename,conftest.filename,lib))end)end
166 …ig.ifdef))return logspawn(L,env,link_command(L,env,config,a_out.filename,conftest.filename))end)end
177 …tra_hdrs,fname,fname))return logspawn(L,env,compile_command(L,env,config,conftest.filename))end)end
211 …me,fname))return logspawn(L,env,link_command(L,env,config,a_out.filename,conftest.filename))end)end
216 end
217 end
218 end
219 end
220 …es(includes)return map(includes or{},function(include)return format('#include "%s"',include)end)end
223 end
224 end)or fatal('cannot find '..config.checkprog)end},{checkheader=function(L,env,config)checking(L,'f…
226 return found_library(L,{})end
227 end
229 local trylibs=reduce(libraries,{''},function(r,lib)append(r,'-l'..lib)end)return dropuntil(trylibs,…
233 end
235 end
236 return found_library(L,lib)end
237 end)or call(function()L.verbose'\n'fatal("required symbol '%s' not found in any of libc, lib%s",sym…
238 end,['table']=function()return dropuntil(self,function(fname)if config[fname]~=nil then
239 add_external_deps(env,config,prefix)return apply(self[fname],list(L,env,config))end
240 end)or fatal("unable to configure with keys '%s'",concat(keys(config),"', '"))end,function(type)fat…
242 CC=configure(L,env,{checkprog='C compiler',progs=CCPROGS})env=makeenv(env,{CC=CC})end
243 …onftest:write('typedef int x;\n')return spawn(env,'$compile',conftest.filename)end)if works~=0 then
245 L.log(err)end
246 fatal('could not find a working C compiler')end
248 end,config_ldoc=function(L,env)local LDOC=env.LDOC
250 …configure(L,env,{checkprog='LDocs generator',progs={'ldoc','true'}})env=makeenv(env,{LDOC=LDOC})end
252 end,configure=configure,}
253 end
258 end
259 end)end,}local function interpolate_with(pattern,env,s)local r=''while r~=s do
261 s=gsub(r,pattern,function(varname)return env[varname]or''end)end
263 end
265 end
266 … -fPIC',},},SHELLENV=setmetatable({},{__index=function(_,v)return getenv(v)end,}),expand=bind(inte…
268 append(r,t)end
269 end)return setmetatable(env,env_mt)end,}
270 end
272 …l function run_ldocs(L,env,ldocs)return run_command(L,env,flatten{'$LDOC -c',ldocs.sources,'.'})end
274 conf=config_ldoc(L,conf)env=makeenv(env,{LDOC=conf.LDOC})end
276 conf=config_compiler(L,conf)env=makeenv(env,{CC=conf.CC})end
277 …e)local status=dropuntil(c,isnonzero,function(name)return build_c_module(L,env,L.luke,name)end)or 0
279 status=run_ldocs(L,env,L.luke.ldocs)end
281 end
284 map(L.valreqs,function(name)print(interpolate(env,concat{name,"='$",name,"'"}))end)exit(0)end
286 status=build_modules(L,env)end
288 status=install_modules(L,env,L.luke,L.install)end
290 end,}
291 end
294 end))end
295 local function isconfig(x)return istable(x)and has_anykey(x,configure)end
301 collect_configs(rules,name,configs)end
303 collect_configs(v,modulename,configs)end
304 end
305 end
307 end
308 …n mapvalues(t,function(v)return case(type(v),{['table']=function()return deepcopy(v)end,v,})end)end
312 end
313 end
314 end})local function config_cmp(a,b)return weighting(a)<weighting(b)end
316 cm:write(expand(env,line)..'\n')end
317 end)return dest
318 end
319 ….in']=function(r)L.write('creating '..r..'\n')return fill_templates(env,r..'.in',r)end,source,})end
322 …e..'_INCDIR']=rootdir..'/include'variables[name..'_LIBDIR']=rootdir..'/lib'end)elseif istable(v)th…
323 collect_variables(v,variables)end
324 end
326 end
327end,},{[true]=function()local keymap={include='includes',prog='progs',library='libraries',}return …
328 … case(type(rules),{['nil']=nop,['string']=function()return{sources={rules}}end,['table']=function(…
330 return merge({sources={rules.sources}},normalize_configs(rules))end
331 return normalize_configs(rules)end,function(v)fatal("unsupported rule type '%s'",v)end,})end
335 …bdirs or{},format('$%s_LIBDIR',prefix))luke.libraries=append(luke.libraries or{},config.library)end
336 end
338 end
340 end
343 end
346 end
349 end
351 end,collect_variables=function(luke)return collect_variables(luke,{})end,run_configs=function(L,env…
352 r.ldocs.sources=map(r.ldocs.sources,rewrite)end
354 end,}
355 end
358 end)end)local function match_uname(canon,uname,x)return match(uname,x)and canon[x]end
359 …b(k,1,1)~='^'end)return(pluck(literalkeys,canon)or{})[uname]or dropuntil(map(patternkeys,bind(matc…
361 end
368 end
369 end
371 end
373 end
375 local _ENV=require'std.normalize'{destructure=next,isfile=function(x)return io.type(x)=='file'end,w…
376 return fn(unpack(argu))end
378 end
380 return fn(...)end
382 end
385 end
386 end
387 end
389 return wrapnonnil(seq)end
392 return list(seq[i])end
393 end
394 end
396 end
397 end
399 end
400 local function mkpredicate(x)return type(x)=='function'and x or eq(x)end
403 r[#r+1]=unpack(valu)end
404 end
406 end
409 visit(unpack(valu))end
411 yield(x)end
412 end
415 end
417 end
421 end
422 end
424 end,apply=apply,bind=function(fn,bound)local n=bound.n or maxn(bound)return function(...)local argu…
428 end
430 end
432 return apply(fn,argu)end
433 end,call=call,case=function(s,branches)if branches[s]~=nil then
434 return call(branches[s],s)end
439 return apply(fn,argu)end
440 end
441 end
443 return call(default,s)end
445 end,cond=function(...)for clauseu in each(list(...))do
447 return call(consequence,expr)end
448 end
449 end,contains=function(seq,predicate)if type(predicate)~='function'then
450 predicate=eq(predicate)end
454 end
455 end
456 end,destructure=destructure,dropuntil=function(seq,predicate,block)if block==nil then
458 end
462 return unpack(r)end
463 end
467 return unpack(r)end
468 end
469 end
470 end,except=except,filter=function(seq,predicate)predicate=mkpredicate(predicate)local r={}for valu …
472 r[#r+1]=unpack(valu)end
473 end
475 end,flatten=flatten,foldkeys=function(keymap,dict,combinator)local r={}for k,v in next,dict or{}do
479 end
480 end
482 end,get=function(dict,key)return(dict or{})[key]end,hoist=function(keylist,dict)local r={}for keyu …
483 merge(r,dict[unpack(keyu)])end
485 end,id=function(...)return...end,isempty=function(x)return type(x)=='table'and not next(x)end,isfil…
486 end,isstring=function(x)return type(x)=='string'end,istable=function(x)return type(x)=='table'end,i…
487 end,keys=function(iterable)local r=list()for k in next,iterable or{}do
488 append(r,k)end
490 end,map=function(seq,block)local r=list()for valu in each(seq)do
491 append(r,block(unpack(valu)))end
493 end,mapvalues=function(iterable,block)local r={}for k,v in next,iterable or{}do
495 end
497 end,nop=function()end,partition=function(seq,block)local r,s=list(),list()for valu in each(seq)do
498 append(block(unpack(valu))and r or s,unpack(valu))end
500 end,pluck=function(keylist,dict)local r={}for keyu in each(keylist)do
501 local key=unpack(keyu)r[key]=dict[key]end
503 end,reduce=function(seq,acc,block)if block==nil then
505 end
508 end
510 end,values=function(iterable)local r=list()for _,v in next,iterable or{}do
511 append(r,v)end
513 end,zip_with=function(iterable,block)local r=list()for k,v in next,iterable or{}do
514 append(r,block(k,v))end
516 end,}
517 end
526 local pack=table.pack or function(...)return{n=select('#',...),...}end
536 end
538 end
542 end
543 end
546 return tointeger(x)end
547 end
548 end
550 end)(tointeger)local function iscallable(x)return type(x)=='function'and x or(getmetatable(x)or{}).…
551 end
552 local function getmetamethod(x,n)return iscallable((getmetatable(x)or{})[tostring(n)])end
555 end
560 end
561 end
563 end
564 local function len(x)local m=getmetamethod(x,'__len')return m and m(x)or rawlen(x)end
568 setfenv(chunk,env)end
570 end
572 loadstring=function(s,filename,env)return load(s,filename,"t",env)end
573 setfenv=function()end
574 end
578 return int(b)==nil and tostring(a)<tostring(b)end
579 end
580 …ion str(x,roots)roots=roots or{}local function stop_roots(x)return roots[x]or str(x,copy(roots))end
585 end
589 buf[#buf+1]=type(kp)=='number'and k~=kp+1 and'; 'or', 'end
592 buf[#buf+1]=stop_roots(k)..'='..stop_roots(x[k])end
594 end
595 buf[#buf+1]='}'return concat(buf)end
596 end
600 end,arg=arg,assert=assert,char=string.char,close=io.close,concat=concat,copy=copy,dirsep=dirsep,exi…
604 end
605 end
607 end,merge=function(r,...)local argu=pack(...)for i=1,argu.n do
610 end
611 end
613 end,next=next,open=io.open,pack=pack,pcall=pcall,pop=function(seq)local n,r=seq.n or len(seq)r,seq[…
615 end
617 end,popen=io.popen,print=print,rawget=rawget,rawset=rawset,rep=string.rep,rm=os.remove,select=selec…
622 end
625 end
626 end
628 end,})
629 end
632 return function(_,...)return self.context[key](self.context,...)end
633 end
635 return self[1]end
636 end,}local function ContextManager(release,acquire,...)local fh,err=acquire(...)if not fh then
638 end
640 setmetatable(cm,contextmanager_mt)end
642 end
643 local function context_close(cm)return isfile(cm.context)and close(cm.context)end
645 cm:release()end
646 end)return unpack(r)end
648 return rm(cm.filename)end
650 end,open,conftest..'.c','w')end,File=function(fname,mode)return ContextManager(context_close,open,f…
651 return rm(cm.filename)end
653 end,open,fname or tmpname(),mode or'w')end,slurp=function(cm,...)if not cm then
654 return cm,...end
655 return with(cm,function(h)return h:read'*a'end)end,with=with,}
656 end
660 end
662 end,}
663 end
666 …nction(path)return(gsub(path,BASENAMEPAT,''))end,dirname=function(path)return(gsub(path,DIRNAMEPAT…
668 end
670 end,}
671 end