blob: 8b8a341e3e2fba4f2d0125b94e5b76d548746b4c [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 \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050036 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037SDK_INHERIT_BLACKLIST ?= "buildhistory icecc"
38SDK_UPDATE_URL ?= ""
39
40SDK_TARGETS ?= "${PN}"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050041
Patrick Williamsc0f7c042017-02-23 20:41:17 -060042def get_sdk_install_targets(d, images_only=False):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050043 sdk_install_targets = ''
Brad Bishop6e60e8b2018-02-01 10:27:11 -050044 if images_only or d.getVar('SDK_EXT_TYPE') != 'minimal':
45 sdk_install_targets = d.getVar('SDK_TARGETS')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050046
47 depd = d.getVar('BB_TASKDEPDATA', False)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048 tasklist = bb.build.tasksbetween('do_image_complete', 'do_build', d)
49 tasklist.remove('do_build')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060050 for v in depd.values():
Brad Bishop6e60e8b2018-02-01 10:27:11 -050051 if v[1] in tasklist:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050052 if v[0] not in sdk_install_targets:
53 sdk_install_targets += ' {}'.format(v[0])
54
Patrick Williamsc0f7c042017-02-23 20:41:17 -060055 if not images_only:
Brad Bishop6e60e8b2018-02-01 10:27:11 -050056 if d.getVar('SDK_INCLUDE_PKGDATA') == '1':
Patrick Williamsc0f7c042017-02-23 20:41:17 -060057 sdk_install_targets += ' meta-world-pkgdata:do_allpackagedata'
Brad Bishop6e60e8b2018-02-01 10:27:11 -050058 if d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1':
Patrick Williamsc0f7c042017-02-23 20:41:17 -060059 sdk_install_targets += ' meta-extsdk-toolchain:do_populate_sysroot'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050060
61 return sdk_install_targets
62
63get_sdk_install_targets[vardepsexclude] = "BB_TASKDEPDATA"
64
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065OE_INIT_ENV_SCRIPT ?= "oe-init-build-env"
66
67# The files from COREBASE that you want preserved in the COREBASE copied
68# into the sdk. This allows someone to have their own setup scripts in
69# COREBASE be preserved as well as untracked files.
70COREBASE_FILES ?= " \
71 oe-init-build-env \
72 oe-init-build-env-memres \
73 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 Bishop6e60e8b2018-02-01 10:27:11 -050086SDK_TITLE_task-populate-sdk-ext = "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} Extensible SDK"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087
Patrick Williamsc0f7c042017-02-23 20:41:17 -060088def clean_esdk_builddir(d, sdkbasepath):
89 """Clean up traces of the fake build for create_filtered_tasklist()"""
90 import shutil
Brad Bishop37a0e4d2017-12-04 01:01:44 -050091 cleanpaths = 'cache conf/sanity_info tmp'.split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -060092 for pth in cleanpaths:
93 fullpth = os.path.join(sdkbasepath, pth)
94 if os.path.isdir(fullpth):
95 shutil.rmtree(fullpth)
96 elif os.path.isfile(fullpth):
97 os.remove(fullpth)
98
99def create_filtered_tasklist(d, sdkbasepath, tasklistfile, conf_initpath):
100 """
101 Create a filtered list of tasks. Also double-checks that the build system
102 within the SDK basically works and required sstate artifacts are available.
103 """
104 import tempfile
105 import shutil
106 import oe.copy_buildsystem
107
108 # Create a temporary build directory that we can pass to the env setup script
109 shutil.copyfile(sdkbasepath + '/conf/local.conf', sdkbasepath + '/conf/local.conf.bak')
110 try:
111 with open(sdkbasepath + '/conf/local.conf', 'a') as f:
112 # Force the use of sstate from the build system
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113 f.write('\nSSTATE_DIR_forcevariable = "%s"\n' % d.getVar('SSTATE_DIR'))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600114 f.write('SSTATE_MIRRORS_forcevariable = ""\n')
115 # Ensure TMPDIR is the default so that clean_esdk_builddir() can delete it
116 f.write('TMPDIR_forcevariable = "${TOPDIR}/tmp"\n')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500117 f.write('TCLIBCAPPEND_forcevariable = ""\n')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600118 # Drop uninative if the build isn't using it (or else NATIVELSBSTRING will
119 # be different and we won't be able to find our native sstate)
120 if not bb.data.inherits_class('uninative', d):
121 f.write('INHERIT_remove = "uninative"\n')
122
123 # Unfortunately the default SDKPATH (or even a custom value) may contain characters that bitbake
124 # will not allow in its COREBASE path, so we need to rename the directory temporarily
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500125 temp_sdkbasepath = d.getVar('SDK_OUTPUT') + '/tmp-renamed-sdk'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600126 # Delete any existing temp dir
127 try:
128 shutil.rmtree(temp_sdkbasepath)
129 except FileNotFoundError:
130 pass
131 os.rename(sdkbasepath, temp_sdkbasepath)
132 try:
133 cmdprefix = '. %s .; ' % conf_initpath
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500134 logfile = d.getVar('WORKDIR') + '/tasklist_bb_log.txt'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600135 try:
136 oe.copy_buildsystem.check_sstate_task_list(d, get_sdk_install_targets(d), tasklistfile, cmdprefix=cmdprefix, cwd=temp_sdkbasepath, logfile=logfile)
137 except bb.process.ExecutionError as e:
138 msg = 'Failed to generate filtered task list for extensible SDK:\n%s' % e.stdout.rstrip()
139 if 'attempted to execute unexpectedly and should have been setscened' in e.stdout:
140 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'
141 bb.fatal(msg)
142 finally:
143 os.rename(temp_sdkbasepath, sdkbasepath)
144 # Clean out residue of running bitbake, which check_sstate_task_list()
145 # will effectively do
146 clean_esdk_builddir(d, sdkbasepath)
147 finally:
148 os.replace(sdkbasepath + '/conf/local.conf.bak', sdkbasepath + '/conf/local.conf')
149
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150python copy_buildsystem () {
151 import re
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500152 import shutil
153 import glob
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500154 import oe.copy_buildsystem
155
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500156 oe_init_env_script = d.getVar('OE_INIT_ENV_SCRIPT')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157
158 conf_bbpath = ''
159 conf_initpath = ''
160 core_meta_subdir = ''
161
162 # Copy in all metadata layers + bitbake (as repositories)
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500163 buildsystem = oe.copy_buildsystem.BuildSystem('extensible SDK', d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500164 baseoutpath = d.getVar('SDK_OUTPUT') + '/' + d.getVar('SDKPATH')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500165
166 # Determine if we're building a derivative extensible SDK (from devtool build-sdk)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500167 derivative = (d.getVar('SDK_DERIVATIVE') or '') == '1'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500168 if derivative:
169 workspace_name = 'orig-workspace'
170 else:
171 workspace_name = None
172 layers_copied = buildsystem.copy_bitbake_and_layers(baseoutpath + '/layers', workspace_name)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173
174 sdkbblayers = []
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500175 corebase = os.path.basename(d.getVar('COREBASE'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176 for layer in layers_copied:
177 if corebase == os.path.basename(layer):
178 conf_bbpath = os.path.join('layers', layer, 'bitbake')
179 else:
180 sdkbblayers.append(layer)
181
182 for path in os.listdir(baseoutpath + '/layers'):
183 relpath = os.path.join('layers', path, oe_init_env_script)
184 if os.path.exists(os.path.join(baseoutpath, relpath)):
185 conf_initpath = relpath
186
187 relpath = os.path.join('layers', path, 'scripts', 'devtool')
188 if os.path.exists(os.path.join(baseoutpath, relpath)):
189 scriptrelpath = os.path.dirname(relpath)
190
191 relpath = os.path.join('layers', path, 'meta')
192 if os.path.exists(os.path.join(baseoutpath, relpath, 'lib', 'oe')):
193 core_meta_subdir = relpath
194
195 d.setVar('oe_init_build_env_path', conf_initpath)
196 d.setVar('scriptrelpath', scriptrelpath)
197
198 # Write out config file for devtool
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600199 import configparser
200 config = configparser.SafeConfigParser()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500201 config.add_section('General')
202 config.set('General', 'bitbake_subdir', conf_bbpath)
203 config.set('General', 'init_path', conf_initpath)
204 config.set('General', 'core_meta_subdir', core_meta_subdir)
205 config.add_section('SDK')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500206 config.set('SDK', 'sdk_targets', d.getVar('SDK_TARGETS'))
207 updateurl = d.getVar('SDK_UPDATE_URL')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500208 if updateurl:
209 config.set('SDK', 'updateserver', updateurl)
210 bb.utils.mkdirhier(os.path.join(baseoutpath, 'conf'))
211 with open(os.path.join(baseoutpath, 'conf', 'devtool.conf'), 'w') as f:
212 config.write(f)
213
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500214 unlockedsigs = os.path.join(baseoutpath, 'conf', 'unlocked-sigs.inc')
215 with open(unlockedsigs, 'w') as f:
216 pass
217
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500218 # Create a layer for new recipes / appends
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500219 bbpath = d.getVar('BBPATH')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500220 bb.process.run(['devtool', '--bbpath', bbpath, '--basepath', baseoutpath, 'create-workspace', '--create-only', os.path.join(baseoutpath, 'workspace')])
221
222 # Create bblayers.conf
223 bb.utils.mkdirhier(baseoutpath + '/conf')
224 with open(baseoutpath + '/conf/bblayers.conf', 'w') as f:
225 f.write('# WARNING: this configuration has been automatically generated and in\n')
226 f.write('# most cases should not be edited. If you need more flexibility than\n')
227 f.write('# this configuration provides, it is strongly suggested that you set\n')
228 f.write('# up a proper instance of the full build system and use that instead.\n\n')
229
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500230 # LCONF_VERSION may not be set, for example when using meta-poky
231 # so don't error if it isn't found
232 lconf_version = d.getVar('LCONF_VERSION', False)
233 if lconf_version is not None:
234 f.write('LCONF_VERSION = "%s"\n\n' % lconf_version)
235
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500236 f.write('BBPATH = "$' + '{TOPDIR}"\n')
237 f.write('SDKBASEMETAPATH = "$' + '{TOPDIR}"\n')
238 f.write('BBLAYERS := " \\\n')
239 for layerrelpath in sdkbblayers:
240 f.write(' $' + '{SDKBASEMETAPATH}/layers/%s \\\n' % layerrelpath)
241 f.write(' $' + '{SDKBASEMETAPATH}/workspace \\\n')
242 f.write(' "\n')
243
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600244 # Copy uninative tarball
245 # For now this is where uninative.bbclass expects the tarball
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500246 if bb.data.inherits_class('uninative', d):
247 uninative_file = d.expand('${UNINATIVE_DLDIR}/' + d.getVarFlag("UNINATIVE_CHECKSUM", d.getVar("BUILD_ARCH")) + '/${UNINATIVE_TARBALL}')
248 uninative_checksum = bb.utils.sha256_file(uninative_file)
249 uninative_outdir = '%s/downloads/uninative/%s' % (baseoutpath, uninative_checksum)
250 bb.utils.mkdirhier(uninative_outdir)
251 shutil.copy(uninative_file, uninative_outdir)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600252
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500253 env_whitelist = (d.getVar('BB_ENV_EXTRAWHITE') or '').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500254 env_whitelist_values = {}
255
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500256 # Create local.conf
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500257 builddir = d.getVar('TOPDIR')
258 if derivative and os.path.exists(builddir + '/conf/auto.conf'):
259 shutil.copyfile(builddir + '/conf/auto.conf', baseoutpath + '/conf/auto.conf')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500260 if derivative:
261 shutil.copyfile(builddir + '/conf/local.conf', baseoutpath + '/conf/local.conf')
262 else:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500263 local_conf_whitelist = (d.getVar('SDK_LOCAL_CONF_WHITELIST') or '').split()
264 local_conf_blacklist = (d.getVar('SDK_LOCAL_CONF_BLACKLIST') or '').split()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500265 def handle_var(varname, origvalue, op, newlines):
266 if varname in local_conf_blacklist or (origvalue.strip().startswith('/') and not varname in local_conf_whitelist):
267 newlines.append('# Removed original setting of %s\n' % varname)
268 return None, op, 0, True
269 else:
270 if varname in env_whitelist:
271 env_whitelist_values[varname] = origvalue
272 return origvalue, op, 0, True
273 varlist = ['[^#=+ ]*']
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500274 oldlines = []
275 if os.path.exists(builddir + '/conf/auto.conf'):
276 with open(builddir + '/conf/auto.conf', 'r') as f:
277 oldlines += f.readlines()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500278 with open(builddir + '/conf/local.conf', 'r') as f:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500279 oldlines += f.readlines()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500280 (updated, newlines) = bb.utils.edit_metadata(oldlines, varlist, handle_var)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500281
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500282 with open(baseoutpath + '/conf/local.conf', 'w') as f:
283 f.write('# WARNING: this configuration has been automatically generated and in\n')
284 f.write('# most cases should not be edited. If you need more flexibility than\n')
285 f.write('# this configuration provides, it is strongly suggested that you set\n')
286 f.write('# up a proper instance of the full build system and use that instead.\n\n')
287 for line in newlines:
288 if line.strip() and not line.startswith('#'):
289 f.write(line)
290 # Write a newline just in case there's none at the end of the original
291 f.write('\n')
292
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500293 f.write('TMPDIR = "${TOPDIR}/tmp"\n')
294 f.write('TCLIBCAPPEND = ""\n')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600295 f.write('DL_DIR = "${TOPDIR}/downloads"\n')
296
297 f.write('INHERIT += "%s"\n' % 'uninative')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500298 f.write('UNINATIVE_CHECKSUM[%s] = "%s"\n\n' % (d.getVar('BUILD_ARCH'), uninative_checksum))
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500299 f.write('CONF_VERSION = "%s"\n\n' % d.getVar('CONF_VERSION', False))
300
301 # Some classes are not suitable for SDK, remove them from INHERIT
302 f.write('INHERIT_remove = "%s"\n' % d.getVar('SDK_INHERIT_BLACKLIST', False))
303
304 # Bypass the default connectivity check if any
305 f.write('CONNECTIVITY_CHECK_URIS = ""\n\n')
306
307 # This warning will come out if reverse dependencies for a task
308 # don't have sstate as well as the task itself. We already know
309 # this will be the case for the extensible sdk, so turn off the
310 # warning.
311 f.write('SIGGEN_LOCKEDSIGS_SSTATE_EXISTS_CHECK = "none"\n\n')
312
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600313 # Warn if the sigs in the locked-signature file don't match
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500314 # the sig computed from the metadata.
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600315 f.write('SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "warn"\n\n')
316
317 # Set up whitelist for run on install
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500318 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 -0500319
320 # Hide the config information from bitbake output (since it's fixed within the SDK)
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500321 f.write('BUILDCFG_HEADER = ""\n\n')
322
323 # Map gcc-dependent uninative sstate cache for installer usage
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500324 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 -0500325
326 # Allow additional config through sdk-extra.conf
327 fn = bb.cookerdata.findConfigFile('sdk-extra.conf', d)
328 if fn:
329 with open(fn, 'r') as xf:
330 for line in xf:
331 f.write(line)
332
333 # If you define a sdk_extraconf() function then it can contain additional config
334 # (Though this is awkward; sdk-extra.conf should probably be used instead)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500335 extraconf = (d.getVar('sdk_extraconf') or '').strip()
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500336 if extraconf:
337 # Strip off any leading / trailing spaces
338 for line in extraconf.splitlines():
339 f.write(line.strip() + '\n')
340
341 f.write('require conf/locked-sigs.inc\n')
342 f.write('require conf/unlocked-sigs.inc\n')
343
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500344 # Write a templateconf.cfg
345 with open(baseoutpath + '/conf/templateconf.cfg', 'w') as f:
346 f.write('meta/conf\n')
347
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500348 # Ensure any variables set from the external environment (by way of
349 # BB_ENV_EXTRAWHITE) are set in the SDK's configuration
350 extralines = []
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600351 for name, value in env_whitelist_values.items():
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500352 actualvalue = d.getVar(name) or ''
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500353 if value != actualvalue:
354 extralines.append('%s = "%s"\n' % (name, actualvalue))
355 if extralines:
356 with open(baseoutpath + '/conf/local.conf', 'a') as f:
357 f.write('\n')
358 f.write('# Extra settings from environment:\n')
359 for line in extralines:
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500360 f.write(line)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500361 f.write('\n')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500362
363 # Filter the locked signatures file to just the sstate tasks we are interested in
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600364 excluded_targets = get_sdk_install_targets(d, images_only=True)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500365 sigfile = d.getVar('WORKDIR') + '/locked-sigs.inc'
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500366 lockedsigs_pruned = baseoutpath + '/conf/locked-sigs.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500367 oe.copy_buildsystem.prune_lockedsigs([],
368 excluded_targets.split(),
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500369 sigfile,
370 lockedsigs_pruned)
371
372 sstate_out = baseoutpath + '/sstate-cache'
373 bb.utils.remove(sstate_out, True)
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500374
375 # uninative.bbclass sets NATIVELSBSTRING to 'universal%s' % oe.utils.host_gcc_version(d)
376 fixedlsbstring = "universal%s" % oe.utils.host_gcc_version(d)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500377
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500378 sdk_include_toolchain = (d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1')
379 sdk_ext_type = d.getVar('SDK_EXT_TYPE')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600380 if sdk_ext_type != 'minimal' or sdk_include_toolchain or derivative:
381 # Create the filtered task list used to generate the sstate cache shipped with the SDK
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500382 tasklistfn = d.getVar('WORKDIR') + '/tasklist.txt'
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600383 create_filtered_tasklist(d, baseoutpath, tasklistfn, conf_initpath)
384 else:
385 tasklistfn = None
386
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500387 # Add packagedata if enabled
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500388 if d.getVar('SDK_INCLUDE_PKGDATA') == '1':
389 lockedsigs_base = d.getVar('WORKDIR') + '/locked-sigs-base.inc'
390 lockedsigs_copy = d.getVar('WORKDIR') + '/locked-sigs-copy.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500391 shutil.move(lockedsigs_pruned, lockedsigs_base)
392 oe.copy_buildsystem.merge_lockedsigs(['do_packagedata'],
393 lockedsigs_base,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500394 d.getVar('STAGING_DIR_HOST') + '/world-pkgdata/locked-sigs-pkgdata.inc',
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500395 lockedsigs_pruned,
396 lockedsigs_copy)
397
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600398 if sdk_include_toolchain:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500399 lockedsigs_base = d.getVar('WORKDIR') + '/locked-sigs-base2.inc'
400 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 -0600401 shutil.move(lockedsigs_pruned, lockedsigs_base)
402 oe.copy_buildsystem.merge_lockedsigs([],
403 lockedsigs_base,
404 lockedsigs_toolchain,
405 lockedsigs_pruned)
406 oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_toolchain,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500407 d.getVar('SSTATE_DIR'),
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600408 sstate_out, d,
409 fixedlsbstring,
410 filterfile=tasklistfn)
411
412 if sdk_ext_type == 'minimal':
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500413 if derivative:
414 # Assume the user is not going to set up an additional sstate
415 # mirror, thus we need to copy the additional artifacts (from
416 # workspace recipes) into the derivative SDK
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500417 lockedsigs_orig = d.getVar('TOPDIR') + '/conf/locked-sigs.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500418 if os.path.exists(lockedsigs_orig):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500419 lockedsigs_extra = d.getVar('WORKDIR') + '/locked-sigs-extra.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500420 oe.copy_buildsystem.merge_lockedsigs(None,
421 lockedsigs_orig,
422 lockedsigs_pruned,
423 None,
424 lockedsigs_extra)
425 oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_extra,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500426 d.getVar('SSTATE_DIR'),
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500427 sstate_out, d,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600428 fixedlsbstring,
429 filterfile=tasklistfn)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500430 else:
431 oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_pruned,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500432 d.getVar('SSTATE_DIR'),
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500433 sstate_out, d,
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600434 fixedlsbstring,
435 filterfile=tasklistfn)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500436
437 # We don't need sstate do_package files
438 for root, dirs, files in os.walk(sstate_out):
439 for name in files:
440 if name.endswith("_package.tgz"):
441 f = os.path.join(root, name)
442 os.remove(f)
443
444 # Write manifest file
445 # Note: at the moment we cannot include the env setup script here to keep
446 # it updated, since it gets modified during SDK installation (see
447 # sdk_ext_postinst() below) thus the checksum we take here would always
448 # be different.
449 manifest_file_list = ['conf/*']
450 manifest_file = os.path.join(baseoutpath, 'conf', 'sdk-conf-manifest')
451 with open(manifest_file, 'w') as f:
452 for item in manifest_file_list:
453 for fn in glob.glob(os.path.join(baseoutpath, item)):
454 if fn == manifest_file:
455 continue
456 chksum = bb.utils.sha256_file(fn)
457 f.write('%s\t%s\n' % (chksum, os.path.relpath(fn, baseoutpath)))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500458}
459
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600460def get_current_buildtools(d):
461 """Get the file name of the current buildtools installer"""
462 import glob
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500463 btfiles = glob.glob(os.path.join(d.getVar('SDK_DEPLOY'), '*-buildtools-nativesdk-standalone-*.sh'))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600464 btfiles.sort(key=os.path.getctime)
465 return os.path.basename(btfiles[-1])
466
467def get_sdk_required_utilities(buildtools_fn, d):
468 """Find required utilities that aren't provided by the buildtools"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500469 sanity_required_utilities = (d.getVar('SANITY_REQUIRED_UTILITIES') or '').split()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600470 sanity_required_utilities.append(d.expand('${BUILD_PREFIX}gcc'))
471 sanity_required_utilities.append(d.expand('${BUILD_PREFIX}g++'))
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500472 buildtools_installer = os.path.join(d.getVar('SDK_DEPLOY'), buildtools_fn)
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600473 filelist, _ = bb.process.run('%s -l' % buildtools_installer)
474 localdata = bb.data.createCopy(d)
475 localdata.setVar('SDKPATH', '.')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500476 sdkpathnative = localdata.getVar('SDKPATHNATIVE')
477 sdkbindirs = [localdata.getVar('bindir_nativesdk'),
478 localdata.getVar('sbindir_nativesdk'),
479 localdata.getVar('base_bindir_nativesdk'),
480 localdata.getVar('base_sbindir_nativesdk')]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600481 for line in filelist.splitlines():
482 splitline = line.split()
483 if len(splitline) > 5:
484 fn = splitline[5]
485 if not fn.startswith('./'):
486 fn = './%s' % fn
487 if fn.startswith(sdkpathnative):
488 relpth = '/' + os.path.relpath(fn, sdkpathnative)
489 for bindir in sdkbindirs:
490 if relpth.startswith(bindir):
491 relpth = os.path.relpath(relpth, bindir)
492 if relpth in sanity_required_utilities:
493 sanity_required_utilities.remove(relpth)
494 break
495 return ' '.join(sanity_required_utilities)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500496
497install_tools() {
498 install -d ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600499 scripts="devtool recipetool oe-find-native-sysroot runqemu*"
500 for script in $scripts; do
501 for scriptfn in `find ${SDK_OUTPUT}/${SDKPATH}/${scriptrelpath} -maxdepth 1 -executable -name "$script"`; do
502 lnr ${scriptfn} ${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}/`basename $scriptfn`
503 done
504 done
505 # We can't use the same method as above because files in the sysroot won't exist at this point
506 # (they get populated from sstate on installation)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500507 unfsd_path="${SDK_OUTPUT}/${SDKPATHNATIVE}${bindir_nativesdk}/unfsd"
508 if [ "${SDK_INCLUDE_TOOLCHAIN}" = "1" -a ! -e $unfsd_path ] ; then
509 binrelpath=${@os.path.relpath(d.getVar('STAGING_BINDIR_NATIVE'), d.getVar('TMPDIR'))}
510 lnr ${SDK_OUTPUT}/${SDKPATH}/tmp/$binrelpath/unfsd $unfsd_path
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600511 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500512 touch ${SDK_OUTPUT}/${SDKPATH}/.devtoolbase
513
514 # find latest buildtools-tarball and install it
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600515 install ${SDK_DEPLOY}/${SDK_BUILDTOOLS_INSTALLER} ${SDK_OUTPUT}/${SDKPATH}
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500516
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500517 install -m 0644 ${COREBASE}/meta/files/ext-sdk-prepare.py ${SDK_OUTPUT}/${SDKPATH}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500518}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500519do_populate_sdk_ext[file-checksums] += "${COREBASE}/meta/files/ext-sdk-prepare.py:True"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500520
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500521sdk_ext_preinst() {
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600522 # Since bitbake won't run as root it doesn't make sense to try and install
523 # the extensible sdk as root.
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500524 if [ "`id -u`" = "0" ]; then
525 echo "ERROR: The extensible sdk cannot be installed as root."
526 exit 1
527 fi
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600528 if ! command -v locale > /dev/null; then
529 echo "ERROR: The installer requires the locale command, please install it first"
530 exit 1
531 fi
532 # Check setting of LC_ALL set above
533 canonicalised_locale=`echo $LC_ALL | sed 's/UTF-8/utf8/'`
534 if ! locale -a | grep -q $canonicalised_locale ; then
535 echo "ERROR: the installer requires the $LC_ALL locale to be installed (but not selected), please install it first"
536 exit 1
537 fi
538 # The relocation script used by buildtools installer requires python
539 if ! command -v python > /dev/null; then
540 echo "ERROR: The installer requires python, please install it first"
541 exit 1
542 fi
543 missing_utils=""
544 for util in ${SDK_REQUIRED_UTILITIES}; do
545 if ! command -v $util > /dev/null; then
546 missing_utils="$missing_utils $util"
547 fi
548 done
549 if [ -n "$missing_utils" ] ; then
550 echo "ERROR: the SDK requires the following missing utilities, please install them: $missing_utils"
551 exit 1
552 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500553 SDK_EXTENSIBLE="1"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500554 if [ "$publish" = "1" ] ; then
555 EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=ext-sdk-prepare.py"
556 if [ "${SDK_EXT_TYPE}" = "minimal" ] ; then
557 EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=sstate-cache"
558 fi
559 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500560}
561SDK_PRE_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_preinst}"
562
563# FIXME this preparation should be done as part of the SDK construction
564sdk_ext_postinst() {
565 printf "\nExtracting buildtools...\n"
566 cd $target_sdk_dir
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600567 env_setup_script="$target_sdk_dir/environment-setup-${REAL_MULTIMACH_TARGET_SYS}"
568 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 -0500569
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500570 # Delete the buildtools tar file since it won't be used again
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600571 rm -f ./${SDK_BUILDTOOLS_INSTALLER}
572 # We don't need the log either since it succeeded
573 rm -f buildtools.log
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500574
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500575 # Make sure when the user sets up the environment, they also get
576 # the buildtools-tarball tools in their path.
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500577 echo ". $target_sdk_dir/buildtools/environment-setup*" >> $env_setup_script
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500578
579 # Allow bitbake environment setup to be ran as part of this sdk.
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500580 echo "export OE_SKIP_SDK_CHECK=1" >> $env_setup_script
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500581 # Work around runqemu not knowing how to get this information within the eSDK
582 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 -0500583
584 # A bit of another hack, but we need this in the path only for devtool
585 # so put it at the end of $PATH.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500586 echo "export PATH=$target_sdk_dir/sysroots/${SDK_SYS}${bindir_nativesdk}:\$PATH" >> $env_setup_script
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500587
588 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
589
590 # Warn if trying to use external bitbake and the ext SDK together
591 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 -0500592
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500593 if [ "$prepare_buildsystem" != "no" ]; then
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500594 printf "Preparing build system...\n"
595 # dash which is /bin/sh on Ubuntu will not preserve the
596 # current working directory when first ran, nor will it set $1 when
597 # sourcing a script. That is why this has to look so ugly.
598 LOGFILE="$target_sdk_dir/preparing_build_system.log"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600599 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 -0500600 rm $target_sdk_dir/ext-sdk-prepare.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500601 fi
602 echo done
603}
604
605SDK_POST_INSTALL_COMMAND_task-populate-sdk-ext = "${sdk_ext_postinst}"
606
607SDK_POSTPROCESS_COMMAND_prepend_task-populate-sdk-ext = "copy_buildsystem; install_tools; "
608
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500609SDK_INSTALL_TARGETS = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500610fakeroot python do_populate_sdk_ext() {
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500611 # FIXME hopefully we can remove this restriction at some point, but uninative
612 # currently forces this upon us
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500613 if d.getVar('SDK_ARCH') != d.getVar('BUILD_ARCH'):
614 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 -0500615
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500616 d.setVar('SDK_INSTALL_TARGETS', get_sdk_install_targets(d))
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600617 buildtools_fn = get_current_buildtools(d)
618 d.setVar('SDK_REQUIRED_UTILITIES', get_sdk_required_utilities(buildtools_fn, d))
619 d.setVar('SDK_BUILDTOOLS_INSTALLER', buildtools_fn)
620 d.setVar('SDKDEPLOYDIR', '${SDKEXTDEPLOYDIR}')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500621
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600622 populate_sdk_common(d)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500623}
624
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500625def get_ext_sdk_depends(d):
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600626 # Note: the deps varflag is a list not a string, so we need to specify expand=False
627 deps = d.getVarFlag('do_image_complete', 'deps', False)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500628 pn = d.getVar('PN')
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600629 deplist = ['%s:%s' % (pn, dep) for dep in deps]
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500630 tasklist = bb.build.tasksbetween('do_image_complete', 'do_build', d)
631 tasklist.append('do_rootfs')
632 for task in tasklist:
633 deplist.extend((d.getVarFlag(task, 'depends') or '').split())
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600634 return ' '.join(deplist)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500635
636python do_sdk_depends() {
637 # We have to do this separately in its own task so we avoid recursing into
638 # dependencies we don't need to (e.g. buildtools-tarball) and bringing those
639 # into the SDK's sstate-cache
640 import oe.copy_buildsystem
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500641 sigfile = d.getVar('WORKDIR') + '/locked-sigs.inc'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500642 oe.copy_buildsystem.generate_locked_sigs(sigfile, d)
643}
644addtask sdk_depends
645
646do_sdk_depends[dirs] = "${WORKDIR}"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500647do_sdk_depends[depends] = "${@get_ext_sdk_depends(d)} meta-extsdk-toolchain:do_populate_sysroot"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500648do_sdk_depends[recrdeptask] = "${@d.getVarFlag('do_populate_sdk', 'recrdeptask', False)}"
649do_sdk_depends[recrdeptask] += "do_populate_lic do_package_qa do_populate_sysroot do_deploy ${SDK_RECRDEP_TASKS}"
650do_sdk_depends[rdepends] = "${@get_sdk_ext_rdepends(d)}"
651
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500652def get_sdk_ext_rdepends(d):
653 localdata = d.createCopy()
654 localdata.appendVar('OVERRIDES', ':task-populate-sdk-ext')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500655 return localdata.getVarFlag('do_populate_sdk', 'rdepends')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500656
657do_populate_sdk_ext[dirs] = "${@d.getVarFlag('do_populate_sdk', 'dirs', False)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500658
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500659do_populate_sdk_ext[depends] = "${@d.getVarFlag('do_populate_sdk', 'depends', False)} \
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500660 buildtools-tarball:do_populate_sdk \
661 ${@'meta-world-pkgdata:do_collect_packagedata' if d.getVar('SDK_INCLUDE_PKGDATA') == '1' else ''} \
662 ${@'meta-extsdk-toolchain:do_locked_sigs' if d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1' else ''}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500663
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500664# We must avoid depending on do_build here if rm_work.bbclass is active,
665# because otherwise do_rm_work may run before do_populate_sdk_ext itself.
666# We can't mark do_populate_sdk_ext and do_sdk_depends as having to
667# run before do_rm_work, because then they would also run as part
668# of normal builds.
669do_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 -0500670
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500671# Make sure code changes can result in rebuild
672do_populate_sdk_ext[vardeps] += "copy_buildsystem \
673 sdk_ext_postinst"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500674
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500675# Since any change in the metadata of any layer should cause a rebuild of the
676# sdk(since the layers are put in the sdk) set the task to nostamp so it
677# always runs.
678do_populate_sdk_ext[nostamp] = "1"
679
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600680SDKEXTDEPLOYDIR = "${WORKDIR}/deploy-${PN}-populate-sdk-ext"
681
682SSTATETASKS += "do_populate_sdk_ext"
683SSTATE_SKIP_CREATION_task-populate-sdk-ext = '1'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500684do_populate_sdk_ext[cleandirs] = "${SDKEXTDEPLOYDIR}"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600685do_populate_sdk_ext[sstate-inputdirs] = "${SDKEXTDEPLOYDIR}"
686do_populate_sdk_ext[sstate-outputdirs] = "${SDK_DEPLOY}"
687do_populate_sdk_ext[stamp-extra-info] = "${MACHINE}"
688
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500689addtask populate_sdk_ext after do_sdk_depends