Merge branch 'develop' of https://github.com/ivankravets/platformio into develop

This commit is contained in:
Valeriy Koval
2015-03-16 19:37:19 +02:00
28 changed files with 101 additions and 44 deletions

View File

@ -4,6 +4,8 @@ Framework ``arduino``
===================== =====================
Arduino Framework allows writing cross-platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding, interactive objects, spaces or physical experiences. Arduino Framework allows writing cross-platform software to control devices attached to a wide range of Arduino boards to create all kinds of creative coding, interactive objects, spaces or physical experiences.
For more detailed information please visit `vendor site <http://arduino.cc/en/Reference/HomePage>`_.
.. contents:: .. contents::
Boards Boards

View File

@ -4,6 +4,8 @@ Framework ``cmsis``
=================== ===================
The ARM Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for the Cortex-M processor series and specifies debugger interfaces. The CMSIS enables consistent and simple software interfaces to the processor for interface peripherals, real-time operating systems, and middleware. It simplifies software re-use, reducing the learning curve for new microcontroller developers and cutting the time-to-market for devices. The ARM Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for the Cortex-M processor series and specifies debugger interfaces. The CMSIS enables consistent and simple software interfaces to the processor for interface peripherals, real-time operating systems, and middleware. It simplifies software re-use, reducing the learning curve for new microcontroller developers and cutting the time-to-market for devices.
For more detailed information please visit `vendor site <http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php>`_.
.. contents:: .. contents::
Boards Boards

View File

@ -4,6 +4,8 @@ Framework ``energia``
===================== =====================
Energia framework enables pretty much anyone to start easily creating microcontroller-based projects and applications. Its easy-to-use libraries and functions provide developers of all experience levels to start blinking LEDs, buzzing buzzers and sensing sensors more quickly than ever before. Energia framework enables pretty much anyone to start easily creating microcontroller-based projects and applications. Its easy-to-use libraries and functions provide developers of all experience levels to start blinking LEDs, buzzing buzzers and sensing sensors more quickly than ever before.
For more detailed information please visit `vendor site <http://energia.nu/reference/>`_.
.. contents:: .. contents::
Boards Boards

View File

@ -4,6 +4,8 @@ Framework ``mbed``
================== ==================
The mbed framework The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed. In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries have been built on top of the SDK by the mbed Developer Community. The mbed framework The mbed SDK has been designed to provide enough hardware abstraction to be intuitive and concise, yet powerful enough to build complex projects. It is built on the low-level ARM CMSIS APIs, allowing you to code down to the metal if needed. In addition to RTOS, USB and Networking libraries, a cookbook of hundreds of reusable peripheral and module libraries have been built on top of the SDK by the mbed Developer Community.
For more detailed information please visit `vendor site <http://mbed.org/>`_.
.. contents:: .. contents::
Boards Boards

View File

@ -2,7 +2,9 @@
Framework ``opencm3`` Framework ``opencm3``
===================== =====================
The libopencm3 framework aims to create a free/libre/open-source firmware library for various ARM Cortex-M0(+)/M3/M4 microcontrollers, including ST STM32, Ti Tiva and Stellaris, NXP LPC 11xx, 13xx, 15xx, 17xx parts, Atmel SAM3, Energy Micro EFM32 and others. The libOpenCM3 framework aims to create a free/libre/open-source firmware library for various ARM Cortex-M0(+)/M3/M4 microcontrollers, including ST STM32, Ti Tiva and Stellaris, NXP LPC 11xx, 13xx, 15xx, 17xx parts, Atmel SAM3, Energy Micro EFM32 and others.
For more detailed information please visit `vendor site <http://www.libopencm3.org/wiki/Main_Page>`_.
.. contents:: .. contents::

View File

