Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 from __future__ import with_statement | 6 from __future__ import with_statement |
| 7 | 7 |
| 8 import errno | 8 import errno |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 os.makedirs(os.path.dirname(destination)) | 232 os.makedirs(os.path.dirname(destination)) |
| 233 except OSError as exception_info: | 233 except OSError as exception_info: |
| 234 if exception_info.errno != errno.EEXIST: | 234 if exception_info.errno != errno.EEXIST: |
| 235 raise | 235 raise |
| 236 if (os.path.normcase(os.path.abspath(source)) != | 236 if (os.path.normcase(os.path.abspath(source)) != |
| 237 os.path.normcase(os.path.abspath(destination))): | 237 os.path.normcase(os.path.abspath(destination))): |
| 238 shutil.copy2(source, destination) | 238 shutil.copy2(source, destination) |
| 239 | 239 |
| 240 def _GenerateManifest(self, runnable=True): | 240 def _GenerateManifest(self, runnable=True): |
| 241 '''Create a JSON formatted dict containing the files | 241 '''Create a JSON formatted dict containing the files |
| 242 | 242 |
| 243 NaCl will map url requests based on architecture. The startup NEXE | 243 NaCl will map url requests based on architecture. The startup NEXE |
| 244 can always be found under the top key PROGRAM. Additional files are under | 244 can always be found under the top key PROGRAM. Additional files are under |
| 245 the FILES key further mapped by file name. In the case of 'runnable' the | 245 the FILES key further mapped by file name. In the case of 'runnable' the |
| 246 PROGRAM key is populated with urls pointing the runnable-ld.so which acts | 246 PROGRAM key is populated with urls pointing the runnable-ld.so which acts |
| 247 as the startup nexe. The application itself, is then placed under the | 247 as the startup nexe. The application itself, is then placed under the |
| 248 FILES key mapped as 'main.exe' instead of it's original name so that the | 248 FILES key mapped as 'main.exe' instead of it's original name so that the |
| 249 loader can find it.''' | 249 loader can find it.''' |
| 250 manifest = { FILES_KEY: {}, PROGRAM_KEY: {} } | 250 manifest = { FILES_KEY: {}, PROGRAM_KEY: {} } |
| 251 needed = self.GetNeeded() | 251 needed = self.GetNeeded() |
| 252 | 252 |
| 253 for need in needed: | 253 for need in needed: |
| 254 archinfo = needed[need] | 254 archinfo = needed[need] |
| 255 urlinfo = { URL_KEY: archinfo.url } | 255 urlinfo = { URL_KEY: archinfo.url } |
| 256 name = archinfo.name | 256 name = archinfo.name |
| 257 | 257 |
| 258 # If starting with runnable-ld.so, make that the main executable. | 258 # If starting with runnable-ld.so, make that the main executable. |
| 259 if runnable: | 259 if runnable: |
| 260 if need.endswith(RUNNABLE_LD): | 260 if need.endswith(RUNNABLE_LD): |
| 261 manifest[PROGRAM_KEY][archinfo.arch] = urlinfo | 261 manifest[PROGRAM_KEY][archinfo.arch] = urlinfo |
| 262 continue | 262 continue |
| 263 | 263 |
| 264 # For the main nexes: | 264 # For the main nexes: |
| 265 if need.endswith('.nexe') and need in self.main_files: | 265 if need.endswith('.nexe') and need in self.main_files: |
| 266 # Insure that the nexe name is relative, not absolute. | |
|
dmichael (off chromium)
2012/05/22 00:04:43
Insure->Ensure?
Brad Chen
2012/05/22 18:35:00
Done.
| |
| 267 # We assume that the nexe and the correspodning nmf file are | |
|
dmichael (off chromium)
2012/05/22 00:04:43
corresponding?
Brad Chen
2012/05/22 18:35:00
Done.
| |
| 268 # installed in the same directory. | |
| 269 urlinfo[URL_KEY] = os.path.basename(urlinfo[URL_KEY]) | |
| 266 # Place it under program if we aren't using the runnable-ld.so. | 270 # Place it under program if we aren't using the runnable-ld.so. |
| 267 if not runnable: | 271 if not runnable: |
| 268 manifest[PROGRAM_KEY][archinfo.arch] = urlinfo | 272 manifest[PROGRAM_KEY][archinfo.arch] = urlinfo |
| 269 continue | 273 continue |
| 270 # Otherwise, treat it like another another file named main.nexe. | 274 # Otherwise, treat it like another another file named main.nexe. |
| 271 name = MAIN_NEXE | 275 name = MAIN_NEXE |
| 272 | 276 |
| 273 fileinfo = manifest[FILES_KEY].get(name, {}) | 277 fileinfo = manifest[FILES_KEY].get(name, {}) |
| 274 fileinfo[archinfo.arch] = urlinfo | 278 fileinfo[archinfo.arch] = urlinfo |
| 275 manifest[FILES_KEY][name] = fileinfo | 279 manifest[FILES_KEY][name] = fileinfo |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 with open(options.output, 'w') as output: | 333 with open(options.output, 'w') as output: |
| 330 output.write(nmf.GetJson()) | 334 output.write(nmf.GetJson()) |
| 331 | 335 |
| 332 if options.stage_dependencies: | 336 if options.stage_dependencies: |
| 333 nmf.StageDependencies(options.stage_dependencies) | 337 nmf.StageDependencies(options.stage_dependencies) |
| 334 | 338 |
| 335 | 339 |
| 336 # Invoke this file directly for simple testing. | 340 # Invoke this file directly for simple testing. |
| 337 if __name__ == '__main__': | 341 if __name__ == '__main__': |
| 338 sys.exit(Main(sys.argv[1:])) | 342 sys.exit(Main(sys.argv[1:])) |
| OLD | NEW |