1 """SCons.Platform.posix
2
3 Platform-specific initialization for POSIX (Linux, UNIX, etc.) systems.
4
5 There normally shouldn't be any need to import this module directly. It
6 will usually be imported through the generic SCons.Platform.Platform()
7 selection method.
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 __revision__ = "src/engine/SCons/Platform/posix.py 3a41ed6b288cee8d085373ad7fa02894e1903864 2019-01-23 17:30:35 bdeegan"
34
35 import errno
36 import os
37 import os.path
38 import subprocess
39 import sys
40 import select
41
42 import SCons.Util
43 from SCons.Platform import TempFileMunge
44 from SCons.Platform.virtualenv import ImportVirtualenv
45 from SCons.Platform.virtualenv import ignore_virtualenv, enable_virtualenv
46
47 exitvalmap = {
48 2 : 127,
49 13 : 126,
50 }
51
53 """escape shell special characters"""
54 slash = '\\'
55 special = '"$'
56
57 arg = arg.replace(slash, slash+slash)
58 for c in special:
59 arg = arg.replace(c, slash+c)
60
61
62 return '"' + arg + '"'
63
64
66 proc = subprocess.Popen(l, env = env, close_fds = True)
67 return proc.wait()
68
71
73 proc = subprocess.Popen(l, env = env, close_fds = True,
74 stdout = stdout,
75 stderr = stderr)
76 return proc.wait()
77
79
80
81
82 return exec_popen3([sh, '-c', ' '.join(args)],
83 env, stdout, stderr)
84
85
87
88 spawn = subprocess_spawn
89 pspawn = piped_env_spawn
90
91
92 if 'ENV' not in env:
93 env['ENV'] = {}
94 env['ENV']['PATH'] = '/usr/local/bin:/opt/bin:/bin:/usr/bin'
95 env['OBJPREFIX'] = ''
96 env['OBJSUFFIX'] = '.o'
97 env['SHOBJPREFIX'] = '$OBJPREFIX'
98 env['SHOBJSUFFIX'] = '$OBJSUFFIX'
99 env['PROGPREFIX'] = ''
100 env['PROGSUFFIX'] = ''
101 env['LIBPREFIX'] = 'lib'
102 env['LIBSUFFIX'] = '.a'
103 env['SHLIBPREFIX'] = '$LIBPREFIX'
104 env['SHLIBSUFFIX'] = '.so'
105 env['LIBPREFIXES'] = [ '$LIBPREFIX' ]
106 env['LIBSUFFIXES'] = [ '$LIBSUFFIX', '$SHLIBSUFFIX' ]
107 env['PSPAWN'] = pspawn
108 env['SPAWN'] = spawn
109 env['SHELL'] = 'sh'
110 env['ESCAPE'] = escape
111 env['TEMPFILE'] = TempFileMunge
112 env['TEMPFILEPREFIX'] = '@'
113
114
115 env['MAXLINELENGTH'] = 128072
116
117
118 env['__RPATH'] = '$_RPATH'
119
120
121
122 env['__DRPATH'] = '$_DRPATH'
123
124 if enable_virtualenv and not ignore_virtualenv:
125 ImportVirtualenv(env)
126
127
128
129
130
131
132