def setup_sources(self, tempdir, sources): strings, files = separate_sources(sources) log.debug("version: %s", version.intversion()) log.debug( """input sources: strings: %s files: %s """, "\n----\n".join(strings), "\n".join(files), ) allfiles = [] for x in strings: f = tmpfile(x, tempdir, version.sketch_extension()) allfiles += [f] for x in files: x = x.abspath() f = tempdir / x.namebase + version.sketch_extension() if x.parent.name == x.namebase: # copy other files from pde directory for y in x.parent.files(): if y != x: y.copy(tempdir / y.name) # copy pde x.copy(f) allfiles += [f] log.debug(" converted to:\n%s", "\n".join(allfiles)) return allfiles
def setup_sources(self, tempdir, sources): strings, files = separate_sources(sources) log.debug('version: %s', version.intversion()) log.debug('''input sources: strings: %s files: %s ''', '\n----\n'.join(strings), '\n'.join(files)) allfiles = [] for x in strings: f = tmpfile(x, tempdir, version.sketch_extension()) allfiles += [f] for x in files: x = x.abspath() f = tempdir / x.namebase + version.sketch_extension() if x.parent.name == x.namebase: # copy other files from pde directory for y in x.parent.files(): if y != x: y.copy(tempdir / y.name) # copy pde x.copy(f) allfiles += [f] log.debug(' converted to:\n%s', '\n'.join(allfiles)) return allfiles
def build(self, sources=None, headers=None): ''' sources can be file name or code: sources=['x.c','int main(){}'] or sources='int main(){}' ''' tempdir = None strings, files = separate_sources(sources) if len(strings) or headers: # TODO: remove tempdir tempdir = tmpdir() temp_list = [tmpfile(x, tempdir, '.c') for x in strings] if headers: for n, s in headers.items(): (Path(tempdir) / n).write_text(s) cmd = self.command_list(files + temp_list) if tempdir: cmd += ['-I' + tempdir] self.proc = Proc(cmd).call() # for x in temp_list: # os.remove(x) if not self.ok: raise AvrGccCompileError(cmd, sources, self.error_text)