summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oe/copy_buildsystem.py70
1 files changed, 70 insertions, 0 deletions
diff --git a/meta/lib/oe/copy_buildsystem.py b/meta/lib/oe/copy_buildsystem.py
new file mode 100644
index 0000000000..5a4d8c332e
--- /dev/null
+++ b/meta/lib/oe/copy_buildsystem.py
@@ -0,0 +1,70 @@
1# This class should provide easy access to the different aspects of the
2# buildsystem such as layers, bitbake location, etc.
3import stat
4import shutil
5
6def _smart_copy(src, dest):
7 # smart_copy will choose the correct function depending on whether the
8 # source is a file or a directory.
9 mode = os.stat(src).st_mode
10 if stat.S_ISDIR(mode):
11 shutil.copytree(src, dest, symlinks=True)
12 else:
13 shutil.copyfile(src, dest)
14 shutil.copymode(src, dest)
15
16class BuildSystem(object):
17 def __init__(self, d):
18 self.d = d
19 self.layerdirs = d.getVar('BBLAYERS', True).split()
20
21 def copy_bitbake_and_layers(self, destdir):
22 # Copy in all metadata layers + bitbake (as repositories)
23 layers_copied = []
24 bb.utils.mkdirhier(destdir)
25 layers = list(self.layerdirs)
26
27 corebase = self.d.getVar('COREBASE', True)
28 layers.append(corebase)
29
30 corebase_files = self.d.getVar('COREBASE_FILES', True).split()
31
32 # bitbake belongs in corebase so make sure it goes there
33 if "bitbake" not in corebase_files:
34 corebase_files.append("bitbake")
35 corebase_files = [corebase + '/' +x for x in corebase_files]
36
37 for layer in layers:
38 layerconf = os.path.join(layer, 'conf', 'layer.conf')
39 if os.path.exists(layerconf):
40 with open(layerconf, 'r') as f:
41 if f.readline().startswith("# ### workspace layer auto-generated by devtool ###"):
42 bb.warn("Skipping local workspace layer %s" % layer)
43 continue
44
45 # If the layer was already under corebase, leave it there
46 # since layers such as meta have issues when moved.
47 layerdestpath = destdir
48 if corebase == os.path.dirname(layer):
49 layerdestpath += '/' + os.path.basename(corebase)
50 layerdestpath += '/' + os.path.basename(layer)
51
52 layer_relative = os.path.relpath(layerdestpath,
53 destdir)
54 layers_copied.append(layer_relative)
55
56 # Treat corebase as special since it typically will contain
57 # build directories or other custom items.
58 if corebase == layer:
59 bb.utils.mkdirhier(layerdestpath)
60 for f in corebase_files:
61 f_basename = os.path.basename(f)
62 destname = os.path.join(layerdestpath, f_basename)
63 _smart_copy(f, destname)
64 else:
65 if os.path.exists(layerdestpath):
66 bb.note("Skipping layer %s, already handled" % layer)
67 else:
68 _smart_copy(layer, layerdestpath)
69
70 return layers_copied