@ -4,6 +4,8 @@ Framework ``spl``
================= =================
The ST Standard Peripheral Library provides a set of functions for handling the peripherals on the STM32 Cortex-M3 family. The idea is to save the user (the new user, in particular) having to deal directly with the registers. The ST Standard Peripheral Library provides a set of functions for handling the peripherals on the STM32 Cortex-M3 family. The idea is to save the user (the new user, in particular) having to deal directly with the registers.
For more detailed information please visit `vendor site <http://www.st.com/web/en/catalog/tools/FM147/CL1794/SC961/SS1743?sc=stm32embeddedsoftware>`_.
.. contents:: .. contents::
Boards Boards

View File

@ -2,6 +2,8 @@
# See LICENSE for details. # See LICENSE for details.
""" """
Arduino
Arduino Framework allows writing cross-platform software to control Arduino Framework allows writing cross-platform software to control
devices attached to a wide range of Arduino boards to create all devices attached to a wide range of Arduino boards to create all
kinds of creative coding, interactive objects, spaces or physical experiences. kinds of creative coding, interactive objects, spaces or physical experiences.

View File

@ -2,6 +2,8 @@
# See LICENSE for details. # See LICENSE for details.
""" """
CMSIS
The ARM Cortex Microcontroller Software Interface Standard (CMSIS) is a The ARM Cortex Microcontroller Software Interface Standard (CMSIS) is a
vendor-independent hardware abstraction layer for the Cortex-M processor vendor-independent hardware abstraction layer for the Cortex-M processor
series and specifies debugger interfaces. The CMSIS enables consistent and series and specifies debugger interfaces. The CMSIS enables consistent and

View File

@ -2,6 +2,8 @@
# See LICENSE for details. # See LICENSE for details.
""" """
Energia
Energia framework enables pretty much anyone to start easily creating Energia framework enables pretty much anyone to start easily creating
microcontroller-based projects and applications. Its easy-to-use libraries microcontroller-based projects and applications. Its easy-to-use libraries
and functions provide developers of all experience levels to start and functions provide developers of all experience levels to start

View File

@ -2,7 +2,9 @@
# See LICENSE for details. # See LICENSE for details.
""" """
The libopencm3 framework aims to create a free/libre/open-source libOpenCM3
The libOpenCM3 framework aims to create a free/libre/open-source
firmware library for various ARM Cortex-M0(+)/M3/M4 microcontrollers, firmware library for various ARM Cortex-M0(+)/M3/M4 microcontrollers,
including ST STM32, Ti Tiva and Stellaris, NXP LPC 11xx, 13xx, 15xx, including ST STM32, Ti Tiva and Stellaris, NXP LPC 11xx, 13xx, 15xx,
17xx parts, Atmel SAM3, Energy Micro EFM32 and others. 17xx parts, Atmel SAM3, Energy Micro EFM32 and others.

View File

@ -2,6 +2,8 @@
# See LICENSE for details. # See LICENSE for details.
""" """
mbed
The mbed framework The mbed SDK has been designed to provide enough The mbed framework The mbed SDK has been designed to provide enough
hardware abstraction to be intuitive and concise, yet powerful enough to hardware abstraction to be intuitive and concise, yet powerful enough to
build complex projects. It is built on the low-level ARM CMSIS APIs, build complex projects. It is built on the low-level ARM CMSIS APIs,

View File

@ -2,6 +2,8 @@
# See LICENSE for details. # See LICENSE for details.
""" """
SPL
The ST Standard Peripheral Library provides a set of functions for The ST Standard Peripheral Library provides a set of functions for
handling the peripherals on the STM32 Cortex-M3 family. handling the peripherals on the STM32 Cortex-M3 family.
The idea is to save the user (the new user, in particular) having to deal The idea is to save the user (the new user, in particular) having to deal

View File

