mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Add "env.IsCleanTarget()" to the Build API
This commit is contained in:
@ -157,11 +157,6 @@ if env.subst("$BUILD_CACHE_DIR"):
|
|||||||
os.makedirs(env.subst("$BUILD_CACHE_DIR"))
|
os.makedirs(env.subst("$BUILD_CACHE_DIR"))
|
||||||
env.CacheDir("$BUILD_CACHE_DIR")
|
env.CacheDir("$BUILD_CACHE_DIR")
|
||||||
|
|
||||||
is_clean_all = "cleanall" in COMMAND_LINE_TARGETS
|
|
||||||
if env.GetOption("clean") or is_clean_all:
|
|
||||||
env.PioClean(is_clean_all)
|
|
||||||
env.Exit(0)
|
|
||||||
|
|
||||||
if not int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
if not int(ARGUMENTS.get("PIOVERBOSE", 0)):
|
||||||
click.echo("Verbose mode can be enabled via `-v, --verbose` option")
|
click.echo("Verbose mode can be enabled via `-v, --verbose` option")
|
||||||
|
|
||||||
@ -185,6 +180,10 @@ env.SConsignFile(
|
|||||||
for item in env.GetExtraScripts("pre"):
|
for item in env.GetExtraScripts("pre"):
|
||||||
env.SConscript(item, exports="env")
|
env.SConscript(item, exports="env")
|
||||||
|
|
||||||
|
if env.IsCleanTarget():
|
||||||
|
env.CleanProject("cleanall" in COMMAND_LINE_TARGETS)
|
||||||
|
env.Exit(0)
|
||||||
|
|
||||||
env.SConscript("$BUILD_SCRIPT")
|
env.SConscript("$BUILD_SCRIPT")
|
||||||
|
|
||||||
if "UPLOAD_FLAGS" in env:
|
if "UPLOAD_FLAGS" in env:
|
||||||
|
@ -16,6 +16,7 @@ import os
|
|||||||
|
|
||||||
from SCons.Action import Action # pylint: disable=import-error
|
from SCons.Action import Action # pylint: disable=import-error
|
||||||
from SCons.Script import ARGUMENTS # pylint: disable=import-error
|
from SCons.Script import ARGUMENTS # pylint: disable=import-error
|
||||||
|
from SCons.Script import COMMAND_LINE_TARGETS # pylint: disable=import-error
|
||||||
from SCons.Script import AlwaysBuild # pylint: disable=import-error
|
from SCons.Script import AlwaysBuild # pylint: disable=import-error
|
||||||
|
|
||||||
from platformio import compat, fs
|
from platformio import compat, fs
|
||||||
@ -27,7 +28,11 @@ def VerboseAction(_, act, actstr):
|
|||||||
return Action(act, actstr)
|
return Action(act, actstr)
|
||||||
|
|
||||||
|
|
||||||
def PioClean(env, clean_all=False):
|
def IsCleanTarget(env):
|
||||||
|
return env.GetOption("clean") or ("cleanall" in COMMAND_LINE_TARGETS)
|
||||||
|
|
||||||
|
|
||||||
|
def CleanProject(env, clean_all=False):
|
||||||
def _relpath(path):
|
def _relpath(path):
|
||||||
if compat.IS_WINDOWS:
|
if compat.IS_WINDOWS:
|
||||||
prefix = os.getcwd()[:2].lower()
|
prefix = os.getcwd()[:2].lower()
|
||||||
@ -103,7 +108,8 @@ def exists(_):
|
|||||||
|
|
||||||
def generate(env):
|
def generate(env):
|
||||||
env.AddMethod(VerboseAction)
|
env.AddMethod(VerboseAction)
|
||||||
env.AddMethod(PioClean)
|
env.AddMethod(IsCleanTarget)
|
||||||
|
env.AddMethod(CleanProject)
|
||||||
env.AddMethod(AddTarget)
|
env.AddMethod(AddTarget)
|
||||||
env.AddMethod(AddPlatformTarget)
|
env.AddMethod(AddPlatformTarget)
|
||||||
env.AddMethod(AddCustomTarget)
|
env.AddMethod(AddCustomTarget)
|
||||||
|
Reference in New Issue
Block a user