- add sources.
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / build_tools / sdk_tools / command / list.py
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 def List(remote_manifest, local_manifest, display_revisions):
6   any_bundles_need_update = False
7   print 'Bundles:'
8   print ' I: installed\n *: update available\n'
9   for bundle in remote_manifest.GetBundles():
10     local_bundle = local_manifest.GetBundle(bundle.name)
11     needs_update = local_bundle and local_manifest.BundleNeedsUpdate(bundle)
12     if needs_update:
13       any_bundles_need_update = True
14
15     _PrintBundle(local_bundle, bundle, needs_update, display_revisions)
16
17   if not any_bundles_need_update:
18     print '\nAll installed bundles are up-to-date.'
19
20   local_only_bundles = set([b.name for b in local_manifest.GetBundles()])
21   local_only_bundles -= set([b.name for b in remote_manifest.GetBundles()])
22   if local_only_bundles:
23     print '\nBundles installed locally that are not available remotely:'
24     for bundle_name in local_only_bundles:
25       local_bundle = local_manifest.GetBundle(bundle_name)
26       _PrintBundle(local_bundle, None, False, display_revisions)
27
28
29 def _PrintBundle(local_bundle, bundle, needs_update, display_revisions):
30   installed = local_bundle is not None
31   # If bundle is None, there is no longer a remote bundle with this name.
32   if bundle is None:
33     bundle = local_bundle
34
35   if display_revisions:
36     if needs_update:
37       revision = ' (r%s -> r%s)' % (local_bundle.revision, bundle.revision)
38     else:
39       revision = ' (r%s)' % (bundle.revision,)
40   else:
41     revision = ''
42
43   print ('  %s%s %s (%s)%s' % (
44     'I' if installed else ' ',
45     '*' if needs_update else ' ',
46     bundle.name,
47     bundle.stability,
48     revision))