Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bryantaylor 0:eafc3fd41f75 1 """
bryantaylor 0:eafc3fd41f75 2 mbed SDK
bryantaylor 0:eafc3fd41f75 3 Copyright (c) 2011-2013 ARM Limited
bryantaylor 0:eafc3fd41f75 4
bryantaylor 0:eafc3fd41f75 5 Licensed under the Apache License, Version 2.0 (the "License");
bryantaylor 0:eafc3fd41f75 6 you may not use this file except in compliance with the License.
bryantaylor 0:eafc3fd41f75 7 You may obtain a copy of the License at
bryantaylor 0:eafc3fd41f75 8
bryantaylor 0:eafc3fd41f75 9 http://www.apache.org/licenses/LICENSE-2.0
bryantaylor 0:eafc3fd41f75 10
bryantaylor 0:eafc3fd41f75 11 Unless required by applicable law or agreed to in writing, software
bryantaylor 0:eafc3fd41f75 12 distributed under the License is distributed on an "AS IS" BASIS,
bryantaylor 0:eafc3fd41f75 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bryantaylor 0:eafc3fd41f75 14 See the License for the specific language governing permissions and
bryantaylor 0:eafc3fd41f75 15 limitations under the License.
bryantaylor 0:eafc3fd41f75 16
bryantaylor 0:eafc3fd41f75 17
bryantaylor 0:eafc3fd41f75 18 One repository to update them all
bryantaylor 0:eafc3fd41f75 19 On mbed.org the mbed SDK is split up in multiple repositories, this script takes
bryantaylor 0:eafc3fd41f75 20 care of updating them all.
bryantaylor 0:eafc3fd41f75 21 """
bryantaylor 0:eafc3fd41f75 22 import sys
bryantaylor 0:eafc3fd41f75 23 from copy import copy
bryantaylor 0:eafc3fd41f75 24 from os import walk, remove, makedirs
bryantaylor 0:eafc3fd41f75 25 from os.path import join, abspath, dirname, relpath, exists, isfile
bryantaylor 0:eafc3fd41f75 26 from shutil import copyfile
bryantaylor 0:eafc3fd41f75 27 from optparse import OptionParser
bryantaylor 0:eafc3fd41f75 28 import re
bryantaylor 0:eafc3fd41f75 29 import string
bryantaylor 0:eafc3fd41f75 30
bryantaylor 0:eafc3fd41f75 31 ROOT = abspath(join(dirname(__file__), ".."))
bryantaylor 0:eafc3fd41f75 32 sys.path.insert(0, ROOT)
bryantaylor 0:eafc3fd41f75 33
bryantaylor 0:eafc3fd41f75 34 from tools.settings import MBED_ORG_PATH, MBED_ORG_USER, BUILD_DIR
bryantaylor 0:eafc3fd41f75 35 from tools.paths import *
bryantaylor 0:eafc3fd41f75 36 from tools.utils import run_cmd
bryantaylor 0:eafc3fd41f75 37
bryantaylor 0:eafc3fd41f75 38 MBED_URL = "mbed.org"
bryantaylor 0:eafc3fd41f75 39 MBED_USER = "mbed_official"
bryantaylor 0:eafc3fd41f75 40
bryantaylor 0:eafc3fd41f75 41 changed = []
bryantaylor 0:eafc3fd41f75 42 push_remote = True
bryantaylor 0:eafc3fd41f75 43 quiet = False
bryantaylor 0:eafc3fd41f75 44 commit_msg = ''
bryantaylor 0:eafc3fd41f75 45
bryantaylor 0:eafc3fd41f75 46 # Code that does have a mirror in the mbed SDK
bryantaylor 0:eafc3fd41f75 47 # Tuple data: (repo_name, list_of_code_dirs, [team])
bryantaylor 0:eafc3fd41f75 48 # team is optional - if not specified, the code is published under mbed_official
bryantaylor 0:eafc3fd41f75 49 OFFICIAL_CODE = (
bryantaylor 0:eafc3fd41f75 50 ("mbed-dev" , MBED_BASE),
bryantaylor 0:eafc3fd41f75 51 ("mbed-rtos", RTOS),
bryantaylor 0:eafc3fd41f75 52 ("mbed-dsp" , DSP),
bryantaylor 0:eafc3fd41f75 53 ("mbed-rpc" , MBED_RPC),
bryantaylor 0:eafc3fd41f75 54
bryantaylor 0:eafc3fd41f75 55 ("lwip" , LWIP_SOURCES+"/lwip"),
bryantaylor 0:eafc3fd41f75 56 ("lwip-sys", LWIP_SOURCES+"/lwip-sys"),
bryantaylor 0:eafc3fd41f75 57 ("Socket" , LWIP_SOURCES+"/Socket"),
bryantaylor 0:eafc3fd41f75 58
bryantaylor 0:eafc3fd41f75 59 ("lwip-eth" , ETH_SOURCES+"/lwip-eth"),
bryantaylor 0:eafc3fd41f75 60 ("EthernetInterface", ETH_SOURCES+"/EthernetInterface"),
bryantaylor 0:eafc3fd41f75 61
bryantaylor 0:eafc3fd41f75 62 ("USBDevice", USB),
bryantaylor 0:eafc3fd41f75 63 ("USBHost" , USB_HOST),
bryantaylor 0:eafc3fd41f75 64
bryantaylor 0:eafc3fd41f75 65 ("CellularModem", CELLULAR_SOURCES),
bryantaylor 0:eafc3fd41f75 66 ("CellularUSBModem", CELLULAR_USB_SOURCES),
bryantaylor 0:eafc3fd41f75 67 ("UbloxUSBModem", UBLOX_SOURCES),
bryantaylor 0:eafc3fd41f75 68 ("UbloxModemHTTPClientTest", [TEST_DIR+"/net/cellular/http/common", TEST_DIR+"/net/cellular/http/ubloxusb"]),
bryantaylor 0:eafc3fd41f75 69 ("UbloxModemSMSTest", [TEST_DIR+"/net/cellular/sms/common", TEST_DIR+"/net/cellular/sms/ubloxusb"]),
bryantaylor 0:eafc3fd41f75 70 ("FATFileSystem", FAT_FS, "mbed-official"),
bryantaylor 0:eafc3fd41f75 71 )
bryantaylor 0:eafc3fd41f75 72
bryantaylor 0:eafc3fd41f75 73
bryantaylor 0:eafc3fd41f75 74 # Code that does have dependencies to libraries should point to
bryantaylor 0:eafc3fd41f75 75 # the latest revision. By default, they point to a specific revision.
bryantaylor 0:eafc3fd41f75 76 CODE_WITH_DEPENDENCIES = (
bryantaylor 0:eafc3fd41f75 77 # Libraries
bryantaylor 0:eafc3fd41f75 78 "EthernetInterface",
bryantaylor 0:eafc3fd41f75 79
bryantaylor 0:eafc3fd41f75 80 # RTOS Examples
bryantaylor 0:eafc3fd41f75 81 "rtos_basic",
bryantaylor 0:eafc3fd41f75 82 "rtos_isr",
bryantaylor 0:eafc3fd41f75 83 "rtos_mail",
bryantaylor 0:eafc3fd41f75 84 "rtos_mutex",
bryantaylor 0:eafc3fd41f75 85 "rtos_queue",
bryantaylor 0:eafc3fd41f75 86 "rtos_semaphore",
bryantaylor 0:eafc3fd41f75 87 "rtos_signals",
bryantaylor 0:eafc3fd41f75 88 "rtos_timer",
bryantaylor 0:eafc3fd41f75 89
bryantaylor 0:eafc3fd41f75 90 # Net Examples
bryantaylor 0:eafc3fd41f75 91 "TCPEchoClient",
bryantaylor 0:eafc3fd41f75 92 "TCPEchoServer",
bryantaylor 0:eafc3fd41f75 93 "TCPSocket_HelloWorld",
bryantaylor 0:eafc3fd41f75 94 "UDPSocket_HelloWorld",
bryantaylor 0:eafc3fd41f75 95 "UDPEchoClient",
bryantaylor 0:eafc3fd41f75 96 "UDPEchoServer",
bryantaylor 0:eafc3fd41f75 97 "BroadcastReceive",
bryantaylor 0:eafc3fd41f75 98 "BroadcastSend",
bryantaylor 0:eafc3fd41f75 99
bryantaylor 0:eafc3fd41f75 100 # mbed sources
bryantaylor 0:eafc3fd41f75 101 "mbed-src-program",
bryantaylor 0:eafc3fd41f75 102 )
bryantaylor 0:eafc3fd41f75 103
bryantaylor 0:eafc3fd41f75 104 # A list of regular expressions that will be checked against each directory
bryantaylor 0:eafc3fd41f75 105 # name and skipped if they match.
bryantaylor 0:eafc3fd41f75 106 IGNORE_DIRS = (
bryantaylor 0:eafc3fd41f75 107 )
bryantaylor 0:eafc3fd41f75 108
bryantaylor 0:eafc3fd41f75 109 IGNORE_FILES = (
bryantaylor 0:eafc3fd41f75 110 'COPYING',
bryantaylor 0:eafc3fd41f75 111 '\.md',
bryantaylor 0:eafc3fd41f75 112 "\.lib",
bryantaylor 0:eafc3fd41f75 113 "\.bld"
bryantaylor 0:eafc3fd41f75 114 )
bryantaylor 0:eafc3fd41f75 115
bryantaylor 0:eafc3fd41f75 116 def ignore_path(name, reg_exps):
bryantaylor 0:eafc3fd41f75 117 for r in reg_exps:
bryantaylor 0:eafc3fd41f75 118 if re.search(r, name):
bryantaylor 0:eafc3fd41f75 119 return True
bryantaylor 0:eafc3fd41f75 120 return False
bryantaylor 0:eafc3fd41f75 121
bryantaylor 0:eafc3fd41f75 122 class MbedRepository:
bryantaylor 0:eafc3fd41f75 123 @staticmethod
bryantaylor 0:eafc3fd41f75 124 def run_and_print(command, cwd):
bryantaylor 0:eafc3fd41f75 125 stdout, _, _ = run_cmd(command, work_dir=cwd, redirect=True)
bryantaylor 0:eafc3fd41f75 126 print(stdout)
bryantaylor 0:eafc3fd41f75 127
bryantaylor 0:eafc3fd41f75 128 def __init__(self, name, team = None):
bryantaylor 0:eafc3fd41f75 129 self.name = name
bryantaylor 0:eafc3fd41f75 130 self.path = join(MBED_ORG_PATH, name)
bryantaylor 0:eafc3fd41f75 131 if team is None:
bryantaylor 0:eafc3fd41f75 132 self.url = "http://" + MBED_URL + "/users/" + MBED_USER + "/code/%s/"
bryantaylor 0:eafc3fd41f75 133 else:
bryantaylor 0:eafc3fd41f75 134 self.url = "http://" + MBED_URL + "/teams/" + team + "/code/%s/"
bryantaylor 0:eafc3fd41f75 135 if not exists(self.path):
bryantaylor 0:eafc3fd41f75 136 # Checkout code
bryantaylor 0:eafc3fd41f75 137 if not exists(MBED_ORG_PATH):
bryantaylor 0:eafc3fd41f75 138 makedirs(MBED_ORG_PATH)
bryantaylor 0:eafc3fd41f75 139
bryantaylor 0:eafc3fd41f75 140 self.run_and_print(['hg', 'clone', self.url % name], cwd=MBED_ORG_PATH)
bryantaylor 0:eafc3fd41f75 141
bryantaylor 0:eafc3fd41f75 142 else:
bryantaylor 0:eafc3fd41f75 143 # Update
bryantaylor 0:eafc3fd41f75 144 self.run_and_print(['hg', 'pull'], cwd=self.path)
bryantaylor 0:eafc3fd41f75 145 self.run_and_print(['hg', 'update'], cwd=self.path)
bryantaylor 0:eafc3fd41f75 146
bryantaylor 0:eafc3fd41f75 147 def publish(self):
bryantaylor 0:eafc3fd41f75 148 # The maintainer has to evaluate the changes first and explicitly accept them
bryantaylor 0:eafc3fd41f75 149 self.run_and_print(['hg', 'addremove'], cwd=self.path)
bryantaylor 0:eafc3fd41f75 150 stdout, _, _ = run_cmd(['hg', 'status'], work_dir=self.path)
bryantaylor 0:eafc3fd41f75 151 if stdout == '':
bryantaylor 0:eafc3fd41f75 152 print "No changes"
bryantaylor 0:eafc3fd41f75 153 return False
bryantaylor 0:eafc3fd41f75 154 print stdout
bryantaylor 0:eafc3fd41f75 155 if quiet:
bryantaylor 0:eafc3fd41f75 156 commit = 'Y'
bryantaylor 0:eafc3fd41f75 157 else:
bryantaylor 0:eafc3fd41f75 158 commit = raw_input(push_remote and "Do you want to commit and push? Y/N: " or "Do you want to commit? Y/N: ")
bryantaylor 0:eafc3fd41f75 159 if commit == 'Y':
bryantaylor 0:eafc3fd41f75 160 args = ['hg', 'commit', '-u', MBED_ORG_USER]
bryantaylor 0:eafc3fd41f75 161 if commit_msg:
bryantaylor 0:eafc3fd41f75 162 args = args + ['-m', commit_msg]
bryantaylor 0:eafc3fd41f75 163 self.run_and_print(args, cwd=self.path)
bryantaylor 0:eafc3fd41f75 164 if push_remote:
bryantaylor 0:eafc3fd41f75 165 self.run_and_print(['hg', 'push'], cwd=self.path)
bryantaylor 0:eafc3fd41f75 166 return True
bryantaylor 0:eafc3fd41f75 167
bryantaylor 0:eafc3fd41f75 168 # Check if a file is a text file or a binary file
bryantaylor 0:eafc3fd41f75 169 # Taken from http://code.activestate.com/recipes/173220/
bryantaylor 0:eafc3fd41f75 170 text_characters = "".join(map(chr, range(32, 127)) + list("\n\r\t\b"))
bryantaylor 0:eafc3fd41f75 171 _null_trans = string.maketrans("", "")
bryantaylor 0:eafc3fd41f75 172 def is_text_file(filename):
bryantaylor 0:eafc3fd41f75 173 block_size = 1024
bryantaylor 0:eafc3fd41f75 174 def istext(s):
bryantaylor 0:eafc3fd41f75 175 if "\0" in s:
bryantaylor 0:eafc3fd41f75 176 return 0
bryantaylor 0:eafc3fd41f75 177
bryantaylor 0:eafc3fd41f75 178 if not s: # Empty files are considered text
bryantaylor 0:eafc3fd41f75 179 return 1
bryantaylor 0:eafc3fd41f75 180
bryantaylor 0:eafc3fd41f75 181 # Get the non-text characters (maps a character to itself then
bryantaylor 0:eafc3fd41f75 182 # use the 'remove' option to get rid of the text characters.)
bryantaylor 0:eafc3fd41f75 183 t = s.translate(_null_trans, text_characters)
bryantaylor 0:eafc3fd41f75 184
bryantaylor 0:eafc3fd41f75 185 # If more than 30% non-text characters, then
bryantaylor 0:eafc3fd41f75 186 # this is considered a binary file
bryantaylor 0:eafc3fd41f75 187 if float(len(t))/len(s) > 0.30:
bryantaylor 0:eafc3fd41f75 188 return 0
bryantaylor 0:eafc3fd41f75 189 return 1
bryantaylor 0:eafc3fd41f75 190 with open(filename) as f:
bryantaylor 0:eafc3fd41f75 191 res = istext(f.read(block_size))
bryantaylor 0:eafc3fd41f75 192 return res
bryantaylor 0:eafc3fd41f75 193
bryantaylor 0:eafc3fd41f75 194 # Return the line ending type for the given file ('cr' or 'crlf')
bryantaylor 0:eafc3fd41f75 195 def get_line_endings(f):
bryantaylor 0:eafc3fd41f75 196 examine_size = 1024
bryantaylor 0:eafc3fd41f75 197 try:
bryantaylor 0:eafc3fd41f75 198 tf = open(f, "rb")
bryantaylor 0:eafc3fd41f75 199 lines, ncrlf = tf.readlines(examine_size), 0
bryantaylor 0:eafc3fd41f75 200 tf.close()
bryantaylor 0:eafc3fd41f75 201 for l in lines:
bryantaylor 0:eafc3fd41f75 202 if l.endswith("\r\n"):
bryantaylor 0:eafc3fd41f75 203 ncrlf = ncrlf + 1
bryantaylor 0:eafc3fd41f75 204 return 'crlf' if ncrlf > len(lines) >> 1 else 'cr'
bryantaylor 0:eafc3fd41f75 205 except:
bryantaylor 0:eafc3fd41f75 206 return 'cr'
bryantaylor 0:eafc3fd41f75 207
bryantaylor 0:eafc3fd41f75 208 # Copy file to destination, but preserve destination line endings if possible
bryantaylor 0:eafc3fd41f75 209 # This prevents very annoying issues with huge diffs that appear because of
bryantaylor 0:eafc3fd41f75 210 # differences in line endings
bryantaylor 0:eafc3fd41f75 211 def copy_with_line_endings(sdk_file, repo_file):
bryantaylor 0:eafc3fd41f75 212 if not isfile(repo_file):
bryantaylor 0:eafc3fd41f75 213 copyfile(sdk_file, repo_file)
bryantaylor 0:eafc3fd41f75 214 return
bryantaylor 0:eafc3fd41f75 215 is_text = is_text_file(repo_file)
bryantaylor 0:eafc3fd41f75 216 if is_text:
bryantaylor 0:eafc3fd41f75 217 sdk_le = get_line_endings(sdk_file)
bryantaylor 0:eafc3fd41f75 218 repo_le = get_line_endings(repo_file)
bryantaylor 0:eafc3fd41f75 219 if not is_text or sdk_le == repo_le:
bryantaylor 0:eafc3fd41f75 220 copyfile(sdk_file, repo_file)
bryantaylor 0:eafc3fd41f75 221 else:
bryantaylor 0:eafc3fd41f75 222 print "Converting line endings in '%s' to '%s'" % (abspath(repo_file), repo_le)
bryantaylor 0:eafc3fd41f75 223 f = open(sdk_file, "rb")
bryantaylor 0:eafc3fd41f75 224 data = f.read()
bryantaylor 0:eafc3fd41f75 225 f.close()
bryantaylor 0:eafc3fd41f75 226 f = open(repo_file, "wb")
bryantaylor 0:eafc3fd41f75 227 data = data.replace("\r\n", "\n") if repo_le == 'cr' else data.replace('\n','\r\n')
bryantaylor 0:eafc3fd41f75 228 f.write(data)
bryantaylor 0:eafc3fd41f75 229 f.close()
bryantaylor 0:eafc3fd41f75 230
bryantaylor 0:eafc3fd41f75 231 def visit_files(path, visit):
bryantaylor 0:eafc3fd41f75 232 for root, dirs, files in walk(path):
bryantaylor 0:eafc3fd41f75 233 # Ignore hidden directories
bryantaylor 0:eafc3fd41f75 234 for d in copy(dirs):
bryantaylor 0:eafc3fd41f75 235 full = join(root, d)
bryantaylor 0:eafc3fd41f75 236 if d.startswith('.'):
bryantaylor 0:eafc3fd41f75 237 dirs.remove(d)
bryantaylor 0:eafc3fd41f75 238 if ignore_path(full, IGNORE_DIRS):
bryantaylor 0:eafc3fd41f75 239 print "Skipping '%s'" % full
bryantaylor 0:eafc3fd41f75 240 dirs.remove(d)
bryantaylor 0:eafc3fd41f75 241
bryantaylor 0:eafc3fd41f75 242 for file in files:
bryantaylor 0:eafc3fd41f75 243 if ignore_path(file, IGNORE_FILES):
bryantaylor 0:eafc3fd41f75 244 continue
bryantaylor 0:eafc3fd41f75 245
bryantaylor 0:eafc3fd41f75 246 visit(join(root, file))
bryantaylor 0:eafc3fd41f75 247
bryantaylor 0:eafc3fd41f75 248
bryantaylor 0:eafc3fd41f75 249 def update_repo(repo_name, sdk_paths, team_name):
bryantaylor 0:eafc3fd41f75 250 repo = MbedRepository(repo_name, team_name)
bryantaylor 0:eafc3fd41f75 251 # copy files from mbed SDK to mbed_official repository
bryantaylor 0:eafc3fd41f75 252 def visit_mbed_sdk(sdk_file):
bryantaylor 0:eafc3fd41f75 253 repo_file = join(repo.path, relpath(sdk_file, sdk_path))
bryantaylor 0:eafc3fd41f75 254
bryantaylor 0:eafc3fd41f75 255 repo_dir = dirname(repo_file)
bryantaylor 0:eafc3fd41f75 256 if not exists(repo_dir):
bryantaylor 0:eafc3fd41f75 257 makedirs(repo_dir)
bryantaylor 0:eafc3fd41f75 258
bryantaylor 0:eafc3fd41f75 259 copy_with_line_endings(sdk_file, repo_file)
bryantaylor 0:eafc3fd41f75 260 for sdk_path in sdk_paths:
bryantaylor 0:eafc3fd41f75 261 visit_files(sdk_path, visit_mbed_sdk)
bryantaylor 0:eafc3fd41f75 262
bryantaylor 0:eafc3fd41f75 263 # remove repository files that do not exist in the mbed SDK
bryantaylor 0:eafc3fd41f75 264 def visit_repo(repo_file):
bryantaylor 0:eafc3fd41f75 265 for sdk_path in sdk_paths:
bryantaylor 0:eafc3fd41f75 266 sdk_file = join(sdk_path, relpath(repo_file, repo.path))
bryantaylor 0:eafc3fd41f75 267 if exists(sdk_file):
bryantaylor 0:eafc3fd41f75 268 break
bryantaylor 0:eafc3fd41f75 269 else:
bryantaylor 0:eafc3fd41f75 270 remove(repo_file)
bryantaylor 0:eafc3fd41f75 271 print "remove: %s" % repo_file
bryantaylor 0:eafc3fd41f75 272 visit_files(repo.path, visit_repo)
bryantaylor 0:eafc3fd41f75 273
bryantaylor 0:eafc3fd41f75 274 if repo.publish():
bryantaylor 0:eafc3fd41f75 275 changed.append(repo_name)
bryantaylor 0:eafc3fd41f75 276
bryantaylor 0:eafc3fd41f75 277
bryantaylor 0:eafc3fd41f75 278 def update_code(repositories):
bryantaylor 0:eafc3fd41f75 279 for r in repositories:
bryantaylor 0:eafc3fd41f75 280 repo_name, sdk_dir = r[0], r[1]
bryantaylor 0:eafc3fd41f75 281 team_name = r[2] if len(r) == 3 else None
bryantaylor 0:eafc3fd41f75 282 print '\n=== Updating "%s" ===' % repo_name
bryantaylor 0:eafc3fd41f75 283 sdk_dirs = [sdk_dir] if type(sdk_dir) != type([]) else sdk_dir
bryantaylor 0:eafc3fd41f75 284 update_repo(repo_name, sdk_dirs, team_name)
bryantaylor 0:eafc3fd41f75 285
bryantaylor 0:eafc3fd41f75 286 def update_single_repo(repo):
bryantaylor 0:eafc3fd41f75 287 repos = [r for r in OFFICIAL_CODE if r[0] == repo]
bryantaylor 0:eafc3fd41f75 288 if not repos:
bryantaylor 0:eafc3fd41f75 289 print "Repository '%s' not found" % repo
bryantaylor 0:eafc3fd41f75 290 else:
bryantaylor 0:eafc3fd41f75 291 update_code(repos)
bryantaylor 0:eafc3fd41f75 292
bryantaylor 0:eafc3fd41f75 293 def update_dependencies(repositories):
bryantaylor 0:eafc3fd41f75 294 for repo_name in repositories:
bryantaylor 0:eafc3fd41f75 295 print '\n=== Updating "%s" ===' % repo_name
bryantaylor 0:eafc3fd41f75 296 repo = MbedRepository(repo_name)
bryantaylor 0:eafc3fd41f75 297
bryantaylor 0:eafc3fd41f75 298 # point to the latest libraries
bryantaylor 0:eafc3fd41f75 299 def visit_repo(repo_file):
bryantaylor 0:eafc3fd41f75 300 with open(repo_file, "r") as f:
bryantaylor 0:eafc3fd41f75 301 url = f.read()
bryantaylor 0:eafc3fd41f75 302 with open(repo_file, "w") as f:
bryantaylor 0:eafc3fd41f75 303 f.write(url[:(url.rindex('/')+1)])
bryantaylor 0:eafc3fd41f75 304 visit_files(repo.path, visit_repo, None, MBED_REPO_EXT)
bryantaylor 0:eafc3fd41f75 305
bryantaylor 0:eafc3fd41f75 306 if repo.publish():
bryantaylor 0:eafc3fd41f75 307 changed.append(repo_name)
bryantaylor 0:eafc3fd41f75 308
bryantaylor 0:eafc3fd41f75 309
bryantaylor 0:eafc3fd41f75 310 def update_mbed():
bryantaylor 0:eafc3fd41f75 311 update_repo("mbed", [join(BUILD_DIR, "mbed")], None)
bryantaylor 0:eafc3fd41f75 312
bryantaylor 0:eafc3fd41f75 313 def do_sync(options):
bryantaylor 0:eafc3fd41f75 314 global push_remote, quiet, commit_msg, changed
bryantaylor 0:eafc3fd41f75 315
bryantaylor 0:eafc3fd41f75 316 push_remote = not options.nopush
bryantaylor 0:eafc3fd41f75 317 quiet = options.quiet
bryantaylor 0:eafc3fd41f75 318 commit_msg = options.msg
bryantaylor 0:eafc3fd41f75 319 chnaged = []
bryantaylor 0:eafc3fd41f75 320
bryantaylor 0:eafc3fd41f75 321 if options.code:
bryantaylor 0:eafc3fd41f75 322 update_code(OFFICIAL_CODE)
bryantaylor 0:eafc3fd41f75 323
bryantaylor 0:eafc3fd41f75 324 if options.dependencies:
bryantaylor 0:eafc3fd41f75 325 update_dependencies(CODE_WITH_DEPENDENCIES)
bryantaylor 0:eafc3fd41f75 326
bryantaylor 0:eafc3fd41f75 327 if options.mbed:
bryantaylor 0:eafc3fd41f75 328 update_mbed()
bryantaylor 0:eafc3fd41f75 329
bryantaylor 0:eafc3fd41f75 330 if options.repo:
bryantaylor 0:eafc3fd41f75 331 update_single_repo(options.repo)
bryantaylor 0:eafc3fd41f75 332
bryantaylor 0:eafc3fd41f75 333 if changed:
bryantaylor 0:eafc3fd41f75 334 print "Repositories with changes:", changed
bryantaylor 0:eafc3fd41f75 335
bryantaylor 0:eafc3fd41f75 336 return changed
bryantaylor 0:eafc3fd41f75 337
bryantaylor 0:eafc3fd41f75 338 if __name__ == '__main__':
bryantaylor 0:eafc3fd41f75 339 parser = OptionParser()
bryantaylor 0:eafc3fd41f75 340
bryantaylor 0:eafc3fd41f75 341 parser.add_option("-c", "--code",
bryantaylor 0:eafc3fd41f75 342 action="store_true", default=False,
bryantaylor 0:eafc3fd41f75 343 help="Update the mbed_official code")
bryantaylor 0:eafc3fd41f75 344
bryantaylor 0:eafc3fd41f75 345 parser.add_option("-d", "--dependencies",
bryantaylor 0:eafc3fd41f75 346 action="store_true", default=False,
bryantaylor 0:eafc3fd41f75 347 help="Update the mbed_official code dependencies")
bryantaylor 0:eafc3fd41f75 348
bryantaylor 0:eafc3fd41f75 349 parser.add_option("-m", "--mbed",
bryantaylor 0:eafc3fd41f75 350 action="store_true", default=False,
bryantaylor 0:eafc3fd41f75 351 help="Release a build of the mbed library")
bryantaylor 0:eafc3fd41f75 352
bryantaylor 0:eafc3fd41f75 353 parser.add_option("-n", "--nopush",
bryantaylor 0:eafc3fd41f75 354 action="store_true", default=False,
bryantaylor 0:eafc3fd41f75 355 help="Commit the changes locally only, don't push them")
bryantaylor 0:eafc3fd41f75 356
bryantaylor 0:eafc3fd41f75 357 parser.add_option("", "--commit_message",
bryantaylor 0:eafc3fd41f75 358 action="store", type="string", default='', dest='msg',
bryantaylor 0:eafc3fd41f75 359 help="Commit message to use for all the commits")
bryantaylor 0:eafc3fd41f75 360
bryantaylor 0:eafc3fd41f75 361 parser.add_option("-r", "--repository",
bryantaylor 0:eafc3fd41f75 362 action="store", type="string", default='', dest='repo',
bryantaylor 0:eafc3fd41f75 363 help="Synchronize only the given repository")
bryantaylor 0:eafc3fd41f75 364
bryantaylor 0:eafc3fd41f75 365 parser.add_option("-q", "--quiet",
bryantaylor 0:eafc3fd41f75 366 action="store_true", default=False,
bryantaylor 0:eafc3fd41f75 367 help="Don't ask for confirmation before commiting or pushing")
bryantaylor 0:eafc3fd41f75 368
bryantaylor 0:eafc3fd41f75 369 (options, args) = parser.parse_args()
bryantaylor 0:eafc3fd41f75 370
bryantaylor 0:eafc3fd41f75 371 do_sync(options)
bryantaylor 0:eafc3fd41f75 372