diff --git a/HISTORY.rst b/HISTORY.rst index 880f3c02..7924a633 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,13 @@ Release History =============== +2.3.0 (2015-??-??) +------------------ + +* Added `native `_ + development platform + (`issue #263 `_) + 2.2.2 (2015-07-30) ------------------ diff --git a/docs/platforms/creating_platform.rst b/docs/platforms/creating_platform.rst index dfbd0bdc..7e1199cb 100644 --- a/docs/platforms/creating_platform.rst +++ b/docs/platforms/creating_platform.rst @@ -200,7 +200,7 @@ Build Script Platform's build script is based on a next-generation build tool named `SCons `_. 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 diff --git a/docs/platforms/index.rst b/docs/platforms/index.rst index 1ed7a115..eaf05de1 100644 --- a/docs/platforms/index.rst +++ b/docs/platforms/index.rst @@ -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 diff --git a/docs/platforms/native.rst b/docs/platforms/native.rst new file mode 100644 index 00000000..5a01d633 --- /dev/null +++ b/docs/platforms/native.rst @@ -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 `_. + +.. contents:: \ No newline at end of file diff --git a/docs/projectconf.rst b/docs/projectconf.rst index 34c0feeb..53656704 100644 --- a/docs/projectconf.rst +++ b/docs/projectconf.rst @@ -435,14 +435,8 @@ See built-in examples of `PlatformIO build scripts # See LICENSE for details. -VERSION = (2, 2, 2) +VERSION = (2, 3, "0.dev0") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index 1027b6a4..6bdc2b62 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -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 diff --git a/platformio/builder/scripts/atmelsam.py b/platformio/builder/scripts/atmelsam.py index 083f4136..00d0fa78 100644 --- a/platformio/builder/scripts/atmelsam.py +++ b/platformio/builder/scripts/atmelsam.py @@ -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 diff --git a/platformio/builder/scripts/basearm.py b/platformio/builder/scripts/basearm.py index 33114dca..cb685caf 100644 --- a/platformio/builder/scripts/basearm.py +++ b/platformio/builder/scripts/basearm.py @@ -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( diff --git a/platformio/builder/scripts/baseavr.py b/platformio/builder/scripts/baseavr.py index 3ac52b00..7566bcc4 100644 --- a/platformio/builder/scripts/baseavr.py +++ b/platformio/builder/scripts/baseavr.py @@ -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( diff --git a/platformio/builder/scripts/espressif.py b/platformio/builder/scripts/espressif.py index 3875dd15..09c7196b 100644 --- a/platformio/builder/scripts/espressif.py +++ b/platformio/builder/scripts/espressif.py @@ -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 diff --git a/platformio/builder/scripts/freescalekinetis.py b/platformio/builder/scripts/freescalekinetis.py index c80d7134..0f23c8f6 100644 --- a/platformio/builder/scripts/freescalekinetis.py +++ b/platformio/builder/scripts/freescalekinetis.py @@ -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 diff --git a/platformio/builder/scripts/native.py b/platformio/builder/scripts/native.py new file mode 100644 index 00000000..bdbcd372 --- /dev/null +++ b/platformio/builder/scripts/native.py @@ -0,0 +1,36 @@ +# Copyright (C) Ivan Kravets +# 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]) diff --git a/platformio/builder/scripts/nordicnrf51.py b/platformio/builder/scripts/nordicnrf51.py index 15e67cc2..caed2f55 100644 --- a/platformio/builder/scripts/nordicnrf51.py +++ b/platformio/builder/scripts/nordicnrf51.py @@ -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 diff --git a/platformio/builder/scripts/nxplpc.py b/platformio/builder/scripts/nxplpc.py index 39b9dfd9..9585eb5a 100644 --- a/platformio/builder/scripts/nxplpc.py +++ b/platformio/builder/scripts/nxplpc.py @@ -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 diff --git a/platformio/builder/scripts/siliconlabsefm32.py b/platformio/builder/scripts/siliconlabsefm32.py index 29692f6f..1fd710b9 100644 --- a/platformio/builder/scripts/siliconlabsefm32.py +++ b/platformio/builder/scripts/siliconlabsefm32.py @@ -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 diff --git a/platformio/builder/scripts/ststm32.py b/platformio/builder/scripts/ststm32.py index c1622028..aeff2818 100644 --- a/platformio/builder/scripts/ststm32.py +++ b/platformio/builder/scripts/ststm32.py @@ -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 diff --git a/platformio/builder/scripts/teensy.py b/platformio/builder/scripts/teensy.py index fc4f4f91..e7a5643f 100644 --- a/platformio/builder/scripts/teensy.py +++ b/platformio/builder/scripts/teensy.py @@ -61,7 +61,7 @@ else: # Target: Build executable and linkable firmware # -target_elf = env.BuildFirmware() +target_elf = env.BuildProgram() # # Target: Build the firmware file diff --git a/platformio/builder/scripts/timsp430.py b/platformio/builder/scripts/timsp430.py index 90507539..b38d4c12 100644 --- a/platformio/builder/scripts/timsp430.py +++ b/platformio/builder/scripts/timsp430.py @@ -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 diff --git a/platformio/builder/scripts/titiva.py b/platformio/builder/scripts/titiva.py index db14ecdf..a94a64e7 100644 --- a/platformio/builder/scripts/titiva.py +++ b/platformio/builder/scripts/titiva.py @@ -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 diff --git a/platformio/builder/tools/piomisc.py b/platformio/builder/tools/piomisc.py index 851b1f97..fb3f3fca 100644 --- a/platformio/builder/tools/piomisc.py +++ b/platformio/builder/tools/piomisc.py @@ -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 diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index a2c9746a..1f1d145e 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -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) diff --git a/platformio/platforms/native.py b/platformio/platforms/native.py new file mode 100644 index 00000000..f02478cb --- /dev/null +++ b/platformio/platforms/native.py @@ -0,0 +1,18 @@ +# Copyright (C) Ivan Kravets +# 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 = { + } diff --git a/scripts/docspregen.py b/scripts/docspregen.py index 5f9f3ac5..becb9b57 100644 --- a/scripts/docspregen.py +++ b/scripts/docspregen.py @@ -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)