Switch to new AddPlatformTarget API
Preparation for upcoming PIO Core 4.4
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
# Copyright 2014-present PlatformIO <contact@platformio.org>
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
from SCons.Script import AlwaysBuild, Import
|
||||||
|
|
||||||
|
|
||||||
|
Import("env")
|
||||||
|
|
||||||
|
|
||||||
|
# Added in PIO Core 4.4.0
|
||||||
|
if not hasattr(env, "AddPlatformTarget"):
|
||||||
|
|
||||||
|
def AddPlatformTarget(
|
||||||
|
env,
|
||||||
|
name,
|
||||||
|
dependencies,
|
||||||
|
actions,
|
||||||
|
title=None,
|
||||||
|
description=None,
|
||||||
|
always_build=True,
|
||||||
|
):
|
||||||
|
target = env.Alias(name, dependencies, actions)
|
||||||
|
if always_build:
|
||||||
|
AlwaysBuild(target)
|
||||||
|
return target
|
||||||
|
|
||||||
|
env.AddMethod(AddPlatformTarget)
|
||||||
+21
-11
@@ -128,6 +128,7 @@ def __fetch_spiffs_size(target, source, env):
|
|||||||
|
|
||||||
|
|
||||||
env = DefaultEnvironment()
|
env = DefaultEnvironment()
|
||||||
|
env.SConscript("compat.py", exports="env")
|
||||||
platform = env.PioPlatform()
|
platform = env.PioPlatform()
|
||||||
board = env.BoardConfig()
|
board = env.BoardConfig()
|
||||||
mcu = board.get("build.mcu", "esp32")
|
mcu = board.get("build.mcu", "esp32")
|
||||||
@@ -224,11 +225,11 @@ else:
|
|||||||
target_firm = env.DataToBin(
|
target_firm = env.DataToBin(
|
||||||
join("$BUILD_DIR", "${ESP32_SPIFFS_IMAGE_NAME}"), "$PROJECTDATA_DIR")
|
join("$BUILD_DIR", "${ESP32_SPIFFS_IMAGE_NAME}"), "$PROJECTDATA_DIR")
|
||||||
AlwaysBuild(target_firm)
|
AlwaysBuild(target_firm)
|
||||||
AlwaysBuild(env.Alias("buildfs", target_firm))
|
|
||||||
else:
|
else:
|
||||||
target_firm = env.ElfToBin(
|
target_firm = env.ElfToBin(
|
||||||
join("$BUILD_DIR", "${PROGNAME}"), target_elf)
|
join("$BUILD_DIR", "${PROGNAME}"), target_elf)
|
||||||
|
|
||||||
|
env.AddPlatformTarget("buildfs", target_firm, None, "Build Filesystem Image")
|
||||||
AlwaysBuild(env.Alias("nobuild", target_firm))
|
AlwaysBuild(env.Alias("nobuild", target_firm))
|
||||||
target_buildprog = env.Alias("buildprog", target_firm, target_firm)
|
target_buildprog = env.Alias("buildprog", target_firm, target_firm)
|
||||||
|
|
||||||
@@ -247,10 +248,13 @@ elif set(["checkprogsize", "upload"]) & set(COMMAND_LINE_TARGETS):
|
|||||||
# Target: Print binary size
|
# Target: Print binary size
|
||||||
#
|
#
|
||||||
|
|
||||||
target_size = env.Alias("size", target_elf,
|
target_size = env.AddPlatformTarget(
|
||||||
env.VerboseAction("$SIZEPRINTCMD",
|
"size",
|
||||||
"Calculating size $SOURCE"))
|
target_elf,
|
||||||
AlwaysBuild(target_size)
|
env.VerboseAction("$SIZEPRINTCMD", "Calculating size $SOURCE"),
|
||||||
|
"Program Size",
|
||||||
|
"Calculate program size",
|
||||||
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Upload firmware or SPIFFS image
|
# Target: Upload firmware or SPIFFS image
|
||||||
@@ -395,18 +399,24 @@ elif upload_protocol == "custom":
|
|||||||
else:
|
else:
|
||||||
sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol)
|
sys.stderr.write("Warning! Unknown upload protocol %s\n" % upload_protocol)
|
||||||
|
|
||||||
AlwaysBuild(env.Alias(["upload", "uploadfs"], target_firm, upload_actions))
|
env.AddPlatformTarget("upload", target_firm, upload_actions, "Upload")
|
||||||
|
env.AddPlatformTarget("uploadfs", target_firm, upload_actions, "Upload Filesystem Image")
|
||||||
|
env.AddPlatformTarget(
|
||||||
|
"uploadfsota", target_firm, upload_actions, "Upload Filesystem Image OTA")
|
||||||
|
|
||||||
#
|
#
|
||||||
# Target: Erase Flash
|
# Target: Erase Flash
|
||||||
#
|
#
|
||||||
|
|
||||||
AlwaysBuild(
|
env.AddPlatformTarget(
|
||||||
env.Alias("erase", None, [
|
"erase",
|
||||||
env.VerboseAction(env.AutodetectUploadPort,
|
None,
|
||||||
"Looking for serial port..."),
|
[
|
||||||
|
env.VerboseAction(env.AutodetectUploadPort, "Looking for serial port..."),
|
||||||
env.VerboseAction("$ERASECMD", "Erasing...")
|
env.VerboseAction("$ERASECMD", "Erasing...")
|
||||||
]))
|
],
|
||||||
|
"Erase Flash",
|
||||||
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Information about obsolete method of specifying linker scripts
|
# Information about obsolete method of specifying linker scripts
|
||||||
|
|||||||
Reference in New Issue
Block a user