Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python | |
|
Nick Bray
2012/08/08 18:24:44
Needs copyright header.
Vlad Shcherbina
2012/08/09 10:07:35
Done.
| |
| 2 | |
| 3 """ | |
| 4 Usage: | |
| 5 %s <objdump> <gas> | |
|
Nick Bray
2012/08/08 18:24:44
It doesn't seem like this is really a docstring, i
Vlad Shcherbina
2012/08/09 10:07:35
Made it proper docstring instead.
| |
| 6 | |
| 7 Check out appropriate version of binutils, compile it and | |
| 8 copy objdump and gas binaries to specified places. | |
| 9 """ | |
| 10 | |
| 11 import sys | |
|
Nick Bray
2012/08/08 18:24:44
Alphabetize.
Vlad Shcherbina
2012/08/09 10:07:35
Done.
| |
| 12 import os | |
| 13 import shutil | |
| 14 | |
| 15 CHECKOUT_DIR = '/dev/shm/binutils' | |
| 16 | |
| 17 BINUTILS_REPO = 'http://git.chromium.org/native_client/nacl-binutils.git' | |
| 18 BINUTILS_REVISION = '6993545d5650fa77e75e9ae4b52c5703a53c53cc' | |
| 19 | |
| 20 # We need specific revision of binutils, and it have to include the | |
| 21 # following patches: | |
| 22 # Add prefetch_modified - non-canonical encoding of prefetch | |
| 23 # | |
| 24 # Properly handle data16+rex.w instructions, such as | |
| 25 # 66 48 68 01 02 03 04 data32 pushq $0x4030201 | |
| 26 # | |
| 27 # We are not using head revision because decoder test depends | |
| 28 # on precise format of objdump output. | |
| 29 | |
| 30 | |
| 31 def Command(cmd): | |
| 32 result = os.system(cmd) | |
|
Nick Bray
2012/08/08 18:24:44
I have found that scripts like this benefit from:
Vlad Shcherbina
2012/08/09 10:07:35
Done.
| |
| 33 if result != 0: | |
| 34 print 'Command "%s" returned %s' % (cmd, result) | |
| 35 exit(result) | |
|
Nick Bray
2012/08/08 18:24:44
Use sys.exit instead - it is more standard and "ex
Vlad Shcherbina
2012/08/09 10:07:35
Oh, I never suspected that.
Done.
| |
| 36 | |
| 37 | |
| 38 def main(): | |
| 39 if len(sys.argv) != 3: | |
| 40 print __doc__ % os.path.split(__file__)[1] | |
| 41 exit(1) | |
| 42 | |
| 43 if os.path.exists(CHECKOUT_DIR): | |
| 44 shutil.rmtree(CHECKOUT_DIR) | |
| 45 | |
| 46 Command('git clone %s %s' % (BINUTILS_REPO, CHECKOUT_DIR)) | |
| 47 | |
| 48 old_dir = os.getcwd() | |
| 49 try: | |
| 50 os.chdir(CHECKOUT_DIR) | |
| 51 Command('git checkout %s' % BINUTILS_REVISION) | |
| 52 | |
| 53 # to please make, set the same modification time | |
|
Nick Bray
2012/08/08 18:24:44
Capitalize, period at the end, possibly start the
Vlad Shcherbina
2012/08/09 10:07:35
I rechecked, and it's actually not needed. So I re
| |
| 54 # for all files | |
| 55 Command('find . -print0 | xargs -0 touch -r .') | |
| 56 | |
| 57 # they both are required to make binutils, | |
|
Nick Bray
2012/08/08 18:24:44
Capitalize, period at end.
Vlad Shcherbina
2012/08/09 10:07:35
Done.
| |
| 58 # and when they are missing binutils's make | |
| 59 # error messages are cryptic | |
| 60 Command('flex --version') | |
| 61 Command('bison --version') | |
| 62 | |
| 63 Command('./configure') | |
| 64 Command('make') | |
| 65 finally: | |
| 66 os.chdir(old_dir) | |
|
Nick Bray
2012/08/08 18:24:44
Why? The process terminates in this case. You pr
Vlad Shcherbina
2012/08/09 10:07:35
You are right. But I also need to chdir back becau
| |
| 67 | |
| 68 objdump, gas = sys.argv[1:] | |
| 69 shutil.copy(os.path.join(CHECKOUT_DIR, 'binutils', 'objdump'), objdump) | |
| 70 shutil.copy(os.path.join(CHECKOUT_DIR, 'gas', 'as-new'), gas) | |
| 71 | |
| 72 shutil.rmtree(CHECKOUT_DIR) | |
| 73 | |
| 74 print 'ok' | |
| 75 | |
| 76 | |
| 77 if __name__ == '__main__': | |
| 78 main() | |
| OLD | NEW |