def link(self, arguments, inf, local_external_setting, variant): # Run the linker base.ToolChain.link(self, arguments, inf, local_external_setting, variant) # switch to the build variant output directory vardir = '_' + self._bld utils.push_dir(vardir) # Output Banner message self._printer.output("= Creating HEX file ...") # construct objcopy command options = '-O ihex ' objcpy = '{} {} {} {}'.format(self._objcpy, options, self._final_output_name + '.elf', self._final_output_name + '.hex') # Generate the .HEX file if (arguments['-v']): self._printer.output(objcpy) if (utils.run_shell(self._printer, objcpy)): self._printer.output("=") self._printer.output( "= Build Failed: Failed to create .HEX file from the .ELF") self._printer.output("=") sys.exit(1) # Output Banner message self._printer.output("= Creating the download (.ZIP) file ...") # construct zip command options = 'dfu genpkg --dev-type 0x0052 --application' nrfutil = '{} {} {} {}'.format(self._nrfutil, options, self._final_output_name + '.hex', self._final_output_name + '.zip') # Generate the download file (aka the ZIP file) if (arguments['-v']): self._printer.output(nrfutil) if (utils.run_shell(self._printer, nrfutil)): self._printer.output("=") self._printer.output( "= Build Failed: Failed to create .ZIP file from the .HEX") self._printer.output("=") sys.exit(1) # Return to project dir utils.pop_dir()
def link(self, arguments, inf, local_external_setting, variant): # Run the linker base.ToolChain.link(self, arguments, inf, local_external_setting, variant) # switch to the build variant output directory vardir = '_' + self._bld utils.push_dir(vardir) # Output Banner message self._printer.output("= Creating EEPROM (eep) file ...") # construct objcopy command options = '-O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0' objcpy = '{} {} {} {}'.format(self._objcpy, options, self._final_output_name + '.elf', self._final_output_name + '.eep') # Generate the .HEX file if (arguments['-v']): self._printer.output(objcpy) if (utils.run_shell(self._printer, objcpy)): self._printer.output("=") self._printer.output( "= Build Failed: Failed to create .EEP file from the .ELF") self._printer.output("=") sys.exit(1) # Output Banner message self._printer.output("= Creating HEX file ...") # construct objcopy command options = '-O ihex -R .eeprom' objcpy = '{} {} {} {}'.format(self._objcpy, options, self._final_output_name + '.elf', self._final_output_name + '.hex') # Generate the .HEX file if (arguments['-v']): self._printer.output(objcpy) if (utils.run_shell(self._printer, objcpy)): self._printer.output("=") self._printer.output( "= Build Failed: Failed to create .HEX file from the .ELF") self._printer.output("=") sys.exit(1) # Return to project dir utils.pop_dir()
def _build_project(full_path_of_build_script, verbose, bldopts, config, xconfig, pkgroot): # reconcile config options cfg = None if (config): cfg = os.path.join(pkgroot, config) elif (xconfig): cfg = xconfig # Build the project utils.push_dir(os.path.dirname(full_path_of_build_script)) cmd = full_path_of_build_script + ' ' + " ".join(bldopts) print("BUILDING: " + cmd) if (config): cmd = utils.concatenate_commands(cfg, cmd) utils.run_shell2(cmd, verbose, f"ERROR: Build failure ({cmd})") utils.pop_dir()
def link(self, arguments, inf, local_external_setting, variant): # Run the linker base.ToolChain.link(self, arguments, inf, local_external_setting, variant) # switch to the build variant output directory vardir = '_' + self._bld utils.push_dir(vardir) # Output Banner message self._printer.output("= Creating BIN file ...") # construct objcopy command options = '-O binary ' objcpy = '{} {} {} {}'.format(self._objcpy, options, self._final_output_name + '.elf', self._final_output_name + '.bin') # Generate the .HEX file if (arguments['-v']): self._printer.output(objcpy) if (utils.run_shell(self._printer, objcpy)): self._printer.output("=") self._printer.output( "= Build Failed: Failed to create .BIN file from the .ELF") self._printer.output("=") sys.exit(1) # Output Banner message self._printer.output("= Running Print Size...") # construct zip command options = '--format=berkeley' printsz = '{} {} {}'.format(self._printsz, options, self._final_output_name + '.elf') # Run the 'size' command if (arguments['-v']): self._printer.output(printsz) utils.run_shell(self._printer, printsz) # Return to project dir utils.pop_dir()
# Process 'n' directories at a time while (index < max or busy > 0): # Start multiple processes for i in range(0, cpus): if (handles[i] == None and index < max): j = jobs[index] index += 1 busy += 1 handles[i] = Process(target=_build_project, args=(j, args['-v'], args['<build-opts>'], args['--config'], args['--xconfig'], pkgroot)) handles[i].start() # Poll for processes being done for i in range(0, cpus): if (handles[i] != None and not handles[i].is_alive()): if (handles[i].exitcode != 0): exit(handles[i].exitcode) handles[i] = None busy -= 1 # sleep for 10ms before polling to see if a process has completed if (busy >= cpus): time.sleep(0.010) # restore original cwd utils.pop_dir()