@ -18,18 +18,18 @@ def cli(query, json_output):
platforms.sort() platforms.sort()
for platform in platforms: for platform in platforms:
p = PlatformFactory.newPlatform(platform) p = PlatformFactory.newPlatform(platform)
name = p.get_name() type_ = p.get_type()
description = p.get_description() description = p.get_description()
if query == "all": if query == "all":
query = "" query = ""
search_data = "%s %s %s" % (name, description, p.get_packages()) search_data = "%s %s %s" % (type_, description, p.get_packages())
if query and query.lower() not in search_data.lower(): if query and query.lower() not in search_data.lower():
continue continue
data.append({ data.append({
"name": name, "type": type_,
"description": description, "description": description,
"packages": p.get_packages() "packages": p.get_packages()
}) })
@ -38,9 +38,9 @@ def cli(query, json_output):
click.echo(json.dumps(data)) click.echo(json.dumps(data))
else: else:
for item in data: for item in data:
click.secho(item['name'], fg="cyan", nl=False) click.secho(item['type'], fg="cyan", nl=False)
click.echo(" (available packages: %s)" % ", ".join( click.echo(" (available packages: %s)" % ", ".join(
p.get_packages().keys())) p.get_packages().keys()))
click.secho("-" * len(item['name']), fg="cyan") click.secho("-" * len(item['type']), fg="cyan")
click.echo(item['description']) click.echo(item['description'])
click.echo() click.echo()

View File

@ -30,7 +30,7 @@ def cli(ctx, platform):
p = PlatformFactory.newPlatform(platform) p = PlatformFactory.newPlatform(platform)
click.echo("{name:<20} - {description} [ {url} ]".format( click.echo("{name:<20} - {description} [ {url} ]".format(
name=click.style(p.get_name(), fg="cyan"), name=click.style(p.get_type(), fg="cyan"),
description=p.get_description(), url=p.get_vendor_url())) description=p.get_description(), url=p.get_vendor_url()))
installed_packages = PackageManager.get_installed() installed_packages = PackageManager.get_installed()

View File

@ -37,6 +37,9 @@ class AtmelavrPlatform(BasePlatform):
} }
} }
def get_name(self):
return "Atmel AVR"
def on_run_err(self, line): # pylint: disable=R0201 def on_run_err(self, line): # pylint: disable=R0201
# fix STDERR "flash written" for avrdude # fix STDERR "flash written" for avrdude
if "avrdude" in line: if "avrdude" in line:

View File

@ -34,3 +34,6 @@ class AtmelsamPlatform(BasePlatform):
"default": True "default": True
} }
} }
def get_name(self):
return "Atmel SAM"

View File

