Print human-readable information when processing environments without // Resolve #721

This commit is contained in:
Ivan Kravets
2016-07-17 00:48:59 +03:00
parent 70031040b3
commit daac1b2590
15 changed files with 161 additions and 120 deletions

View File

@ -25,6 +25,9 @@ PlatformIO 3.0
(`issue #289 <https://github.com/platformio/platformio/issues/289>`_)
* Check library compatibility with project environment before building
(`issue #415 <https://github.com/platformio/platformio/issues/415>`_)
* Print human-readable information when processing environments without
``-v, --verbose`` option
(`issue #721 <https://github.com/platformio/platformio/issues/721>`_)
* Added ``license`` field to `library.json <http://docs.platformio.org/en/latest/librarymanager/config.html>`__
(`issue #522 <https://github.com/platformio/platformio/issues/522>`_)
* Show detailed build information about dependent libraries

View File

@ -157,3 +157,7 @@ Allows to override setting :ref:`setting_enable_prompts`.
.. envvar:: PLATFORMIO_SETTING_ENABLE_TELEMETRY
Allows to override setting :ref:`setting_enable_telemetry`.
.. envvar:: PLATFORMIO_SETTING_FORCE_VERBOSE
Allows to override setting :ref:`setting_force_verbose`.

View File

@ -112,8 +112,10 @@ Buid project using pre-configured :ref:`projectconf`.
.. option::
-v, --verbose
Shows details about the results of processing environments. More details
:option:`platformio run --verbose`
Shows detailed information when processing environments.
This option can be set globally using :ref:`setting_force_verbose` setting
or by environment variable :envvar:`PLATFORMIO_SETTING_FORCE_VERBOSE`.
Examples
--------

View File

