# HG changeset patch # User Paul Boddie # Date 1486751466 -3600 # Node ID 37cb73adc7c209b7f52b06e9c1d4522e3529144a # Parent 6d14963cce30db5ce642dd04d9368c2802a9ed69 Added module search path configuration using LICHENPATH and related options. Added extra convenience options for help and version text viewing. diff -r 6d14963cce30 -r 37cb73adc7c2 docs/lplc.1 --- a/docs/lplc.1 Fri Feb 10 17:52:47 2017 +0100 +++ b/docs/lplc.1 Fri Feb 10 19:31:06 2017 +0100 @@ -12,8 +12,14 @@ .B lplc .I --version .SH DESCRIPTION -Compile the program whose principal file is given in place of -.IR file . +.B lplc +compiles programs written in the Lichen language, taking the indicated +.I file +representing the principal source file of a program, compiling the program to an +intermediate representation, and then building the result using a C compiler and +.B make +to produce an executable. Other source files need not be specified: they will be +identified by the compiler and loaded as required. .SH OPTIONS The following options may be specified: .PP @@ -21,9 +27,15 @@ .B \-c Only partially compile the program; do not attempt to build or link it .TP +.B \-E +Ignore environment variables affecting the module search path +.TP .B \-g Generate debugging information for the built executable .TP +.B \-P +Show the module search path +.TP .B \-q Silence messages produced when building an executable .TP @@ -62,11 +74,31 @@ of compiling a program: .PP .TP -.B \-\-help +.BR \-h ", " \-? ", " \-\-help Show a summary of the command syntax and options .TP -.B \-\-version +.BR \-V ", " \-\-version Show version information for this tool +.SH ENVIRONMENT VARIABLES +.TP +ARCH +Indicates a prefix to be used with tool names when building an executable. This +permits things like cross-compilation where tools have been provided with names +featuring architecture- and system-specific prefixes. For example, +.I mipsel-linux-gnu +may be used to indicate the use of tools for the MIPS architecture running +GNU/Linux in little-endian mode. +.TP +LICHENPATH +A collection of directories that are searched before those in the collection +comprising the default "module search path". This collection, if already defined +in the environment, may be excluded by specifying the +.B \-E +option. +.SH AUTHOR +Paul Boddie +.SH RESOURCES +The project Web site: http://projects.boddie.org.uk/Lichen .SH COPYRIGHT Copyright \(co 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Paul Boddie @@ -77,5 +109,3 @@ .SH SEE ALSO .BR cc (1), .BR make (1). -.SH RESOURCES -The project Web site: http://projects.boddie.org.uk/Lichen diff -r 6d14963cce30 -r 37cb73adc7c2 lplc --- a/lplc Fri Feb 10 17:52:47 2017 +0100 +++ b/lplc Fri Feb 10 19:31:06 2017 +0100 @@ -22,7 +22,7 @@ VERSION = "0.1" from errors import * -from os import rename +from os import environ, rename from os.path import abspath, exists, isfile, join, split from pyparser import error from subprocess import Popen, PIPE @@ -32,6 +32,7 @@ libdirs = [ join(split(__file__)[0], "lib"), + split(__file__)[0], "/usr/share/lichen/lib" ] @@ -90,7 +91,7 @@ # Show help text if requested or if no arguments are given. - if "--help" in args or not args: + if "--help" in args or "-h" in args or "-?" in args or not args: print >>sys.stderr, """\ Usage: %s [ ] @@ -98,7 +99,9 @@ The following options may be specified: -c Only partially compile the program; do not attempt to build or link it +-E Ignore environment variables affecting the module search path -g Generate debugging information for the built executable +-P Show the module search path -q Silence messages produced when building an executable -r Reset (discard) cached program information; inspect the whole program again -t Silence timing messages @@ -122,13 +125,16 @@ of compiling a program: --help Show a summary of the command syntax and options +-h Equivalent to --help +-? Equivalent to --help --version Show version information for this tool +-V Equivalent to --version """ % basename sys.exit(1) # Show the version information if requested. - elif "--version" in args: + elif "--version" in args or "-V" in args: print >>sys.stderr, """\ lplc %s Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, @@ -142,6 +148,7 @@ # Determine the options and arguments. debug = False + ignore_env = False make = True make_verbose = True reset = False @@ -160,6 +167,7 @@ for arg in args: if arg == "-c": make = False + elif arg == "-E": ignore_env = True elif arg == "-g": debug = True elif arg == "-q": make_verbose = False elif arg == "-r": reset = True @@ -176,6 +184,20 @@ if needed == 0: l = filenames + # Add extra components to the module search path from the environment. + + if not ignore_env: + extra = environ.get("LICHENPATH") + if extra: + libdirs = extra.split(":") + libdirs + + # Show the module search path if requested. + + if "-P" in args: + for libdir in libdirs: + print libdir + sys.exit(0) + # Obtain the program filename. if len(filenames) != 1: