Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-os
Revision 3:47aa05d37724, committed 2016-03-30
- Comitter:
- screamer
- Date:
- Wed Mar 30 20:17:20 2016 +0000
- Parent:
- 2:df6a22f0c191
- Child:
- 4:6e987db7a950
- Commit message:
- Add neo.py and mbed_settings.py
Changed in this revision
--- a/mbed-os.lib Wed Mar 30 16:27:45 2016 +0000 +++ b/mbed-os.lib Wed Mar 30 20:17:20 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/Morpheus/code/mbed-os/#62119b11b261 +https://developer.mbed.org/teams/Morpheus/code/mbed-os/#47e7723a4f1d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_settings.py Wed Mar 30 20:17:20 2016 +0000
@@ -0,0 +1,109 @@
+"""
+mbed SDK
+Copyright (c) 2011-2013 ARM Limited
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+from os.path import join, abspath, dirname
+import logging
+
+ROOT = abspath(join(dirname(__file__), ".."))
+
+# These default settings have two purposes:
+# 1) Give a template for writing local "private_settings.py"
+# 2) Give default initialization fields for the "toolchains.py" constructors
+
+##############################################################################
+# Build System Settings
+##############################################################################
+BUILD_DIR = abspath(join(ROOT, "build"))
+
+# ARM
+armcc = "standalone" # "keil", or "standalone", or "ds-5"
+
+if armcc == "keil":
+ ARM_PATH = "C:/Keil_4_54/ARM"
+ ARM_BIN = join(ARM_PATH, "BIN40")
+ ARM_INC = join(ARM_PATH, "RV31", "INC")
+ ARM_LIB = join(ARM_PATH, "RV31", "LIB")
+
+elif armcc == "standalone":
+ ARM_PATH = "C:\Program Files\ARM"
+ ARM_BIN = join(ARM_PATH, "bin")
+ ARM_INC = join(ARM_PATH, "include")
+ ARM_LIB = join(ARM_PATH, "lib")
+
+elif armcc == "ds-5":
+ ARM_PATH = "C:/Program Files (x86)/DS-5"
+ ARM_BIN = join(ARM_PATH, "bin")
+ ARM_INC = join(ARM_PATH, "include")
+ ARM_LIB = join(ARM_PATH, "lib")
+
+ARM_CPPLIB = join(ARM_LIB, "cpplib")
+MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib")
+
+# GCC ARM
+GCC_ARM_PATH = "C:/Program Files (x86)/GNU Tools ARM Embedded/4.8 2014q2/bin"
+
+# GCC CodeSourcery
+GCC_CS_PATH = "C:/Program Files (x86)/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
+
+# GCC CodeRed
+GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"
+
+# IAR
+IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
+
+# GCC Code Warrior
+CW_GCC_PATH = "C:/Program Files (x86)/GNU Tools ARM Embedded/4.8 2014q2/arm-none-eabi/bin"
+CW_EWL_PATH = "C:/Freescale/CW MCU v10.3/MCU/ARM_GCC_Support/ewl/lib"
+
+# Goanna static analyzer
+GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.1.4/bin"
+
+BUILD_OPTIONS = []
+
+# mbed.org username
+MBED_ORG_USER = ""
+
+##############################################################################
+# Test System Settings
+##############################################################################
+SERVER_PORT = 59432
+SERVER_ADDRESS = "10.2.200.94"
+LOCALHOST = "10.2.200.94"
+
+MUTs = {
+ "1" : {"mcu": "LPC1768",
+ "port":"COM41", "disk":'E:\\',
+ "peripherals": ["TMP102", "digital_loop", "port_loop", "analog_loop", "SD"]
+ },
+ "2": {"mcu": "LPC11U24",
+ "port":"COM42", "disk":'F:\\',
+ "peripherals": ["TMP102", "digital_loop", "port_loop", "SD"]
+ },
+ "3" : {"mcu": "KL25Z",
+ "port":"COM43", "disk":'G:\\',
+ "peripherals": ["TMP102", "digital_loop", "port_loop", "analog_loop", "SD"]
+ },
+}
+
+##############################################################################
+# Private Settings
+##############################################################################
+try:
+ # Allow to overwrite the default settings without the need to edit the
+ # settings file stored in the repository
+ from tools.private_settings import *
+except ImportError:
+ print '[WARNING] Using default settings. Define you settings in the file "tools/private_settings.py" or in "./mbed_settings.py"'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/neo.py Wed Mar 30 20:17:20 2016 +0000
@@ -0,0 +1,201 @@
+#!/usr/bin/env python
+
+import argparse
+import sys
+import re
+import subprocess
+import os
+import contextlib
+import collections
+
+# Subparser handling
+parser = argparse.ArgumentParser()
+subparsers = parser.add_subparsers()
+
+def subcommand(name, *args, **kwargs):
+ def subcommand(command):
+ subparser = subparsers.add_parser(name, **kwargs)
+
+ for arg in args:
+ subparser.add_argument(arg)
+
+ def thunk(parsed_args):
+ ordered_args = [vars(parsed_args)[arg] for arg in args]
+ return command(*ordered_args)
+
+ subparser.set_defaults(command=thunk)
+ return command
+ return subcommand
+
+# Process execution
+class ProcessException(Exception):
+ pass
+
+def popen(command, stdin=None):
+ # print for debugging
+ print ' '.join(command)
+ proc = subprocess.Popen(command)
+
+ if proc.wait() != 0:
+ raise ProcessException(proc.returncode)
+
+def pquery(command, stdin=None):
+ proc = subprocess.Popen(command, stdout=subprocess.PIPE)
+ stdout, _ = proc.communicate(stdin)
+
+ if proc.returncode != 0:
+ raise ProcessException(proc.returncode)
+
+ return stdout
+
+# Directory navigation
+@contextlib.contextmanager
+def cd(newdir):
+ prevdir = os.getcwd()
+ os.chdir(newdir)
+ try:
+ yield
+ finally:
+ os.chdir(prevdir)
+
+def iterlibs(dir=None):
+ for file in os.listdir(dir or os.getcwd()):
+ if file.startswith('.'):
+ continue
+ elif os.path.isfile(file) and file.endswith('.lib'):
+ with open(file) as f:
+ yield f.read().strip()
+
+def savelib(repo):
+ print repo.name, '->', repo.url
+
+ with open(repo.lib, 'w') as f:
+ f.write(repo.url + '\n')
+
+
+# Handling for multiple version controls
+class Repo(object):
+ def __init__(self, path=None):
+ self.path = path or os.getcwd()
+ self.name = os.path.basename(self.path)
+ self.update()
+
+ @classmethod
+ def fromurl(cls, url):
+ repo = cls.__new__(cls)
+
+ m = re.match('^(.*/([+a-zA-Z0-9_-]+)/?)(?:#(.*))?$', url)
+ repo.repo = m.group(1)
+ repo.name = m.group(2)
+ repo.hash = m.group(3)
+
+ repo.path = os.path.join(os.getcwd(), repo.name)
+ return repo
+
+ @property
+ def lib(self):
+ return self.path + '.lib'
+
+ @property
+ def url(self):
+ if self.repo:
+ if self.hash:
+ return self.repo + '#' + self.hash
+ else:
+ return self.repo
+
+ def update(self):
+ if os.path.isdir(self.path):
+ self.type = self.gettype()
+ self.hash = self.gethash()
+
+ if os.path.isfile(self.lib):
+ with open(self.lib) as f:
+ temp = Repo.fromurl(f.read())
+ self.repo = temp.repo
+
+ def gettype(self):
+ for type, dir in [('git', '.git'), ('hg', '.hg')]:
+ if os.path.isdir(os.path.join(self.path, dir)):
+ return type
+
+ def gethash(self):
+ with cd(self.path):
+ if self.type == 'git':
+ return pquery(['git', 'rev-parse', '--short', 'HEAD']).strip()
+ elif self.type == 'hg':
+ return pquery(['hg', 'id', '-i']).strip()
+
+# Clone command
+@subcommand('import', 'url',
+ help='recursively import a repository')
+def import_(url):
+ repo = Repo.fromurl(url)
+
+ for type in ['git', 'hg']:
+ try:
+ popen([type, 'clone', repo.repo])
+ break
+ except:
+ pass
+
+ repo.type = repo.gettype()
+
+ if repo.hash:
+ with cd(repo.path):
+ popen([repo.type, 'checkout', repo.hash])
+
+ repo.update()
+
+ with cd(repo.path):
+ for lib in iterlibs():
+ import_(lib)
+
+# Install/uninstall command
+@subcommand('install', 'url',
+ help='add a submodule to the current repository')
+def install(url):
+ cwd = Repo()
+ repo = Repo.fromurl(url)
+
+ import_(url)
+
+ repo.update()
+ savelib(repo)
+
+ popen([cwd.type, 'add', repo.lib])
+
+@subcommand('uninstall', 'module',
+ help='remove a submodule')
+def uninstall(module):
+ cwd = Repo()
+ repo = Repo(module)
+
+ popen([cwd.type, 'rm', '-f', repo.lib])
+ if cwd.type == 'hg':
+ popen(['rm', '-f', repo.lib])
+
+ popen(['rm', '-rf', repo.path])
+
+# Synch command
+@subcommand('synch',
+ help='synchronize lib files')
+def synch():
+ cwd = Repo()
+
+ for lib in iterlibs():
+ repo = Repo.fromurl(lib)
+ repo.update()
+ if lib == repo.url:
+ continue
+
+ savelib(repo)
+
+ if cwd.type == 'git':
+ popen([cwd.type, 'add', repo.lib])
+
+# Parse/run command
+args = parser.parse_args()
+status = args.command(args)
+sys.exit(status or 0)
+