Re: [Tack-devel] Prime Mover commands
Moved to https://github.com/davidgiven/ack
Brought to you by:
dtrg
From: David G. <dg...@co...> - 2006-07-31 11:14:06
|
tim kelly wrote: [...] > 1) With targets that are included via including their pmfiles, are the > globals in the master pmfile evaluated? I define ROOTDIR in the master= > pmfile but when I try to build an included target, ROOTDIR is a nil poi= nter: Yes. The way pm works is that it reads in the specified pmfile and executes it as a Lua script. This builds data structures in memory. When the script returns, pm looks at these data structures and decides what needs doing. (You can use pm as a general Lua scripting engine by putting os.exit(0) in the script; this will cause pm to exit cleanly without trying to do anything.) It's difficult to tell what's going on without seeing your code, but have you defined ROOTDIR as local? Local variables in Lua are fundamentally different things to global variables --- local variables are lexically scoped, and included scripts execute in a different scope and so won't see locals defined in the caller. (When the Lua compiler sees a reference to a name, it will first attempt to find a local with that name, and if that fails it'll substitute the equivalent of _G.name instead. That is, undefined names are turned into dynamic references to the global dictionary. When pm does it's hierarchical variable lookups, the global dictionary is the last place it looks for anything.) [...] > local d =3D ROOTDIR.."lib/libsa/" Because ROOTDIR here is used in a Lua expression, it'll get evaluated when the script is read, and so ROOTDIR must be defined before this line is seen. OTOH, if you were to say "%ROOTDIR%lib/libsa/" instead, then the %...% reference will only get expanded at the very last stage of execution, and will be looked up in the call stack of the rules currently being processed. > 2) Is there a flag that is the equivalent of -V in make to display the > value of a variable? If there is not, I would like to make a feature > request to expand the -D flag, such that -D?X lists the first iterative= > evaluation of X and -D??X lists the completely iterated evaluation of X= =2E Sorry, pm doesn't necessarily have this information. However, if you were to put: print(somerule.VARIABLENAME) os.exit() =2E..into a pmfile (called, say, debug.pm), and then do: =2E/pm -f test.pm -f debug.pm =2E..then the value of VARIABLENAME will be dumped without actually doing= anything else. However, string expansion will not be done (as there is no call stack to do it in). > 3) As another feature request, can the cache directory no longer defau= lt > to a "." directory? Sometimes I forget the cache directory is hidden, = and > while at least with OpenBSD "ls" does automatically -a, not all systems= do. Put: pm.intermediatecache =3D "path" =2E..in your pmfile. (The ACK config.pm does this.) [...] > 4) Can I get some bare-bones description on differences between cfiles,= > cprograms, clibraries, and other possible options? cfile compiles a single .c file into a single .o file. clibrary builds an ar archive out of its inputs. cprogram links all of its inputs together into an executable. All this is in rather a state of flux right now --- for example, I've just rewritten the way C dependencies are calculated to be a lot friendlier to non-gcc compilers. In particular, the cryptic set of variables used in the ACK's build mechanism for C programs is being simplified drastically... it ought to be possible to simply add: CBUILDFLAGS =3D {PARENT, "-Osomething"}, =2E..into any rule and have it take effect for that rule *and* any rules referred to by it... although I've just tried it and it's not working quite right. I'll have a look later. If you look in the pm Subversion repository, I've just checked in a bunch of test files in test-pmfiles and test-source --- you may find these useful to look at. --=20 +- David Given --McQ-+ "You cannot truly appreciate _Atlas Shrugged_ | dg...@co... | until you have read it in the original Klingon." | (dg...@ta...) | --- Sea Wasp on r.a.sf.w +- www.cowlark.com --+ |