morelink.py :  » Build » Waf » waf-1.5.17 » playground » crazy_rpath » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Build » Waf 
Waf » waf 1.5.17 » playground » crazy_rpath » morelink.py
#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2010 (ita)

import os
import TaskGen
from TaskGen import feature,after,before
from ccroot import get_target_name
import Constants
import Task

cc = Task.TaskBase.classes['cc_link']
class inst_cc(cc):
  """identical to the link task except that it only runs at install time"""
  def runnable_status(self):
    if not self.generator.bld.is_install:
      return Constants.SKIP_ME
    return Task.Task.runnable_status(self)

old = TaskGen.task_gen.apply_link

@feature('cprogram', 'cshlib', 'cstaticlib')
@after('apply_link')
@before('default_link_install', 'apply_vnum')
def no_rpath(self):
  """This would almost justify a new feature"""
  if self.link_task.__class__.__name__ != 'cc_link':
    return

  name = '__' + get_target_name(self) # not always a .so
  tsk = self.create_task('inst_cc')
  tsk.inputs = self.link_task.inputs
  tsk.set_outputs(self.path.find_or_declare(name))

  tsk.set_run_after(self.link_task)
  self.link_task.env = tsk.env.copy()

  self.meths.remove('default_link_install')
  if not getattr(self, 'vnum', None):
    self.bld.install_as(self.install_path + '/' + self.link_task.outputs[0].name, tsk.outputs[0], env=self.env, chmod=self.chmod)
    return

  self.meths.remove('apply_vnum')

  # following is from apply_vnum
  link = self.link_task
  nums = self.vnum.split('.')
  node = link.outputs[0]

  libname = node.name
  if libname.endswith('.dylib'):
    name3 = libname.replace('.dylib', '.%s.dylib' % self.vnum)
    name2 = libname.replace('.dylib', '.%s.dylib' % nums[0])
  else:
    name3 = libname + '.' + self.vnum
    name2 = libname + '.' + nums[0]

  if self.env.SONAME_ST:
    v = self.env.SONAME_ST % name2
    self.env.append_value('LINKFLAGS', v.split())

  bld = self.bld
  nums = self.vnum.split('.')

  path = self.install_path
  if not path: return

  bld.install_as(path + os.sep + name3, tsk.outputs[0], env=self.env) # not the link task node
  bld.symlink_as(path + os.sep + name2, name3)
  bld.symlink_as(path + os.sep + libname, name3)

  # the following task is just to enable execution from the build dir :-/
  tsk = self.create_task('vnum')
  tsk.set_inputs([node])
  tsk.set_outputs(node.parent.find_or_declare(name2))

@feature('cprogram', 'cshlib', 'cstaticlib')
@after('apply_lib_vars', 'apply_link', 'no_rpath')
@before('apply_obj_vars')
def evil_rpath(self):
  """looks like we should split this processing in waf 1.6 somehow"""
  env = self.env
  rpath_st = env['RPATH_ST']
  app = self.link_task.env.append_unique
  for i in self.env['RPATH']:
    if i and rpath_st:
      # we cannot modify LINKFLAGS since it is shared :-/
      app('LINK_CC', rpath_st % i)
  self.env['RPATH'] = []

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.