|
OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
noelallen_use_chromium
2011/08/23 21:42:05
Clean out plz.
bradn
2011/08/23 21:53:48
Done.
| |
6 #import sys | |
Mark Seaborn
2011/08/23 21:42:21
Don't forget to remove this.
bradn
2011/08/23 21:53:48
Done.
| |
7 #sys.stderr.write('AAAAAAA\n') | |
8 #import os | |
9 #print os.isatty(0) | |
10 #print os.isatty(1) | |
11 #print os.isatty(2) | |
12 #print "here" | |
13 #sys.stdout.flush() | |
14 #import readline | |
15 #sys.stderr.write('BBBBBBB\n') | |
16 | |
6 import optparse | 17 import optparse |
7 import os | 18 import os |
8 import re | 19 import re |
9 import shutil | 20 import shutil |
10 import subprocess | 21 import subprocess |
11 import sys | 22 import sys |
12 | 23 |
13 | 24 |
14 # Where things are in relation to this script. | 25 # Where things are in relation to this script. |
15 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 26 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 continue | 83 continue |
73 if filename.startswith('scons-out'): | 84 if filename.startswith('scons-out'): |
74 continue | 85 continue |
75 if filename.endswith('.nexe'): | 86 if filename.endswith('.nexe'): |
76 continue | 87 continue |
77 # Apply the underlay of gpu/command_buffer (to match scons). | 88 # Apply the underlay of gpu/command_buffer (to match scons). |
78 if filename.startswith(NACL_CMD_BUFFER_DIR + os.sep): | 89 if filename.startswith(NACL_CMD_BUFFER_DIR + os.sep): |
79 filename = GPU_CMD_BUFFER_DIR + filename[len(NACL_CMD_BUFFER_DIR):] | 90 filename = GPU_CMD_BUFFER_DIR + filename[len(NACL_CMD_BUFFER_DIR):] |
80 inputs.add(filename) | 91 inputs.add(filename) |
81 # Check that everything exists and make it script relative. | 92 # Check that everything exists and make it script relative. |
93 # Exclude things above SRC_DIR. | |
82 rel_inputs = set() | 94 rel_inputs = set() |
83 for f in inputs: | 95 for f in inputs: |
84 nf = os.path.join(NACL_DIR, f) | 96 nf = os.path.join(NACL_DIR, f) |
85 if not os.path.exists(nf): | 97 if not os.path.exists(nf): |
86 raise Exception('missing input file "%s"' % nf) | 98 raise Exception('missing input file "%s"' % nf) |
99 # If the relative path from SRC_DIR to the file starts with ../ ignore it. | |
100 # (i.e. the file is outside the client). | |
101 if RelativePath(nf, SRC_DIR).startswith('..' + os.sep): | |
102 continue | |
87 rel_inputs.add(RelativePath(nf, SCRIPT_DIR)) | 103 rel_inputs.add(RelativePath(nf, SCRIPT_DIR)) |
88 # Print it sorted. | 104 # Print it sorted. |
89 rel_inputs = sorted(list(rel_inputs)) | 105 rel_inputs = sorted(list(rel_inputs)) |
90 for f in rel_inputs: | 106 for f in rel_inputs: |
91 print f | 107 print f |
92 | 108 |
93 | 109 |
94 def BuildIRT(platforms, out_dir): | 110 def BuildIRT(platforms, out_dir): |
95 """Build the IRT for several platforms. | 111 """Build the IRT for several platforms. |
96 | 112 |
97 Arguments: | 113 Arguments: |
98 platforms: list of platform names to build for. | 114 platforms: list of platform names to build for. |
99 out_dir: directory to output the IRT to. | 115 out_dir: directory to output the IRT to. |
100 """ | 116 """ |
117 # Make out_dir absolute. | |
118 out_dir = os.path.abspath(out_dir) | |
101 # Clean. | 119 # Clean. |
102 scons_out = os.path.join(NACL_DIR, 'scons-out') | 120 scons_out = os.path.join(NACL_DIR, 'scons-out') |
103 if os.path.exists(scons_out): | 121 if os.path.exists(scons_out): |
104 shutil.rmtree(scons_out) | 122 shutil.rmtree(scons_out) |
105 # Build for each platform. | 123 # Build for each platform. |
106 for platform in platforms: | 124 for platform in platforms: |
107 cmd = [ | 125 cmd = [ |
108 sys.executable, 'scons.py', '--verbose', '-j8', | 126 sys.executable, 'scons.py', '--verbose', '-j8', |
109 '--mode=nacl', 'platform=' + platform, | 127 '--mode=nacl', 'platform=' + platform, |
110 'scons-out/nacl_irt-' + platform + '/staging/irt.nexe', | 128 'scons-out/nacl_irt-' + platform + '/staging/irt.nexe', |
111 ] | 129 ] |
112 print 'Running: ' + ' '.join(cmd) | 130 print 'Running: ' + ' '.join(cmd) |
113 p = subprocess.Popen(cmd, cwd=NACL_DIR) | 131 os.chdir(NACL_DIR) |
132 # Work around the fact that python's readline module (used by scons), | |
133 # attempts to alter file handle state on stdin in a way that blocks if | |
134 # a process is not the primary owner of a terminal on OSX. | |
Mark Seaborn
2011/08/23 21:42:21
"not a member of a foreground job on a tty"?
e.g.
bradn
2011/08/23 21:53:48
Done.
| |
135 if sys.platform == 'darwin': | |
136 devnull = open(os.devnull, 'rb').fileno() | |
Mark Seaborn
2011/08/23 21:42:21
open(os.devnull, 'rb').fileno() is wrong: the file
bradn
2011/08/23 21:53:48
Done.
| |
137 else: | |
138 devnull = None | |
139 p = subprocess.Popen(cmd, cwd=NACL_DIR, stdin=devnull) | |
Mark Seaborn
2011/08/23 21:42:21
Use either cwd= or chdir() but not both?
bradn
2011/08/23 21:53:48
Done.
| |
114 p.wait() | 140 p.wait() |
115 if p.returncode != 0: | 141 if p.returncode != 0: |
116 sys.exit(3) | 142 sys.exit(3) |
117 # Copy out each platform after stripping. | 143 # Copy out each platform after stripping. |
118 for platform in platforms: | 144 for platform in platforms: |
119 uplatform = platform.replace('-', '_') | 145 uplatform = platform.replace('-', '_') |
120 platform2 = {'x86-32': 'i686', 'x86-64': 'x86_64'}.get(platform, platform) | 146 platform2 = {'x86-32': 'i686', 'x86-64': 'x86_64'}.get(platform, platform) |
121 cplatform = { | 147 cplatform = { |
122 'win32': 'win', | 148 'win32': 'win', |
123 'cygwin': 'win', | 149 'cygwin': 'win', |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 sys.exit(1) | 181 sys.exit(1) |
156 | 182 |
157 if options.inputs: | 183 if options.inputs: |
158 PrintInputs(options.platforms) | 184 PrintInputs(options.platforms) |
159 else: | 185 else: |
160 BuildIRT(options.platforms, options.outdir) | 186 BuildIRT(options.platforms, options.outdir) |
161 | 187 |
162 | 188 |
163 if __name__ == '__main__': | 189 if __name__ == '__main__': |
164 Main(sys.argv) | 190 Main(sys.argv) |
OLD | NEW |