• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/support/testing/infra/builder.py
Ricardo MartincoskiRicardo Martincoski committed ef8d1f1b15805 Oct 2017
Raw file
Source viewDiff to previous
 
1
import os
2
import shutil
3
import subprocess
4
​
5
import infra
6
​
7
​
8
class Builder(object):
9
    def __init__(self, config, builddir, logtofile):
10
        self.config = '\n'.join([line.lstrip() for line in
11
                                 config.splitlines()]) + '\n'
12
        self.builddir = builddir
13
        self.logfile = infra.open_log_file(builddir, "build", logtofile)
14
​
15
    def build(self):
16
        if not os.path.isdir(self.builddir):
17
            os.makedirs(self.builddir)
18
​
19
        config_file = os.path.join(self.builddir, ".config")
20
        with open(config_file, "w+") as cf:
21
            cf.write(self.config)
22
        # dump the defconfig to the logfile for easy debugging
23
        self.logfile.write("> start defconfig\n" + self.config +
24
                           "> end defconfig\n")
25
        self.logfile.flush()
26
​
27
        cmd = ["make",
28
               "O={}".format(self.builddir),
29
               "olddefconfig"]
30
        ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile)
31
        if ret != 0:
32
            raise SystemError("Cannot olddefconfig")
33
​
34
        cmd = ["make", "-C", self.builddir]
35
        ret = subprocess.call(cmd, stdout=self.logfile, stderr=self.logfile)
36
        if ret != 0:
37
            raise SystemError("Build failed")
38
​
39
        open(self.stamp_path(), 'a').close()
40
​
41
    def stamp_path(self):
42
        return os.path.join(self.builddir, "build-done")
43
​
44
    def is_finished(self):
45
        return os.path.exists(self.stamp_path())
46
​
47
    def delete(self):
48
        if os.path.exists(self.builddir):
49
            shutil.rmtree(self.builddir)
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.