| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 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 import os |
| 6 import sys |
| 7 |
| 8 # Packages a framework bundle by setting up symlinks for the "Current" version. |
| 9 # Usage: python /path/to/Foo.framework current_version |
| 10 |
| 11 def Main(args): |
| 12 if len(args) != 3: |
| 13 print >> sys.stderr, "Usage: %s /path/to/Something.framework A", (args[0],) |
| 14 return 1 |
| 15 |
| 16 (framework, version) = args[1:] |
| 17 |
| 18 # Find the name of the binary based on the part before the ".framework". |
| 19 binary = os.path.splitext(os.path.basename(framework))[0] |
| 20 |
| 21 CURRENT = 'Current' |
| 22 RESOURCES = 'Resources' |
| 23 VERSIONS = 'Versions' |
| 24 |
| 25 if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): |
| 26 # Binary-less frameworks don't seem to contain symlinks (see e.g. |
| 27 # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). |
| 28 return 0 |
| 29 |
| 30 # Move into the framework directory to set the symlinks correctly. |
| 31 os.chdir(framework) |
| 32 |
| 33 # Set up the Current version. |
| 34 _Relink(version, os.path.join(VERSIONS, CURRENT)) |
| 35 |
| 36 # Set up the root symlinks. |
| 37 _Relink(os.path.join(VERSIONS, CURRENT, binary), binary) |
| 38 _Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) |
| 39 |
| 40 # The following directories are optional but should also be symlinked |
| 41 # in the root. |
| 42 EXTRA_DIRS = [ |
| 43 'Helpers', |
| 44 'Internet Plug-Ins', |
| 45 'Libraries', |
| 46 'XPCServices', |
| 47 ] |
| 48 for extra_dir in EXTRA_DIRS: |
| 49 extra_dir_target = os.path.join(VERSIONS, version, extra_dir) |
| 50 if os.path.exists(extra_dir_target): |
| 51 _Relink(extra_dir_target, extra_dir) |
| 52 |
| 53 return 0 |
| 54 |
| 55 |
| 56 def _Relink(dest, link): |
| 57 """Creates a symlink to |dest| named |link|. If |link| already exists, |
| 58 it is overwritten.""" |
| 59 if os.path.lexists(link): |
| 60 os.remove(link) |
| 61 os.symlink(dest, link) |
| 62 |
| 63 |
| 64 if __name__ == '__main__': |
| 65 sys.exit(Main(sys.argv)) |
| OLD | NEW |