blob: c79ddbbb81edb11a7725068b63abf4e6566039e4 [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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014SDK_RELOCATE_AFTER_INSTALL_task-populate-sdk-ext = "0"
15
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050016SDK_EXT = ""
17SDK_EXT_task-populate-sdk-ext = "-ext"
18
19# Options are full or minimal
20SDK_EXT_TYPE ?= "full"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021SDK_INCLUDE_PKGDATA ?= "0"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050022SDK_INCLUDE_TOOLCHAIN ?= "${@'1' if d.getVar('SDK_EXT_TYPE') == 'full' else '0'}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050023
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 \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060029 BB_NUMBER_PARSE_THREADS \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050030 PARALLEL_MAKE \
31 PRSERV_HOST \
32 SSTATE_MIRRORS \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 DL_DIR \
34 SSTATE_DIR \
35 TMPDIR \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036 BB_SERVER_TIMEOUT \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050037 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038SDK_INHERIT_BLACKLIST ?= "buildhistory icecc"
39SDK_UPDATE_URL ?= ""
40
41SDK_TARGETS ?= "${PN}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050042
Patrick Williamsc0f7c042017-02-23 20:41:17 -060043def get_sdk_install_targets(d, images_only=False):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044 sdk_install_targets = ''
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045 if images_only or d.getVar('SDK_EXT_TYPE') != 'minimal':
46 sdk_install_targets = d.getVar('SDK_TARGETS')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050047
48 depd = d.getVar('BB_TASKDEPDATA', False)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049 tasklist = bb.build.tasksbetween('do_image_complete', 'do_build', d)
50 tasklist.remove('do_build')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060051 for v in depd.values():
Brad Bishop6e60e8b2018-02-01 10:27:11 -050052 if v[1] in tasklist:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050053 if v[0] not in sdk_install_targets:
54 sdk_install_targets += ' {}'.format(v[0])
55
Patrick Williamsc0f7c042017-02-23 20:41:17 -060056 if not images_only:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057 if d.getVar('SDK_INCLUDE_PKGDATA') == '1':
Patrick Williamsc0f7c042017-02-23 20:41:17 -060058 sdk_install_targets += ' meta-world-pkgdata:do_allpackagedata'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050059 if d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1':
Patrick Williamsc0f7c042017-02-23 20:41:17 -060060 sdk_install_targets += ' meta-extsdk-toolchain:do_populate_sysroot'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050061
62 return sdk_install_targets
63
64get_sdk_install_targets[vardepsexclude] = "BB_TASKDEPDATA"
65
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066OE_INIT_ENV_SCRIPT ?= "oe-init-build-env"
67
68# The files from COREBASE that you want preserved in the COREBASE copied
69# into the sdk. This allows someone to have their own setup scripts in
70# COREBASE be preserved as well as untracked files.
71COREBASE_FILES ?= " \
72 oe-init-build-env \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073 scripts \
74 LICENSE \
75 .templateconf \
76"
77
78SDK_DIR_task-populate-sdk-ext = "${WORKDIR}/sdk-ext"
79B_task-populate-sdk-ext = "${SDK_DIR}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050080TOOLCHAINEXT_OUTPUTNAME ?= "${SDK_NAME}-toolchain-ext-${SDK_VERSION}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050081TOOLCHAIN_OUTPUTNAME_task-populate-sdk-ext = "${TOOLCHAINEXT_OUTPUTNAME}"
82
83SDK_EXT_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"
84SDK_EXT_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085
Brad Bishopd7bf8c12018-02-25 22:55:05 -050086python write_target_sdk_ext_manifest () {
87 from oe.sdk import get_extra_sdkinfo
88 sstate_dir = d.expand('${SDK_OUTPUT}/${SDKPATH}/sstate-cache')
89 extra_info = get_extra_sdkinfo(sstate_dir)
90
91 target = d.getVar('TARGET_SYS')
92 target_multimach = d.getVar('MULTIMACH_TARGET_SYS')
93 real_target_multimach = d.getVar('REAL_MULTIMACH_TARGET_SYS')
94
95 pkgs = {}
96 with open(d.getVar('SDK_EXT_TARGET_MANIFEST'), 'w') as f:
97 for fn in extra_info['filesizes']:
98 info = fn.split(':')
99 if info[2] in (target, target_multimach, real_target_multimach) \
100 or info[5] == 'allarch':
101 if not info[1] in pkgs:
102 f.write("%s %s %s\n" % (info[1], info[2], info[3]))
103 pkgs[info[1]] = {}
104}
105python write_host_sdk_ext_manifest () {
106 from oe.sdk import get_extra_sdkinfo
107 sstate_dir = d.expand('${SDK_OUTPUT}/${SDKPATH}/sstate-cache')
108 extra_info = get_extra_sdkinfo(sstate_dir)
109 host = d.getVar('BUILD_SYS')
110 with open(d.getVar('SDK_EXT_HOST_MANIFEST'), 'w') as f:
111 for fn in extra_info['filesizes']:
112 info = fn.split(':')
113 if info[2] == host:
114 f.write("%s %s %s\n" % (info[1], info[2], info[3]))
115}
116
117SDK_POSTPROCESS_COMMAND_append_task-populate-sdk-ext = "write_target_sdk_ext_manifest; write_host_sdk_ext_manifest; "
118
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500119SDK_TITLE_task-populate-sdk-ext = "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} Extensible SDK"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500120
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600121def clean_esdk_builddir(d, sdkbasepath):
122 """Clean up traces of the fake build for create_filtered_tasklist()"""
123 import shutil
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500124 cleanpaths = 'cache conf/sanity_info tmp'.split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600125 for pth in cleanpaths:
126 fullpth = os.path.join(sdkbasepath, pth)
127 if os.path.isdir(fullpth):
128 shutil.rmtree(fullpth)
129 elif os.path.isfile(fullpth):
130 os.remove(fullpth)
131
132def create_filtered_tasklist(d, sdkbasepath, tasklistfile, conf_initpath):
133 """
134 Create a filtered list of tasks. Also double-checks that the build system
135 within the SDK basically works and required sstate artifacts are available.
136 """
137 import tempfile
138 import shutil
139 import oe.copy_buildsystem
140
141 # Create a temporary build directory that we can pass to the env setup script
142 shutil.copyfile(sdkbasepath + '/conf/local.conf', sdkbasepath + '/conf/local.conf.bak')
143 try:
144 with open(sdkbasepath + '/conf/local.conf', 'a') as f:
145 # Force the use of sstate from the build system
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500146 f.write('\nSSTATE_DIR_forcevariable = "%s"\n' % d.getVar('SSTATE_DIR'))
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500147 f.write('SSTATE_MIRRORS_forcevariable = "file://universal/(.*) file://universal-4.9/\\1 file://universal-4.9/(.*) file://universal-4.8/\\1"\n')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600148 # Ensure TMPDIR is the default so that clean_esdk_builddir() can delete it
149 f.write('TMPDIR_forcevariable = "${TOPDIR}/tmp"\n')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500150 f.write('TCLIBCAPPEND_forcevariable = ""\n')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600151 # Drop uninative if the build isn't using it (or else NATIVELSBSTRING will
152 # be different and we won't be able to find our native sstate)
153 if not bb.data.inherits_class('uninative', d):
154 f.write('INHERIT_remove = "uninative"\n')
155
156 # Unfortunately the default SDKPATH (or even a custom value) may contain characters that bitbake
157 # will not allow in its COREBASE path, so we need to rename the directory temporarily
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500158 temp_sdkbasepath = d.getVar('SDK_OUTPUT') + '/tmp-renamed-sdk'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600159 # Delete any existing temp dir
160 try:
161 shutil.rmtree(temp_sdkbasepath)
162 except FileNotFoundError:
163 pass
164 os.rename(sdkbasepath, temp_sdkbasepath)
165 try:
166 cmdprefix = '. %s .; ' % conf_initpath
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500167 logfile = d.getVar('WORKDIR') + '/tasklist_bb_log.txt'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600168 try:
169 oe.copy_buildsystem.check_sstate_task_list(d, get_sdk_install_targets(d), tasklistfile, cmdprefix=cmdprefix, cwd=temp_sdkbasepath, logfile=logfile)
170 except bb.process.ExecutionError as e:
171 msg = 'Failed to generate filtered task list for extensible SDK:\n%s' % e.stdout.rstrip()
172 if 'attempted to execute unexpectedly and should have been setscened' in e.stdout:
173 msg += '\n----------\n\nNOTE: "attempted to execute unexpectedly and should have been setscened" errors indicate this may be caused by missing sstate artifacts that were likely produced in earlier builds, but have been subsequently deleted for some reason.\n'
174 bb.fatal(msg)
175 finally:
176 os.rename(temp_sdkbasepath, sdkbasepath)
177 # Clean out residue of running bitbake, which check_sstate_task_list()
178 # will effectively do
179 clean_esdk_builddir(d, sdkbasepath)
180 finally:
181 os.replace(sdkbasepath + '/conf/local.conf.bak', sdkbasepath + '/conf/local.conf')
182
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500183python copy_buildsystem () {
184 import re
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500185 import shutil
186 import glob
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500187 import oe.copy_buildsystem
188
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500189 oe_init_env_script = d.getVar('OE_INIT_ENV_SCRIPT')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500190
191 conf_bbpath = ''
192 conf_initpath = ''
193 core_meta_subdir = ''
194
195 # Copy in all metadata layers + bitbake (as repositories)
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500196 buildsystem = oe.copy_buildsystem.BuildSystem('extensible SDK', d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500197 baseoutpath = d.getVar('SDK_OUTPUT') + '/' + d.getVar('SDKPATH')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500198
199 # Determine if we're building a derivative extensible SDK (from devtool build-sdk)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500200 derivative = (d.getVar('SDK_DERIVATIVE') or '') == '1'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500201 if derivative:
202 workspace_name = 'orig-workspace'
203 else:
204 workspace_name = None
205 layers_copied = buildsystem.copy_bitbake_and_layers(baseoutpath + '/layers', workspace_name)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500206
207 sdkbblayers = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500208 corebase = os.path.basename(d.getVar('COREBASE'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500209 for layer in layers_copied:
210 if corebase == os.path.basename(layer):
211 conf_bbpath = os.path.join('layers', layer, 'bitbake')
212 else:
213 sdkbblayers.append(layer)
214
215 for path in os.listdir(baseoutpath + '/layers'):
216 relpath = os.path.join('layers', path, oe_init_env_script)
217 if os.path.exists(os.path.join(baseoutpath, relpath)):
218 conf_initpath = relpath
219
220 relpath = os.path.join('layers', path, 'scripts', 'devtool')
221 if os.path.exists(os.path.join(baseoutpath, relpath)):
222 scriptrelpath = os.path.dirname(relpath)
223
224 relpath = os.path.join('layers', path, 'meta')
225 if os.path.exists(os.path.join(baseoutpath, relpath, 'lib', 'oe')):
226 core_meta_subdir = relpath
227
228 d.setVar('oe_init_build_env_path', conf_initpath)
229 d.setVar('scriptrelpath', scriptrelpath)
230
231 # Write out config file for devtool
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600232 import configparser
233 config = configparser.SafeConfigParser()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500234 config.add_section('General')
235 config.set('General', 'bitbake_subdir', conf_bbpath)
236 config.set('General', 'init_path', conf_initpath)
237 config.set('General', 'core_meta_subdir', core_meta_subdir)
238 config.add_section('SDK')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500239 config.set('SDK', 'sdk_targets', d.getVar('SDK_TARGETS'))
240 updateurl = d.getVar('SDK_UPDATE_URL')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500241 if updateurl:
242 config.set('SDK', 'updateserver', updateurl)
243 bb.utils.mkdirhier(os.path.join(baseoutpath, 'conf'))
244 with open(os.path.join(baseoutpath, 'conf', 'devtool.conf'), 'w') as f:
245 config.write(f)
246
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500247 unlockedsigs = os.path.join(baseoutpath, 'conf', 'unlocked-sigs.inc')
248 with open(unlockedsigs, 'w') as f:
249 pass
250
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500251 # Create a layer for new recipes / appends
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500252 bbpath = d.getVar('BBPATH')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500253 bb.process.run(['devtool', '--bbpath', bbpath, '--basepath', baseoutpath, 'create-workspace', '--create-only', os.path.join(baseoutpath, 'workspace')])
254
255 # Create bblayers.conf
256 bb.utils.mkdirhier(baseoutpath + '/conf')
257 with open(baseoutpath + '/conf/bblayers.conf', 'w') as f:
258 f.write('# WARNING: this configuration has been automatically generated and in\n')
259 f.write('# most cases should not be edited. If you need more flexibility than\n')
260 f.write('# this configuration provides, it is strongly suggested that you set\n')
261 f.write('# up a proper instance of the full build system and use that instead.\n\n')
262
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500263 # LCONF_VERSION may not be set, for example when using meta-poky
264 # so don't error if it isn't found
265 lconf_version = d.getVar('LCONF_VERSION', False)
266 if lconf_version is not None:
267 f.write('LCONF_VERSION = "%s"\n\n' % lconf_version)
268
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500269 f.write('BBPATH = "$' + '{TOPDIR}"\n')
270 f.write('SDKBASEMETAPATH = "$' + '{TOPDIR}"\n')
271 f.write('BBLAYERS := " \\\n')
272 for layerrelpath in sdkbblayers:
273 f.write(' $' + '{SDKBASEMETAPATH}/layers/%s \\\n' % layerrelpath)
274 f.write(' $' + '{SDKBASEMETAPATH}/workspace \\\n')
275 f.write(' "\n')
276
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600277 # Copy uninative tarball
278 # For now this is where uninative.bbclass expects the tarball
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500279 if bb.data.inherits_class('uninative', d):
280 uninative_file = d.expand('${UNINATIVE_DLDIR}/' + d.getVarFlag("UNINATIVE_CHECKSUM", d.getVar("BUILD_ARCH")) + '/${UNINATIVE_TARBALL}')
281 uninative_checksum = bb.utils.sha256_file(uninative_file)
282 uninative_outdir = '%s/downloads/uninative/%s' % (baseoutpath, uninative_checksum)
283 bb.utils.mkdirhier(uninative_outdir)
284 shutil.copy(uninative_file, uninative_outdir)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600285
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500286 env_whitelist = (d.getVar('BB_ENV_EXTRAWHITE') or '').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500287 env_whitelist_values = {}
288
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500289 # Create local.conf
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500290 builddir = d.getVar('TOPDIR')
291 if derivative and os.path.exists(builddir + '/conf/auto.conf'):
292 shutil.copyfile(builddir + '/conf/auto.conf', baseoutpath + '/conf/auto.conf')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500293 if derivative:
294 shutil.copyfile(builddir + '/conf/local.conf', baseoutpath + '/conf/local.conf')
295 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500296 local_conf_whitelist = (d.getVar('SDK_LOCAL_CONF_WHITELIST') or '').split()
297 local_conf_blacklist = (d.getVar('SDK_LOCAL_CONF_BLACKLIST') or '').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500298 def handle_var(varname, origvalue, op, newlines):
299 if varname in local_conf_blacklist or (origvalue.strip().startswith('/') and not varname in local_conf_whitelist):
300 newlines.append('# Removed original setting of %s\n' % varname)
301 return None, op, 0, True
302 else:
303 if varname in env_whitelist:
304 env_whitelist_values[varname] = origvalue
305 return origvalue, op, 0, True
306 varlist = ['[^#=+ ]*']
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500307 oldlines = []
308 if os.path.exists(builddir + '/conf/auto.conf'):
309 with open(builddir + '/conf/auto.conf', 'r') as f:
310 oldlines += f.readlines()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500311 with open(builddir + '/conf/local.conf', 'r') as f:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500312 oldlines += f.readlines()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500313 (updated, newlines) = bb.utils.edit_metadata(oldlines, varlist, handle_var)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500314
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500315 with open(baseoutpath + '/conf/local.conf', 'w') as f:
316 f.write('# WARNING: this configuration has been automatically generated and in\n')
317 f.write('# most cases should not be edited. If you need more flexibility than\n')
318 f.write('# this configuration provides, it is strongly suggested that you set\n')
319 f.write('# up a proper instance of the full build system and use that instead.\n\n')
320 for line in newlines:
321 if line.strip() and not line.startswith('#'):
322 f.write(line)
323 # Write a newline just in case there's none at the end of the original
324 f.write('\n')
325
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500326 f.write('TMPDIR = "${TOPDIR}/tmp"\n')
327 f.write('TCLIBCAPPEND = ""\n')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600328 f.write('DL_DIR = "${TOPDIR}/downloads"\n')
329
330 f.write('INHERIT += "%s"\n' % 'uninative')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500331 f.write('UNINATIVE_CHECKSUM[%s] = "%s"\n\n' % (d.getVar('BUILD_ARCH'), uninative_checksum))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500332 f.write('CONF_VERSION = "%s"\n\n' % d.getVar('CONF_VERSION', False))
333
334 # Some classes are not suitable for SDK, remove them from INHERIT
335 f.write('INHERIT_remove = "%s"\n' % d.getVar('SDK_INHERIT_BLACKLIST', False))
336
337 # Bypass the default connectivity check if any
338 f.write('CONNECTIVITY_CHECK_URIS = ""\n\n')
339
340 # This warning will come out if reverse dependencies for a task
341 # don't have sstate as well as the task itself. We already know
342 # this will be the case for the extensible sdk, so turn off the
343 # warning.
344 f.write('SIGGEN_LOCKEDSIGS_SSTATE_EXISTS_CHECK = "none"\n\n')
345
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600346 # Warn if the sigs in the locked-signature file don't match
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500347 # the sig computed from the metadata.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600348 f.write('SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "warn"\n\n')
349
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500350 # We want to be able to set this without a full reparse
351 f.write('BB_HASHCONFIG_WHITELIST_append = " SIGGEN_UNLOCKED_RECIPES"\n\n')
352
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600353 # Set up whitelist for run on install
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500354 f.write('BB_SETSCENE_ENFORCE_WHITELIST = "%:* *:do_shared_workdir *:do_rm_work wic-tools:* *:do_addto_recipe_sysroot"\n\n')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500355
356 # Hide the config information from bitbake output (since it's fixed within the SDK)
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500357 f.write('BUILDCFG_HEADER = ""\n\n')
358
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500359 f.write('# Provide a flag to indicate we are in the EXT_SDK Context\n')
360 f.write('WITHIN_EXT_SDK = "1"\n\n')
361
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500362 # Map gcc-dependent uninative sstate cache for installer usage
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500363 f.write('SSTATE_MIRRORS += " file://universal/(.*) file://universal-4.9/\\1 file://universal-4.9/(.*) file://universal-4.8/\\1"\n\n')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500364
365 # Allow additional config through sdk-extra.conf
366 fn = bb.cookerdata.findConfigFile('sdk-extra.conf', d)
367 if fn:
368 with open(fn, 'r') as xf:
369 for line in xf:
370 f.write(line)
371
372 # If you define a sdk_extraconf() function then it can contain additional config
373 # (Though this is awkward; sdk-extra.conf should probably be used instead)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500374 extraconf = (d.getVar('sdk_extraconf') or '').strip()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500375 if extraconf:
376 # Strip off any leading / trailing spaces
377 for line in extraconf.splitlines():
378 f.write(line.strip() + '\n')
379
380 f.write('require conf/locked-sigs.inc\n')
381 f.write('require conf/unlocked-sigs.inc\n')
382
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500383 # Write a templateconf.cfg
384 with open(baseoutpath + '/conf/templateconf.cfg', 'w') as f:
385 f.write('meta/conf\n')
386
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500387 # Ensure any variables set from the external environment (by way of
388 # BB_ENV_EXTRAWHITE) are set in the SDK's configuration
389 extralines = []
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600390 for name, value in env_whitelist_values.items():
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500391 actualvalue = d.getVar(name) or ''
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500392 if value != actualvalue:
393 extralines.append('%s = "%s"\n' % (name, actualvalue))
394 if extralines:
395 with open(baseoutpath + '/conf/local.conf', 'a') as f:
396 f.write('\n')
397 f.write('# Extra settings from environment:\n')
398 for line in extralines:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500399 f.write(line)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500400 f.write('\n')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500401
402 # Filter the locked signatures file to just the sstate tasks we are interested in
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600403 excluded_targets = get_sdk_install_targets(d, images_only=True)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500404 sigfile = d.getVar('WORKDIR') + '/locked-sigs.inc'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500405 lockedsigs_pruned = baseoutpath + '/conf/locked-sigs.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500406 oe.copy_buildsystem.prune_lockedsigs([],
407 excluded_targets.split(),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500408 sigfile,
409 lockedsigs_pruned)
410
411 sstate_out = baseoutpath + '/sstate-cache'
412 bb.utils.remove(sstate_out, True)
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500413
414 # uninative.bbclass sets NATIVELSBSTRING to 'universal%s' % oe.utils.host_gcc_version(d)
415 fixedlsbstring = "universal%s" % oe.utils.host_gcc_version(d)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500416
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500417 sdk_include_toolchain = (d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1')
418 sdk_ext_type = d.getVar('SDK_EXT_TYPE')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600419 if sdk_ext_type != 'minimal' or sdk_include_toolchain or derivative:
420 # Create the filtered task list used to generate the sstate cache shipped with the SDK
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500421 tasklistfn = d.getVar('WORKDIR') + '/tasklist.txt'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600422 create_filtered_tasklist(d, baseoutpath, tasklistfn, conf_initpath)
423 else:
424 tasklistfn = None
425
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500426 # Add packagedata if enabled
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500427 if d.getVar('SDK_INCLUDE_PKGDATA') == '1':
428 lockedsigs_base = d.getVar('WORKDIR') + '/locked-sigs-base.inc'
429 lockedsigs_copy = d.getVar('WORKDIR') + '/locked-sigs-copy.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500430 shutil.move(lockedsigs_pruned, lockedsigs_base)
431 oe.copy_buildsystem.merge_lockedsigs(['do_packagedata'],
432 lockedsigs_base,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500433 d.getVar('STAGING_DIR_HOST') + '/world-pkgdata/locked-sigs-pkgdata.inc',
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500434 lockedsigs_pruned,
435 lockedsigs_copy)
436
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600437 if sdk_include_toolchain:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500438 lockedsigs_base = d.getVar('WORKDIR') + '/locked-sigs-base2.inc'
439 lockedsigs_toolchain = d.expand("${STAGING_DIR}/${TUNE_PKGARCH}/meta-extsdk-toolchain/locked-sigs/locked-sigs-extsdk-toolchain.inc")
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600440 shutil.move(lockedsigs_pruned, lockedsigs_base)
441 oe.copy_buildsystem.merge_lockedsigs([],
442 lockedsigs_base,
443 lockedsigs_toolchain,
444 lockedsigs_pruned)
445 oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_toolchain,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500446 d.getVar('SSTATE_DIR'),
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600447 sstate_out, d,
448 fixedlsbstring,
449 filterfile=tasklistfn)
450
451 if sdk_ext_type == 'minimal':
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500452 if derivative:
453 # Assume the user is not going to set up an additional sstate
454 # mirror, thus we need to copy the additional artifacts (from
455 # workspace recipes) into the derivative SDK
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500456 lockedsigs_orig = d.getVar('TOPDIR') + '/conf/locked-sigs.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500457 if os.path.exists(lockedsigs_orig):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500458 lockedsigs_extra = d.getVar('WORKDIR') + '/locked-sigs-extra.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500459 oe.copy_buildsystem.merge_lockedsigs(None,
460 lockedsigs_orig,
461 lockedsigs_pruned,
462 None,
463 lockedsigs_extra)
464 oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_extra,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500465 d.getVar('SSTATE_DIR'),
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500466 sstate_out, d,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600467 fixedlsbstring,
468 filterfile=tasklistfn)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500469 else:
470 oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_pruned,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500471 d.getVar('SSTATE_DIR'),
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500472 sstate_out, d,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600473 fixedlsbstring,
474 filterfile=tasklistfn)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500475
476 # We don't need sstate do_package files
477 for root, dirs, files in os.walk(sstate_out):
478 for name in files:
479 if name.endswith("_package.tgz"):
480 f = os.path.join(root, name)
481 os.remove(f)
482
483 # Write manifest file
484 # Note: at the moment we cannot include the env setup script here to keep
485 # it updated, since it gets modified during SDK installation (see
486 # sdk_ext_postinst() below) thus the checksum we take here would always
487 # be different.
488 manifest_file_list = ['conf/*']
489 manifest_file = os.path.join(baseoutpath, 'conf', 'sdk-conf-manifest')
490 with open(manifest_file, 'w') as f:
491 for item in manifest_file_list:
492 for fn in glob.glob(os.path.join(baseoutpath, item)):
493 if fn == manifest_file:
494 continue
495 chksum = bb.utils.sha256_file(fn)
496 f.write('%s\t%s\n' % (chksum, os.path.relpath(fn, baseoutpath)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500497}
498
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600499def get_current_buildtools(d):
500 """Get the file name of the current buildtools installer"""
501 import glob
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500502 btfiles = glob.glob(os.path.join(d.getVar('SDK_DEPLOY'), '*-buildtools-nativesdk-standalone-*.sh'))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600503 btfiles.sort(key=os.path.getctime)
504 return os.path.basename(btfiles[-1])
505
506def get_sdk_required_utilities(buildtools_fn, d):
507 """Find required utilities that aren't provided by the buildtools"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500508 sanity_required_utilities = (d.getVar('SANITY_REQUIRED_UTILITIES') or '').split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600509 sanity_required_utilities.append(d.expand('${BUILD_PREFIX}gcc'))
510 sanity_required_utilities.append(d.expand('${BUILD_PREFIX}g++'))
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500511 buildtools_installer = os.path.join(d.getVar('SDK_DEPLOY'), buildtools_fn)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600512 filelist, _ = bb.process.run('%s -l' % buildtools_installer)
513 localdata = bb.data.createCopy(d)
514 localdata.setVar('SDKPATH', '.')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500515 sdkpathnative = localdata.getVar('SDKPATHNATIVE')
516 sdkbindirs = [localdata.getVar('bindir_nativesdk'),
517 localdata.getVar('sbindir_nativesdk'),
518 localdata.getVar('base_bindir_nativesdk'),
519 localdata.getVar('base_sbindir_nativesdk')]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600520 for line in filelist.splitlines():
521 splitline = line.split()
522 if len(splitline) > 5:
523 fn = splitline[5]
524 if not fn.startswith('./'):
525 fn = './%s' % fn
526 if fn.startswith(sdkpathnative):
527 relpth = '/' + os.path.relpath(fn, sdkpathnative)
528 for bindir in sdkbindirs:
529 if relpth.startswith(bindir):
530 relpth = os.path.relpath(relpth, bindir)
531 if relpth in sanity_required_utilities:
532 sanity_required_utilities.remove(relpth)
533 break
534 return ' '.join(sanity_required_utilities)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500535
536install_tools() {
537 install -d ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600538 scripts="devtool recipetool oe-find-native-sysroot runqemu*"
539 for script in $scripts; do
540 for scriptfn in `find ${SDK_OUTPUT}/${SDKPATH}/${scriptrelpath} -maxdepth 1 -executable -name "$script"`; do
541 lnr ${scriptfn} ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}/`basename $scriptfn`
542 done
543 done
544 # We can't use the same method as above because files in the sysroot won't exist at this point
545 # (they get populated from sstate on installation)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500546 unfsd_path="${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}/unfsd"
547 if [ "${SDK_INCLUDE_TOOLCHAIN}" = "1" -a ! -e $unfsd_path ] ; then
548 binrelpath=${@os.path.relpath(d.getVar('STAGING_BINDIR_NATIVE'), d.getVar('TMPDIR'))}
549 lnr ${SDK_OUTPUT}/${SDKPATH}/tmp/$binrelpath/unfsd $unfsd_path
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600550 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500551 touch ${SDK_OUTPUT}/${SDKPATH}/.devtoolbase
552
553 # find latest buildtools-tarball and install it
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600554 install ${SDK_DEPLOY}/${SDK_BUILDTOOLS_INSTALLER} ${SDK_OUTPUT}/${SDKPATH}
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500555
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500556 install -m 0644 ${COREBASE}/meta/files/ext-sdk-prepare.py ${SDK_OUTPUT}/${SDKPATH}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500557}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500558do_populate_sdk_ext[file-checksums] += "${COREBASE}/meta/files/ext-sdk-prepare.py:True"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500559
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500560sdk_ext_preinst() {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600561 # Since bitbake won't run as root it doesn't make sense to try and install
562 # the extensible sdk as root.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500563 if [ "`id -u`" = "0" ]; then
564 echo "ERROR: The extensible sdk cannot be installed as root."
565 exit 1
566 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600567 if ! command -v locale > /dev/null; then
568 echo "ERROR: The installer requires the locale command, please install it first"
569 exit 1
570 fi
571 # Check setting of LC_ALL set above
572 canonicalised_locale=`echo $LC_ALL | sed 's/UTF-8/utf8/'`
573 if ! locale -a | grep -q $canonicalised_locale ; then
574 echo "ERROR: the installer requires the $LC_ALL locale to be installed (but not selected), please install it first"
575 exit 1
576 fi
577 # The relocation script used by buildtools installer requires python
578 if ! command -v python > /dev/null; then
579 echo "ERROR: The installer requires python, please install it first"
580 exit 1
581 fi
582 missing_utils=""
583 for util in ${SDK_REQUIRED_UTILITIES}; do
584 if ! command -v $util > /dev/null; then
585 missing_utils="$missing_utils $util"
586 fi
587 done
588 if [ -n "$missing_utils" ] ; then
589 echo "ERROR: the SDK requires the following missing utilities, please install them: $missing_utils"
590 exit 1
591 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500592 SDK_EXTENSIBLE="1"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500593 if [ "$publish" = "1" ] ; then
594 EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=ext-sdk-prepare.py"
595 if [ "${SDK_EXT_TYPE}" = "minimal" ] ; then
596 EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=sstate-cache"
597 fi
598 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500599}
600SDK_PRE_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_preinst}"
601
602# FIXME this preparation should be done as part of the SDK construction
603sdk_ext_postinst() {
604 printf "\nExtracting buildtools...\n"
605 cd $target_sdk_dir
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600606 env_setup_script="$target_sdk_dir/environment-setup-${REAL_MULTIMACH_TARGET_SYS}"
607 printf "buildtools\ny" | ./${SDK_BUILDTOOLS_INSTALLER} > buildtools.log || { printf 'ERROR: buildtools installation failed:\n' ; cat buildtools.log ; echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; }
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500608
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500609 # Delete the buildtools tar file since it won't be used again
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600610 rm -f ./${SDK_BUILDTOOLS_INSTALLER}
611 # We don't need the log either since it succeeded
612 rm -f buildtools.log
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500613
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500614 # Make sure when the user sets up the environment, they also get
615 # the buildtools-tarball tools in their path.
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500616 echo ". $target_sdk_dir/buildtools/environment-setup*" >> $env_setup_script
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500617
618 # Allow bitbake environment setup to be ran as part of this sdk.
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500619 echo "export OE_SKIP_SDK_CHECK=1" >> $env_setup_script
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500620 # Work around runqemu not knowing how to get this information within the eSDK
621 echo "export DEPLOY_DIR_IMAGE=$target_sdk_dir/tmp/${@os.path.relpath(d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('TMPDIR'))}" >> $env_setup_script
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500622
623 # A bit of another hack, but we need this in the path only for devtool
624 # so put it at the end of $PATH.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500625 echo "export PATH=$target_sdk_dir/sysroots/${SDK_SYS}${bindir_nativesdk}:\$PATH" >> $env_setup_script
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500626
627 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
628
629 # Warn if trying to use external bitbake and the ext SDK together
630 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 -0500631
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500632 if [ "$prepare_buildsystem" != "no" ]; then
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500633 printf "Preparing build system...\n"
634 # dash which is /bin/sh on Ubuntu will not preserve the
635 # current working directory when first ran, nor will it set $1 when
636 # sourcing a script. That is why this has to look so ugly.
637 LOGFILE="$target_sdk_dir/preparing_build_system.log"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600638 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 $LOGFILE '${SDK_INSTALL_TARGETS}'" || { echo "printf 'ERROR: this SDK was not fully installed and needs reinstalling\n'" >> $env_setup_script ; exit 1 ; }
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500639 rm $target_sdk_dir/ext-sdk-prepare.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500640 fi
641 echo done
642}
643
644SDK_POST_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_postinst}"
645
646SDK_POSTPROCESS_COMMAND_prepend_task-populate-sdk-ext = "copy_buildsystem; install_tools; "
647
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500648SDK_INSTALL_TARGETS = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500649fakeroot python do_populate_sdk_ext() {
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500650 # FIXME hopefully we can remove this restriction at some point, but uninative
651 # currently forces this upon us
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500652 if d.getVar('SDK_ARCH') != d.getVar('BUILD_ARCH'):
653 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'), d.getVar('BUILD_ARCH')))
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500654
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500655 d.setVar('SDK_INSTALL_TARGETS', get_sdk_install_targets(d))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600656 buildtools_fn = get_current_buildtools(d)
657 d.setVar('SDK_REQUIRED_UTILITIES', get_sdk_required_utilities(buildtools_fn, d))
658 d.setVar('SDK_BUILDTOOLS_INSTALLER', buildtools_fn)
659 d.setVar('SDKDEPLOYDIR', '${SDKEXTDEPLOYDIR}')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500660
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600661 populate_sdk_common(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500662}
663
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500664def get_ext_sdk_depends(d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600665 # Note: the deps varflag is a list not a string, so we need to specify expand=False
666 deps = d.getVarFlag('do_image_complete', 'deps', False)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500667 pn = d.getVar('PN')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600668 deplist = ['%s:%s' % (pn, dep) for dep in deps]
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500669 tasklist = bb.build.tasksbetween('do_image_complete', 'do_build', d)
670 tasklist.append('do_rootfs')
671 for task in tasklist:
672 deplist.extend((d.getVarFlag(task, 'depends') or '').split())
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600673 return ' '.join(deplist)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500674
675python do_sdk_depends() {
676 # We have to do this separately in its own task so we avoid recursing into
677 # dependencies we don't need to (e.g. buildtools-tarball) and bringing those
678 # into the SDK's sstate-cache
679 import oe.copy_buildsystem
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500680 sigfile = d.getVar('WORKDIR') + '/locked-sigs.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500681 oe.copy_buildsystem.generate_locked_sigs(sigfile, d)
682}
683addtask sdk_depends
684
685do_sdk_depends[dirs] = "${WORKDIR}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500686do_sdk_depends[depends] = "${@get_ext_sdk_depends(d)} meta-extsdk-toolchain:do_populate_sysroot"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500687do_sdk_depends[recrdeptask] = "${@d.getVarFlag('do_populate_sdk', 'recrdeptask', False)}"
688do_sdk_depends[recrdeptask] += "do_populate_lic do_package_qa do_populate_sysroot do_deploy ${SDK_RECRDEP_TASKS}"
689do_sdk_depends[rdepends] = "${@get_sdk_ext_rdepends(d)}"
690
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500691def get_sdk_ext_rdepends(d):
692 localdata = d.createCopy()
693 localdata.appendVar('OVERRIDES', ':task-populate-sdk-ext')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500694 return localdata.getVarFlag('do_populate_sdk', 'rdepends')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500695
696do_populate_sdk_ext[dirs] = "${@d.getVarFlag('do_populate_sdk', 'dirs', False)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500697
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500698do_populate_sdk_ext[depends] = "${@d.getVarFlag('do_populate_sdk', 'depends', False)} \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500699 buildtools-tarball:do_populate_sdk \
700 ${@'meta-world-pkgdata:do_collect_packagedata' if d.getVar('SDK_INCLUDE_PKGDATA') == '1' else ''} \
701 ${@'meta-extsdk-toolchain:do_locked_sigs' if d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1' else ''}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500702
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500703# We must avoid depending on do_build here if rm_work.bbclass is active,
704# because otherwise do_rm_work may run before do_populate_sdk_ext itself.
705# We can't mark do_populate_sdk_ext and do_sdk_depends as having to
706# run before do_rm_work, because then they would also run as part
707# of normal builds.
708do_populate_sdk_ext[rdepends] += "${@' '.join([x + ':' + (d.getVar('RM_WORK_BUILD_WITHOUT') or 'do_build') for x in d.getVar('SDK_TARGETS').split()])}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500709
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500710# Make sure code changes can result in rebuild
711do_populate_sdk_ext[vardeps] += "copy_buildsystem \
712 sdk_ext_postinst"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500713
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500714# Since any change in the metadata of any layer should cause a rebuild of the
715# sdk(since the layers are put in the sdk) set the task to nostamp so it
716# always runs.
717do_populate_sdk_ext[nostamp] = "1"
718
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600719SDKEXTDEPLOYDIR = "${WORKDIR}/deploy-${PN}-populate-sdk-ext"
720
721SSTATETASKS += "do_populate_sdk_ext"
722SSTATE_SKIP_CREATION_task-populate-sdk-ext = '1'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500723do_populate_sdk_ext[cleandirs] = "${SDKEXTDEPLOYDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600724do_populate_sdk_ext[sstate-inputdirs] = "${SDKEXTDEPLOYDIR}"
725do_populate_sdk_ext[sstate-outputdirs] = "${SDK_DEPLOY}"
726do_populate_sdk_ext[stamp-extra-info] = "${MACHINE}"
727
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500728addtask populate_sdk_ext after do_sdk_depends