summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/copy_buildsystem.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-03-02 23:44:21 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-07 00:11:38 +0000
commit25d9c4e02a90b1fd8c6a2036d29fd2cf87eca098 (patch)
tree29242ee8c4d7a9a12d7da5f40080f17d511a15ec /meta/lib/oe/copy_buildsystem.py
parent41eb36dc4ce7feece2f63c7cae80478f5376459e (diff)
downloadpoky-25d9c4e02a90b1fd8c6a2036d29fd2cf87eca098.tar.gz
devtool: add build-sdk subcommand
Add a build-sdk command which is only available within the extensible SDK that builds a derivative extensible SDK. The idea is recipes in the workspace become a part of the new SDK - for example, this allows taking a vendor provided SDK, adding a few libs and then producing a new SDK with those included. When normally building the extensible SDK, the workspace is excluded; here we need to copy into the new SDK (renaming it in the process); the recipes' task signatures become locked and thus the sources are no longer needed, so they are removed along with the workspace bbappends which would interfere with the locked signatures. Additionally we need to just copy the configuration files (i.e. local.conf and auto.conf) rather than filtering and appending to them since that work has already been done when constructing the original SDK. The extra sstate artifacts from workspace recipes are also determined and copied into the new SDK in minimal mode (on the assumption that you won't set up a new sstate mirror). This reuses some code from build-image, so that needed to be generalised to allow that. Implements [YOCTO #8892]. (From OE-Core rev: 59e207ff6dd4b50a8905e14bc9292cf2794f4e7a) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/copy_buildsystem.py')
-rw-r--r--meta/lib/oe/copy_buildsystem.py59
1 files changed, 53 insertions, 6 deletions
diff --git a/meta/lib/oe/copy_buildsystem.py b/meta/lib/oe/copy_buildsystem.py
index 5074a43cb9..dd0e6641e3 100644
--- a/meta/lib/oe/copy_buildsystem.py
+++ b/meta/lib/oe/copy_buildsystem.py
@@ -20,7 +20,7 @@ class BuildSystem(object):
20 self.layerdirs = d.getVar('BBLAYERS', True).split() 20 self.layerdirs = d.getVar('BBLAYERS', True).split()
21 self.layers_exclude = (d.getVar('SDK_LAYERS_EXCLUDE', True) or "").split() 21 self.layers_exclude = (d.getVar('SDK_LAYERS_EXCLUDE', True) or "").split()
22 22
23 def copy_bitbake_and_layers(self, destdir): 23 def copy_bitbake_and_layers(self, destdir, workspace_name=None):
24 # Copy in all metadata layers + bitbake (as repositories) 24 # Copy in all metadata layers + bitbake (as repositories)
25 layers_copied = [] 25 layers_copied = []
26 bb.utils.mkdirhier(destdir) 26 bb.utils.mkdirhier(destdir)
@@ -34,6 +34,14 @@ class BuildSystem(object):
34 if layer_exclude in layers: 34 if layer_exclude in layers:
35 layers.remove(layer_exclude) 35 layers.remove(layer_exclude)
36 36
37 workspace_newname = workspace_name
38 if workspace_newname:
39 layernames = [os.path.basename(layer) for layer in layers]
40 extranum = 0
41 while workspace_newname in layernames:
42 extranum += 1
43 workspace_newname = '%s-%d' % (workspace_name, extranum)
44
37 corebase_files = self.d.getVar('COREBASE_FILES', True).split() 45 corebase_files = self.d.getVar('COREBASE_FILES', True).split()
38 corebase_files = [corebase + '/' +x for x in corebase_files] 46 corebase_files = [corebase + '/' +x for x in corebase_files]
39 # Make sure bitbake goes in 47 # Make sure bitbake goes in
@@ -42,18 +50,24 @@ class BuildSystem(object):
42 50
43 for layer in layers: 51 for layer in layers:
44 layerconf = os.path.join(layer, 'conf', 'layer.conf') 52 layerconf = os.path.join(layer, 'conf', 'layer.conf')
53 layernewname = os.path.basename(layer)
54 workspace = False
45 if os.path.exists(layerconf): 55 if os.path.exists(layerconf):
46 with open(layerconf, 'r') as f: 56 with open(layerconf, 'r') as f:
47 if f.readline().startswith("# ### workspace layer auto-generated by devtool ###"): 57 if f.readline().startswith("# ### workspace layer auto-generated by devtool ###"):
48 bb.plain("NOTE: Excluding local workspace layer %s from %s" % (layer, self.context)) 58 if workspace_newname:
49 continue 59 layernewname = workspace_newname
60 workspace = True
61 else:
62 bb.plain("NOTE: Excluding local workspace layer %s from %s" % (layer, self.context))
63 continue
50 64
51 # If the layer was already under corebase, leave it there 65 # If the layer was already under corebase, leave it there
52 # since layers such as meta have issues when moved. 66 # since layers such as meta have issues when moved.
53 layerdestpath = destdir 67 layerdestpath = destdir
54 if corebase == os.path.dirname(layer): 68 if corebase == os.path.dirname(layer):
55 layerdestpath += '/' + os.path.basename(corebase) 69 layerdestpath += '/' + os.path.basename(corebase)
56 layerdestpath += '/' + os.path.basename(layer) 70 layerdestpath += '/' + layernewname
57 71
58 layer_relative = os.path.relpath(layerdestpath, 72 layer_relative = os.path.relpath(layerdestpath,
59 destdir) 73 destdir)
@@ -73,6 +87,38 @@ class BuildSystem(object):
73 else: 87 else:
74 _smart_copy(layer, layerdestpath) 88 _smart_copy(layer, layerdestpath)
75 89
90 if workspace:
91 # Make some adjustments original workspace layer
92 # Drop sources (recipe tasks will be locked, so we don't need them)
93 srcdir = os.path.join(layerdestpath, 'sources')
94 if os.path.isdir(srcdir):
95 shutil.rmtree(srcdir)
96 # Drop all bbappends except the one for the image the SDK is being built for
97 # (because of externalsrc, the workspace bbappends will interfere with the
98 # locked signatures if present, and we don't need them anyway)
99 image_bbappend = os.path.splitext(os.path.basename(self.d.getVar('FILE', True)))[0] + '.bbappend'
100 appenddir = os.path.join(layerdestpath, 'appends')
101 if os.path.isdir(appenddir):
102 for fn in os.listdir(appenddir):
103 if fn == image_bbappend:
104 continue
105 else:
106 os.remove(os.path.join(appenddir, fn))
107 # Drop README
108 readme = os.path.join(layerdestpath, 'README')
109 if os.path.exists(readme):
110 os.remove(readme)
111 # Filter out comments in layer.conf and change layer name
112 layerconf = os.path.join(layerdestpath, 'conf', 'layer.conf')
113 with open(layerconf, 'r') as f:
114 origlines = f.readlines()
115 with open(layerconf, 'w') as f:
116 for line in origlines:
117 if line.startswith('#'):
118 continue
119 line = line.replace('workspacelayer', workspace_newname)
120 f.write(line)
121
76 return layers_copied 122 return layers_copied
77 123
78def generate_locked_sigs(sigfile, d): 124def generate_locked_sigs(sigfile, d):
@@ -123,7 +169,7 @@ def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_outpu
123 if line.endswith('\\\n'): 169 if line.endswith('\\\n'):
124 if not line in merged[invalue]: 170 if not line in merged[invalue]:
125 target, task = line.strip().split(':')[:2] 171 target, task = line.strip().split(':')[:2]
126 if task in copy_tasks: 172 if not copy_tasks or task in copy_tasks:
127 tocopy[invalue].append(line) 173 tocopy[invalue].append(line)
128 merged[invalue].append(line) 174 merged[invalue].append(line)
129 else: 175 else:
@@ -150,7 +196,8 @@ def merge_lockedsigs(copy_tasks, lockedsigs_main, lockedsigs_extra, merged_outpu
150 f.write('SIGGEN_LOCKEDSIGS_TYPES = "%s"\n' % ' '.join(fulltypes)) 196 f.write('SIGGEN_LOCKEDSIGS_TYPES = "%s"\n' % ' '.join(fulltypes))
151 197
152 write_sigs_file(copy_output, tocopy.keys(), tocopy) 198 write_sigs_file(copy_output, tocopy.keys(), tocopy)
153 write_sigs_file(merged_output, arch_order, merged) 199 if merged_output:
200 write_sigs_file(merged_output, arch_order, merged)
154 201
155def create_locked_sstate_cache(lockedsigs, input_sstate_cache, output_sstate_cache, d, fixedlsbstring=""): 202def create_locked_sstate_cache(lockedsigs, input_sstate_cache, output_sstate_cache, d, fixedlsbstring=""):
156 bb.note('Generating sstate-cache...') 203 bb.note('Generating sstate-cache...')