/[ascend]/trunk/scons/tcl-config.py
ViewVC logotype

Diff of /trunk/scons/tcl-config.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2436 by jpye, Mon Nov 10 08:22:00 2008 UTC revision 2437 by ballan, Sun Mar 27 17:10:19 2011 UTC
# Line 25  if sys.platform.startswith("win"): Line 25  if sys.platform.startswith("win"):
25    
26  if tclconfigfile is None:  if tclconfigfile is None:
27      # use a 'tclsh' script to find location of tclConfig.sh      # use a 'tclsh' script to find location of tclConfig.sh
28        # location of tclConfig.sh is canonical tcl_pkgPath
29      tclscript = """      tclscript = """
30             #puts stderr "searching for tclConfig.sh ..."
31       foreach d [concat \       foreach d [concat \
32            [list $tcl_library \            [concat $tcl_library $tcl_pkgPath ] \
                 [lindex $tcl_pkgPath 0]] \  
33            $auto_path \            $auto_path \
34            [list [file dirname $tcl_library] \            [list [file dirname $tcl_library] \
35                  [file dirname [lindex $tcl_pkgPath 0]] \                  [file dirname [lindex $tcl_pkgPath 0]] \
# Line 39  if tclconfigfile is None: Line 40  if tclconfigfile is None:
40       ] {       ] {
41           if {[file exists [file join $d tclConfig.sh]]} {           if {[file exists [file join $d tclConfig.sh]]} {
42               puts "[file join $d tclConfig.sh]"               puts "[file join $d tclConfig.sh]"
43               exit               #puts stderr "found $d : [file join $d tclConfig.sh]"
44                 exit 1
45             } else {
46                 #puts stderr "not in $d"
47           }           }
48       }       }
49      """      """
50    
51      import subprocess      import subprocess
52      output = subprocess.Popen(["tclsh"], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(input=tclscript)[0]      output = subprocess.Popen(["tclsh"], stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate(input=tclscript)[0]
53        # print output
54        # print output.strip()
55            # tcl will not return it if not there; already checked
56      if os.path.exists(output.strip()):      if os.path.exists(output.strip()):
57            # print "path exists"
58          # only report the file if it actually exists...          # only report the file if it actually exists...
59          tclconfigfile = output.strip()          tclconfigfile = output.strip()
60            # print tclconfigfile
61    
62    # print tclconfigfile
63  if tclconfigfile is None:  if tclconfigfile is None:
64      print "Unable to locate tclConfig.sh"      print >> sys.stderr, "Unable to locate tclConfig.sh."
65        print >> sys.stderr, "If on Linux/Unix and you have tcl & tk installed, check that tclsh is in your path."
66        print >> sys.stderr, "If tclsh is in your path and this still fails, check that tcl-devel or equivalent package is installed."
67        print >> sys.stderr, "If your vendor doesn't provide tcl-devel and tk-devel equivalents, get free ActiveTcl from activestate.com."
68      sys.exit(1)      sys.exit(1)
69    
70  # parse the file to determine the names of the variables it contains  # parse the file to determine the names of the variables it contains
# Line 80  r = re.compile(r'\$\{([A-Z_0-9]+)\}') Line 93  r = re.compile(r'\$\{([A-Z_0-9]+)\}')
93  # variable substitution/expansion function  # variable substitution/expansion function
94  def expand(s,d):  def expand(s,d):
95      m = r.search(s)      m = r.search(s)
96      #print "MATCHING",s      # print "MATCHING",s
97      if m:      if m:
98          #print "MATCH!"          # print "MATCH!"
99          if d.has_key(m.group(1)):          if d.has_key(m.group(1)):
100              return expand(s[:m.start()] + d[m.group(1)] + s[m.end():],d)              return expand(s[:m.start()] + d[m.group(1)] + s[m.end():],d)
101          else:          else:
# Line 97  for l in f: Line 110  for l in f:
110      if len(v) >= 2 and v[0] == "'" and v[len(v)-1] == "'":      if len(v) >= 2 and v[0] == "'" and v[len(v)-1] == "'":
111          v = v[1:len(v)-1]          v = v[1:len(v)-1]
112    
113      d[k] = expand(v,d)      try:
114            d[k] = expand(v,d)
115        except RuntimeError, err:
116            # print str(err),"probably unneeded"
117            pass
118    
119  # output the variable that the user requests  # output the variable that the user requests
120    
# Line 115  def usage(progname): Line 132  def usage(progname):
132    
133  try:  try:
134      opts, args = getopt.getopt(sys.argv[1:], "h",      opts, args = getopt.getopt(sys.argv[1:], "h",
135          ["help", "cflags", "libs","var=","vars"]          ["help", "cflags", "libs", "var=","vars"]
136      )      )
137  except getopt.GetoptError, err:  except getopt.GetoptError, err:
138      print str(err)      print str(err)

Legend:
Removed from v.2436  
changed lines
  Added in v.2437

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22