@ -100,17 +100,17 @@ def get_packages():
class PlatformFactory(object): class PlatformFactory(object):
@staticmethod @staticmethod
def get_clsname(name): def get_clsname(type_):
return "%sPlatform" % name.title() return "%sPlatform" % type_.title()
@staticmethod @staticmethod
def load_module(name, path): def load_module(type_, path):
module = None module = None
try: try:
module = load_source( module = load_source(
"platformio.platforms.%s" % name, path) "platformio.platforms.%s" % type_, path)
except ImportError: except ImportError:
raise exception.UnknownPlatform(name) raise exception.UnknownPlatform(type_)
return module return module
@classmethod @classmethod
@ -123,15 +123,15 @@ class PlatformFactory(object):
for p in listdir(pdir): for p in listdir(pdir):
if p in ("__init__.py", "base.py") or not p.endswith(".py"): if p in ("__init__.py", "base.py") or not p.endswith(".py"):
continue continue
name = p[:-3] type_ = p[:-3]
path = join(pdir, p) path = join(pdir, p)
try: try:
isplatform = hasattr( isplatform = hasattr(
cls.load_module(name, path), cls.load_module(type_, path),
cls.get_clsname(name) cls.get_clsname(type_)
) )
if isplatform: if isplatform:
platforms[name] = path platforms[type_] = path
except exception.UnknownPlatform: except exception.UnknownPlatform:
pass pass
@ -139,20 +139,20 @@ class PlatformFactory(object):
return platforms return platforms
installed_platforms = {} installed_platforms = {}
for name in get_state_item("installed_platforms", []): for type_ in get_state_item("installed_platforms", []):
if name in platforms: if type_ in platforms:
installed_platforms[name] = platforms[name] installed_platforms[type_] = platforms[type_]
return installed_platforms return installed_platforms
@classmethod @classmethod
def newPlatform(cls, name): def newPlatform(cls, type_):
platforms = cls.get_platforms() platforms = cls.get_platforms()
if name not in platforms: if type_ not in platforms:
raise exception.UnknownPlatform(name) raise exception.UnknownPlatform(type_)
_instance = getattr( _instance = getattr(
cls.load_module(name, platforms[name]), cls.load_module(type_, platforms[type_]),
cls.get_clsname(name) cls.get_clsname(type_)
)() )()
assert isinstance(_instance, BasePlatform) assert isinstance(_instance, BasePlatform)
return _instance return _instance
@ -166,12 +166,15 @@ class BasePlatform(object):
def __init__(self): def __init__(self):
self._found_error = False self._found_error = False
def get_name(self): def get_type(self):
return self.__class__.__name__[:-8].lower() return self.__class__.__name__[:-8].lower()
def get_name(self):
return self.get_type().title()
def get_build_script(self): def get_build_script(self):
builtin = join(util.get_source_dir(), "builder", "scripts", "%s.py" % builtin = join(util.get_source_dir(), "builder", "scripts", "%s.py" %
self.get_name()) self.get_type())
if isfile(builtin): if isfile(builtin):
return builtin return builtin
raise NotImplementedError() raise NotImplementedError()
@ -235,14 +238,14 @@ class BasePlatform(object):
# register installed platform # register installed platform
data = get_state_item("installed_platforms", []) data = get_state_item("installed_platforms", [])
if self.get_name() not in data: if self.get_type() not in data:
data.append(self.get_name()) data.append(self.get_type())
set_state_item("installed_platforms", data) set_state_item("installed_platforms", data)
return len(requirements) return len(requirements)
def uninstall(self): def uninstall(self):
platform = self.get_name() platform = self.get_type()
installed_platforms = PlatformFactory.get_platforms( installed_platforms = PlatformFactory.get_platforms(
installed=True).keys() installed=True).keys()
@ -286,8 +289,8 @@ class BasePlatform(object):
installed=True).keys() installed=True).keys()
installed_packages = PackageManager.get_installed() installed_packages = PackageManager.get_installed()
if self.get_name() not in installed_platforms: if self.get_type() not in installed_platforms:
raise exception.PlatformNotInstalledYet(self.get_name()) raise exception.PlatformNotInstalledYet(self.get_type())
if "clean" in targets: if "clean" in targets:
targets.remove("clean") targets.remove("clean")

View File

@ -26,3 +26,6 @@ class FreescalekinetisPlatform(BasePlatform):
"default": True "default": True
} }
} }
def get_name(self):
return "Freescale Kinetis"

View File

@ -28,3 +28,6 @@ class Nordicnrf51Platform(BasePlatform):
"default": True "default": True
} }
} }
def get_name(self):
return "Nordic nRF51"

View File

@ -28,3 +28,6 @@ class NxplpcPlatform(BasePlatform):
"default": True "default": True
} }
} }
def get_name(self):
return "NXP LPC"

View File

@ -49,3 +49,6 @@ class Ststm32Platform(BasePlatform):
"default": True "default": True
} }
} }
def get_name(self):
return "ST STM32"

View File

@ -41,6 +41,9 @@ class TeensyPlatform(BasePlatform):
} }
} }
def get_name(self):
return "Teensy"
def run(self, variables, targets): def run(self, variables, targets):
for v in variables: for v in variables:
if "BOARD=" not in v: if "BOARD=" not in v:

View File

