blob: 87518d1767312cd57b4336602c78d71d71ee3ce1 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001# Extensible SDK
2
3inherit populate_sdk_base
4
5# NOTE: normally you cannot use task overrides for this kind of thing - this
6# only works because of get_sdk_ext_rdepends()
7
8TOOLCHAIN_HOST_TASK_task-populate-sdk-ext = " \
9 meta-environment-extsdk-${MACHINE} \
10 "
11
12TOOLCHAIN_TARGET_TASK_task-populate-sdk-ext = ""
13
14SDK_RDEPENDS_append_task-populate-sdk-ext = " ${SDK_TARGETS}"
15
16SDK_RELOCATE_AFTER_INSTALL_task-populate-sdk-ext = "0"
17
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050018SDK_EXT = ""
19SDK_EXT_task-populate-sdk-ext = "-ext"
20
21# Options are full or minimal
22SDK_EXT_TYPE ?= "full"
23
24SDK_RECRDEP_TASKS ?= ""
25
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026SDK_LOCAL_CONF_WHITELIST ?= ""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050027SDK_LOCAL_CONF_BLACKLIST ?= "CONF_VERSION \
28 BB_NUMBER_THREADS \
29 PARALLEL_MAKE \
30 PRSERV_HOST \
31 SSTATE_MIRRORS \
32 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033SDK_INHERIT_BLACKLIST ?= "buildhistory icecc"
34SDK_UPDATE_URL ?= ""
35
36SDK_TARGETS ?= "${PN}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050037
38def get_sdk_install_targets(d):
39 sdk_install_targets = ''
40 if d.getVar('SDK_EXT_TYPE', True) != 'minimal':
41 sdk_install_targets = d.getVar('SDK_TARGETS', True)
42
43 depd = d.getVar('BB_TASKDEPDATA', False)
44 for v in depd.itervalues():
45 if v[1] == 'do_image_complete':
46 if v[0] not in sdk_install_targets:
47 sdk_install_targets += ' {}'.format(v[0])
48
49 if d.getVar('SDK_INCLUDE_PKGDATA', True) == '1':
50 sdk_install_targets += ' meta-world-pkgdata:do_allpackagedata'
51
52 return sdk_install_targets
53
54get_sdk_install_targets[vardepsexclude] = "BB_TASKDEPDATA"
55
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056OE_INIT_ENV_SCRIPT ?= "oe-init-build-env"
57
58# The files from COREBASE that you want preserved in the COREBASE copied
59# into the sdk. This allows someone to have their own setup scripts in
60# COREBASE be preserved as well as untracked files.
61COREBASE_FILES ?= " \
62 oe-init-build-env \
63 oe-init-build-env-memres \
64 scripts \
65 LICENSE \
66 .templateconf \
67"
68
69SDK_DIR_task-populate-sdk-ext = "${WORKDIR}/sdk-ext"
70B_task-populate-sdk-ext = "${SDK_DIR}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050071TOOLCHAINEXT_OUTPUTNAME = "${SDK_NAME}-toolchain-ext-${SDK_VERSION}"
72TOOLCHAIN_OUTPUTNAME_task-populate-sdk-ext = "${TOOLCHAINEXT_OUTPUTNAME}"
73
74SDK_EXT_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"
75SDK_EXT_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050076
77SDK_TITLE_task-populate-sdk-ext = "${@d.getVar('DISTRO_NAME', True) or d.getVar('DISTRO', True)} Extensible SDK"
78
79python copy_buildsystem () {
80 import re
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050081 import shutil
82 import glob
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083 import oe.copy_buildsystem
84
85 oe_init_env_script = d.getVar('OE_INIT_ENV_SCRIPT', True)
86
87 conf_bbpath = ''
88 conf_initpath = ''
89 core_meta_subdir = ''
90
91 # Copy in all metadata layers + bitbake (as repositories)
Patrick Williamsf1e5d692016-03-30 15:21:19 -050092 buildsystem = oe.copy_buildsystem.BuildSystem('extensible SDK', d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093 baseoutpath = d.getVar('SDK_OUTPUT', True) + '/' + d.getVar('SDKPATH', True)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050094
95 # Determine if we're building a derivative extensible SDK (from devtool build-sdk)
96 derivative = (d.getVar('SDK_DERIVATIVE', True) or '') == '1'
97 if derivative:
98 workspace_name = 'orig-workspace'
99 else:
100 workspace_name = None
101 layers_copied = buildsystem.copy_bitbake_and_layers(baseoutpath + '/layers', workspace_name)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102
103 sdkbblayers = []
104 corebase = os.path.basename(d.getVar('COREBASE', True))
105 for layer in layers_copied:
106 if corebase == os.path.basename(layer):
107 conf_bbpath = os.path.join('layers', layer, 'bitbake')
108 else:
109 sdkbblayers.append(layer)
110
111 for path in os.listdir(baseoutpath + '/layers'):
112 relpath = os.path.join('layers', path, oe_init_env_script)
113 if os.path.exists(os.path.join(baseoutpath, relpath)):
114 conf_initpath = relpath
115
116 relpath = os.path.join('layers', path, 'scripts', 'devtool')
117 if os.path.exists(os.path.join(baseoutpath, relpath)):
118 scriptrelpath = os.path.dirname(relpath)
119
120 relpath = os.path.join('layers', path, 'meta')
121 if os.path.exists(os.path.join(baseoutpath, relpath, 'lib', 'oe')):
122 core_meta_subdir = relpath
123
124 d.setVar('oe_init_build_env_path', conf_initpath)
125 d.setVar('scriptrelpath', scriptrelpath)
126
127 # Write out config file for devtool
128 import ConfigParser
129 config = ConfigParser.SafeConfigParser()
130 config.add_section('General')
131 config.set('General', 'bitbake_subdir', conf_bbpath)
132 config.set('General', 'init_path', conf_initpath)
133 config.set('General', 'core_meta_subdir', core_meta_subdir)
134 config.add_section('SDK')
135 config.set('SDK', 'sdk_targets', d.getVar('SDK_TARGETS', True))
136 updateurl = d.getVar('SDK_UPDATE_URL', True)
137 if updateurl:
138 config.set('SDK', 'updateserver', updateurl)
139 bb.utils.mkdirhier(os.path.join(baseoutpath, 'conf'))
140 with open(os.path.join(baseoutpath, 'conf', 'devtool.conf'), 'w') as f:
141 config.write(f)
142
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500143 unlockedsigs = os.path.join(baseoutpath, 'conf', 'unlocked-sigs.inc')
144 with open(unlockedsigs, 'w') as f:
145 pass
146
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500147 # Create a layer for new recipes / appends
148 bbpath = d.getVar('BBPATH', True)
149 bb.process.run(['devtool', '--bbpath', bbpath, '--basepath', baseoutpath, 'create-workspace', '--create-only', os.path.join(baseoutpath, 'workspace')])
150
151 # Create bblayers.conf
152 bb.utils.mkdirhier(baseoutpath + '/conf')
153 with open(baseoutpath + '/conf/bblayers.conf', 'w') as f:
154 f.write('# WARNING: this configuration has been automatically generated and in\n')
155 f.write('# most cases should not be edited. If you need more flexibility than\n')
156 f.write('# this configuration provides, it is strongly suggested that you set\n')
157 f.write('# up a proper instance of the full build system and use that instead.\n\n')
158
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500159 # LCONF_VERSION may not be set, for example when using meta-poky
160 # so don't error if it isn't found
161 lconf_version = d.getVar('LCONF_VERSION', False)
162 if lconf_version is not None:
163 f.write('LCONF_VERSION = "%s"\n\n' % lconf_version)
164
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500165 f.write('BBPATH = "$' + '{TOPDIR}"\n')
166 f.write('SDKBASEMETAPATH = "$' + '{TOPDIR}"\n')
167 f.write('BBLAYERS := " \\\n')
168 for layerrelpath in sdkbblayers:
169 f.write(' $' + '{SDKBASEMETAPATH}/layers/%s \\\n' % layerrelpath)
170 f.write(' $' + '{SDKBASEMETAPATH}/workspace \\\n')
171 f.write(' "\n')
172
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500173 env_whitelist = (d.getVar('BB_ENV_EXTRAWHITE', True) or '').split()
174 env_whitelist_values = {}
175
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176 # Create local.conf
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177 builddir = d.getVar('TOPDIR', True)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500178 if derivative:
179 shutil.copyfile(builddir + '/conf/local.conf', baseoutpath + '/conf/local.conf')
180 else:
181 local_conf_whitelist = (d.getVar('SDK_LOCAL_CONF_WHITELIST', True) or '').split()
182 local_conf_blacklist = (d.getVar('SDK_LOCAL_CONF_BLACKLIST', True) or '').split()
183 def handle_var(varname, origvalue, op, newlines):
184 if varname in local_conf_blacklist or (origvalue.strip().startswith('/') and not varname in local_conf_whitelist):
185 newlines.append('# Removed original setting of %s\n' % varname)
186 return None, op, 0, True
187 else:
188 if varname in env_whitelist:
189 env_whitelist_values[varname] = origvalue
190 return origvalue, op, 0, True
191 varlist = ['[^#=+ ]*']
192 with open(builddir + '/conf/local.conf', 'r') as f:
193 oldlines = f.readlines()
194 (updated, newlines) = bb.utils.edit_metadata(oldlines, varlist, handle_var)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500195
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500196 with open(baseoutpath + '/conf/local.conf', 'w') as f:
197 f.write('# WARNING: this configuration has been automatically generated and in\n')
198 f.write('# most cases should not be edited. If you need more flexibility than\n')
199 f.write('# this configuration provides, it is strongly suggested that you set\n')
200 f.write('# up a proper instance of the full build system and use that instead.\n\n')
201 for line in newlines:
202 if line.strip() and not line.startswith('#'):
203 f.write(line)
204 # Write a newline just in case there's none at the end of the original
205 f.write('\n')
206
207 f.write('INHERIT += "%s"\n\n' % 'uninative')
208 f.write('CONF_VERSION = "%s"\n\n' % d.getVar('CONF_VERSION', False))
209
210 # Some classes are not suitable for SDK, remove them from INHERIT
211 f.write('INHERIT_remove = "%s"\n' % d.getVar('SDK_INHERIT_BLACKLIST', False))
212
213 # Bypass the default connectivity check if any
214 f.write('CONNECTIVITY_CHECK_URIS = ""\n\n')
215
216 # This warning will come out if reverse dependencies for a task
217 # don't have sstate as well as the task itself. We already know
218 # this will be the case for the extensible sdk, so turn off the
219 # warning.
220 f.write('SIGGEN_LOCKEDSIGS_SSTATE_EXISTS_CHECK = "none"\n\n')
221
222 # Error if the sigs in the locked-signature file don't match
223 # the sig computed from the metadata.
224 f.write('SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "error"\n\n')
225
226 # Hide the config information from bitbake output (since it's fixed within the SDK)
227 f.write('BUILDCFG_HEADER = ""\n')
228
229 # Allow additional config through sdk-extra.conf
230 fn = bb.cookerdata.findConfigFile('sdk-extra.conf', d)
231 if fn:
232 with open(fn, 'r') as xf:
233 for line in xf:
234 f.write(line)
235
236 # If you define a sdk_extraconf() function then it can contain additional config
237 # (Though this is awkward; sdk-extra.conf should probably be used instead)
238 extraconf = (d.getVar('sdk_extraconf', True) or '').strip()
239 if extraconf:
240 # Strip off any leading / trailing spaces
241 for line in extraconf.splitlines():
242 f.write(line.strip() + '\n')
243
244 f.write('require conf/locked-sigs.inc\n')
245 f.write('require conf/unlocked-sigs.inc\n')
246
247 if os.path.exists(builddir + '/conf/auto.conf'):
248 if derivative:
249 shutil.copyfile(builddir + '/conf/auto.conf', baseoutpath + '/conf/auto.conf')
250 else:
251 with open(builddir + '/conf/auto.conf', 'r') as f:
252 oldlines = f.readlines()
253 (updated, newlines) = bb.utils.edit_metadata(oldlines, varlist, handle_var)
254 with open(baseoutpath + '/conf/auto.conf', 'w') as f:
255 f.write('# WARNING: this configuration has been automatically generated and in\n')
256 f.write('# most cases should not be edited. If you need more flexibility than\n')
257 f.write('# this configuration provides, it is strongly suggested that you set\n')
258 f.write('# up a proper instance of the full build system and use that instead.\n\n')
259 for line in newlines:
260 if line.strip() and not line.startswith('#'):
261 f.write(line)
262
263 # Ensure any variables set from the external environment (by way of
264 # BB_ENV_EXTRAWHITE) are set in the SDK's configuration
265 extralines = []
266 for name, value in env_whitelist_values.iteritems():
267 actualvalue = d.getVar(name, True) or ''
268 if value != actualvalue:
269 extralines.append('%s = "%s"\n' % (name, actualvalue))
270 if extralines:
271 with open(baseoutpath + '/conf/local.conf', 'a') as f:
272 f.write('\n')
273 f.write('# Extra settings from environment:\n')
274 for line in extralines:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500275 f.write(line)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500276 f.write('\n')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500277
278 # Filter the locked signatures file to just the sstate tasks we are interested in
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500279 excluded_targets = d.getVar('SDK_TARGETS', True)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500280 sigfile = d.getVar('WORKDIR', True) + '/locked-sigs.inc'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500281 lockedsigs_pruned = baseoutpath + '/conf/locked-sigs.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500282 oe.copy_buildsystem.prune_lockedsigs([],
283 excluded_targets.split(),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500284 sigfile,
285 lockedsigs_pruned)
286
287 sstate_out = baseoutpath + '/sstate-cache'
288 bb.utils.remove(sstate_out, True)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500289 # uninative.bbclass sets NATIVELSBSTRING to 'universal'
290 fixedlsbstring = 'universal'
291
292 # Add packagedata if enabled
293 if d.getVar('SDK_INCLUDE_PKGDATA', True) == '1':
294 lockedsigs_base = d.getVar('WORKDIR', True) + '/locked-sigs-base.inc'
295 lockedsigs_copy = d.getVar('WORKDIR', True) + '/locked-sigs-copy.inc'
296 shutil.move(lockedsigs_pruned, lockedsigs_base)
297 oe.copy_buildsystem.merge_lockedsigs(['do_packagedata'],
298 lockedsigs_base,
299 d.getVar('STAGING_DIR_HOST', True) + '/world-pkgdata/locked-sigs-pkgdata.inc',
300 lockedsigs_pruned,
301 lockedsigs_copy)
302
303 if d.getVar('SDK_EXT_TYPE', True) == 'minimal':
304 if derivative:
305 # Assume the user is not going to set up an additional sstate
306 # mirror, thus we need to copy the additional artifacts (from
307 # workspace recipes) into the derivative SDK
308 lockedsigs_orig = d.getVar('TOPDIR', True) + '/conf/locked-sigs.inc'
309 if os.path.exists(lockedsigs_orig):
310 lockedsigs_extra = d.getVar('WORKDIR', True) + '/locked-sigs-extra.inc'
311 oe.copy_buildsystem.merge_lockedsigs(None,
312 lockedsigs_orig,
313 lockedsigs_pruned,
314 None,
315 lockedsigs_extra)
316 oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_extra,
317 d.getVar('SSTATE_DIR', True),
318 sstate_out, d,
319 fixedlsbstring)
320 else:
321 oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_pruned,
322 d.getVar('SSTATE_DIR', True),
323 sstate_out, d,
324 fixedlsbstring)
325
326 # We don't need sstate do_package files
327 for root, dirs, files in os.walk(sstate_out):
328 for name in files:
329 if name.endswith("_package.tgz"):
330 f = os.path.join(root, name)
331 os.remove(f)
332
333 # Write manifest file
334 # Note: at the moment we cannot include the env setup script here to keep
335 # it updated, since it gets modified during SDK installation (see
336 # sdk_ext_postinst() below) thus the checksum we take here would always
337 # be different.
338 manifest_file_list = ['conf/*']
339 manifest_file = os.path.join(baseoutpath, 'conf', 'sdk-conf-manifest')
340 with open(manifest_file, 'w') as f:
341 for item in manifest_file_list:
342 for fn in glob.glob(os.path.join(baseoutpath, item)):
343 if fn == manifest_file:
344 continue
345 chksum = bb.utils.sha256_file(fn)
346 f.write('%s\t%s\n' % (chksum, os.path.relpath(fn, baseoutpath)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500347}
348
349def extsdk_get_buildtools_filename(d):
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500350 return '*-buildtools-nativesdk-standalone-*.sh'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500351
352install_tools() {
353 install -d ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}
354 lnr ${SDK_OUTPUT}/${SDKPATH}/${scriptrelpath}/devtool ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}/devtool
355 lnr ${SDK_OUTPUT}/${SDKPATH}/${scriptrelpath}/recipetool ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}/recipetool
356 touch ${SDK_OUTPUT}/${SDKPATH}/.devtoolbase
357
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500358 localconf=${SDK_OUTPUT}/${SDKPATH}/conf/local.conf
359
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500360 # find latest buildtools-tarball and install it
361 buildtools_path=`ls -t1 ${SDK_DEPLOY}/${@extsdk_get_buildtools_filename(d)} | head -n1`
362 install $buildtools_path ${SDK_OUTPUT}/${SDKPATH}
363
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500364 # For now this is where uninative.bbclass expects the tarball
365 chksum=`sha256sum ${SDK_DEPLOY}/${BUILD_ARCH}-nativesdk-libc.tar.bz2 | cut -f 1 -d ' '`
366 install -d ${SDK_OUTPUT}/${SDKPATH}/downloads/uninative/$chksum/
367 install ${SDK_DEPLOY}/${BUILD_ARCH}-nativesdk-libc.tar.bz2 ${SDK_OUTPUT}/${SDKPATH}/downloads/uninative/$chksum/
368 echo "UNINATIVE_CHECKSUM[${BUILD_ARCH}] = '$chksum'" >> ${SDK_OUTPUT}/${SDKPATH}/conf/local.conf
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500369
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500370 install -m 0644 ${COREBASE}/meta/files/ext-sdk-prepare.py ${SDK_OUTPUT}/${SDKPATH}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500371}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500372do_populate_sdk_ext[file-checksums] += "${COREBASE}/meta/files/ext-sdk-prepare.py:True"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500373
374# Since bitbake won't run as root it doesn't make sense to try and install
375# the extensible sdk as root.
376sdk_ext_preinst() {
377 if [ "`id -u`" = "0" ]; then
378 echo "ERROR: The extensible sdk cannot be installed as root."
379 exit 1
380 fi
381 SDK_EXTENSIBLE="1"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500382 if [ "$publish" = "1" ] ; then
383 EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=ext-sdk-prepare.py"
384 if [ "${SDK_EXT_TYPE}" = "minimal" ] ; then
385 EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=sstate-cache"
386 fi
387 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500388}
389SDK_PRE_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_preinst}"
390
391# FIXME this preparation should be done as part of the SDK construction
392sdk_ext_postinst() {
393 printf "\nExtracting buildtools...\n"
394 cd $target_sdk_dir
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500395 printf "buildtools\ny" | ./*buildtools-nativesdk-standalone* > /dev/null || ( printf 'ERROR: buildtools installation failed\n' ; exit 1 )
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500396
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500397 # Delete the buildtools tar file since it won't be used again
398 rm ./*buildtools-nativesdk-standalone*.sh -f
399
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500400 # Make sure when the user sets up the environment, they also get
401 # the buildtools-tarball tools in their path.
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500402 env_setup_script="$target_sdk_dir/environment-setup-${REAL_MULTIMACH_TARGET_SYS}"
403 echo ". $target_sdk_dir/buildtools/environment-setup*" >> $env_setup_script
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500404
405 # Allow bitbake environment setup to be ran as part of this sdk.
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500406 echo "export OE_SKIP_SDK_CHECK=1" >> $env_setup_script
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500407
408 # A bit of another hack, but we need this in the path only for devtool
409 # so put it at the end of $PATH.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500410 echo "export PATH=$target_sdk_dir/sysroots/${SDK_SYS}${bindir_nativesdk}:\$PATH" >> $env_setup_script
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500411
412 echo "printf 'SDK environment now set up; additionally you may now run devtool to perform development tasks.\nRun devtool --help for further details.\n'" >> $env_setup_script
413
414 # Warn if trying to use external bitbake and the ext SDK together
415 echo "(which bitbake > /dev/null 2>&1 && echo 'WARNING: attempting to use the extensible SDK in an environment set up to run bitbake - this may lead to unexpected results. Please source this script in a new shell session instead.') || true" >> $env_setup_script
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500416
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500417 if [ "$prepare_buildsystem" != "no" ]; then
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500418 printf "Preparing build system...\n"
419 # dash which is /bin/sh on Ubuntu will not preserve the
420 # current working directory when first ran, nor will it set $1 when
421 # sourcing a script. That is why this has to look so ugly.
422 LOGFILE="$target_sdk_dir/preparing_build_system.log"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500423 sh -c ". buildtools/environment-setup* > $LOGFILE && cd $target_sdk_dir/`dirname ${oe_init_build_env_path}` && set $target_sdk_dir && . $target_sdk_dir/${oe_init_build_env_path} $target_sdk_dir >> $LOGFILE && python $target_sdk_dir/ext-sdk-prepare.py '${SDK_INSTALL_TARGETS}' >> $LOGFILE 2>&1" || { echo "ERROR: SDK preparation failed: see $LOGFILE"; echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; }
424 rm $target_sdk_dir/ext-sdk-prepare.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500425 fi
426 echo done
427}
428
429SDK_POST_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_postinst}"
430
431SDK_POSTPROCESS_COMMAND_prepend_task-populate-sdk-ext = "copy_buildsystem; install_tools; "
432
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500433SDK_INSTALL_TARGETS = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500434fakeroot python do_populate_sdk_ext() {
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500435 # FIXME hopefully we can remove this restriction at some point, but uninative
436 # currently forces this upon us
437 if d.getVar('SDK_ARCH', True) != d.getVar('BUILD_ARCH', True):
438 bb.fatal('The extensible SDK can currently only be built for the same architecture as the machine being built on - SDK_ARCH is set to %s (likely via setting SDKMACHINE) which is different from the architecture of the build machine (%s). Unable to continue.' % (d.getVar('SDK_ARCH', True), d.getVar('BUILD_ARCH', True)))
439
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500440 d.setVar('SDK_INSTALL_TARGETS', get_sdk_install_targets(d))
441
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500442 bb.build.exec_func("do_populate_sdk", d)
443}
444
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500445def get_ext_sdk_depends(d):
446 return d.getVarFlag('do_rootfs', 'depends', True) + ' ' + d.getVarFlag('do_build', 'depends', True)
447
448python do_sdk_depends() {
449 # We have to do this separately in its own task so we avoid recursing into
450 # dependencies we don't need to (e.g. buildtools-tarball) and bringing those
451 # into the SDK's sstate-cache
452 import oe.copy_buildsystem
453 sigfile = d.getVar('WORKDIR', True) + '/locked-sigs.inc'
454 oe.copy_buildsystem.generate_locked_sigs(sigfile, d)
455}
456addtask sdk_depends
457
458do_sdk_depends[dirs] = "${WORKDIR}"
459do_sdk_depends[depends] = "${@get_ext_sdk_depends(d)}"
460do_sdk_depends[recrdeptask] = "${@d.getVarFlag('do_populate_sdk', 'recrdeptask', False)}"
461do_sdk_depends[recrdeptask] += "do_populate_lic do_package_qa do_populate_sysroot do_deploy ${SDK_RECRDEP_TASKS}"
462do_sdk_depends[rdepends] = "${@get_sdk_ext_rdepends(d)}"
463
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500464def get_sdk_ext_rdepends(d):
465 localdata = d.createCopy()
466 localdata.appendVar('OVERRIDES', ':task-populate-sdk-ext')
467 bb.data.update_data(localdata)
468 return localdata.getVarFlag('do_populate_sdk', 'rdepends', True)
469
470do_populate_sdk_ext[dirs] = "${@d.getVarFlag('do_populate_sdk', 'dirs', False)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500471
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500472do_populate_sdk_ext[depends] = "${@d.getVarFlag('do_populate_sdk', 'depends', False)} \
473 buildtools-tarball:do_populate_sdk uninative-tarball:do_populate_sdk \
474 ${@'meta-world-pkgdata:do_collect_packagedata' if d.getVar('SDK_INCLUDE_PKGDATA', True) == '1' else ''}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500475
476do_populate_sdk_ext[rdepends] += "${@' '.join([x + ':do_build' for x in d.getVar('SDK_TARGETS', True).split()])}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500477
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500478# Make sure code changes can result in rebuild
479do_populate_sdk_ext[vardeps] += "copy_buildsystem \
480 sdk_ext_postinst"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500481
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500482# Since any change in the metadata of any layer should cause a rebuild of the
483# sdk(since the layers are put in the sdk) set the task to nostamp so it
484# always runs.
485do_populate_sdk_ext[nostamp] = "1"
486
487addtask populate_sdk_ext after do_sdk_depends