Merge branch 'feature/issue-263-native-platform' into develop

This commit is contained in:
Ivan Kravets
2015-08-03 12:34:03 +03:00
25 changed files with 201 additions and 60 deletions

View File

@@ -1,6 +1,13 @@
Release History
===============
2.3.0 (2015-??-??)
------------------
* Added `native <http://docs.platformio.org/en/latest/platforms/native.html>`_
development platform
(`issue #263 <https://github.com/platformio/platformio/issues/263>`_)
2.2.2 (2015-07-30)
------------------

View File

@@ -200,7 +200,7 @@ Build Script
Platform's build script is based on a next-generation build tool named
`SCons <http://www.scons.org>`_. PlatformIO has own built-in firmware builder
``env.BuildFirmware`` with the nested libraries search. Please look into a
``env.BuildProgram`` with the nested libraries search. Please look into a
base template of ``test-builder.py``.
.. code-block:: python
@@ -260,7 +260,7 @@ base template of ``test-builder.py``.
#
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file
@@ -383,7 +383,7 @@ and copy there two files:
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file

View File

@@ -11,6 +11,9 @@ Also it has pre-configured settings for most popular **Embedded Platform
Boards**. You have no need to specify in :ref:`projectconf` type or frequency of
MCU, upload protocol or etc. Please use ``board`` option.
Embedded
--------
.. toctree::
:maxdepth: 2
@@ -25,5 +28,20 @@ MCU, upload protocol or etc. Please use ``board`` option.
teensy
timsp430
titiva
Desktop
-------
.. toctree::
:maxdepth: 2
native
Own Platform/Board
------------------
.. toctree::
:maxdepth: 2
creating_platform
creating_board

View File

@@ -0,0 +1,9 @@
.. _platform_native:
Platform ``native``
===================
Native development platform is intended to be used for desktop OS. This platform uses built-in tool chains (preferable based on GCC), frameworks, libs from particular OS where it will be run.
For more detailed information please visit `vendor site <http://platformio.org/#!/platforms/native>`_.
.. contents::

View File

@@ -435,14 +435,8 @@ See built-in examples of `PlatformIO build scripts <https://github.com/platformi
^^^^^^^^^^^
A list with targets which will be processed by :ref:`cmd_run` command by
default. You can enter more then one target separated with "space".
Pre-built targets:
* ``clean`` delete compiled object files, libraries and firmware binaries
* ``upload`` enable "auto-uploading" for embedded platforms after building
operation
* ``envdump`` dump current build environment
default. You can enter more then one target separated with "space". Which
targets are supported is described in :option:`platformio run --target`.
**Tip!** You can use these targets like an option to
:option:`platformio run --target` command. For example:

View File

@@ -33,7 +33,16 @@ Process specified environments
.. option::
-t, --target
Process specified targets
Process specified targets.
Pre-built targets:
* ``clean`` delete compiled object files, libraries and firmware/program binaries
* ``upload`` enable "auto-uploading" for embedded platforms after building
operation
* ``uploadlazy`` upload existing firmware without project rebuilding
* ``envdump`` dump current build environment
* ``size`` print the size of the sections in a firmware/program
.. option::
--upload-port

View File

@@ -1,7 +1,7 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
VERSION = (2, 2, 2)
VERSION = (2, 3, "0.dev0")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@@ -95,7 +95,7 @@ else:
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Extract EEPROM data (from EEMEM directive) to .eep file

View File

@@ -77,7 +77,7 @@ env.Append(
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file

View File

@@ -52,7 +52,10 @@ env.Replace(
LIBS=["c", "gcc", "m"],
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES'
SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES',
PROGNAME="firmware",
PROGSUFFIX=".elf"
)
env.Append(

View File

@@ -49,7 +49,10 @@ env.Replace(
LIBS=["m"],
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES'
SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES',
PROGNAME="firmware",
PROGSUFFIX=".elf"
)
env.Append(

View File

@@ -80,7 +80,10 @@ env.Replace(
"-ca", "0x40000" if "FRAMEWORK" not in env else "0x10000",
"-cf", "${SOURCES[1]}"
],
UPLOADCMD='$UPLOADER $UPLOADERFLAGS'
UPLOADCMD='$UPLOADER $UPLOADERFLAGS',
PROGNAME="firmware",
PROGSUFFIX=".elf"
)
env.Append(
@@ -129,7 +132,7 @@ if "FRAMEWORK" not in env:
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .hex

View File

@@ -18,7 +18,7 @@ SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file

View File

@@ -0,0 +1,36 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
"""
Builder for native platform
"""
from SCons.Script import DefaultEnvironment, AlwaysBuild, Default
env = DefaultEnvironment()
env.Replace(
SIZEPRINTCMD="size $SOURCES",
PROGNAME="program"
)
#
# Target: Build executable program
#
target_bin = env.BuildProgram()
#
# Target: Print binary size
#
target_size = env.Alias("size", target_bin, "$SIZEPRINTCMD")
AlwaysBuild(target_size)
#
# Target: Define targets
#
Default([target_bin])

View File

@@ -18,7 +18,7 @@ SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file

View File

@@ -27,7 +27,7 @@ SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file

View File

@@ -18,7 +18,7 @@ SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file

View File

@@ -65,7 +65,7 @@ env.Append(
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file

View File

@@ -61,7 +61,7 @@ else:
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the firmware file

View File

@@ -57,7 +57,10 @@ env.Replace(
"$UPLOAD_PROTOCOL" if system() != "Windows" else "tilib",
"--force-reset"
],
UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"'
UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"',
PROGNAME="firmware",
PROGSUFFIX=".elf"
)
env.Append(
@@ -80,7 +83,7 @@ env.Append(
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .hex

View File

@@ -31,7 +31,7 @@ env.Append(
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
target_elf = env.BuildProgram()
#
# Target: Build the .bin file

View File

@@ -4,9 +4,11 @@
import atexit
import re
from glob import glob
from os import remove
from os import environ, remove
from os.path import basename, join
from platformio.util import exec_command
class InoToCPPConverter(object):
@@ -157,6 +159,22 @@ def DumpIDEData(env):
return data
def GetCompilerType(env):
try:
sysenv = environ.copy()
sysenv['PATH'] = str(env['ENV']['PATH'])
result = exec_command([env.subst("$CC"), "-v"], env=sysenv)
except OSError:
return None
if result['returncode'] != 0:
return None
output = "".join([result['out'], result['err']]).lower()
for type_ in ("clang", "gcc"):
if type_ in output:
return type_
return None
def exists(_):
return True
@@ -164,4 +182,5 @@ def exists(_):
def generate(env):
env.AddMethod(ConvertInoToCpp)
env.AddMethod(DumpIDEData)
env.AddMethod(GetCompilerType)
return env

View File

@@ -20,7 +20,7 @@ SRC_DEFAULT_FILTER = " ".join([
])
def BuildFirmware(env):
def BuildProgram(env):
# fix ASM handling under non-casitive OS
if not case_sensitive_suffixes(".s", ".S"):
@@ -43,7 +43,7 @@ def BuildFirmware(env):
)
# enable "cyclic reference" for linker
if env.get("LIBS", deplibs):
if env.get("LIBS", deplibs) and env.GetCompilerType() == "gcc":
env.Prepend(
_LIBFLAGS="-Wl,--start-group "
)
@@ -63,14 +63,13 @@ def BuildFirmware(env):
)
return env.Program(
join("$BUILD_DIR", "firmware"),
join("$BUILD_DIR", env.subst("$PROGNAME")),
env.LookupSources(
"$BUILDSRC_DIR", "$PROJECTSRC_DIR", duplicate=False,
src_filter=getenv("PLATFORMIO_SRC_FILTER",
env.get("SRC_FILTER", None))),
LIBS=env.get("LIBS", []) + deplibs,
LIBPATH=env.get("LIBPATH", []) + ["$BUILD_DIR"],
PROGSUFFIX=".elf"
LIBPATH=env.get("LIBPATH", []) + ["$BUILD_DIR"]
)
@@ -331,7 +330,7 @@ def exists(_):
def generate(env):
env.AddMethod(BuildFirmware)
env.AddMethod(BuildProgram)
env.AddMethod(ProcessFlags)
env.AddMethod(IsFileWithExt)
env.AddMethod(VariantDirWrap)

View File

@@ -0,0 +1,18 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
from platformio.platforms.base import BasePlatform
class NativePlatform(BasePlatform):
"""
Native development platform is intended to be used for desktop OS.
This platform uses built-in tool chains (preferable based on GCC),
frameworks, libs from particular OS where it will be run.
http://platformio.org/#!/platforms/native
"""
PACKAGES = {
}

View File

@@ -67,8 +67,14 @@ def generate_boards(boards):
def generate_packages(packages):
if not packages:
return
allpackages = get_packages()
lines = []
lines.append("""
Packages
--------
""")
lines.append(""".. list-table::
:header-rows: 1
@@ -116,13 +122,30 @@ For more detailed information please visit `vendor site <%s>`_.""" %
p.get_vendor_url())
lines.append("""
.. contents::""")
lines.append("""
Packages
--------
""")
lines.append(generate_packages(p.get_packages()))
lines.append("""
#
# Packages
#
_packages_content = generate_packages(p.get_packages())
if _packages_content:
lines.append(_packages_content)
#
# Frameworks
#
_frameworks = util.get_frameworks()
_frameworks_lines = []
for framework in sorted(_frameworks.keys()):
if not is_compat_platform_and_framework(name, framework):
continue
_frameworks_lines.append("""
* - :ref:`framework_{type_}`
- {description}""".format(
type_=framework,
description=_frameworks[framework]['description']))
if _frameworks_lines:
lines.append("""
Frameworks
----------
.. list-table::
@@ -130,18 +153,23 @@ Frameworks
* - Name
- Description""")
lines.extend(_frameworks_lines)
_frameworks = util.get_frameworks()
for framework in sorted(_frameworks.keys()):
if not is_compat_platform_and_framework(name, framework):
continue
#
# Boards
#
vendors = {}
for board, data in util.get_boards().items():
platform = data['platform']
vendor = data['vendor']
if name in platform:
if vendor in vendors:
vendors[vendor].append({board: data})
else:
vendors[vendor] = [{board: data}]
if vendors:
lines.append("""
* - :ref:`framework_{type_}`
- {description}""".format(
type_=framework,
description=_frameworks[framework]['description']))
lines.append("""
Boards
------
@@ -152,19 +180,11 @@ Boards
horizontal.
""")
vendors = {}
for board, data in util.get_boards().items():
platform = data['platform']
vendor = data['vendor']
if name in platform:
if vendor in vendors:
vendors[vendor].append({board: data})
else:
vendors[vendor] = [{board: data}]
for vendor, boards in sorted(vendors.iteritems()):
lines.append(str(vendor))
lines.append("~" * len(vendor))
lines.append(generate_boards(boards))
return "\n".join(lines)