diff options
author | Conley Owens <cco3@android.com> | 2012-04-16 11:02:21 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2012-04-23 12:50:00 -0700 |
commit | d21720db313369f25b99b4d2f3f87c8be46513d9 (patch) | |
tree | a73e659e8fd18c7e3fc67880a1a9be8c2a409c86 | |
parent | 971de8ea7b7e474a4d9253b6c9f47da3f1130973 (diff) | |
download | git-repo-d21720db313369f25b99b4d2f3f87c8be46513d9.tar.gz |
Add a --platform flag
Projects may optionally specify their platform
(eg, groups="platform-linux" in the manifest).
By default, repo will automatically detect the platform. However,
users may specify --platform=[auto|all|linux|darwin].
Change-Id: Ie678851fb2fec5b0938aede01f16c53138a16537
-rw-r--r-- | command.py | 3 | ||||
-rwxr-xr-x | repo | 5 | ||||
-rw-r--r-- | subcmds/init.py | 23 |
3 files changed, 29 insertions, 2 deletions
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | import os | 16 | import os |
17 | import optparse | 17 | import optparse |
18 | import platform | ||
18 | import re | 19 | import re |
19 | import sys | 20 | import sys |
20 | 21 | ||
@@ -69,7 +70,7 @@ class Command(object): | |||
69 | 70 | ||
70 | groups = mp.config.GetString('manifest.groups') | 71 | groups = mp.config.GetString('manifest.groups') |
71 | if groups is None: | 72 | if groups is None: |
72 | groups = 'default' | 73 | groups = 'default,platform-' + platform.system().lower() |
73 | groups = [x for x in re.split('[,\s]+', groups) if x] | 74 | groups = [x for x in re.split('[,\s]+', groups) if x] |
74 | 75 | ||
75 | if not args: | 76 | if not args: |
@@ -129,6 +129,11 @@ group.add_option('-g', '--groups', | |||
129 | dest='groups', default='default', | 129 | dest='groups', default='default', |
130 | help='restrict manifest projects to ones with a specified group', | 130 | help='restrict manifest projects to ones with a specified group', |
131 | metavar='GROUP') | 131 | metavar='GROUP') |
132 | group.add_option('-p', '--platform', | ||
133 | dest='platform', default="auto", | ||
134 | help='restrict manifest projects to ones with a specified' | ||
135 | 'platform group [auto|all|none|linux|darwin|...]', | ||
136 | metavar='PLATFORM') | ||
132 | 137 | ||
133 | 138 | ||
134 | # Tool | 139 | # Tool |
diff --git a/subcmds/init.py b/subcmds/init.py index d1c497c1..2e3215b2 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -14,6 +14,7 @@ | |||
14 | # limitations under the License. | 14 | # limitations under the License. |
15 | 15 | ||
16 | import os | 16 | import os |
17 | import platform | ||
17 | import re | 18 | import re |
18 | import shutil | 19 | import shutil |
19 | import sys | 20 | import sys |
@@ -91,6 +92,11 @@ to update the working directory files. | |||
91 | dest='groups', default='default', | 92 | dest='groups', default='default', |
92 | help='restrict manifest projects to ones with a specified group', | 93 | help='restrict manifest projects to ones with a specified group', |
93 | metavar='GROUP') | 94 | metavar='GROUP') |
95 | g.add_option('-p', '--platform', | ||
96 | dest='platform', default='auto', | ||
97 | help='restrict manifest projects to ones with a specified' | ||
98 | 'platform group [auto|all|none|linux|darwin|...]', | ||
99 | metavar='PLATFORM') | ||
94 | 100 | ||
95 | # Tool | 101 | # Tool |
96 | g = p.add_option_group('repo Version options') | 102 | g = p.add_option_group('repo Version options') |
@@ -141,9 +147,24 @@ to update the working directory files. | |||
141 | r.Save() | 147 | r.Save() |
142 | 148 | ||
143 | groups = re.split('[,\s]+', opt.groups) | 149 | groups = re.split('[,\s]+', opt.groups) |
150 | all_platforms = ['linux', 'darwin'] | ||
151 | platformize = lambda x: 'platform-' + x | ||
152 | if opt.platform == 'auto': | ||
153 | if (not opt.mirror and | ||
154 | not m.config.GetString('repo.mirror') == 'true'): | ||
155 | groups.append(platformize(platform.system().lower())) | ||
156 | elif opt.platform == 'all': | ||
157 | groups.extend(map(platformize, all_platfroms)) | ||
158 | elif opt.platform in all_platforms: | ||
159 | groups.extend(platformize(opt.platform)) | ||
160 | elif opt.platform != 'none': | ||
161 | print >>sys.stderr, 'fatal: invalid platform flag' | ||
162 | sys.exit(1) | ||
163 | |||
144 | groups = [x for x in groups if x] | 164 | groups = [x for x in groups if x] |
145 | groupstr = ','.join(groups) | 165 | groupstr = ','.join(groups) |
146 | if groupstr == 'default': | 166 | if opt.platform == 'auto' and |
167 | groupstr == 'default,platform-' + platform.system.lower(): | ||
147 | groupstr = None | 168 | groupstr = None |
148 | m.config.SetString('manifest.groups', groupstr) | 169 | m.config.SetString('manifest.groups', groupstr) |
149 | 170 | ||