@ -31,3 +31,6 @@ class Timsp430Platform(BasePlatform):
"default": True "default": True
} }
} }
def get_name(self):
return "TI MSP430"

View File

@ -39,3 +39,6 @@ class TitivaPlatform(BasePlatform):
"default": True "default": True
} }
} }
def get_name(self):
return "TI TIVA"

View File

@ -284,10 +284,11 @@ def get_frameworks(type_=None):
_doc_start = fcontent.index('"""') + 3 _doc_start = fcontent.index('"""') + 3
fdoc = fcontent[ fdoc = fcontent[
_doc_start:fcontent.index('"""', _doc_start)].strip() _doc_start:fcontent.index('"""', _doc_start)].strip()
description = " ".join(fdoc.split("\n")[:-2]) doclines = [l.strip() for l in fdoc.splitlines() if l.strip()]
frameworks[_type] = { frameworks[_type] = {
"description": description, "name": doclines[0],
"url": fdoc.split("\n")[-1].strip(), "description": " ".join(doclines[1:-1]),
"url": doclines[-1],
"script": script_path "script": script_path
} }
get_frameworks._cache = frameworks # pylint: disable=W0212 get_frameworks._cache = frameworks # pylint: disable=W0212

View File

@ -103,7 +103,6 @@ def generate_platform(name):
lines.append(""" lines.append("""
For more detailed information please visit `vendor site <%s>`_.""" % For more detailed information please visit `vendor site <%s>`_.""" %
p.get_vendor_url()) p.get_vendor_url())
lines.append(""" lines.append("""
.. contents::""") .. contents::""")
lines.append(""" lines.append("""
@ -146,18 +145,21 @@ def update_platform_docs():
f.write(generate_platform(name)) f.write(generate_platform(name))
def generate_framework(name, data): def generate_framework(type_, data):
print "Processing framework: %s" % name print "Processing framework: %s" % type_
lines = [] lines = []
lines.append(".. _framework_%s:" % name) lines.append(".. _framework_%s:" % type_)
lines.append("") lines.append("")
_title = "Framework ``%s``" % name _title = "Framework ``%s``" % type_
lines.append(_title) lines.append(_title)
lines.append("=" * len(_title)) lines.append("=" * len(_title))
lines.append(data['description']) lines.append(data['description'])
lines.append(""" lines.append("""
For more detailed information please visit `vendor site <%s>`_.""" %
data['url'])
lines.append("""
.. contents:: .. contents::
Boards Boards
@ -173,7 +175,7 @@ Boards
for board, data in util.get_boards().items(): for board, data in util.get_boards().items():
frameworks = data['frameworks'] frameworks = data['frameworks']
vendor = data['vendor'] vendor = data['vendor']
if name in frameworks: if type_ in frameworks:
if vendor in vendors: if vendor in vendors:
vendors[vendor].append({board: data}) vendors[vendor].append({board: data})
else: else:

View File

@ -34,9 +34,9 @@ def test_board_options(platformio_setup, clirunner, validate_cliresult):
search_result = json.loads(result.output) search_result = json.loads(result.output)
assert isinstance(search_result, list) assert isinstance(search_result, list)
assert len(search_result) assert len(search_result)
platforms = [item['name'] for item in search_result] platforms = [item['type'] for item in search_result]
for name, opts in util.get_boards().iteritems(): for _, opts in util.get_boards().iteritems():
assert required_opts.issubset(set(opts)) assert required_opts.issubset(set(opts))
assert opts['platform'] in platforms assert opts['platform'] in platforms

View File

@ -12,7 +12,7 @@ def test_search_json_output(clirunner, validate_cliresult):
search_result = json.loads(result.output) search_result = json.loads(result.output)
assert isinstance(search_result, list) assert isinstance(search_result, list)
assert len(search_result) assert len(search_result)
platforms = [item['name'] for item in search_result] platforms = [item['type'] for item in search_result]
assert "atmelsam" in platforms assert "atmelsam" in platforms