Allow linking to outputs without using Dep nodes.
authorDavid Anderson <dvander@alliedmods.net>
Sat Nov 23 18:29:16 2013 -0800 (2013-11-23)
changeset 210966c633d0530
parent 209 582b84e577a8
child 211 7df3be7fbab3
Allow linking to outputs without using Dep nodes.
ambuild2/frontend/amb2/gen.py
ambuild2/frontend/cpp.py
     1.1 --- a/ambuild2/frontend/amb2/gen.py	Sat Nov 23 18:19:23 2013 -0800
     1.2 +++ b/ambuild2/frontend/amb2/gen.py	Sat Nov 23 18:29:16 2013 -0800
     1.3 @@ -457,7 +457,9 @@
     1.4        if util.IsString(val):
     1.5          continue
     1.6  
     1.7 -      if util.IsLambda(val.node):
     1.8 +      if type(val) is nodetypes.Entry:
     1.9 +        item = val
    1.10 +      elif util.IsLambda(val.node):
    1.11          item = val.node(context, binary)
    1.12        elif val.node is None:
    1.13          item = val.text
     2.1 --- a/ambuild2/frontend/cpp.py	Sat Nov 23 18:19:23 2013 -0800
     2.2 +++ b/ambuild2/frontend/cpp.py	Sat Nov 23 18:29:16 2013 -0800
     2.3 @@ -35,10 +35,10 @@
     2.4  
     2.5    @staticmethod
     2.6    def IncludePath(outputPath, includePath):
     2.7 -    #Hack - try and get a relative path because CL, with either 
     2.8 -    #/Zi or /ZI, combined with subprocess, apparently tries and
     2.9 -    #looks for paths like c:\bleh\"c:\bleh" <-- wtf
    2.10 -    #.. this according to Process Monitor
    2.11 +    # Hack - try and get a relative path because CL, with either 
    2.12 +    # /Zi or /ZI, combined with subprocess, apparently tries and
    2.13 +    # looks for paths like c:\bleh\"c:\bleh" <-- wtf
    2.14 +    # .. this according to Process Monitor
    2.15      outputPath = os.path.normcase(outputPath)
    2.16      includePath = os.path.normcase(includePath)
    2.17      outputDrive = os.path.splitdrive(outputPath)[0]
    2.18 @@ -104,7 +104,7 @@
    2.19      'mac': ['cc', 'clang', 'gcc', 'icc'],
    2.20      'windows': ['cl'],
    2.21      'default': ['cc', 'gcc', 'clang', 'icc']
    2.22 -    },
    2.23 +  },
    2.24    'CXX': {
    2.25      'mac': ['c++', 'clang++', 'g++', 'icc'],
    2.26      'windows': ['cl'],
    2.27 @@ -332,20 +332,6 @@
    2.28      self.cl_argv = cl_argv 
    2.29      self.rc_argv = rc_argv
    2.30  
    2.31 -def LinkFlags(compiler):
    2.32 -  argv = []
    2.33 -  for item in compiler.linkflags:
    2.34 -    if type(item) is not Dep:
    2.35 -      argv.append(item)
    2.36 -    else:
    2.37 -      argv.append(item.text)
    2.38 -  for item in compiler.postlink:
    2.39 -    if type(item) is not Dep:
    2.40 -      argv.append(item)
    2.41 -    else:
    2.42 -      argv.append(item.text)
    2.43 -  return argv
    2.44 -
    2.45  class BinaryBuilder(object):
    2.46    def __init__(self, compiler, name):
    2.47      super(BinaryBuilder, self).__init__()
    2.48 @@ -377,6 +363,24 @@
    2.49    def getBuildFolder(self, builder):
    2.50      return os.path.join(builder.buildFolder, self.localFolder)
    2.51  
    2.52 +  def linkFlag(self, cx, item):
    2.53 +    if type(item) is Dep:
    2.54 +      return item.text
    2.55 +
    2.56 +    if hasattr(item, 'path'):
    2.57 +      if os.path.isabs(item.path):
    2.58 +        return item.path
    2.59 +
    2.60 +      local_path = os.path.join(cx.buildFolder, self.localFolder)
    2.61 +      return os.path.relpath(item.path, local_path)
    2.62 +
    2.63 +    return item
    2.64 +
    2.65 +  def linkFlags(self, cx):
    2.66 +    argv = [self.linkFlag(cx, item) for item in self.compiler.linkflags]
    2.67 +    argv += [self.linkFlag(cx, item) for item in self.compiler.postlink]
    2.68 +    return argv
    2.69 +
    2.70    def finish(self, cx):
    2.71      # Because we want to compute relative include folders for MSVC (see its
    2.72      # vendor object), we need to compute an absolute path to the build folder.
    2.73 @@ -451,7 +455,7 @@
    2.74  
    2.75      if isinstance(self.linker_, MSVC):
    2.76        argv.append('/link')
    2.77 -    argv.extend(LinkFlags(self.compiler))
    2.78 +    argv.extend(self.linkFlags(cx))
    2.79      if isinstance(self.linker_, MSVC):
    2.80        argv.append('/OUT:' + self.outputFile)
    2.81        argv.append('/DEBUG')
    2.82 @@ -477,7 +481,7 @@
    2.83  
    2.84      if isinstance(self.linker_, MSVC):
    2.85        argv.append('/link')
    2.86 -    argv.extend(LinkFlags(self.compiler))
    2.87 +    argv.extend(self.linkFlags(cx))
    2.88      if isinstance(self.linker_, MSVC):
    2.89        argv.append('/OUT:' + self.outputFile)
    2.90        argv.append('/DEBUG')