예제 #1
0
파일: arduino.py 프로젝트: ponty/pyavrutils
    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
예제 #2
0
    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)
예제 #3
0
    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
예제 #4
0
파일: avrgcc.py 프로젝트: x2nie/pyavrutils
    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)
예제 #5
0
def test_separate_sources():
    eq_(separate_sources('int main(){}'), (['int main(){}'],[]))
    eq_(separate_sources(['int main(){}']), (['int main(){}'],[]))
    eq_(separate_sources(['int main(){}','int main(){}']), (['int main(){}','int main(){}'],[]))

    eq_(separate_sources('main.c'), ([],['main.c']))
    eq_(separate_sources(['main.c']), ([],['main.c']))
    eq_(separate_sources(['main.c','main2.c']), ([],['main.c','main2.c']))
    
예제 #6
0
def test_separate_sources():
    eq_(separate_sources('int main(){}'), (['int main(){}'], []))
    eq_(separate_sources(['int main(){}']), (['int main(){}'], []))
    eq_(separate_sources(['int main(){}', 'int main(){}']),
        (['int main(){}', 'int main(){}'], []))

    eq_(separate_sources('main.c'), ([], ['main.c']))
    eq_(separate_sources(['main.c']), ([], ['main.c']))
    eq_(separate_sources(['main.c', 'main2.c']), ([], ['main.c', 'main2.c']))