From 187315fc08063e770dcf9f72e8b5582f892cde41 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sun, 24 Jul 2016 20:04:09 +0300 Subject: [PATCH] Allow to disable library archiving ("*.ar") // Resolve #719 --- HISTORY.rst | 39 +++++++++++++++----------- docs/librarymanager/config.rst | 4 +++ platformio/__init__.py | 2 +- platformio/builder/tools/piolib.py | 25 +++++++++++++++-- platformio/builder/tools/platformio.py | 29 +++++++++++-------- 5 files changed, 66 insertions(+), 33 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 084ce934..b78463ae 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -13,28 +13,33 @@ PlatformIO 3.0 (`issue #479 `_) * Unit Testing for Embedded (`docs `__) (`issue #408 `_) -* New Library Build System: intelligent dependency finder that interprets - C Preprocessor conditional macros, - `library deep search `__, - `library compatibility level `__, - support for the 3rd party manifests (Arduino IDE ``library.properties``, - ARM mbed ``module.json``) - (`issue #432 `_) -* New `lib_extra_dirs `__ option for project environment. - Multiple custom library locations! - (`issue #537 `_) -* Handle extra build flags and build script from - `library.json `__ - (`issue #289 `_) -* Check library compatibility with project environment before building - (`issue #415 `_) +* New Intelligent Library Build System + + + `Library Dependency Finder `__ + that interprets C Preprocessor conditional macros and nested includes/chain + + Check library compatibility with project environment before building + (`issue #415 `_) + + Control Library Dependency Finder for compatibility using + `lib_compat_level `__ + option + + Custom library storages/directories with + `lib_extra_dirs `__ option + (`issue #537 `_) + + Handle extra build flags, source filters and build script from + `library.json `__ + (`issue #289 `_) + + Allowed to disable library archiving (``*.ar``) + (`issue #719 `_) + + Show detailed build information about dependent libraries + (`issue #617 `_) + + Support for the 3rd party manifests (Arduino IDE "library.properties" + and ARM mbed "module.json") + * Print human-readable information when processing environments without ``-v, --verbose`` option (`issue #721 `_) * Added ``license`` field to `library.json `__ (`issue #522 `_) -* Show detailed build information about dependent libraries - (`issue #617 `_) * Embedded Board compatibility with more than one development platform (`issue #456 `_) diff --git a/docs/librarymanager/config.rst b/docs/librarymanager/config.rst index 709e42ff..ae31284e 100644 --- a/docs/librarymanager/config.rst +++ b/docs/librarymanager/config.rst @@ -461,6 +461,10 @@ options: - ``String`` - Launch extra script before build process. More details :ref:`projectconf_extra_script` + * - ``libArchive`` + - ``Boolean`` + - Archive object files to Static Library. This is default behavior of + PlatformIO Build System (``"libArchive": true``). **Examples** diff --git a/platformio/__init__.py b/platformio/__init__.py index f133db64..d37c5b19 100644 --- a/platformio/__init__.py +++ b/platformio/__init__.py @@ -14,7 +14,7 @@ import sys -VERSION = (3, 0, "0.dev10") +VERSION = (3, 0, "0.dev11") __version__ = ".".join([str(s) for s in VERSION]) __title__ = "platformio" diff --git a/platformio/builder/tools/piolib.py b/platformio/builder/tools/piolib.py index b930fe2f..777dbb7e 100644 --- a/platformio/builder/tools/piolib.py +++ b/platformio/builder/tools/piolib.py @@ -121,6 +121,10 @@ class LibBuilderBase(object): def extra_script(self): return None + @property + def lib_archive(self): + return True + @property def is_built(self): return self._is_built @@ -162,7 +166,12 @@ class LibBuilderBase(object): for key in ("CPPPATH", "LIBPATH", "LIBS", "LINKFLAGS"): self.env.AppendUnique(**{key: env.get(key)}) - return env.BuildLibrary(self.build_dir, self.src_dir, self.src_filter) + if self.lib_archive: + return env.BuildLibrary( + self.build_dir, self.src_dir, self.src_filter) + else: + return env.BuildSources( + self.build_dir, self.src_dir, self.src_filter) class UnknownLibBuilder(LibBuilderBase): @@ -260,6 +269,12 @@ class PlatformIOLibBuilder(LibBuilderBase): return self._manifest.get("build").get("extra_script") return LibBuilderBase.extra_script.fget(self) + @property + def lib_archive(self): + if "libArchive" in self._manifest.get("build", {}): + return self._manifest.get("build").get("libArchive") + return LibBuilderBase.lib_archive.fget(self) + def is_platform_compatible(self, platform): items = self._manifest.get("platforms") if not items: @@ -315,7 +330,9 @@ def find_and_build_deps(env, lib_builders, scanner, lb.append_to_cpppath() # start builder for lb in target_lbs: - libs.append(lb.build()) + lib_node = lb.build() + if lib_node: + libs.append(lib_node) if env.get("LIB_DEEP_SEARCH", "").lower() == "true": for lb in target_lbs: @@ -377,7 +394,9 @@ def BuildDependentLibraries(env, src_dir): libs.extend(find_and_build_deps( env, lib_builders, scanner, lb.src_dir, lb.src_filter)) if not lb.is_built: - libs.append(lb.build()) + lib_node = lb.build() + if lib_node: + libs.append(lib_node) # process project source code libs.extend(find_and_build_deps( diff --git a/platformio/builder/tools/platformio.py b/platformio/builder/tools/platformio.py index 66e4893c..e4875e15 100644 --- a/platformio/builder/tools/platformio.py +++ b/platformio/builder/tools/platformio.py @@ -85,24 +85,24 @@ def BuildProgram(env): env.Append( CPPPATH=["$PROJECTSRC_DIR"], LIBS=deplibs, - LIBPATH=["$BUILD_DIR"] - ) - - sources = env.CollectBuildFiles( - "$BUILDSRC_DIR", "$PROJECTSRC_DIR", - src_filter=env.get("SRC_FILTER"), duplicate=False) + LIBPATH=["$BUILD_DIR"], + PIOBUILDFILES=env.CollectBuildFiles( + "$BUILDSRC_DIR", + "$PROJECTSRC_DIR", + src_filter=env.get("SRC_FILTER"), + duplicate=False)) if "test" in COMMAND_LINE_TARGETS: - sources.extend(env.ProcessTest()) + env.Append(PIOBUILDFILES=env.ProcessTest()) - if not sources and not COMMAND_LINE_TARGETS: + if not env['PIOBUILDFILES'] and not COMMAND_LINE_TARGETS: env.Exit( "Error: Nothing to build. Please put your source code files " "to '%s' folder" % env.subst("$PROJECTSRC_DIR")) program = env.Program( join("$BUILD_DIR", env.subst("$PROGNAME")), - sources + env['PIOBUILDFILES'] ) if set(["upload", "uploadlazy", "program"]) & set(COMMAND_LINE_TARGETS): @@ -262,11 +262,15 @@ def BuildFrameworks(env, frameworks): def BuildLibrary(env, variant_dir, src_dir, src_filter=None): lib = env.Clone() - return lib.Library( + return lib.StaticLibrary( lib.subst(variant_dir), lib.CollectBuildFiles( - variant_dir, src_dir, src_filter=src_filter) - ) + variant_dir, src_dir, src_filter=src_filter)) + + +def BuildSources(env, variant_dir, src_dir, src_filter=None): + DefaultEnvironment().Append(PIOBUILDFILES=env.Clone().CollectBuildFiles( + variant_dir, src_dir, src_filter=src_filter)) def exists(_): @@ -283,4 +287,5 @@ def generate(env): env.AddMethod(CollectBuildFiles) env.AddMethod(BuildFrameworks) env.AddMethod(BuildLibrary) + env.AddMethod(BuildSources) return env