diff --git a/.gitignore b/.gitignore index 2de54be75f..f3fa86a211 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ examples/ide-eclipse/.metadata examples/ide-eclipse/RemoteSystemsTempFiles docs/_build +dist diff --git a/HISTORY.rst b/HISTORY.rst index 423b0c19ab..610b2eb6bf 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,17 @@ Release History =============== +0.8.0 (?) +--------- + +0.7.1 (2014-10-06) +------------------ + +* Fixed bug with order for includes in conversation from INO/PDE to CPP +* Automatic detection of port on upload (`issue #15 `_) +* Fixed lib update crashing when no libs are installed (`issue #19 `_) + + 0.7.0 (2014-09-24) ------------------ diff --git a/docs/index.rst b/docs/index.rst index d76fb76d61..05b996a0ab 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,5 @@ -PlatformIO: A cross-platform code builder and library manager -============================================================= +PlatformIO: A cross-platform code builder and library manager (Arduino, MSP430, ARM) +==================================================================================== `Website + Library Search `_ | `Project Examples `_ | diff --git a/docs/librarymanager/index.rst b/docs/librarymanager/index.rst index 3840872c87..73b4fd0432 100644 --- a/docs/librarymanager/index.rst +++ b/docs/librarymanager/index.rst @@ -9,7 +9,7 @@ Library Manager *PlatformIO Library Manager* allows you to organize external embedded libraries. You can search for new libraries via :ref:`Command Line ` -or `WebSite `_ interfaces. +or `WebSite `_ interfaces. You don't need to bother for finding the latest version of library. Due to :ref:`cmd_lib_update` command you will have up-to-date external libraries. diff --git a/platformio/__init__.py b/platformio/__init__.py index dcc97ca2c5..846f38f9f6 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -1,11 +1,12 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. -VERSION = (0, 7, 0) +VERSION = (0, 7, 1) __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" -__description__ = ("A cross-platform code builder and library manager") +__description__ = ("A cross-platform code builder and library manager " + "(Arduino, MSP430, ARM)") __url__ = "http://platformio.ikravets.com" __author__ = "Ivan Kravets" diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index dcaed8f637..e3806c2389 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -11,7 +11,7 @@ from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default, DefaultEnvironment, Exit) -from platformio.util import reset_serialport +from platformio.util import get_serialports, reset_serialport env = DefaultEnvironment() @@ -164,9 +164,19 @@ def rpi_sysgpio(path, value): is_uptarget = (set(["upload", "uploadlazy", "uploadeep"]) & set(COMMAND_LINE_TARGETS)) -if is_uptarget and not env.subst("$UPLOAD_PORT"): - Exit("Please specify environment 'upload_port' or use global " - "--upload-port option.") + +if is_uptarget: + # try autodetect upload port + if "UPLOAD_PORT" not in env: + for item in get_serialports(): + if "VID:PID" in item['hwid']: + print "Auto-detected UPLOAD_PORT: %s" % item['port'] + env['UPLOAD_PORT'] = item['port'] + break + + if "UPLOAD_PORT" not in env: + Exit("Please specify environment 'upload_port' or use global " + "--upload-port option.") # # Setup default targets diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 5285309fec..19302a1a0a 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -173,22 +173,29 @@ def delete_tmpcpp(files): continue ino_contents = item.get_text_contents() - # fetch prototypes - regexp = re.compile( + re_includes = re.compile(r"^(#include\s+(?:\<|\")[^\r\n]+)", + re.M | re.I) + includes = re_includes.findall(ino_contents) + prototypes = re.findall( r"""^( (?:\s*[a-z_\d]+){1,2} # return type \s+[a-z_\d]+\s* # name of prototype \([a-z_,\.\*\&\[\]\s\d]*\) # args )\s*\{ # must end with { """, + ino_contents, re.X | re.M | re.I ) - prototypes = regexp.findall(ino_contents) - # print prototypes + # print includes, prototypes + + # disable previous includes + ino_contents = re_includes.sub(r"//\1", ino_contents) # create new temporary C++ valid file with open(cppfile, "w") as f: f.write("#include \n") + if includes: + f.write("%s\n" % "\n".join(includes)) if prototypes: f.write("%s;\n" % ";\n".join(prototypes)) f.write("#line 1 \"%s\"\n" % basename(item.path)) diff --git a/platformio/commands/lib.py b/platformio/commands/lib.py index 9de31be267..07aef25a71 100644 --- a/platformio/commands/lib.py +++ b/platformio/commands/lib.py @@ -140,9 +140,12 @@ def lib_show(name): @cli.command("update", short_help="Update installed libraries") def lib_update(): lm = LibraryManager(get_lib_dir()) + lib_names = lm.get_installed() - versions = get_api_result("/lib/version/" + ",".join(lib_names)) + if not lib_names: + return + versions = get_api_result("/lib/version/" + ",".join(lib_names)) for name in lib_names: info = lm.get_info(name) diff --git a/platformio/commands/run.py b/platformio/commands/run.py index 5e989c1798..4ed95befcf 100644 --- a/platformio/commands/run.py +++ b/platformio/commands/run.py @@ -25,7 +25,10 @@ def cli(environment, target, upload_port): raise UnknownEnvNames(", ".join(unknown)) for section in config.sections(): - if section[:4] != "env:": + # skip main configuration section + if section == "platformio": + continue + elif section[:4] != "env:": raise InvalidEnvName(section) envname = section[4:] diff --git a/platformio/libmanager.py b/platformio/libmanager.py index 2fb4a18587..2f6960d91b 100644 --- a/platformio/libmanager.py +++ b/platformio/libmanager.py @@ -33,6 +33,8 @@ def unpack(pkgpath, dest_dir): def get_installed(self): items = [] + if not isdir(self.lib_dir): + return items for item in listdir(self.lib_dir): conf_path = join(self.lib_dir, item, self.CONFIG_NAME) if isfile(conf_path): @@ -53,14 +55,13 @@ def install(self, name, version=None): if self.is_installed(name): raise LibAlreadyInstalledError() - _lib_dir = join(self.lib_dir, name) - if not isdir(_lib_dir): - makedirs(_lib_dir) - dlinfo = get_api_result("/lib/download/" + name, dict(version=version) if version else None) try: dlpath = self.download(dlinfo['url'], gettempdir()) + _lib_dir = join(self.lib_dir, name) + if not isdir(_lib_dir): + makedirs(_lib_dir) self.unpack(dlpath, _lib_dir) finally: remove(dlpath) diff --git a/platformio/util.py b/platformio/util.py index c29347d95a..ef42b73cb4 100644 --- a/platformio/util.py +++ b/platformio/util.py @@ -46,7 +46,11 @@ def get_lib_dir(): config = get_project_config() if (config.has_section("platformio") and config.has_option("platformio", "lib_dir")): - return config.get("platformio", "lib_dir") + lib_dir = config.get("platformio", "lib_dir") + if lib_dir.startswith("~"): + return expanduser(lib_dir) + else: + return lib_dir except NotPlatformProject: pass return join(get_home_dir(), "lib") diff --git a/requirements.txt b/requirements.txt index 984e12bdab..9a7891b485 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ click==3.3 colorama==0.3.1 pyserial==2.7 -requests==2.4.1 +requests==2.4.3 scons==2.3.0 diff --git a/scripts/get-platformio.py b/scripts/get-platformio.py index aff8ba6c48..be38fcdeb9 100644 --- a/scripts/get-platformio.py +++ b/scripts/get-platformio.py @@ -73,16 +73,20 @@ def install_pip(): def install_pypi_packages(packages): - for p in packages: - print (exec_python_cmd(["-m", "pip", "install", "-U"] + p.split())) + for pipargs in packages: + print (exec_python_cmd(["-m", "pip", "install", "-U"] + pipargs)) def main(): steps = [ ("Fixing Windows %PATH% Environment", fix_winpython_pathenv, []), ("Installing Python Package Manager", install_pip, []), - ("Installing PlatformIO and dependencies", install_pypi_packages, - (["platformio", "--egg scons"],)), + ("Installing PlatformIO and dependencies", install_pypi_packages, [ + [["platformio"], [ + "--egg", + "http://sourceforge.net/projects/scons/files/latest/download" + ]] + ]) ] if not IS_WINDOWS: diff --git a/tox.ini b/tox.ini index 0185fd254a..28baf1c180 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ deps = isort flake8 commands = - pip install --egg scons + pip install --egg http://sourceforge.net/projects/scons/files/latest/download [testenv:docs] deps =