@ -77,17 +77,10 @@ to current working directory (``CWD``).
.. option::
-v, --verbose
Shows details about the results of processing environments. Each instance of
``--verbose`` on the command line increases the verbosity level by one, so if
you need more details on the output, specify it twice.
Shows detailed information when processing environments.
There 3 levels of verbosity:
1. ``-v`` - output errors only
2. ``-vv`` - output errors and warnings
3. ``-vvv`` - output errors, warnings and additional information
By default, verbosity level is set to 3 (maximum information).
This option can be set globally using :ref:`setting_force_verbose` setting
or by environment variable :envvar:`PLATFORMIO_SETTING_FORCE_VERBOSE`.
.. option::
--disable-auto-clean
@ -103,17 +96,34 @@ Examples
.. code-block:: bash
$ platformio run
Processing arduino_pro5v environment:
scons: `.pioenvs/arduino_pro5v/firmware.elf' is up to date.
scons: `.pioenvs/arduino_pro5v/firmware.hex' is up to date.
[Sun Jul 17 00:09:16 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino)
-----------------------------------------------------------------------------------------------
Looking for dependencies...
Collecting 32 compatible libraries
Processing src/main.cpp
Processing .pioenvs/uno/libFrameworkArduinoVariant.a
Processing .platformio/packages/framework-arduinoavr/cores/arduino/CDC.cpp
Processing .platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial.cpp
Processing .platformio/packages/framework-arduinoavr/cores/arduino/HardwareSerial0.cpp
...
Processing .platformio/packages/framework-arduinoavr/cores/arduino/wiring_analog.c
Processing .platformio/packages/framework-arduinoavr/cores/arduino/wiring_digital.c
Processing .platformio/packages/framework-arduinoavr/cores/arduino/wiring_pulse.c
Processing .platformio/packages/framework-arduinoavr/cores/arduino/wiring_shift.c
Processing .pioenvs/uno/libFrameworkArduino.a
Processing .pioenvs/uno/firmware.elf
Processing .pioenvs/uno/firmware.hex
Processing size
AVR Memory Usage
----------------
Device: atmega328p
Processing launchpad_msp430g2 environment:
scons: `.pioenvs/launchpad_msp430g2/firmware.elf' is up to date.
scons: `.pioenvs/launchpad_msp430g2/firmware.hex' is up to date.
Program: 1034 bytes (3.2% Full)
(.text + .data + .bootloader)
Data: 9 bytes (0.4% Full)
(.data + .bss + .noinit)
Processing launchpad_lm4f120 environment:
scons: `.pioenvs/launchpad_lm4f120/firmware.elf' is up to date.
scons: `.pioenvs/launchpad_lm4f120/firmware.hex' is up to date
2. Process specific environment
@ -121,13 +131,27 @@ Examples
.. code-block:: bash
$ platformio run -e arduino_pro5v -e launchpad_lm4f120
Processing arduino_pro5v environment:
scons: `.pioenvs/arduino_pro5v/firmware.elf' is up to date.
scons: `.pioenvs/arduino_pro5v/firmware.hex' is up to date.
Processing launchpad_lm4f120 environment:
scons: `.pioenvs/launchpad_lm4f120/firmware.elf' is up to date.
scons: `.pioenvs/launchpad_lm4f120/firmware.hex' is up to date.
[Sun Jul 17 00:10:14 2016] Processing nodemcu (platform: espressif, board: nodemcu, framework: arduino)
--------------------------------------------------------------------------------------------------------
Looking for dependencies...
Collecting 29 compatible libraries
Processing src/main.cpp
Processing .pioenvs/nodemcu/libFrameworkArduinoVariant.a
Processing .platformio/packages/framework-arduinoespressif/cores/esp8266/Esp.cpp
...
Processing .platformio/packages/framework-arduinoespressif/cores/esp8266/pgmspace.cpp
Processing .platformio/packages/framework-arduinoespressif/cores/esp8266/setjmp.S
Processing .pioenvs/nodemcu/libFrameworkArduino.a
Processing .platformio/packages/framework-arduinoespressif/tools/sdk/lib/libmesh.a
...
Processing .platformio/packages/framework-arduinoespressif/tools/sdk/lib/libaxtls.a
Processing .platformio/packages/framework-arduinoespressif/tools/sdk/lib/libstdc++.a
Processing .pioenvs/nodemcu/firmware.elf
Processing .platformio/packages/tool-esptool/esptool
Processing .pioenvs/nodemcu/firmware.bin
Processing size
text data bss dec hex filename
221456 884 29496 251836 3d7bc .pioenvs/nodemcu/firmware.elf
3. Process specific target
@ -135,52 +159,49 @@ Examples
.. code-block:: bash
$ platformio run -t clean
Processing arduino_pro5v environment:
Removed .pioenvs/arduino_pro5v/src/main.o
[Sun Jul 17 00:19:36 2016] Processing uno (platform: atmelavr, board: uno, framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Looking for dependencies...
Collecting 32 compatible libraries
Removed .pioenvs/uno/FrameworkArduino/CDC.o
Removed .pioenvs/uno/FrameworkArduino/HardwareSerial.o
...
Removed .pioenvs/arduino_pro5v/firmware.hex
Processing launchpad_msp430g2 environment:
Removed .pioenvs/launchpad_msp430g2/src/main.o
...
Removed .pioenvs/launchpad_msp430g2/firmware.hex
Processing launchpad_lm4f120 environment:
Removed .pioenvs/launchpad_lm4f120/src/main.o
...
Removed .pioenvs/launchpad_lm4f120/firmware.hex
Removed .pioenvs/uno/libFrameworkArduinoVariant.a
Removed .pioenvs/uno/src/main.o
Removed .pioenvs/uno/libFrameworkArduino.a
Removed .pioenvs/uno/firmware.elf
Removed .pioenvs/uno/firmware.hex
4. Mix environments and targets
.. code-block:: bash
$ platformio run -e launchpad_msp430g2 -t upload
Processing launchpad_msp430g2 environment:
/Users/ikravets/.platformio/timsp430/tools/mspdebug/mspdebug rf2500 --force-reset "prog .pioenvs/launchpad_msp430g2/firmware.hex"
MSPDebug version 0.20 - debugging tool for MSP430 MCUs
Copyright (C) 2009-2012 Daniel Beer <dlbeer@gmail.com>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Trying to open interface 1 on 009
Initializing FET...
FET protocol version is 30394216
Configured for Spy-Bi-Wire
Sending reset...
Set Vcc: 3000 mV
Device ID: 0x2553
Code start address: 0xc000
Code size : 16384 byte = 16 kb
RAM start address: 0x200
RAM end address: 0x3ff
RAM size : 512 byte = 0 kb
Device: MSP430G2553/G2403
Code memory starts at 0xc000
Number of breakpoints: 2
Chip ID data: 25 53
Erasing...
Programming...
Writing 646 bytes at c000...
Writing 32 bytes at ffe0...
Done, 678 bytes total
$ platformio run -e teensy31 -t upload
[Sun Jul 17 00:27:14 2016] Processing teensy31 (platform: teensy, board: teensy31, framework: arduino)
-------------------------------------------------------------------------------------------------------
Looking for dependencies...
Collecting 25 compatible libraries
Processing src/main.cpp
Processing .platformio/packages/framework-arduinoteensy/cores/teensy3/AudioStream.cpp
Processing .platformio/packages/framework-arduinoteensy/cores/teensy3/DMAChannel.cpp
Processing .platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial1.cpp
...
Processing .platformio/packages/framework-arduinoteensy/cores/teensy3/yield.cpp
Processing .platformio/packages/tool-teensy/teensy_loader_cli
Processing .pioenvs/teensy31/libFrameworkArduino.a
Processing .pioenvs/teensy31/firmware.elf
Check program size...
text data bss dec hex filename
11080 168 2288 13536 34e0 .pioenvs/teensy31/firmware.elf
Processing .pioenvs/teensy31/firmware.hex
Processing upload
Teensy Loader, Command Line, Version 2.0
Read ".pioenvs/teensy31/firmware.hex": 11248 bytes, 4.3% usage
Soft reboot is not implemented for OSX
Waiting for Teensy device...
(hint: press the reset button)
Found HalfKay Bootloader
Read ".pioenvs/teensy31/firmware.hex": 11248 bytes, 4.3% usage
Programming...........
Booting

View File

@ -87,6 +87,20 @@ Check for the new PlatformIO interval.
Check for the platform updates interval.
.. _setting_force_verbose:
``force_verbose``
^^^^^^^^^^^^^^^^^
:Default: No
:Values: Yes/No
Force verbose output when processing environments. This setting overrides
* :option:`platformio run --verbose`
* :option:`platformio ci --verbose`
* :option:`platformio test --verbose`
.. _setting_enable_prompts:
``enable_prompts``

View File

@ -85,8 +85,10 @@ to current working directory (``CWD``).
.. option::
-v, --verbose
Shows details about the results of processing environments. More details
:option:`platformio run --verbose`
Shows detailed information when processing environments.
This option can be set globally using :ref:`setting_force_verbose` setting
or by environment variable :envvar:`PLATFORMIO_SETTING_FORCE_VERBOSE`.
Examples
--------

View File

@ -14,7 +14,7 @@
import sys
VERSION = (3, 0, "0.dev7")
VERSION = (3, 0, "0.dev8")
__version__ = ".".join([str(s) for s in VERSION])
__title__ = "platformio"

View File

@ -44,6 +44,10 @@ DEFAULT_SETTINGS = {
"description": "Automatically update libraries (Yes/No)",
"value": False
},
"force_verbose": {
"description": "Force verbose output when processing environments",
"value": False
},
"enable_telemetry": {
"description": (
"Telemetry service <http://docs.platformio.org/en/latest/"

View File

@ -19,11 +19,12 @@ from os import environ
from os.path import join, normpath
from time import time
from SCons.Script import COMMAND_LINE_TARGETS, DefaultEnvironment, Variables
from SCons.Script import (COMMAND_LINE_TARGETS, AllowSubstExceptions,
DefaultEnvironment, Progress, Variables)
from platformio import util
# AllowSubstExceptions()
AllowSubstExceptions(NameError)
# allow common variables from INI file
commonvars = Variables(None)
@ -65,7 +66,7 @@ commonvars.AddVariables(
DefaultEnvironment(
tools=[
"gcc", "g++", "as", "ar", "gnulink",
"ar", "as", "gcc", "g++", "gnulink",
"platformio", "devplatform",
"piolib", "piotest", "pioupload", "pioar", "piomisc"
],
@ -99,6 +100,9 @@ DefaultEnvironment(
env = DefaultEnvironment()
if env.GetOption("silent"):
Progress(env.ProgressHandler)
# decode common variables
for k in commonvars.keys():
if k in env:

View File

@ -264,6 +264,14 @@ def GetActualLDScript(env):
return None
def ProgressHandler(env, node):
item = str(node)
if "toolchain-" in item or item.endswith((".o", ".h", ".hpp", ".ipp")):
return
item = item.replace(env['PIOHOME_DIR'], ".platformio")
print "Processing %s" % item
def exists(_):
return True
@ -273,4 +281,5 @@ def generate(env):
env.AddMethod(DumpIDEData)
env.AddMethod(GetCompilerType)
env.AddMethod(GetActualLDScript)
env.AddMethod(ProgressHandler)
return env

View File

@ -205,13 +205,13 @@ def MatchSourceFiles(env, src_dir, src_filter=None):
return sorted(list(matches))
def VariantDirWrap(env, variant_dir, src_dir, duplicate=True):
def VariantDirWrap(env, variant_dir, src_dir, duplicate=None):
DefaultEnvironment().Append(VARIANT_DIRS=[(variant_dir, src_dir)])
env.VariantDir(variant_dir, src_dir, duplicate)
def CollectBuildFiles(env, variant_dir, src_dir,
src_filter=None, duplicate=True):
src_filter=None, duplicate=None):
sources = []
variants = []

View File

@ -58,7 +58,7 @@ def validate_path(ctx, param, value): # pylint: disable=W0613
@click.option("--project-conf",
type=click.Path(exists=True, file_okay=True, dir_okay=False,
readable=True, resolve_path=True))
@click.option("--verbose", "-v", count=True, default=3)
@click.option("--verbose", "-v", is_flag=True)
@click.pass_context
def cli(ctx, src, lib, exclude, board, # pylint: disable=R0913
build_dir, keep_build_dir, project_conf, verbose):

View File

@ -36,7 +36,7 @@ from platformio.managers.platform import PlatformFactory
@click.option("--project-dir", "-d", default=getcwd,
type=click.Path(exists=True, file_okay=False, dir_okay=True,
writable=True, resolve_path=True))
@click.option("--verbose", "-v", count=True, default=3)
@click.option("--verbose", "-v", is_flag=True)
@click.option("--disable-auto-clean", is_flag=True)
@click.pass_context
def cli(ctx, environment, target, upload_port, # pylint: disable=R0913,R0914
@ -111,7 +111,7 @@ class EnvironmentProcessor(object):
self.options = self._validate_options(options)
self.targets = targets
self.upload_port = upload_port
self.verbose_level = int(verbose)
self.verbose = verbose
def process(self):
terminal_width, _ = click.get_terminal_size()
@ -197,7 +197,7 @@ class EnvironmentProcessor(object):
cmd_platform_install, platforms=[self.options['platform']])
p = PlatformFactory.newPlatform(platform, version)
return p.run(build_vars, build_targets, self.verbose_level)
return p.run(build_vars, build_targets, self.verbose)
def _autoinstall_libs(ctx, libids_list):

View File

@ -35,7 +35,7 @@ from platformio.managers.platform import PlatformFactory
@click.option("--project-dir", "-d", default=getcwd,
type=click.Path(exists=True, file_okay=False, dir_okay=True,
writable=True, resolve_path=True))
@click.option("--verbose", "-v", count=True, default=3)
@click.option("--verbose", "-v", is_flag=True)
@click.pass_context
def cli(ctx, environment, skip, upload_port, project_dir, verbose):
assert check_project_envs(project_dir, environment)

View File

@ -23,7 +23,7 @@ from os.path import basename, dirname, isdir, isfile, join
import click
import semantic_version
from platformio import exception, util
from platformio import app, exception, util
from platformio.managers.package import BasePkgManager, PackageManager
PACKAGE_DIR = join(util.get_home_dir(), "packages")
@ -224,11 +224,10 @@ class PlatformRunMixin(object):
self.configure_default_packages(variables, targets)
self.install_packages(silent=True)
self._verbose_level = int(verbose)
self._verbose = verbose or app.get_setting("force_verbose")
if "clean" in targets:
targets.remove("clean")
targets.append("-c")
targets = ["-c", "."]
variables['platform_manifest'] = self.manifest_path
@ -237,14 +236,8 @@ class PlatformRunMixin(object):
if not isfile(variables['build_script']):
raise exception.BuildScriptNotFound(variables['build_script'])
self._found_error = False
result = self._run_scons(variables, targets)
assert "returncode" in result
# if self._found_error:
# result['returncode'] = 1
if self._last_echo_line == ".":
click.echo("")
return result
@ -266,7 +259,10 @@ class PlatformRunMixin(object):
"-j %d" % self.get_job_nums(),
"--warn=no-no-parallel-support",
"-f", join(util.get_source_dir(), "builder", "main.py")
] + targets
]
if not self._verbose and "-c" not in targets:
cmd.append("--silent")
cmd += targets
# encode and append variables
for key, value in variables.items():
@ -280,31 +276,19 @@ class PlatformRunMixin(object):
return result
def on_run_out(self, line):
self._echo_line(line, level=3)
self._echo_line(line, level=1)
def on_run_err(self, line):
is_error = self.LINE_ERROR_RE.search(line) is not None
if is_error:
self._found_error = True
self._echo_line(line, level=1 if is_error else 2)
self._echo_line(line, level=3 if is_error else 2)
def _echo_line(self, line, level):
@staticmethod
def _echo_line(line, level):
assert 1 <= level <= 3
fg = ("red", "yellow", None)[level - 1]
if level == 3 and "is up to date" in line:
fg = (None, "yellow", "red")[level - 1]
if level == 1 and "is up to date" in line:
fg = "green"
if level > self._verbose_level:
click.secho(".", fg=fg, err=level < 3, nl=False)
self._last_echo_line = "."
return
if self._last_echo_line == ".":
click.echo("")
self._last_echo_line = line
click.secho(line, fg=fg, err=level < 3)
click.secho(line, fg=fg, err=level > 1)
@staticmethod
def get_job_nums():
@ -326,13 +310,7 @@ class PlatformBase(PlatformPackagesMixin, PlatformRunMixin):
self.pm = PackageManager(
PACKAGE_DIR, self._manifest.get("packageRepositories"))
self._found_error = False
self._last_echo_line = None
# 1 = errors
# 2 = 1 + warnings
# 3 = 2 + others
self._verbose_level = 3
self._verbose = False
@property
def name(self):