summaryrefslogtreecommitdiff
path: root/buildtools/wafsamba/samba_cross.py
blob: 70d74e0c94070833bc797c2933ec4b95c2d69bef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# functions for handling cross-compilation

import pproc, Utils
from Configure import conf
from pproc import Popen

real_Popen = None

class cross_Popen(Popen):
    '''cross-compilation wrapper for Popen'''
    def __init__(*k, **kw):
        (obj, args) = k
        if '--cross-execute' in args:
            # when --cross-execute is set, then change the arguments
            # to use the cross emulator
            i = args.index('--cross-execute')
            newargs = args[i+1].split()
            newargs.extend(args[0:i])
            args = newargs
        Popen.__init__(*(obj, args), **kw)


@conf
def SAMBA_CROSS_ARGS(conf):
    '''get exec_args to pass when running cross compiled binaries'''
    if not conf.env.CROSS_COMPILE or not conf.env.CROSS_EXECUTE:
        return []

    global real_Popen
    if real_Popen is None:
        real_Popen  = Utils.pproc.Popen
        Utils.pproc.Popen = cross_Popen

    return ['--cross-execute', conf.env.CROSS_EXECUTE]