| 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 |
| 6 import optparse | 6 import optparse |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 continue | 72 continue |
| 73 if filename.startswith('scons-out'): | 73 if filename.startswith('scons-out'): |
| 74 continue | 74 continue |
| 75 if filename.endswith('.nexe'): | 75 if filename.endswith('.nexe'): |
| 76 continue | 76 continue |
| 77 # Apply the underlay of gpu/command_buffer (to match scons). | 77 # Apply the underlay of gpu/command_buffer (to match scons). |
| 78 if filename.startswith(NACL_CMD_BUFFER_DIR + os.sep): | 78 if filename.startswith(NACL_CMD_BUFFER_DIR + os.sep): |
| 79 filename = GPU_CMD_BUFFER_DIR + filename[len(NACL_CMD_BUFFER_DIR):] | 79 filename = GPU_CMD_BUFFER_DIR + filename[len(NACL_CMD_BUFFER_DIR):] |
| 80 inputs.add(filename) | 80 inputs.add(filename) |
| 81 # Check that everything exists and make it script relative. | 81 # Check that everything exists and make it script relative. |
| 82 # Exclude things above SRC_DIR. |
| 82 rel_inputs = set() | 83 rel_inputs = set() |
| 83 for f in inputs: | 84 for f in inputs: |
| 84 nf = os.path.join(NACL_DIR, f) | 85 nf = os.path.join(NACL_DIR, f) |
| 85 if not os.path.exists(nf): | 86 if not os.path.exists(nf): |
| 86 raise Exception('missing input file "%s"' % nf) | 87 raise Exception('missing input file "%s"' % nf) |
| 88 # If the relative path from SRC_DIR to the file starts with ../ ignore it. |
| 89 # (i.e. the file is outside the client). |
| 90 if RelativePath(nf, SRC_DIR).startswith('..' + os.sep): |
| 91 continue |
| 87 rel_inputs.add(RelativePath(nf, SCRIPT_DIR)) | 92 rel_inputs.add(RelativePath(nf, SCRIPT_DIR)) |
| 88 # Print it sorted. | 93 # Print it sorted. |
| 89 rel_inputs = sorted(list(rel_inputs)) | 94 rel_inputs = sorted(list(rel_inputs)) |
| 90 for f in rel_inputs: | 95 for f in rel_inputs: |
| 91 print f | 96 print f |
| 92 | 97 |
| 93 | 98 |
| 94 def BuildIRT(platforms, out_dir): | 99 def BuildIRT(platforms, out_dir): |
| 95 """Build the IRT for several platforms. | 100 """Build the IRT for several platforms. |
| 96 | 101 |
| 97 Arguments: | 102 Arguments: |
| 98 platforms: list of platform names to build for. | 103 platforms: list of platform names to build for. |
| 99 out_dir: directory to output the IRT to. | 104 out_dir: directory to output the IRT to. |
| 100 """ | 105 """ |
| 106 # Make out_dir absolute. |
| 107 out_dir = os.path.abspath(out_dir) |
| 101 # Clean. | 108 # Clean. |
| 102 scons_out = os.path.join(NACL_DIR, 'scons-out') | 109 scons_out = os.path.join(NACL_DIR, 'scons-out') |
| 103 if os.path.exists(scons_out): | 110 if os.path.exists(scons_out): |
| 104 shutil.rmtree(scons_out) | 111 shutil.rmtree(scons_out) |
| 105 # Build for each platform. | 112 # Build for each platform. |
| 106 for platform in platforms: | 113 for platform in platforms: |
| 107 cmd = [ | 114 cmd = [ |
| 108 sys.executable, 'scons.py', '--verbose', '-j8', | 115 sys.executable, 'scons.py', '--verbose', '-j8', |
| 109 '--mode=nacl', 'platform=' + platform, | 116 '--mode=nacl', 'platform=' + platform, |
| 110 'scons-out/nacl_irt-' + platform + '/staging/irt.nexe', | 117 'scons-out/nacl_irt-' + platform + '/staging/irt.nexe', |
| 111 ] | 118 ] |
| 112 print 'Running: ' + ' '.join(cmd) | 119 print 'Running: ' + ' '.join(cmd) |
| 113 p = subprocess.Popen(cmd, cwd=NACL_DIR) | 120 # Work around the fact that python's readline module (used by scons), |
| 121 # attempts to alter file handle state on stdin in a way that blocks if |
| 122 # a process is not a member of a foreground job on a tty on OSX. |
| 123 # e.g. On a Mac: |
| 124 # |
| 125 # hydric:test mseaborn$ python -c 'import readline' & |
| 126 # [1] 67058 |
| 127 # hydric:test mseaborn$ |
| 128 # [1]+ Stopped python -c 'import readline' |
| 129 # |
| 130 # i.e. the process receives a stop signal when it's a background job. |
| 131 if sys.platform == 'darwin': |
| 132 devnull = open(os.devnull, 'r') |
| 133 else: |
| 134 devnull = None |
| 135 p = subprocess.Popen(cmd, cwd=NACL_DIR, stdin=devnull) |
| 114 p.wait() | 136 p.wait() |
| 115 if p.returncode != 0: | 137 if p.returncode != 0: |
| 116 sys.exit(3) | 138 sys.exit(3) |
| 117 # Copy out each platform after stripping. | 139 # Copy out each platform after stripping. |
| 118 for platform in platforms: | 140 for platform in platforms: |
| 119 uplatform = platform.replace('-', '_') | 141 uplatform = platform.replace('-', '_') |
| 120 platform2 = {'x86-32': 'i686', 'x86-64': 'x86_64'}.get(platform, platform) | 142 platform2 = {'x86-32': 'i686', 'x86-64': 'x86_64'}.get(platform, platform) |
| 121 cplatform = { | 143 cplatform = { |
| 122 'win32': 'win', | 144 'win32': 'win', |
| 123 'cygwin': 'win', | 145 'cygwin': 'win', |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 sys.exit(1) | 177 sys.exit(1) |
| 156 | 178 |
| 157 if options.inputs: | 179 if options.inputs: |
| 158 PrintInputs(options.platforms) | 180 PrintInputs(options.platforms) |
| 159 else: | 181 else: |
| 160 BuildIRT(options.platforms, options.outdir) | 182 BuildIRT(options.platforms, options.outdir) |
| 161 | 183 |
| 162 | 184 |
| 163 if __name__ == '__main__': | 185 if __name__ == '__main__': |
| 164 Main(sys.argv) | 186 Main(sys.argv) |
| OLD | NEW |