Esempio n. 1
0
    def build_arscons(self, sources=None):
        # TODO: remove tempdir
        tempdir = tmpdir(dir=tmpdir())

        SConstruct = Path(__file__).parent / "SConstruct"
        SConstruct.copy(tempdir / "SConstruct")

        allfiles = self.setup_sources(tempdir, sources)
        projname = self.guess_projname(allfiles)
        tempdir = rename(tempdir, tempdir.parent / projname)
        cmd = self.command_list()

        self.proc = Proc(cmd, cwd=tempdir).call()
        if not self.ok:
            raise ArduinoCompileError(cmd, sources, self.error_text)
        self.output = tempdir.files("*.elf")[0]
Esempio n. 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)
Esempio n. 3
0
    def build_ino(self, sources=None):
        # TODO: remove tempdir
        tempdir = tmpdir(dir=tmpdir())
        lib = tempdir / "lib"
        src = tempdir / "src"
        build = tempdir / ".build"
        lib.mkdir()
        src.mkdir()

        self.setup_sources(src, sources)
        cmd = self.command_list()

        self.proc = Proc(cmd, cwd=tempdir).call()
        if not self.ok:
            raise ArduinoCompileError(cmd, sources, self.error_text)
        self.output = build.walkfiles("*.elf")[0]
Esempio n. 4
0
    def build_arscons(self, sources=None):
        # TODO: remove tempdir
        tempdir = tmpdir(dir=tmpdir())

        SConstruct = Path(__file__).parent / 'SConstruct'
        SConstruct.copy(tempdir / 'SConstruct')

        allfiles = self.setup_sources(tempdir, sources)
        projname = self.guess_projname(allfiles)
        tempdir = rename(tempdir, tempdir.parent / projname)
        cmd = self.command_list()

        self.proc = Proc(cmd, cwd=tempdir).call()
        if not self.ok:
            raise ArduinoCompileError(cmd, sources, self.error_text)
        self.output = tempdir.files('*.elf')[0]
Esempio n. 5
0
    def build_ino(self, sources=None):
        # TODO: remove tempdir
        tempdir = tmpdir(dir=tmpdir())
        lib = tempdir / 'lib'
        src = tempdir / 'src'
        build = tempdir / '.build'
        lib.mkdir()
        src.mkdir()

        self.setup_sources(src, sources)
        cmd = self.command_list()

        self.proc = Proc(cmd, cwd=tempdir).call()
        if not self.ok:
            raise ArduinoCompileError(cmd, sources, self.error_text)
        self.output = build.walkfiles('*.elf')[0]
Esempio n. 6
0
def test_more_files():
    d = tmpdir() / 'Foo'
    d.makedirs()
    f = d / 'Foo.pde'
    f.write_text('#include "x.h" \n int x=foo; \n' + Arduino.minprog)
    (d / 'x.h').write_text('#define foo 3')
    Arduino().build(f)
Esempio n. 7
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)
Esempio n. 8
0
def test_file():
    d = tmpdir() / 'Foo'
    d.makedirs()
    f = d / 'Foo.pde'
    f.write_text(Arduino.minprog)
    Arduino().build(f)