def generate(env): """Called when the tool is loaded into the environment at startup of script""" assert(exists(env)) # Set-up ms tools paths msvc_setup_env_once(env) env.SetDefault( # Location of the dumpbin executable DUMPBIN = 'dumpbin', ) # Register the builder bld = Builder(action = __Dll2Lib_func, emitter = __Dll2Lib_emitter) env.Append(BUILDERS = {'Dll2Lib' : bld})
def profile(self): # print "calling profile",self if self._built: # print "has been built" return action = Action(self.build, "Profile '%s' [%s]" % (self.act.__name__, self.name)) builder = Builder(action=action, emitter=self.emitter, suffix='.hotshot') builder(self.env, self.name) self._built = True
def CreateSLIMpyBuilder(name, act, file_name=None, str_func=None, emitters=None, depends_on=None): ''' ??? ''' if str_func is None: str_func = default_str_closure(name) pm_act = post_mortem_closure(act) slimpy_action = Action(pm_act, str_func) if file_name is None: mod = sys.modules[act.__module__] file_name = mod.__file__ if depends_on is None: depends_on = [] if hasattr(act, "__additional_dependancies__"): additional_deps = getattr(act, "__additional_dependancies__") depends_on.extend(additional_deps) slim_emitters = [ rsf_binary_emitter, logfile_emitter, slimpy_variable_emitter, slimpy_file(file_name), additional_parameters(depends_on), profile_emitter_wrapper(act), dottest_emitter_wrapper(act), help_emitter ] add_function_emitter(act, slim_emitters) if emitters is None: emitters = [] slim_emitters.extend(emitters) slimpy_builder = Builder(action=slimpy_action, emitter=slim_emitters, suffix='.rsf', src_suffix='.rsf') return slimpy_builder
def dev_init(env, platform): dev_create_template(env, ["baremetal.c", "app_manifest.json"]) dev_initialize(env, True) env.Append( CPPDEFINES=[], CPPPATH=[ join(env.framework_dir, "Sysroots", env.sysroot, "usr", "include"), join("$PROJECT_DIR", "lib"), join("$PROJECT_DIR", "include") ], CFLAGS=[ "-O0", "-fno-omit-frame-pointer", "-fno-strict-aliasing", "-Wall", "-fno-exceptions", ], CXXFLAGS=[ "-O0", "-fno-rtti", "-fno-exceptions", "-fno-non-call-exceptions", "-fno-use-cxa-atexit", "-fno-threadsafe-statics", ], CCFLAGS=[env.cortex], LINKFLAGS=[ env.cortex, "-nostartfiles", "-Wl,--no-undefined", "-Wl,-n", ], LDSCRIPT_PATH=join(env.framework_dir, "Hardwares", "linker.ld"), #LIBPATH = [], LIBSOURCE_DIRS=[ join(env.framework_dir, platform, "libraries"), ], # userware LIBS=["gcc"], BUILDERS=dict(PackImage=Builder( action=env.VerboseAction(dev_image_pack, " "), suffix=".bin")), UPLOADCMD=dev_image_upload) libs = [] libs.append( env.BuildLibrary( join("$BUILD_DIR", "_custom"), join("$PROJECT_DIR", "lib"), )) env.Append(LIBS=libs)
def generate(env): ''' SymLink(link_name,source) env.SymLink(link_name,source) Makes a symbolic link named "link_name" that points to the real file or directory "source". The link produced is always relative. ''' bldr = Builder(action=Action(symlink_builder, symlink_print), target_factory=FS.File, source_factory=FS.Entry, single_target=True, single_source=True, emitter=symlink_emitter) env.Append(BUILDERS={'SymLink': bldr})
def generate(env): """Called when the tool is loaded into the environment at startup of script""" assert(exists(env)) DoxygenCommon.setup_opts(env) doxyfile_scanner = env.Scanner( DoxygenCommon.DoxySourceScan, "DoxySourceScan", scan_check=DoxygenCommon.DoxySourceScanCheck, ) bld = Builder( action = __Doxygen_func, emitter = DoxygenCommon.DoxyEmitter, target_factory=env.fs.Entry, source_scanner=doxyfile_scanner ) env.Append(BUILDERS = {'Doxygen' : bld})
def generate(env): """ Add builders and construction variables for the DistTar builder. """ disttar_action=SCons.Action.Action(disttar, disttar_string) env['BUILDERS']['DistTar'] = Builder( action=disttar_action , emitter=disttar_emitter , suffix = disttar_suffix , target_factory = env.fs.Entry ) env.AppendUnique( DISTTAR_FORMAT = 'gz' )
def addTemplateBuilder(env): def filterKeys(keys, env): if not ('TEMPLATE_ENV_FILTER' in env): return keys filters = env['TEMPLATE_ENV_FILTER'] matched = [] for filter in filters: for name in keys: if fnmatch.fnmatch(name, filter): matched.append(name) return list(dict.fromkeys(matched)) def buildEmitter(target, source, env): dict = env.Dictionary() keys = filterKeys(dict.keys(), env) for key in keys: if isinstance(dict[key], str): env.Depends(target, env.Value(dict[key])) return target, source def buildFile(target, source, env): source_dest = str(target[0]) wfile = open(source_dest, 'w', encoding='utf-8') dict = env.Dictionary() keys = filterKeys(dict.keys(), env) if len(source) == 0: data = env['TEMPLATE_SOURCE'] else: data = open(source[0].srcnode().get_path(), 'r').read() for key in keys: if isinstance(dict[key], str): data = re.sub('@' + key + '@', dict[key], data) wfile.write(data) wfile.close() return 0 def buildString(target, source, env): return 'Preparing file %s' % os.path.basename(str(target[0])) env.Append( BUILDERS={ 'Template': Builder( action=Action(buildFile, buildString), emitter=buildEmitter, ), })
def ADD_BUILDERS(env): build_yoda_from_hepmc = Builder( action='rivet --quiet --pwd -H $TARGET -a $ANALYSIS $SOURCES', suffix='.yoda', src_suffix='.hepmc') build_analysis = Builder(action='rivet-buildplugin $SOURCES', suffix='.so', src_suffix='.cc') merge_yodas = Builder( action='yodamerge --assume-normalized -o $TARGET $SOURCES', suffix='.yoda', src_suffix='.yoda') merge_yodas_noscale = Builder( action='./yodamerge_noscale --assume-normalized -o $TARGET $SOURCES', suffix='.yoda', src_suffix='.yoda') build_envelope = Builder( action='./yodaenvelopes -o $TARGET -c $SOURCE $SOURCES', suffix='.yoda', src_suffix='.yoda') build_plot_with_lo_line_and_nlo_band = \ Builder(generator=generate_plot_with_lo_line_and_nlo_band, suffix='.html', src_suffix='.yoda') build_plot = Builder(generator=generate_plot, suffix='.html', src_suffix='.yoda') env.Append( BUILDERS={ 'Yoda': build_yoda_from_hepmc, 'Analysis': build_analysis, 'MergeYodas': merge_yodas, 'MergeYodasNoScale': merge_yodas_noscale, 'BuildEnvelope': build_envelope, 'Plot': build_plot, 'PlotLOLineWithNLOBand': build_plot_with_lo_line_and_nlo_band })
def addResourceTemplateBuilder(env): def buildResourceFile(target, source, env): source_dest = SCons.Util.splitext(str(target[0]))[0] + ".rc" wfile = open(source_dest, "w") data = open(str(File(source[0]).srcnode())).read() for key, var in env['RESOURCE_TEMPLATE_VARS'].iteritems(): data = re.sub("%" + key + "%", var, data) wfile.write(data) wfile.close() return 0 def buildResourceFileString(target, source, env): return "Preparing resource file %s" % os.path.basename(str(target[0])) env.Append( BUILDERS={ 'ResourceTemplate': Builder( action=Action(buildResourceFile, buildResourceFileString), suffix='.rc', src_suffix='.rct', ), })
def generate(env): env.Tool('python') env.SetDefault(CYTHONPATH=[]) env['BUILDERS']['Cython'] = Builder( action=Action( cython_build_action, strfunction=cython_build_strfunction, ), suffix='.cpp', src_suffix='.pyx', ) scanner = env.Scanner( function=cython_scan, skeys=['.pyx', '.pyd', '.pyi'], path_function=lambda *args: (FindPathDirs('PYTHONPATH')(*args) + FindPathDirs('CYTHONPATH') (*args)), recursive=True, ) env.Append(SCANNERS=scanner)
UPLOADER=join("$PLATFORMTOOLS_DIR", "mspdebug", "mspdebug"), UPLOADERFLAGS=[ "$UPLOAD_PROTOCOL" if system() != "Windows" else "tilib", "--force-reset" ], UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"' ) env.Append( BUILDERS=dict( ElfToHex=Builder( action=" ".join([ "$OBJCOPY", "-O", "ihex", "-R", ".eeprom", "$SOURCES", "$TARGET"]), suffix=".hex" ) ) ) CORELIBS = env.ProcessGeneral() # # Target: Build executable and linkable firmware # target_elf = env.BuildFirmware(CORELIBS + ["m"])
SIZEPRINTCMD='$SIZETOOL -d $SOURCES', PROGSUFFIX=".elf" ) # Allow user to override via pre:script if env.get("PROGNAME", "program") == "program": env.Replace(PROGNAME="firmware") env.Append( BUILDERS=dict( ElfToHex=Builder( action=env.VerboseAction(" ".join([ "$OBJCOPY", "-O", "ihex", "$SOURCES", "$TARGET" ]), "Building $TARGET"), suffix=".hex" ) ) ) pioframework = env.get("PIOFRAMEWORK", []) if not pioframework: env.SConscript("frameworks/_bare.py", exports="env") # # Target: Build executable and linkable firmware #
SIZEPRINTCMD='$SIZETOOL -B -d $SOURCES', PROGSUFFIX=".elf" ) # Allow user to override via pre:script if env.get("PROGNAME", "program") == "program": env.Replace(PROGNAME="firmware") env.Append( BUILDERS=dict( ElfToBin=Builder( action=env.VerboseAction(" ".join([ "$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET" ]), "Building $TARGET"), suffix=".bin" ), ElfToHex=Builder( action=env.VerboseAction(" ".join([ "$OBJCOPY", "-O", "ihex", "-R", ".eeprom", "$SOURCES", "$TARGET" ]), "Building $TARGET"), suffix=".hex"
"-std=gnu++11" ], CPPDEFINES=[("F_CPU", "$BOARD_F_CPU")], LINKFLAGS=[ "-Os", "-mmcu=$BOARD_MCU", "-Wl,--gc-sections", "-flto", "-fuse-linker-plugin" ], LIBS=["m"], SIZEPRINTCMD='$SIZETOOL --mcu=$BOARD_MCU -C -d $SOURCES', PROGSUFFIX=".elf") env.Append(ASFLAGS=env.get("CCFLAGS", [])[:], BUILDERS=dict(ElfToEep=Builder(action=env.VerboseAction( " ".join([ "$OBJCOPY", "-O", "ihex", "-j", ".eeprom", '--set-section-flags=.eeprom="alloc,load"', "--no-change-warnings", "--change-section-lma", ".eeprom=0", "$SOURCES", "$TARGET" ]), "Building $TARGET"), suffix=".eep"), ElfToHex=Builder(action=env.VerboseAction( " ".join([ "$OBJCOPY", "-O", "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"):
"-DSERIAL_USB", "-DDGENERIC_BOOTLOADER", "-DVECT_TAB_ADDR=0x8002000" ]) # new upload protocol added to support maple compatible Olimexino STM32 board # address has been obtained from a working configuration of Arduino IDE elif env.subst("$UPLOAD_PROTOCOL") == "maple_dfu": env.Append(CCFLAGS=["-DSERIAL_USB", "-DVECT_TAB_ADDR=0x8005000"]) else: env.Append(CCFLAGS=["-DVECT_TAB_ADDR=0x8000000"]) if "BOARD" in env: env.Append(CCFLAGS=["-mcpu=%s" % env.BoardConfig().get("build.cpu")], LINKFLAGS=["-mcpu=%s" % env.BoardConfig().get("build.cpu")]) env.Append(ASFLAGS=env.get("CCFLAGS", [])[:], BUILDERS=dict(ElfToBin=Builder(action=" ".join( ["$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET"]), suffix=".bin"), ElfToHex=Builder(action=" ".join([ "$OBJCOPY", "-O", "ihex", "-R", ".eeprom", "$SOURCES", "$TARGET" ]), suffix=".hex"))) uploadPlatform = "none" uploadProtocol = "serial_upload" uploadParams = "{upload.altID} {upload.usbID} $PROJECT_DIR/$SOURCES" from sys import platform as _platform if _platform == "linux" or _platform == "linux2": uploadPlatform = "linux" elif _platform == "darwin":
ESP32_APP_OFFSET="0x10000", PROGSUFFIX=".elf") # Allow user to override via pre:script if env.get("PROGNAME", "program") == "program": env.Replace(PROGNAME="firmware") env.Append( # copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode) ASFLAGS=env.get("CCFLAGS", [])[:], BUILDERS=dict( ElfToBin=Builder(action=env.VerboseAction( " ".join([ '"$PYTHONEXE" "$OBJCOPY"', "--chip", mcu, "elf2image", "--flash_mode", "$BOARD_FLASH_MODE", "--flash_freq", "${__get_board_f_flash(__env__)}", "--flash_size", board.get("upload.flash_size", "detect"), "-o", "$TARGET", "$SOURCES" ]), "Building $TARGET"), suffix=".bin"), DataToBin=Builder(action=env.VerboseAction( " ".join([ '"$MKSPIFFSTOOL"', "-c", "$SOURCES", "-p", "$SPIFFS_PAGE", "-b", "$SPIFFS_BLOCK", "-s", "$SPIFFS_SIZE", "$TARGET" ]), "Building SPIFFS image from '$SOURCES' directory to $TARGET"), emitter=__fetch_spiffs_size, source_factory=env.Dir, suffix=".bin"))) if not env.get("PIOFRAMEWORK"): env.SConscript("frameworks/_bare.py", exports="env")
"stdc++", "m", "c", "gcc" ], LIBSOURCE_DIRS=[ join(FRAMEWORK_DIR, "libraries") ], BUILDERS=dict( ElfToBin=Builder( action=env.VerboseAction(" ".join([ '"$PYTHONEXE"', '"%s"' % join(FRAMEWORK_DIR, "tools", "elf2bin.py"), "--eboot", '"%s"' % join( FRAMEWORK_DIR, "bootloaders", "eboot", "eboot.elf"), "--app", "$SOURCE", "--flash_mode", "$BOARD_FLASH_MODE", "--flash_freq", "${__get_board_f_flash(__env__)}", "--flash_size", "${__get_flash_size(__env__)}", "--path", '"%s"' % join( platform.get_package_dir("toolchain-xtensa"), "bin"), "--out", "$TARGET" ]), "Building $TARGET"), suffix=".bin" ) ) ) # copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode) env.Append(ASFLAGS=env.get("CCFLAGS", [])[:]) flatten_cppdefines = env.Flatten(env['CPPDEFINES'])
SIZEPRINTCMD='$SIZETOOL -B -d $SOURCES', PROGNAME="firmware", PROGSUFFIX=".elf") # Clone actual CCFLAGS to ASFLAGS env.Append(ASFLAGS=env.get("CCFLAGS", [])[:]) # # Framework and SDK specific configuration # env.Append(BUILDERS=dict(ElfToBin=Builder(action=env.VerboseAction( " ".join([ '"$PYTHONEXE" "$OBJCOPY"', "--chip", "esp32", "elf2image", "--flash_mode", "$BOARD_FLASH_MODE", "--flash_freq", "${__get_board_f_flash(__env__)}", "--flash_size", env.BoardConfig().get("upload.flash_size", "4MB"), "-o", "$TARGET", "$SOURCES" ]), "Building $TARGET"), suffix=".bin"))) if env.subst("$PIOFRAMEWORK") == "arduino": # Handle uploading via OTA ota_port = None if env.get("UPLOAD_PORT"): ota_port = re.match( r"\"?((([0-9]{1,3}\.){3}[0-9]{1,3})|.+\.local)\"?$", env.get("UPLOAD_PORT")) if ota_port: env.Replace(UPLOADCMD="$UPLOADOTACMD")
join(FRAMEWORK_DIR, "include", "ssl"), join(FRAMEWORK_DIR, "include", "json"), join(FRAMEWORK_DIR, "include", "openssl"), ], LIBPATH=[join(FRAMEWORK_DIR, "lib"), join(FRAMEWORK_DIR, "ld")], LIBS=[ "cirom", "crypto", "driver", "espconn", "espnow", "freertos", "gcc", "json", "hal", "lwip", "main", "mesh", "mirom", "net80211", "nopoll", "phy", "pp", "pwm", "smartconfig", "spiffs", "ssl", "wpa", "wps" ], BUILDERS=dict(ElfToBin=Builder(action=env.VerboseAction( " ".join([ '"%s"' % join(platform.get_package_dir("tool-esptool"), "esptool"), "-eo", "$SOURCE", "-bo", "${TARGET}", "-bm", "$BOARD_FLASH_MODE", "-bf", "${__get_board_f_flash(__env__)}", "-bz", "${__get_flash_size(__env__)}", "-bs", ".text", "-bs", ".data", "-bs", ".rodata", "-bc", "-ec", "-eo", "$SOURCE", "-es", ".irom0.text", "${TARGET}.irom0text.bin", "-ec", "-v" ]), "Building $TARGET"), suffix=".bin"))) # copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode) env.Append(ASFLAGS=env.get("CCFLAGS", [])[:]) if not env.BoardConfig().get("build.ldscript", ""): env.Replace(LDSCRIPT_PATH=join(FRAMEWORK_DIR, "ld", "eagle.app.v6.ld"), ) # Extra flash images board_flash_size = int(env.BoardConfig().get("upload.maximum_size", 0)) if board_flash_size > 8388608: init_data_flash_address = 0xffc000 # for 16 MB
UPLOADCMD='"$UPLOADER" $UPLOADERFLAGS -cf $SOURCE', UPLOADOTACMD='"$PYTHONEXE" "$UPLOADEROTA" $UPLOADEROTAFLAGS -f $SOURCE', # # Misc # MKSPIFFSTOOL=join("$PIOPACKAGES_DIR", "tool-mkspiffs", "mkspiffs"), SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', PROGNAME="firmware", PROGSUFFIX=".elf") env.Append(BUILDERS=dict(ElfToBin=Builder(action=" ".join([ '"$UPLOADER"', "-eo", '"%s"' % join("$PLATFORMFW_DIR", "bootloaders", "eboot", "eboot.elf"), "-bo", "$TARGET", "-bm", "dio", "-bf", "${BOARD_OPTIONS['build']['f_cpu'][:2]}", "-bz", "${__get_flash_size(__env__)}", "-bs", ".text", "-bp", "4096", "-ec", "-eo", "$SOURCES", "-bs", ".irom0.text", "-bs", ".text", "-bs", ".data", "-bs", ".rodata", "-bc", "-ec" ]), suffix=".bin"))) # # SPIFFS # def _fetch_spiffs_size(target, source, env): spiffs_re = re.compile( r"PROVIDE\s*\(\s*_SPIFFS_(\w+)\s*=\s*(0x[\dA-F]+)\s*\)") with open(env.GetActualLDScript()) as f: for line in f.readlines():
def dev_init(env, platform): dev_create_template(env) dev_compiler(env) framework_dir = env.PioPlatform().get_package_dir("framework-quectel") core = env.BoardConfig().get("build.core") env.sdk = env.BoardConfig().get( "build.sdk", "SDK2").upper() #SDK2 #SDK2831 #SDK325 #SDK424 env.base = env.BoardConfig().get("build.base", "0x40000000") env.heap = env.BoardConfig().get("build.heap", "1048576") print("CORE", core, env.sdk, "RO_BASE =", env.base, "HEAP =", env.heap) env.Append( CPPDEFINES=[ # -D platform.upper(), "CORE_" + core.upper().replace("-", "_"), "QAPI_TXM_MODULE", "TXM_MODULE", "TX_DAM_QC_CUSTOMIZATIONS", "TX_ENABLE_PROFILING", "TX_ENABLE_EVENT_TRACE", "TX_DISABLE_NOTIFY_CALLBACKS", "FX_FILEX_PRESENT", "TX_ENABLE_IRQ_NESTING", "TX3_CHANGES", "_RO_BASE_=" + env.base, # 0x40000000 "HEAP=" + env.heap # 1M ], CPPPATH=[ # -I join(framework_dir, platform, core, env.sdk), join(framework_dir, platform, core, env.sdk, "qapi"), join(framework_dir, platform, core, env.sdk, "threadx_api"), join(framework_dir, platform, core, "quectel"), join("$PROJECT_DIR", "lib"), join("$PROJECT_DIR", "include") ], CFLAGS=[ "-O1", "-marm", "-mcpu=cortex-a7", "-mfloat-abi=softfp", #"-std=c11", "-fdata-sections", "-ffunction-sections", "-fno-strict-aliasing", "-fno-zero-initialized-in-bss", "-fsingle-precision-constant", "-Wall", "-Wstrict-prototypes", "-Wp,-w", ], LINKFLAGS=[ "-O1", "-g", "-marm", "-mcpu=cortex-a7", "-mfloat-abi=softfp", "-nostartfiles", "-fno-use-cxa-atexit", "-fno-zero-initialized-in-bss", "-Xlinker", "--defsym=_RO_BASE_=" + env.base, "-Xlinker", "--gc-sections", "-Wl,--gc-sections", ], LIBSOURCE_DIRS=[ join(framework_dir, platform, "libraries", core), ], LDSCRIPT_PATH=join(framework_dir, platform, core, "c.ld"), LIBS=["gcc", "m"], BUILDERS=dict(ElfToBin=Builder(action=env.VerboseAction( " ".join([ "$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET", ]), "Building $TARGET"), suffix=".bin"), MakeHeader=Builder(action=env.VerboseAction( dev_header, "ADD HEADER"), suffix=".ini")), UPLOADCMD=dev_uploader) libs = [] #THREADX libs.append( env.BuildLibrary( join("$BUILD_DIR", platform), join(framework_dir, platform, core, env.sdk), )) libs.append( env.BuildLibrary( join("$BUILD_DIR", "_quectel"), join(framework_dir, platform, core, "quectel"), )) #PROJECT libs.append( env.BuildLibrary( join("$BUILD_DIR", "custom"), join("$PROJECT_DIR", "lib"), )) env.Append(LIBS=libs)
RANLIB="riscv64-unknown-elf-gcc-ranlib", SIZETOOL="riscv64-unknown-elf-size", ARFLAGS=["rc"], SIZEPRINTCMD="$SIZETOOL -d $SOURCES", PROGSUFFIX=".elf", ) # Allow user to override via pre:script if env.get("PROGNAME", "program") == "program": env.Replace(PROGNAME="firmware") env.Append(BUILDERS=dict( ElfToHex=Builder( action=env.VerboseAction( " ".join(["$OBJCOPY", "-O", "ihex", "$SOURCES", "$TARGET"]), "Building $TARGET", ), suffix=".hex", ), ElfToBin=Builder( action=env.VerboseAction( " ".join(["$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET"]), "Building $TARGET", ), suffix=".bin", ), BinToVh=Builder(action=env.VerboseAction(generate_vh, "Building $TARGET"), suffix=".vh"), )) if not env.get("PIOFRAMEWORK"):
def bg96_init(env): print("\n\033[31mFramework is in development..." ) CORE = env.BoardConfig().get("build.core") # "bg96" CORE_DIR = join(env.PioPlatform().get_package_dir("framework-quectel"), "threadx", CORE) env.Append( CPPDEFINES=["THREADX", "CORE_"+CORE.upper(), # -D "TXM_MODULE", "QAPI_TXM_MODULE", "TX_ENABLE_PROFILING", "TX_ENABLE_EVENT_TRACE", "TX_DISABLE_NOTIFY_CALLBACKS", "TX_DAM_QC_CUSTOMIZATIONS", "_RO_BASE_=0x40000000", ], CPPPATH=[ # -I CORE_DIR, join(CORE_DIR, "interface"), join(CORE_DIR, "interface", "qapi"), join(CORE_DIR, "interface", "threadx_api"), ], CFLAGS=[ "-marm", "-mcpu=cortex-a7", "-mfloat-abi=hard", "-mfpu=vfpv4", "-std=gnu11", "-Os", "-mno-long-calls" ], CXXFLAGS=["-std=gnu++11", "-fno-exceptions", "-fno-rtti", "-fno-non-call-exceptions", ], LINKFLAGS=[ "-marm", "-mcpu=cortex-a7", "-mfloat-abi=hard", "-mfpu=vfpv4", "-Xlinker", "--defsym=ROM_ADDRESS=0x40000000", "-nostartfiles", "-mno-long-calls", "-ffunction-sections", "-fdata-sections", "-fno-use-cxa-atexit", "-Rbuild", "-Wl,--gc-sections,--relax", ], LIBPATH=[CORE_DIR], LDSCRIPT_PATH=join(CORE_DIR, "interface","linkscript.ld"), LIBS=["gcc", "m"], BUILDERS=dict( ElfToBin=Builder( action=env.VerboseAction(" ".join([ "$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET" ]), "Building $TARGET"), suffix=".dat" ), MakeHeader = Builder(action="", suffix=".2") ), #dict UPLOADCMD = bg96_uploader ) # env.Append libs = [] libs.append( env.BuildLibrary( join("$BUILD_DIR", "framework"), join(CORE_DIR) )) libs.append( env.BuildLibrary( join("$BUILD_DIR", "framework", "interface"), join(CORE_DIR, "interface") )) env.Append( LIBS=libs )
_value -= 0x200000 # esptool offset env[k] = hex(_value) return (target, source) env.Append( BUILDERS=dict( DataToBin=Builder( action=env.VerboseAction(" ".join([ '"$MKSPIFFSTOOL"', "-c", "$SOURCES", "-p", "${int(SPIFFS_PAGE, 16)}", "-b", "${int(SPIFFS_BLOCK, 16)}", "-s", "${int(SPIFFS_END, 16) - int(SPIFFS_START, 16)}", "$TARGET" ]), "Building SPIFFS image from '$SOURCES' directory to $TARGET"), emitter=_fetch_spiffs_size, source_factory=env.Dir, suffix=".bin" ) ) ) if "uploadfs" in COMMAND_LINE_TARGETS: env.Append( UPLOADERFLAGS=["-ca", "$SPIFFS_START"], UPLOADEROTAFLAGS=["-s"] )
_print('targets:\n' + \ env.subst("${TARGETS}", target=target, source=source).replace(' ', '\n')) _print('sources:\n' + \ env.subst("${SOURCES}", target=target, source=source).replace(' ', '\n')) _print('-' * 50) return target, source _protoc_builder = Builder( action=Action('$PROTOC_COM', '$PROTOC_COMSTR'), suffix='$PROTOC_CCSUFFIX', src_suffix='$PROTOC_SUFFIX', emitter=_protoc_emitter, ) def _multiGet(kwd, defaultVal, kwargs, env): return kwargs.get(kwd) or \ env.get(kwd) or \ defaultVal def _detect(env, kwargs): """Try to find the Protoc compiler""" return _multiGet('PROTOC', '', env,
CPPDEFINES=["F_CPU=$BOARD_F_CPU"], LINK="$CC", LINKFLAGS=["-Os", "-mmcu=$BOARD_MCU", "-Wl,-gc-sections,-u,main"], LIBS=["m"], SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', UPLOADER=join("$PIOPACKAGES_DIR", "tool-mspdebug", "mspdebug"), UPLOADERFLAGS=[ "$UPLOAD_PROTOCOL" if system() != "Windows" else "tilib", "--force-reset" ], UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"', PROGNAME="firmware", PROGSUFFIX=".elf") env.Append(BUILDERS=dict(ElfToHex=Builder(action=" ".join( ["$OBJCOPY", "-O", "ihex", "-R", ".eeprom", "$SOURCES", "$TARGET"]), suffix=".hex"))) # # Target: Build executable and linkable firmware # target_elf = env.BuildProgram() # # Target: Build the .hex # if "uploadlazy" in COMMAND_LINE_TARGETS: target_firm = join("$BUILD_DIR", "firmware.hex") else:
if env.get("PROGNAME", "program") == "program": env.Replace(PROGNAME="firmware") env.Append( # ARFLAGS=["..."], # ASFLAGS=["flag1", "flag2", "flagN"], CCFLAGS=["-mstrict-align"], # CXXFLAGS=["flag1", "flag2", "flagN"], LINKFLAGS=["-mstrict-align"], CPPDEFINES=["-DBONFIRE"], # LIBS=["additional", "libs", "here"], BUILDERS=dict(ElfToBin=Builder(action=" ".join( ["$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET"]), suffix=".bin"), ElfToLst=Builder(action=" ".join( ["$OBJDUMP", "-S", "-d", "$SOURCES", ">$TARGET"]), suffix=".lst"), ElfToHex=Builder(action=env.VerboseAction( " ".join( ["$OBJCOPY", "-O", "ihex", "$SOURCES", "$TARGET"]), "Building $TARGET"), suffix=".hex"))) # The source code of "platformio-build-tool" is here # https://github.com/platformio/platformio-core/blob/develop/platformio/builder/tools/platformio.py # # Target: Build executable and linkable firmware
SIZEPROGREGEXP= r"^(?:\.text|\.data|\.rodata|\.text.align|\.ARM.exidx)\s+(\d+).*", SIZEDATAREGEXP=r"^(?:\.data|\.bss|\.noinit)\s+(\d+).*", SIZECHECKCMD="$SIZETOOL -A -d $SOURCES", SIZEPRINTCMD='$SIZETOOL -B -d $SOURCES', ERASEFLAGS=["--eraseall", "-f", "nrf52"], ERASECMD="nrfjprog $ERASEFLAGS", PROGSUFFIX=".elf") # Allow user to override via pre:script if env.get("PROGNAME", "program") == "program": env.Replace(PROGNAME="firmware") env.Append(BUILDERS=dict( ElfToBin=Builder(action=env.VerboseAction( " ".join(["$OBJCOPY", "-O", "binary", "$SOURCES", "$TARGET"]), "Building $TARGET"), suffix=".bin"), ElfToHex=Builder(action=env.VerboseAction( " ".join([ "$OBJCOPY", "-O", "ihex", "-R", ".eeprom", "$SOURCES", "$TARGET" ]), "Building $TARGET"), suffix=".hex"), MergeHex=Builder(action=env.VerboseAction( " ".join([ join(platform.get_package_dir("tool-sreccat") or "", "srec_cat"), "$SOFTDEVICEHEX", "-intel", "$SOURCES", "-intel", "-o", "$TARGET", "-intel", "--line-length=44" ]), "Building $TARGET"), suffix=".hex"))) if use_adafruit:
def dev_init(env, platform): env.tool_dir = env.PioPlatform().get_package_dir("tool-azure") env.framework_dir = env.PioPlatform().get_package_dir("framework-azure") env.toolchain_dir = env.PioPlatform().get_package_dir( "toolchain-gccarmnoneeabi") env.baremetal = True dev_create_template(env) dev_guid(env) dev_compiler(env) env.sysroot = env.BoardConfig().get( "build.sysroot", "2+Beta1905") # from ini file, default must be BETA env.delete = env.BoardConfig().get( "build.delete", "current") # from ini file, delete current OR ALL print(Fore.MAGENTA + "AZURE SPHERE SDK SYSROOT:", env.sysroot, "[", env.BoardConfig().get("build.core").upper(), "]", env.BoardConfig().get("build.variant") + Fore.BLACK) env.Append( CPPDEFINES=[], CPPPATH=[ join(env.framework_dir, "Sysroots", env.sysroot, "usr", "include"), join("$PROJECT_DIR", "lib"), join("$PROJECT_DIR", "include") ], CFLAGS=[ "-O0", "-c", "-mcpu=cortex-m4", "-mfloat-abi=soft", "-march=armv7e-m", "-mthumb", "-fno-omit-frame-pointer", "-fno-strict-aliasing", "-Wall", "-fno-exceptions", ], CXXFLAGS=[ "-fno-rtti", "-fno-exceptions", "-fno-non-call-exceptions", "-fno-use-cxa-atexit", "-fno-threadsafe-statics", ], CCFLAGS=[ "-mcpu=cortex-m4", "-mfloat-abi=soft", "-march=armv7e-m", "-mthumb", ], #LIBPATH = [], LDSCRIPT_PATH=join(env.framework_dir, "Sysroots", env.sysroot, "linker.ld"), LINKFLAGS=[ "-mcpu=cortex-m4", "-mfloat-abi=soft", "-march=armv7e-m", "-mthumb", "-nostartfiles", "-Wl,--no-undefined", "-Wl,-n", ], LIBSOURCE_DIRS=[ join(env.framework_dir, platform, "libraries"), ], # userware LIBS=["gcc"], BUILDERS=dict(ElfToBin=Builder(action="", suffix=".1"), MakeHeader=Builder(action=env.VerboseAction( dev_pack_image, "Packing image..."), suffix=".bin")), UPLOADCMD=dev_uploader) libs = [] libs.append( env.BuildLibrary( join("$BUILD_DIR", "_custom"), join("$PROJECT_DIR", "lib"), )) env.Append(LIBS=libs) use_original_sdk(env)