本文整理汇总了Python中SCons.Script.DefaultEnvironment.subst方法的典型用法代码示例。如果您正苦于以下问题:Python DefaultEnvironment.subst方法的具体用法?Python DefaultEnvironment.subst怎么用?Python DefaultEnvironment.subst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SCons.Script.DefaultEnvironment
的用法示例。
在下文中一共展示了DefaultEnvironment.subst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _FindPackagePath
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
def _FindPackagePath(env, optvar, globspec, defaultpath=None):
"""Check for a package installation path matching globspec."""
options = es_vars.GlobalVariables()
pdir = defaultpath
try:
pdir = os.environ[optvar]
except KeyError:
if not env:
env = DefaultEnvironment()
options.Update(env)
dirs = glob.glob(env.subst(globspec))
dirs.sort()
dirs.reverse()
for d in dirs:
if os.path.isdir(d):
pdir = d
break
return pdir
示例2: DefaultEnvironment
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
if upload_options.get("use_1200bps_touch", False):
env.TouchSerialPort("$UPLOAD_PORT", 1200)
if upload_options.get("wait_for_upload_port", False):
env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports))
# use only port name for BOSSA
if ("/" in env.subst("$UPLOAD_PORT") and
env.subst("$UPLOAD_PROTOCOL") == "sam-ba"):
env.Replace(UPLOAD_PORT=basename(env.subst("$UPLOAD_PORT")))
env = DefaultEnvironment()
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
BOARD_OPTIONS = env.get("BOARD_OPTIONS", {})
env.Append(
CCFLAGS=[
"--param", "max-inline-insns-single=500",
"-MMD"
],
CFLAGS=[
"-std=gnu11"
],
示例3: import
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
# 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.
"""
Builder for Nordic nRF51 series ARM microcontrollers.
"""
from os.path import join
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
DefaultEnvironment, SConscript)
env = DefaultEnvironment()
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
if env.subst("$BOARD") == "rfduino":
env.Append(
CCFLAGS=["-fno-builtin"],
LINKFLAGS=["--specs=nano.specs"]
)
env.Replace(
UPLOADER=join("$PIOPACKAGES_DIR", "tool-rfdloader", "rfdloader"),
UPLOADERFLAGS=["-q", '"$UPLOAD_PORT"'],
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS $SOURCES'
)
#
# Target: Build executable and linkable firmware
#
示例4: join
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
CPPDEFINES=["LM4F"]
)
env.VariantDirWrap(
join("$BUILD_DIR", "FrameworkLibOpenCM3Variant"),
join("$PLATFORMFW_DIR", "include")
)
env.Append(
CPPPATH=[
join("$BUILD_DIR", "FrameworkLibOpenCM3"),
join("$BUILD_DIR", "FrameworkLibOpenCM3Variant")
]
)
root_dir = env.subst(
join("$PLATFORMFW_DIR", "lib", BOARD_BUILDOPTS.get("core")))
if BOARD_BUILDOPTS.get("core") == "stm32":
root_dir = join(root_dir, BOARD_BUILDOPTS.get("variant")[-2:])
ldscript_path = find_ldscript(root_dir)
merge_ld_scripts(ldscript_path)
generate_nvic_files()
# override ldscript by libopencm3
assert "LDSCRIPT_PATH" in env
env.Replace(
LDSCRIPT_PATH=ldscript_path
)
libs = []
env.VariantDirWrap(
示例5: import
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
Build script for lattice ice40 FPGAs
latticeice40-builder.py
"""
import os
from os.path import join
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
DefaultEnvironment, Environment, Exit, GetOption,
Glob)
env = DefaultEnvironment()
env.Replace(PROGNAME="hardware")
env.Append(SIMULNAME="simulation")
# -- Get the local folder in which the icestorm tools should be installed
piopackages_dir = env.subst('$PIOPACKAGES_DIR')
bin_dir = join(piopackages_dir, 'toolchain-icestorm', 'bin')
# -- Add this path to the PATH env variable. First the building tools will be
# -- searched in the local PATH. If they are not founde, the global ones will
# -- be executed (if installed)
env.PrependENVPath('PATH', bin_dir)
# -- Target name for synthesis
TARGET = join(env['BUILD_DIR'], env['PROGNAME'])
# -- Target name for simulation
# TARGET_SIM = join(env['PROJECT_DIR'], env['SIMULNAME'])
# -- Get a list of all the verilog files in the src folfer, in ASCII, with
# -- the full path. All these files are used for the simulation
示例6: import
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
from shutil import copyfile
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
DefaultEnvironment, SConscript)
def UploadToDisk(target, source, env): # pylint: disable=W0613,W0621
env.AutodetectUploadPort()
copyfile(join(env.subst("$BUILD_DIR"), "firmware.bin"),
join(env.subst("$UPLOAD_PORT"), "firmware.bin"))
print ("Firmware has been successfully uploaded.\n"
"Please restart your board.")
env = DefaultEnvironment()
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
#
# Target: Build executable and linkable firmware
#
target_elf = env.BuildFirmware()
#
# Target: Build the .bin file
#
if "uploadlazy" in COMMAND_LINE_TARGETS:
target_firm = join("$BUILD_DIR", "firmware.bin")
else:
target_firm = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf)
示例7: join
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
BUILDSRC_DIR=join("$BUILD_DIR", "src"),
LIBSOURCE_DIRS=[
"$PROJECTLIB_DIR",
util.get_lib_dir(),
join("$PLATFORMFW_DIR", "libraries")
],
PYTHONEXE=normpath(sys.executable)
)
env = DefaultEnvironment()
env.Prepend(LIBPATH=[join("$PIOPACKAGES_DIR", "ldscripts")])
if "BOARD" in env:
try:
env.Replace(BOARD_OPTIONS=util.get_boards(env.subst("$BOARD")))
except UnknownBoard as e:
env.Exit("Error: %s" % str(e))
for k in commonvars.keys():
if (k in env or
not any([k.startswith("BOARD_"), k.startswith("UPLOAD_")])):
continue
_opt, _val = k.lower().split("_", 1)
if _opt == "board":
_opt = "build"
if _val in env['BOARD_OPTIONS'][_opt]:
env.Replace(**{k: "${BOARD_OPTIONS['%s']['%s']}" % (_opt, _val)})
if "ldscript" in env.get("BOARD_OPTIONS", {}).get("build", {}):
env.Replace(
示例8: join
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
env.Replace(
PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-spl")
)
env.VariantDirWrap(
join("$BUILD_DIR", "FrameworkCMSIS"),
join("$PLATFORMFW_DIR", "${BOARD_OPTIONS['build']['core']}",
"cmsis", "cores", "${BOARD_OPTIONS['build']['core']}")
)
env.VariantDirWrap(
join("$BUILD_DIR", "FrameworkSPLInc"),
join(
"$PLATFORMFW_DIR", "${BOARD_OPTIONS['build']['core']}", "spl",
"variants", env.subst("${BOARD_OPTIONS['build']['variant']}")[0:7],
"inc"
)
)
env.Append(
CPPPATH=[
join("$BUILD_DIR", "FrameworkCMSIS"),
join("$BUILD_DIR", "FrameworkCMSISVariant"),
join("$BUILD_DIR", "FrameworkSPLInc"),
join("$BUILD_DIR", "FrameworkSPL")
]
)
envsafe = env.Clone()
示例9: in
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
"ihex",
"-R",
".eeprom",
"$SOURCES",
"$TARGET"
]), "Building $TARGET"),
suffix=".hex"
)
)
)
# Allow user to override via pre:script
if env.get("PROGNAME", "program") == "program":
env.Replace(PROGNAME="firmware")
if env.subst("$UPLOAD_PROTOCOL") in ("digispark", "micronucleus"):
env.Replace(
UPLOADER="micronucleus",
UPLOADERFLAGS=[
"-c", "$UPLOAD_PROTOCOL",
"--timeout", "60"
],
UPLOADHEXCMD='$UPLOADER $UPLOADERFLAGS $SOURCES',
PROGRAMHEXCMD="$UPLOADHEXCMD"
)
else:
env.Replace(
UPLOADER="avrdude",
UPLOADERFLAGS=[
"-p", "$BOARD_MCU",
示例10:
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
"ihex",
"-R",
".eeprom",
"$SOURCES",
"$TARGET"
]), "Building $TARGET"),
suffix=".hex"
)
)
)
# Allow user to override via pre:script
if env.get("PROGNAME", "program") == "program":
env.Replace(PROGNAME="firmware")
if env.subst("$UPLOAD_PROTOCOL") == "micronucleus":
env.Replace(
UPLOADER="micronucleus",
UPLOADERFLAGS=[
"-c", "$UPLOAD_PROTOCOL",
"--timeout", "60"
],
UPLOADHEXCMD='$UPLOADER $UPLOADERFLAGS $SOURCES',
PROGRAMHEXCMD="$UPLOADHEXCMD"
)
else:
env.Replace(
UPLOADER="avrdude",
UPLOADERFLAGS=[
"-p", "$BOARD_MCU",
示例11: Copyright
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
# Copyright (C) Ivan Kravets <[email protected]>
# See LICENSE for details.
"""
Builder for ST STM32 Series ARM microcontrollers.
"""
import platform
from os.path import join
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Default,
DefaultEnvironment, SConscript)
env = DefaultEnvironment()
SConscript(env.subst(join("$PIOBUILDER_DIR", "scripts", "basearm.py")))
env.Replace(
UPLOADER=join("$PIOPACKAGES_DIR", "tool-stlink", "st-flash"),
UPLOADERFLAGS=[
"write", # write in flash
"$SOURCES", # firmware path to flash
"0x08000000" # flash start adress
],
UPLOADCMD="$UPLOADER $UPLOADERFLAGS"
)
env.Append(
CPPDEFINES=[
示例12: join
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
"-T", "esp32.peripherals.ld"
],
UPLOADERFLAGS=[
"0x1000", join("$BUILD_DIR", "bootloader.bin"),
"0x8000", join("$BUILD_DIR", "partitions_table.bin"),
"0x10000"
]
)
#
# Handle missing sdkconfig.h
#
if not isfile(join(env.subst("$PROJECTSRC_DIR"), "sdkconfig.h")):
search_path = join(
env.subst("$PIOHOME_DIR"), "platforms",
env.subst("$PIOPLATFORM"), "examples", "*", "src", "sdkconfig.h"
)
files = glob(search_path)
if not files:
sys.stderr.write(
"Error: \"sdkconfig.h\" file is required for esp-idf framework!\n")
env.Exit(1)
print("Warning! Cannot find \"sdk_config.h\" file. "
"Default \"sdk_config.h\" will be added to your project!")
copy(files[0], join(env.subst("$PROJECTSRC_DIR"), "sdkconfig.h"))
示例13: in
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
suffix=".bin"
)
)
)
if "uploadfs" in COMMAND_LINE_TARGETS:
env.Append(
UPLOADERFLAGS=["-ca", "$SPIFFS_START"],
UPLOADEROTAFLAGS=["-s"]
)
#
# Framework and SDK specific configuration
#
if env.subst("$PIOFRAMEWORK") in ("arduino", "simba"):
env.Append(
BUILDERS=dict(
ElfToBin=Builder(
action=env.VerboseAction(" ".join([
'"$OBJCOPY"',
"-eo",
'"%s"' % join("$FRAMEWORK_ARDUINOESP8266_DIR",
"bootloaders", "eboot", "eboot.elf"),
"-bo", "$TARGET",
"-bm", "$BOARD_FLASH_MODE",
"-bf", "${__get_board_f_flash(__env__)}",
"-bz", "${__get_flash_size(__env__)}",
"-bs", ".text",
"-bp", "4096",
"-ec",
示例14: join
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
CPPPATH=[
join("$BUILD_DIR", "FrameworkCMSIS"),
join("$BUILD_DIR", "FrameworkCMSISCommon"),
join("$BUILD_DIR", "FrameworkCMSISVariant"),
]
)
envsafe = env.Clone()
#
# Target: Build Core Library
#
# use mbed ldscript with bootloader section
ldscript = env.get("BOARD_OPTIONS", {}).get("build", {}).get("ldscript")
if not isfile(join(env.subst("$PIOPACKAGES_DIR"), "ldscripts", ldscript)):
if "mbed" in env.get("BOARD_OPTIONS", {}).get("frameworks", {}):
env.Append(
LINKFLAGS=[
'-Wl,-T"%s"'
% join(
"$PIOPACKAGES_DIR",
"framework-mbed",
"variant",
env.subst("$BOARD").upper(),
"mbed",
"TARGET_%s" % env.subst("$BOARD").upper(),
"TOOLCHAIN_GCC_ARM",
"%s.ld" % ldscript.upper()[:-3],
)
]
示例15: join
# 需要导入模块: from SCons.Script import DefaultEnvironment [as 别名]
# 或者: from SCons.Script.DefaultEnvironment import subst [as 别名]
join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers",
MCU_FAMILY.upper() + "xx_HAL_Driver", "Inc"),
join(FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers",
"BSP", "Components", "Common")
],
LIBPATH=[
join(FRAMEWORK_DIR, FRAMEWORK_CORE,
"Drivers", "CMSIS", "Lib", "GCC"),
join(FRAMEWORK_DIR, "platformio", "ldscripts")
]
)
variants_remap = util.load_json(
join(FRAMEWORK_DIR, "platformio", "variants_remap.json"))
board_type = env.subst("$BOARD")
variant = variants_remap[
board_type] if board_type in variants_remap else board_type.upper()
#
# Generate framework specific files
#
generate_hal_config_file(env.BoardConfig().get("build.mcu"))
#
# Process BSP components
#
components_dir = join(
FRAMEWORK_DIR, FRAMEWORK_CORE, "Drivers", "BSP", "Components")