~ubuntu-branches/ubuntu/trusty/mapnik/trusty

« back to all changes in this revision

Viewing changes to scons/scons-local-1.2.0/SCons/Tool/linkloc.py

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2009-05-20 15:39:58 UTC
  • mfrom: (3.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090520153958-cf6z1ql9zva4y4dq
Tags: 0.6.0-1ubuntu1
* Merge from debian unstable (LP: #378819), remaining changes:
  - debian/control:
    + Change bdeps from python2.5-dev to python-all-dev (>= 2.5)
    + Change XS-Python-Version from 2.5 to >= 2.5
  - debian/rules:
    + Various changes to enable python2.5 and python2.6 builds
* debian/patches/libtool2_2.diff Dropped. Included upsteam.
* Removed quilt support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""SCons.Tool.linkloc
 
2
 
 
3
Tool specification for the LinkLoc linker for the Phar Lap ETS embedded
 
4
operating system.
 
5
 
 
6
There normally shouldn't be any need to import this module directly.
 
7
It will usually be imported through the generic SCons.Tool.Tool()
 
8
selection method.
 
9
 
 
10
"""
 
11
 
 
12
#
 
13
# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation
 
14
#
 
15
# Permission is hereby granted, free of charge, to any person obtaining
 
16
# a copy of this software and associated documentation files (the
 
17
# "Software"), to deal in the Software without restriction, including
 
18
# without limitation the rights to use, copy, modify, merge, publish,
 
19
# distribute, sublicense, and/or sell copies of the Software, and to
 
20
# permit persons to whom the Software is furnished to do so, subject to
 
21
# the following conditions:
 
22
#
 
23
# The above copyright notice and this permission notice shall be included
 
24
# in all copies or substantial portions of the Software.
 
25
#
 
26
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
 
27
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 
28
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
29
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
30
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
31
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
32
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
33
#
 
34
 
 
35
__revision__ = "src/engine/SCons/Tool/linkloc.py 3842 2008/12/20 22:59:52 scons"
 
36
 
 
37
import os.path
 
38
import re
 
39
 
 
40
import SCons.Action
 
41
import SCons.Defaults
 
42
import SCons.Errors
 
43
import SCons.Tool
 
44
import SCons.Util
 
45
 
 
46
from SCons.Tool.msvc import get_msvc_paths
 
47
from SCons.Tool.PharLapCommon import addPharLapPaths
 
48
 
 
49
_re_linker_command = re.compile(r'(\s)@\s*([^\s]+)')
 
50
 
 
51
def repl_linker_command(m):
 
52
    # Replaces any linker command file directives (e.g. "@foo.lnk") with
 
53
    # the actual contents of the file.
 
54
    try:
 
55
        f=open(m.group(2), "r")
 
56
        return m.group(1) + f.read()
 
57
    except IOError:
 
58
        # the linker should return an error if it can't
 
59
        # find the linker command file so we will remain quiet.
 
60
        # However, we will replace the @ with a # so we will not continue
 
61
        # to find it with recursive substitution
 
62
        return m.group(1) + '#' + m.group(2)
 
63
 
 
64
class LinklocGenerator:
 
65
    def __init__(self, cmdline):
 
66
        self.cmdline = cmdline
 
67
 
 
68
    def __call__(self, env, target, source, for_signature):
 
69
        if for_signature:
 
70
            # Expand the contents of any linker command files recursively
 
71
            subs = 1
 
72
            strsub = env.subst(self.cmdline, target=target, source=source)
 
73
            while subs:
 
74
                strsub, subs = _re_linker_command.subn(repl_linker_command, strsub)
 
75
            return strsub
 
76
        else:
 
77
            return "${TEMPFILE('" + self.cmdline + "')}"
 
78
 
 
79
def generate(env):
 
80
    """Add Builders and construction variables for ar to an Environment."""
 
81
    SCons.Tool.createSharedLibBuilder(env)
 
82
    SCons.Tool.createProgBuilder(env)
 
83
 
 
84
    env['SUBST_CMD_FILE'] = LinklocGenerator
 
85
    env['SHLINK']      = '$LINK'
 
86
    env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS')
 
87
    env['SHLINKCOM']   = '${SUBST_CMD_FILE("$SHLINK $SHLINKFLAGS $( $_LIBDIRFLAGS $) $_LIBFLAGS -dll $TARGET $SOURCES")}'
 
88
    env['SHLIBEMITTER']= None
 
89
    env['LINK']        = "linkloc"
 
90
    env['LINKFLAGS']   = SCons.Util.CLVar('')
 
91
    env['LINKCOM']     = '${SUBST_CMD_FILE("$LINK $LINKFLAGS $( $_LIBDIRFLAGS $) $_LIBFLAGS -exe $TARGET $SOURCES")}'
 
92
    env['LIBDIRPREFIX']='-libpath '
 
93
    env['LIBDIRSUFFIX']=''
 
94
    env['LIBLINKPREFIX']='-lib '
 
95
    env['LIBLINKSUFFIX']='$LIBSUFFIX'
 
96
 
 
97
    msvs_version = env.get('MSVS_VERSION')
 
98
    include_path, lib_path, exe_path = get_msvc_paths(env, version = msvs_version)
 
99
    env['ENV']['LIB'] = lib_path
 
100
    env.PrependENVPath('PATH', exe_path)
 
101
 
 
102
    addPharLapPaths(env)
 
103
 
 
104
def exists(env):
 
105
    return env.Detect('linkloc')