1.1 --- a/lplc Fri Feb 10 17:52:47 2017 +0100
1.2 +++ b/lplc Fri Feb 10 19:31:06 2017 +0100
1.3 @@ -22,7 +22,7 @@
1.4 VERSION = "0.1"
1.5
1.6 from errors import *
1.7 -from os import rename
1.8 +from os import environ, rename
1.9 from os.path import abspath, exists, isfile, join, split
1.10 from pyparser import error
1.11 from subprocess import Popen, PIPE
1.12 @@ -32,6 +32,7 @@
1.13
1.14 libdirs = [
1.15 join(split(__file__)[0], "lib"),
1.16 + split(__file__)[0],
1.17 "/usr/share/lichen/lib"
1.18 ]
1.19
1.20 @@ -90,7 +91,7 @@
1.21
1.22 # Show help text if requested or if no arguments are given.
1.23
1.24 - if "--help" in args or not args:
1.25 + if "--help" in args or "-h" in args or "-?" in args or not args:
1.26 print >>sys.stderr, """\
1.27 Usage: %s [ <options> ] <filename>
1.28
1.29 @@ -98,7 +99,9 @@
1.30 The following options may be specified:
1.31
1.32 -c Only partially compile the program; do not attempt to build or link it
1.33 +-E Ignore environment variables affecting the module search path
1.34 -g Generate debugging information for the built executable
1.35 +-P Show the module search path
1.36 -q Silence messages produced when building an executable
1.37 -r Reset (discard) cached program information; inspect the whole program again
1.38 -t Silence timing messages
1.39 @@ -122,13 +125,16 @@
1.40 of compiling a program:
1.41
1.42 --help Show a summary of the command syntax and options
1.43 +-h Equivalent to --help
1.44 +-? Equivalent to --help
1.45 --version Show version information for this tool
1.46 +-V Equivalent to --version
1.47 """ % basename
1.48 sys.exit(1)
1.49
1.50 # Show the version information if requested.
1.51
1.52 - elif "--version" in args:
1.53 + elif "--version" in args or "-V" in args:
1.54 print >>sys.stderr, """\
1.55 lplc %s
1.56 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
1.57 @@ -142,6 +148,7 @@
1.58 # Determine the options and arguments.
1.59
1.60 debug = False
1.61 + ignore_env = False
1.62 make = True
1.63 make_verbose = True
1.64 reset = False
1.65 @@ -160,6 +167,7 @@
1.66
1.67 for arg in args:
1.68 if arg == "-c": make = False
1.69 + elif arg == "-E": ignore_env = True
1.70 elif arg == "-g": debug = True
1.71 elif arg == "-q": make_verbose = False
1.72 elif arg == "-r": reset = True
1.73 @@ -176,6 +184,20 @@
1.74 if needed == 0:
1.75 l = filenames
1.76
1.77 + # Add extra components to the module search path from the environment.
1.78 +
1.79 + if not ignore_env:
1.80 + extra = environ.get("LICHENPATH")
1.81 + if extra:
1.82 + libdirs = extra.split(":") + libdirs
1.83 +
1.84 + # Show the module search path if requested.
1.85 +
1.86 + if "-P" in args:
1.87 + for libdir in libdirs:
1.88 + print libdir
1.89 + sys.exit(0)
1.90 +
1.91 # Obtain the program filename.
1.92
1.93 if len(filenames) != 1: