5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
group-onsemi
Date:
Wed Jan 25 20:34:15 2017 +0000
Revision:
0:098463de4c5d
Initial commit

Who changed what in which revision?

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