Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / native_client / pnacl / driver / pnacl-ar.py
1 #!/usr/bin/python
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 #
6 # IMPORTANT NOTE: If you make local mods to this file, you must run:
7 #   %  pnacl/build.sh driver
8 # in order for them to take effect in the scons build.  This command
9 # updates the copy in the toolchain/ tree.
10 #
11
12 import driver_tools
13 from driver_env import env
14
15 EXTRA_ENV = {
16   'ARGS':    '',
17   'COMMAND': ''
18 }
19 # just pass all args through to 'ARGS' and eventually to the underlying tool
20 PATTERNS = [ ( '(.*)',  "env.append('ARGS', $0)") ]
21
22 def main(argv):
23   if len(argv) ==  0:
24     print get_help(argv)
25     return 1
26
27   env.update(EXTRA_ENV)
28   driver_tools.ParseArgs(argv, PATTERNS)
29
30   # Note: --plugin must come after the command flags, but before the filename.
31   #       (definitely confirmed that it cannot go before the command)
32   #       for now assume command is just the very first args
33   args = env.get('ARGS')
34   command = args.pop(0)
35   env.set('COMMAND', command)
36   env.set('ARGS', *args)
37   driver_tools.Run('"${AR}" ${COMMAND} --plugin=${GOLD_PLUGIN_SO} ${ARGS}')
38   # only reached in case of no errors
39   return 0
40
41
42 def get_help(unused_argv):
43   return """
44 Usage: %s [-]{dmpqrstx}[abcDfilMNoPsSTuvV] [member-name] [count] archive-file file...
45  commands:
46   d            - delete file(s) from the archive
47   m[ab]        - move file(s) in the archive
48   p            - print file(s) found in the archive
49   q[f]         - quick append file(s) to the archive
50   r[ab][f][u]  - replace existing or insert new file(s) into the archive
51   s            - act as ranlib
52   t            - display contents of archive
53   x[o]         - extract file(s) from the archive
54  command specific modifiers:
55   [a]          - put file(s) after [member-name]
56   [b]          - put file(s) before [member-name] (same as [i])
57   [D]          - use zero for timestamps and uids/gids
58   [N]          - use instance [count] of name
59   [f]          - truncate inserted file names
60   [P]          - use full path names when matching
61   [o]          - preserve original dates
62   [u]          - only replace files that are newer than current archive contents
63  generic modifiers:
64   [c]          - do not warn if the library had to be created
65   [s]          - create an archive index (cf. ranlib)
66   [S]          - do not build a symbol table
67   [T]          - make a thin archive
68   [v]          - be verbose
69   [V]          - display the version number
70   @<file>      - read options from <file>
71 """ % env.getone('SCRIPT_NAME')