mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 18:44:27 +02:00
Improve "clean" target // Resolve #747
This commit is contained in:
@@ -94,7 +94,6 @@ DEFAULT_ENV_OPTIONS = dict(
|
|||||||
PYTHONEXE=util.get_pythonexe_path())
|
PYTHONEXE=util.get_pythonexe_path())
|
||||||
|
|
||||||
if not int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
if not int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
||||||
print "Verbose mode can be enabled via `-v, --verbose` option"
|
|
||||||
DEFAULT_ENV_OPTIONS['ARCOMSTR'] = "Archiving $TARGET"
|
DEFAULT_ENV_OPTIONS['ARCOMSTR'] = "Archiving $TARGET"
|
||||||
DEFAULT_ENV_OPTIONS['LINKCOMSTR'] = "Linking $TARGET"
|
DEFAULT_ENV_OPTIONS['LINKCOMSTR'] = "Linking $TARGET"
|
||||||
DEFAULT_ENV_OPTIONS['RANLIBCOMSTR'] = "Indexing $TARGET"
|
DEFAULT_ENV_OPTIONS['RANLIBCOMSTR'] = "Indexing $TARGET"
|
||||||
@@ -108,6 +107,12 @@ for k in commonvars.keys():
|
|||||||
if k in env:
|
if k in env:
|
||||||
env[k] = base64.b64decode(env[k])
|
env[k] = base64.b64decode(env[k])
|
||||||
|
|
||||||
|
if env.GetOption('clean'):
|
||||||
|
env.PioClean(env.subst("$BUILD_DIR"))
|
||||||
|
env.Exit(0)
|
||||||
|
elif not int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
||||||
|
print "Verbose mode can be enabled via `-v, --verbose` option"
|
||||||
|
|
||||||
# Handle custom variables from system environment
|
# Handle custom variables from system environment
|
||||||
for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPT",
|
for var in ("BUILD_FLAGS", "SRC_BUILD_FLAGS", "SRC_FILTER", "EXTRA_SCRIPT",
|
||||||
"UPLOAD_PORT", "UPLOAD_FLAGS", "LIB_EXTRA_DIRS"):
|
"UPLOAD_PORT", "UPLOAD_FLAGS", "LIB_EXTRA_DIRS"):
|
||||||
@@ -138,8 +143,8 @@ if env.get("EXTRA_SCRIPT"):
|
|||||||
|
|
||||||
if "envdump" in COMMAND_LINE_TARGETS:
|
if "envdump" in COMMAND_LINE_TARGETS:
|
||||||
print env.Dump()
|
print env.Dump()
|
||||||
env.Exit()
|
env.Exit(0)
|
||||||
|
|
||||||
if "idedata" in COMMAND_LINE_TARGETS:
|
if "idedata" in COMMAND_LINE_TARGETS:
|
||||||
print json.dumps(env.DumpIDEData())
|
print json.dumps(env.DumpIDEData())
|
||||||
env.Exit()
|
env.Exit(0)
|
||||||
|
@@ -18,8 +18,8 @@ import atexit
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from os import environ, remove
|
from os import environ, remove, walk
|
||||||
from os.path import basename, isfile, join
|
from os.path import basename, isdir, isfile, join, relpath
|
||||||
from tempfile import mkstemp
|
from tempfile import mkstemp
|
||||||
|
|
||||||
from SCons.Action import Action
|
from SCons.Action import Action
|
||||||
@@ -317,6 +317,19 @@ def VerboseAction(_, act, actstr):
|
|||||||
return Action(act, actstr)
|
return Action(act, actstr)
|
||||||
|
|
||||||
|
|
||||||
|
def PioClean(env, clean_dir):
|
||||||
|
if not isdir(clean_dir):
|
||||||
|
print "Build environment is clean"
|
||||||
|
env.Exit(0)
|
||||||
|
for root, _, files in walk(clean_dir):
|
||||||
|
for file_ in files:
|
||||||
|
remove(join(root, file_))
|
||||||
|
print "Removed %s" % relpath(join(root, file_))
|
||||||
|
print "Done cleaning"
|
||||||
|
util.rmtree_(clean_dir)
|
||||||
|
env.Exit(0)
|
||||||
|
|
||||||
|
|
||||||
def exists(_):
|
def exists(_):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -327,4 +340,5 @@ def generate(env):
|
|||||||
env.AddMethod(GetCompilerType)
|
env.AddMethod(GetCompilerType)
|
||||||
env.AddMethod(GetActualLDScript)
|
env.AddMethod(GetActualLDScript)
|
||||||
env.AddMethod(VerboseAction)
|
env.AddMethod(VerboseAction)
|
||||||
|
env.AddMethod(PioClean)
|
||||||
return env
|
return env
|
||||||
|
@@ -279,6 +279,8 @@ class PlatformRunMixin(object):
|
|||||||
self._echo_line(line, level=3 if is_error else 2)
|
self._echo_line(line, level=3 if is_error else 2)
|
||||||
|
|
||||||
def _echo_line(self, line, level):
|
def _echo_line(self, line, level):
|
||||||
|
if line.startswith("scons: "):
|
||||||
|
line = line[7:]
|
||||||
assert 1 <= level <= 3
|
assert 1 <= level <= 3
|
||||||
if self.silent and (level < 2 or not line):
|
if self.silent and (level < 2 or not line):
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user