lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




On Sun, May 6, 2018 at 9:25 PM, Sean Conner <sean@conman.org> wrote:
It was thus said that the Great Russell Haley once stated:
> On Sun, May 6, 2018 at 5:43 PM, Sean Conner <sean@conman.org> wrote:
>
> >   If you are going down this path, then plan to go all-out:  options can be
> > set by
> >
> >         command line, which overrides (or extends)
> >         environment variables, which overrides
> >         per-directory config file (example ./megalua.conf), which overrides
> >         per-user config file (example $HOME/.megalua), which overrides
> >         system-wide config file (example /etc/megalua), which overrides
> >         default setting in the program.
> >
>
> That's exactly what I was thinking but perhaps a slightly different order
> of override:
> - command line overides
> - local directory config file overrides
> - environment variables
> - user config file
> - global per interpreter file

  I would still put environmental over local directory, because you can
specify a temporary setting for an environment variable for running a
command:

[spc]lucy:~>lua -e 'print(os.getenv "HOME")'
/home/spc
[spc]lucy:~>HOME=/tmp lua -e 'print(os.getenv "HOME")'
/tmp
[spc]lucy:~>lua -e 'print(os.getenv "HOME")'
/home/spc
[spc]lucy:~>
A very common pattern in nix, not so much in Windows. The thought is a local config file trumps everything except command line, making for easily portable projects in Windows? I really liked using node.js and creating little packages that 'just execute' because npm creates local repositories by default. Dump your source directory in git (replete with .modules directory), pull it out on different machine that has node (properly) installed and it just runs. Maybe node *is* setup to use environment variables first. I don't know.

As I said to someone else, global language installation with local modules was a pattern I had thought of when I started compiling Lua on Windows, and when I used node.js it validated that pattern to me. It's sort of silly with a language that's as small as Lua, but... I just want it to be easy and 'standardized'. 1) download installer and install 2) open editor and hack. 3) fall to powershell and type lua ... 

As someone else has said to me privately in an email, others have tried and failed where I am walking. (In my head I paraphrase that to say better men than I have died in these waters! tee hee). That said loud and clear to me that *something* needs to be done because others have seen the painful need too (especially in the age of so much choice). I do think things are much different now. It looks to me like the change from 5.1 to 5.3 was where the schism really occurred. The death of luadist and luaforge has really coalesced people around LuaRocks and I think we have a chance to explore that and bringing the Lua pattern in line with some of the other languages. Like one frigging exe to run all your scripts. 

I've also heard of efforts in standardizing Lua on nix projects as well. If possible, I'll leverage that too in both directions (FreeBSD to Windows and vise-versa).

Also, with my discovery of JamPlus, it makes compiling C on Windows really easy. Here is the example jam file that builds 'dtlua' plus two 5.1 and 5.4:

SubDir TOP ;

# Output all of our user-facing files into the bin/ directory.
BIN_PATH = bin ;
C.OutputPath * : $(BIN_PATH) ;

###############################################################################
# Create the lua54 shared library.
###############################################################################
C.ActiveTarget lua54 ;

# Tell Lua's code to export the appropriate functions to the DLL.
C.Defines : LUA_BUILD_AS_DLL ;
C.IncludeDirectories : lua-5.4.0-work1/src ;
#C.Library : lua/*@=**.c@=**.h@-**/lua.c@-**/luac.c : shared ;
C.Library : lua-5.4.0-work1/src/*@=**.c@=**.h@-**/luac.c : shared ;

###############################################################################
# Create the lua51 shared library.
###############################################################################
C.ActiveTarget lua51 ;

# Tell Lua's code to export the appropriate functions to the DLL.
C.Defines : LUA_BUILD_AS_DLL ;
C.IncludeDirectories : lua-5.1.5/src ;
#C.Library : lua/*@=**.c@=**.h@-**/lua.c@-**/luac.c : shared ;
C.Library : lua-5.1.5/src/*@=**.c@=**.h@-**/luac.c : shared ;

###############################################################################
# Create the lua executable.
###############################################################################
C.ActiveTarget "dtlua" ;
C.IncludeDirectories : lua-5.4.0-work1/src ;
C.LinkLibraries : lua54 lua51 ;
C.Application : src/dtlua.c src/util.c ;

ramble ramble... I still can't even load a script properly in lua in C yet. XD
Russ

  -spc