From a8a9451c73446f353736b418e569fab2be659e81 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 20 Mar 2015 21:55:08 +0200 Subject: [PATCH] Fix re-arranging the *.ino/pde files when converting to *.cpp // Resolve #100 --- HISTORY.rst | 8 ++++++-- platformio/builder/tools/platformio.py | 19 ++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 7029819e..7a681716 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -4,8 +4,8 @@ Release History 1.2.0 (2015-03-??) ------------------ -* Initial support of `mbed `__ - framework (only core SDK) +* Added full support of `mbed `__ + framework including libraries: *RTOS, Ethernet, DSP, FAT, USB*. * Added `freescalekinetis `_ development platform with Freescale Kinetis Freedom boards * Added `nordicnrf51 `_ @@ -26,8 +26,12 @@ Release History builder (`issue #105 `_) * Renamed ``stm32`` development platform to `ststm32 `__ +* Renamed ``opencm3`` framework to + `libopencm3 `__ * Fixed uploading for `atmelsam `__ development platform +* Fixed re-arranging the ``*.ino/pde`` files when converting to ``*.cpp`` + (`issue #100 `_) 1.1.0 (2015-03-05) ------------------ diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 0b283fb2..a27d8654 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -176,7 +176,11 @@ def BuildDependentLibraries(env, src_dir): # pylint: disable=R0914 for ld in listdir(lsd_dir): inc_path = normpath(join(lsd_dir, ld, self.name)) - lib_dir = inc_path[:inc_path.index(sep, len(lsd_dir) + 1)] + try: + lib_dir = inc_path[:inc_path.index( + sep, len(lsd_dir) + 1)] + except ValueError: + continue lib_name = basename(lib_dir) # ignore user's specified libs @@ -284,9 +288,6 @@ def ConvertInoToCpp(env): continue ino_contents = item.get_text_contents() - 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 @@ -297,19 +298,15 @@ def ConvertInoToCpp(env): ino_contents, re.X | re.M | re.I ) - # print includes, prototypes - - # disable previous includes - ino_contents = re_includes.sub(r"//\1", ino_contents) + prototypes = [p.strip() for p in prototypes] + # print prototypes # 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)) + f.write('#line 1 "%s"\n' % basename(item.path)) f.write(ino_contents) tmpcpp.append(cppfile)