populate_sdk_ext.bbclass 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. # Extensible SDK
  7. inherit populate_sdk_base
  8. # Used to override TOOLCHAIN_HOST_TASK in the eSDK case
  9. TOOLCHAIN_HOST_TASK_ESDK = " \
  10. meta-environment-extsdk-${MACHINE} \
  11. "
  12. SDK_RELOCATE_AFTER_INSTALL:task-populate-sdk-ext = "0"
  13. SDK_EXT = ""
  14. SDK_EXT:task-populate-sdk-ext = "-ext"
  15. # Options are full or minimal
  16. SDK_EXT_TYPE ?= "full"
  17. SDK_INCLUDE_PKGDATA ?= "0"
  18. SDK_INCLUDE_TOOLCHAIN ?= "${@'1' if d.getVar('SDK_EXT_TYPE') == 'full' else '0'}"
  19. SDK_INCLUDE_NATIVESDK ?= "0"
  20. SDK_INCLUDE_BUILDTOOLS ?= '1'
  21. SDK_RECRDEP_TASKS ?= ""
  22. SDK_CUSTOM_TEMPLATECONF ?= "0"
  23. ESDK_LOCALCONF_ALLOW ?= ""
  24. ESDK_LOCALCONF_REMOVE ?= "CONF_VERSION \
  25. BB_NUMBER_THREADS \
  26. BB_NUMBER_PARSE_THREADS \
  27. PARALLEL_MAKE \
  28. PRSERV_HOST \
  29. SSTATE_MIRRORS \
  30. DL_DIR \
  31. SSTATE_DIR \
  32. TMPDIR \
  33. BB_SERVER_TIMEOUT \
  34. "
  35. ESDK_CLASS_INHERIT_DISABLE ?= "buildhistory icecc"
  36. SDK_UPDATE_URL ?= ""
  37. SDK_TARGETS ?= "${PN}"
  38. def get_sdk_install_targets(d, images_only=False):
  39. sdk_install_targets = ''
  40. if images_only or d.getVar('SDK_EXT_TYPE') != 'minimal':
  41. sdk_install_targets = d.getVar('SDK_TARGETS')
  42. depd = d.getVar('BB_TASKDEPDATA', False)
  43. tasklist = bb.build.tasksbetween('do_image_complete', 'do_build', d)
  44. tasklist.remove('do_build')
  45. for v in depd.values():
  46. if v[1] in tasklist:
  47. if v[0] not in sdk_install_targets:
  48. sdk_install_targets += ' {}'.format(v[0])
  49. if not images_only:
  50. if d.getVar('SDK_INCLUDE_PKGDATA') == '1':
  51. sdk_install_targets += ' meta-world-pkgdata:do_allpackagedata'
  52. if d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1':
  53. sdk_install_targets += ' meta-extsdk-toolchain:do_populate_sysroot'
  54. return sdk_install_targets
  55. get_sdk_install_targets[vardepsexclude] = "BB_TASKDEPDATA"
  56. OE_INIT_ENV_SCRIPT ?= "oe-init-build-env"
  57. # The files from COREBASE that you want preserved in the COREBASE copied
  58. # into the sdk. This allows someone to have their own setup scripts in
  59. # COREBASE be preserved as well as untracked files.
  60. COREBASE_FILES ?= " \
  61. oe-init-build-env \
  62. scripts \
  63. LICENSE \
  64. .templateconf \
  65. "
  66. SDK_DIR:task-populate-sdk-ext = "${WORKDIR}/sdk-ext"
  67. B:task-populate-sdk-ext = "${SDK_DIR}"
  68. TOOLCHAINEXT_OUTPUTNAME ?= "${SDK_NAME}-toolchain-ext-${SDK_VERSION}"
  69. TOOLCHAIN_OUTPUTNAME:task-populate-sdk-ext = "${TOOLCHAINEXT_OUTPUTNAME}"
  70. SDK_EXT_TARGET_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"
  71. SDK_EXT_HOST_MANIFEST = "${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest"
  72. python write_target_sdk_ext_manifest () {
  73. from oe.sdk import get_extra_sdkinfo
  74. sstate_dir = d.expand('${SDK_OUTPUT}/${SDKPATH}/sstate-cache')
  75. extra_info = get_extra_sdkinfo(sstate_dir)
  76. target = d.getVar('TARGET_SYS')
  77. target_multimach = d.getVar('MULTIMACH_TARGET_SYS')
  78. real_target_multimach = d.getVar('REAL_MULTIMACH_TARGET_SYS')
  79. pkgs = {}
  80. os.makedirs(os.path.dirname(d.getVar('SDK_EXT_TARGET_MANIFEST')), exist_ok=True)
  81. with open(d.getVar('SDK_EXT_TARGET_MANIFEST'), 'w') as f:
  82. for fn in extra_info['filesizes']:
  83. info = fn.split(':')
  84. if info[2] in (target, target_multimach, real_target_multimach) \
  85. or info[5] == 'allarch':
  86. if not info[1] in pkgs:
  87. f.write("%s %s %s\n" % (info[1], info[2], info[3]))
  88. pkgs[info[1]] = {}
  89. }
  90. python write_host_sdk_ext_manifest () {
  91. from oe.sdk import get_extra_sdkinfo
  92. sstate_dir = d.expand('${SDK_OUTPUT}/${SDKPATH}/sstate-cache')
  93. extra_info = get_extra_sdkinfo(sstate_dir)
  94. host = d.getVar('BUILD_SYS')
  95. with open(d.getVar('SDK_EXT_HOST_MANIFEST'), 'w') as f:
  96. for fn in extra_info['filesizes']:
  97. info = fn.split(':')
  98. if info[2] == host:
  99. f.write("%s %s %s\n" % (info[1], info[2], info[3]))
  100. }
  101. SDK_POSTPROCESS_COMMAND:append:task-populate-sdk-ext = " write_target_sdk_ext_manifest write_host_sdk_ext_manifest"
  102. SDK_TITLE:task-populate-sdk-ext = "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} Extensible SDK"
  103. def clean_esdk_builddir(d, sdkbasepath):
  104. """Clean up traces of the fake build for create_filtered_tasklist()"""
  105. import shutil
  106. cleanpaths = ['cache', 'tmp']
  107. for pth in cleanpaths:
  108. fullpth = os.path.join(sdkbasepath, pth)
  109. if os.path.isdir(fullpth):
  110. shutil.rmtree(fullpth)
  111. elif os.path.isfile(fullpth):
  112. os.remove(fullpth)
  113. def create_filtered_tasklist(d, sdkbasepath, tasklistfile, conf_initpath):
  114. """
  115. Create a filtered list of tasks. Also double-checks that the build system
  116. within the SDK basically works and required sstate artifacts are available.
  117. """
  118. import tempfile
  119. import shutil
  120. import oe.copy_buildsystem
  121. # Create a temporary build directory that we can pass to the env setup script
  122. shutil.copyfile(sdkbasepath + '/conf/local.conf', sdkbasepath + '/conf/local.conf.bak')
  123. try:
  124. with open(sdkbasepath + '/conf/local.conf', 'a') as f:
  125. # Force the use of sstate from the build system
  126. f.write('\nSSTATE_DIR:forcevariable = "%s"\n' % d.getVar('SSTATE_DIR'))
  127. f.write('SSTATE_MIRRORS:forcevariable = "file://universal/(.*) file://universal-4.9/\\1 file://universal-4.9/(.*) file://universal-4.8/\\1"\n')
  128. # Ensure TMPDIR is the default so that clean_esdk_builddir() can delete it
  129. f.write('TMPDIR:forcevariable = "${TOPDIR}/tmp"\n')
  130. # Drop uninative if the build isn't using it (or else NATIVELSBSTRING will
  131. # be different and we won't be able to find our native sstate)
  132. if not bb.data.inherits_class('uninative', d):
  133. f.write('INHERIT:remove = "uninative"\n')
  134. # Unfortunately the default SDKPATH (or even a custom value) may contain characters that bitbake
  135. # will not allow in its COREBASE path, so we need to rename the directory temporarily
  136. temp_sdkbasepath = d.getVar('SDK_OUTPUT') + '/tmp-renamed-sdk'
  137. # Delete any existing temp dir
  138. try:
  139. shutil.rmtree(temp_sdkbasepath)
  140. except FileNotFoundError:
  141. pass
  142. bb.utils.rename(sdkbasepath, temp_sdkbasepath)
  143. cmdprefix = '. %s .; ' % conf_initpath
  144. logfile = d.getVar('WORKDIR') + '/tasklist_bb_log.txt'
  145. try:
  146. oe.copy_buildsystem.check_sstate_task_list(d, get_sdk_install_targets(d), tasklistfile, cmdprefix=cmdprefix, cwd=temp_sdkbasepath, logfile=logfile)
  147. except bb.process.ExecutionError as e:
  148. msg = 'Failed to generate filtered task list for extensible SDK:\n%s' % e.stdout.rstrip()
  149. if 'attempted to execute unexpectedly and should have been setscened' in e.stdout:
  150. 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'
  151. bb.fatal(msg)
  152. bb.utils.rename(temp_sdkbasepath, sdkbasepath)
  153. # Clean out residue of running bitbake, which check_sstate_task_list()
  154. # will effectively do
  155. clean_esdk_builddir(d, sdkbasepath)
  156. finally:
  157. localconf = sdkbasepath + '/conf/local.conf'
  158. if os.path.exists(localconf + '.bak'):
  159. os.replace(localconf + '.bak', localconf)
  160. def copy_bitbake_and_layers(d, baseoutpath, derivative):
  161. oe_init_env_script = d.getVar('OE_INIT_ENV_SCRIPT')
  162. conf_bbpath = ''
  163. conf_initpath = ''
  164. core_meta_subdir = ''
  165. # Copy in all metadata layers + bitbake (as repositories)
  166. buildsystem = oe.copy_buildsystem.BuildSystem('extensible SDK', d)
  167. if derivative:
  168. workspace_name = 'orig-workspace'
  169. else:
  170. workspace_name = None
  171. corebase, sdkbblayers = buildsystem.copy_bitbake_and_layers(baseoutpath + '/layers', workspace_name)
  172. conf_bbpath = os.path.join('layers', corebase, 'bitbake')
  173. for path in os.listdir(baseoutpath + '/layers'):
  174. relpath = os.path.join('layers', path, oe_init_env_script)
  175. if os.path.exists(os.path.join(baseoutpath, relpath)):
  176. conf_initpath = relpath
  177. relpath = os.path.join('layers', path, 'scripts', 'esdk-tools', 'devtool')
  178. if os.path.exists(os.path.join(baseoutpath, relpath)):
  179. esdk_tools_path = os.path.dirname(relpath)
  180. relpath = os.path.join('layers', path, 'meta')
  181. if os.path.exists(os.path.join(baseoutpath, relpath, 'lib', 'oe')):
  182. core_meta_subdir = relpath
  183. d.setVar('oe_init_build_env_path', conf_initpath)
  184. d.setVar('esdk_tools_path', esdk_tools_path)
  185. return (conf_initpath, conf_bbpath, core_meta_subdir, sdkbblayers)
  186. def write_devtool_config(d, baseoutpath, conf_bbpath, conf_initpath, core_meta_subdir):
  187. # Write out config file for devtool
  188. import configparser
  189. config = configparser.ConfigParser()
  190. config.add_section('General')
  191. config.set('General', 'bitbake_subdir', conf_bbpath)
  192. config.set('General', 'init_path', conf_initpath)
  193. config.set('General', 'core_meta_subdir', core_meta_subdir)
  194. config.add_section('SDK')
  195. config.set('SDK', 'sdk_targets', d.getVar('SDK_TARGETS'))
  196. updateurl = d.getVar('SDK_UPDATE_URL')
  197. if updateurl:
  198. config.set('SDK', 'updateserver', updateurl)
  199. bb.utils.mkdirhier(os.path.join(baseoutpath, 'conf'))
  200. with open(os.path.join(baseoutpath, 'conf', 'devtool.conf'), 'w') as f:
  201. config.write(f)
  202. def write_unlocked_sigs(d, baseoutpath):
  203. unlockedsigs = os.path.join(baseoutpath, 'conf', 'unlocked-sigs.inc')
  204. with open(unlockedsigs, 'w') as f:
  205. pass
  206. def write_bblayers_conf(d, baseoutpath, sdkbblayers):
  207. # Create a layer for new recipes / appends
  208. bbpath = d.getVar('BBPATH')
  209. env = os.environ.copy()
  210. env['PYTHONDONTWRITEBYTECODE'] = '1'
  211. bb.process.run(['devtool', '--bbpath', bbpath, '--basepath', baseoutpath, 'create-workspace', '--layerseries', d.getVar("LAYERSERIES_CORENAMES"), '--create-only', os.path.join(baseoutpath, 'workspace')], env=env)
  212. # Create bblayers.conf
  213. bb.utils.mkdirhier(baseoutpath + '/conf')
  214. with open(baseoutpath + '/conf/bblayers.conf', 'w') as f:
  215. f.write('# WARNING: this configuration has been automatically generated and in\n')
  216. f.write('# most cases should not be edited. If you need more flexibility than\n')
  217. f.write('# this configuration provides, it is strongly suggested that you set\n')
  218. f.write('# up a proper instance of the full build system and use that instead.\n\n')
  219. # LCONF_VERSION may not be set, for example when using meta-poky
  220. # so don't error if it isn't found
  221. lconf_version = d.getVar('LCONF_VERSION', False)
  222. if lconf_version is not None:
  223. f.write('LCONF_VERSION = "%s"\n\n' % lconf_version)
  224. f.write('BBPATH = "$' + '{TOPDIR}"\n')
  225. f.write('SDKBASEMETAPATH = "$' + '{TOPDIR}"\n')
  226. f.write('BBLAYERS := " \\\n')
  227. for layerrelpath in sdkbblayers:
  228. f.write(' $' + '{SDKBASEMETAPATH}/layers/%s \\\n' % layerrelpath)
  229. f.write(' $' + '{SDKBASEMETAPATH}/workspace \\\n')
  230. f.write(' "\n')
  231. def copy_uninative(d, baseoutpath):
  232. import shutil
  233. uninative_checksum = None
  234. # Copy uninative tarball
  235. # For now this is where uninative.bbclass expects the tarball
  236. if bb.data.inherits_class('uninative', d):
  237. uninative_file = d.expand('${UNINATIVE_DLDIR}/' + d.getVarFlag("UNINATIVE_CHECKSUM", d.getVar("BUILD_ARCH")) + '/${UNINATIVE_TARBALL}')
  238. uninative_checksum = bb.utils.sha256_file(uninative_file)
  239. uninative_outdir = '%s/downloads/uninative/%s' % (baseoutpath, uninative_checksum)
  240. bb.utils.mkdirhier(uninative_outdir)
  241. shutil.copy(uninative_file, uninative_outdir)
  242. return uninative_checksum
  243. def write_local_conf(d, baseoutpath, derivative, core_meta_subdir, uninative_checksum):
  244. import shutil
  245. #check if custome templateconf path is set
  246. use_custom_templateconf = d.getVar('SDK_CUSTOM_TEMPLATECONF')
  247. env_passthrough = (d.getVar('BB_ENV_PASSTHROUGH_ADDITIONS') or '').split()
  248. env_passthrough_values = {}
  249. # Create local.conf
  250. builddir = d.getVar('TOPDIR')
  251. if derivative and os.path.exists(builddir + '/conf/site.conf'):
  252. shutil.copyfile(builddir + '/conf/site.conf', baseoutpath + '/conf/site.conf')
  253. if derivative and os.path.exists(builddir + '/conf/auto.conf'):
  254. shutil.copyfile(builddir + '/conf/auto.conf', baseoutpath + '/conf/auto.conf')
  255. if derivative:
  256. shutil.copyfile(builddir + '/conf/local.conf', baseoutpath + '/conf/local.conf')
  257. else:
  258. local_conf_allowed = (d.getVar('ESDK_LOCALCONF_ALLOW') or '').split()
  259. local_conf_remove = (d.getVar('ESDK_LOCALCONF_REMOVE') or '').split()
  260. def handle_var(varname, origvalue, op, newlines):
  261. if varname in local_conf_remove or (origvalue.strip().startswith('/') and not varname in local_conf_allowed):
  262. newlines.append('# Removed original setting of %s\n' % varname)
  263. return None, op, 0, True
  264. else:
  265. if varname in env_passthrough:
  266. env_passthrough_values[varname] = origvalue
  267. return origvalue, op, 0, True
  268. varlist = ['[^#=+ ]*']
  269. oldlines = []
  270. if os.path.exists(builddir + '/conf/site.conf'):
  271. with open(builddir + '/conf/site.conf', 'r') as f:
  272. oldlines += f.readlines()
  273. if os.path.exists(builddir + '/conf/auto.conf'):
  274. with open(builddir + '/conf/auto.conf', 'r') as f:
  275. oldlines += f.readlines()
  276. if os.path.exists(builddir + '/conf/local.conf'):
  277. with open(builddir + '/conf/local.conf', 'r') as f:
  278. oldlines += f.readlines()
  279. (updated, newlines) = bb.utils.edit_metadata(oldlines, varlist, handle_var)
  280. with open(baseoutpath + '/conf/local.conf', 'w') as f:
  281. f.write('# WARNING: this configuration has been automatically generated and in\n')
  282. f.write('# most cases should not be edited. If you need more flexibility than\n')
  283. f.write('# this configuration provides, it is strongly suggested that you set\n')
  284. f.write('# up a proper instance of the full build system and use that instead.\n\n')
  285. for line in newlines:
  286. if line.strip() and not line.startswith('#'):
  287. f.write(line)
  288. # Write a newline just in case there's none at the end of the original
  289. f.write('\n')
  290. f.write('TMPDIR = "${TOPDIR}/tmp"\n')
  291. f.write('DL_DIR = "${TOPDIR}/downloads"\n')
  292. if bb.data.inherits_class('uninative', d):
  293. f.write('INHERIT += "%s"\n' % 'uninative')
  294. f.write('UNINATIVE_CHECKSUM[%s] = "%s"\n\n' % (d.getVar('BUILD_ARCH'), uninative_checksum))
  295. f.write('CONF_VERSION = "%s"\n\n' % d.getVar('CONF_VERSION', False))
  296. # Some classes are not suitable for SDK, remove them from INHERIT
  297. f.write('INHERIT:remove = "%s"\n' % d.getVar('ESDK_CLASS_INHERIT_DISABLE', False))
  298. # Bypass the default connectivity check if any
  299. f.write('CONNECTIVITY_CHECK_URIS = ""\n\n')
  300. # This warning will come out if reverse dependencies for a task
  301. # don't have sstate as well as the task itself. We already know
  302. # this will be the case for the extensible sdk, so turn off the
  303. # warning.
  304. f.write('SIGGEN_LOCKEDSIGS_SSTATE_EXISTS_CHECK = "none"\n\n')
  305. # Warn if the sigs in the locked-signature file don't match
  306. # the sig computed from the metadata.
  307. f.write('SIGGEN_LOCKEDSIGS_TASKSIG_CHECK = "warn"\n\n')
  308. # We want to be able to set this without a full reparse
  309. f.write('BB_HASHCONFIG_IGNORE_VARS:append = " SIGGEN_UNLOCKED_RECIPES"\n\n')
  310. # Set up which tasks are ignored for run on install
  311. f.write('BB_SETSCENE_ENFORCE_IGNORE_TASKS = "%:* *:do_shared_workdir *:do_rm_work wic-tools:* *:do_addto_recipe_sysroot"\n\n')
  312. # Hide the config information from bitbake output (since it's fixed within the SDK)
  313. f.write('BUILDCFG_HEADER = ""\n\n')
  314. # Write METADATA_REVISION
  315. # Needs distro override so it can override the value set in the bbclass code (later than local.conf)
  316. f.write('METADATA_REVISION:%s = "%s"\n\n' % (d.getVar('DISTRO'), d.getVar('METADATA_REVISION')))
  317. f.write('# Provide a flag to indicate we are in the EXT_SDK Context\n')
  318. f.write('WITHIN_EXT_SDK = "1"\n\n')
  319. # Map gcc-dependent uninative sstate cache for installer usage
  320. f.write('SSTATE_MIRRORS += " file://universal/(.*) file://universal-4.9/\\1 file://universal-4.9/(.*) file://universal-4.8/\\1"\n\n')
  321. if d.getVar("PRSERV_HOST"):
  322. # Override this, we now include PR data, so it should only point ot the local database
  323. f.write('PRSERV_HOST = "localhost:0"\n\n')
  324. # Allow additional config through sdk-extra.conf
  325. fn = bb.cookerdata.findConfigFile('sdk-extra.conf', d)
  326. if fn:
  327. with open(fn, 'r') as xf:
  328. for line in xf:
  329. f.write(line)
  330. # If you define a sdk_extraconf() function then it can contain additional config
  331. # (Though this is awkward; sdk-extra.conf should probably be used instead)
  332. extraconf = (d.getVar('sdk_extraconf') or '').strip()
  333. if extraconf:
  334. # Strip off any leading / trailing spaces
  335. for line in extraconf.splitlines():
  336. f.write(line.strip() + '\n')
  337. f.write('require conf/locked-sigs.inc\n')
  338. f.write('require conf/unlocked-sigs.inc\n')
  339. # Copy multiple configurations if they exist in the users config directory
  340. if d.getVar('BBMULTICONFIG') is not None:
  341. bb.utils.mkdirhier(os.path.join(baseoutpath, 'conf', 'multiconfig'))
  342. for mc in d.getVar('BBMULTICONFIG').split():
  343. dest_stub = "/conf/multiconfig/%s.conf" % (mc,)
  344. if os.path.exists(builddir + dest_stub):
  345. shutil.copyfile(builddir + dest_stub, baseoutpath + dest_stub)
  346. # If PR Service is in use, we need to export this as well
  347. bb.note('Do we have a pr database?')
  348. if d.getVar("PRSERV_HOST"):
  349. bb.note('Writing PR database...')
  350. # Based on the code in classes/prexport.bbclass
  351. import oe.prservice
  352. #dump meta info of tables
  353. localdata = d.createCopy()
  354. localdata.setVar('PRSERV_DUMPOPT_COL', "1")
  355. localdata.setVar('PRSERV_DUMPDIR', os.path.join(baseoutpath, 'conf'))
  356. localdata.setVar('PRSERV_DUMPFILE', '${PRSERV_DUMPDIR}/prserv.inc')
  357. bb.note('PR Database write to %s' % (localdata.getVar('PRSERV_DUMPFILE')))
  358. retval = oe.prservice.prserv_dump_db(localdata)
  359. if not retval:
  360. bb.error("prexport_handler: export failed!")
  361. return
  362. (metainfo, datainfo) = retval
  363. oe.prservice.prserv_export_tofile(localdata, metainfo, datainfo, True)
  364. # Use templateconf.cfg file from builddir if exists
  365. if os.path.exists(builddir + '/conf/templateconf.cfg') and use_custom_templateconf == '1':
  366. shutil.copyfile(builddir + '/conf/templateconf.cfg', baseoutpath + '/conf/templateconf.cfg')
  367. else:
  368. # Write a templateconf.cfg
  369. with open(baseoutpath + '/conf/templateconf.cfg', 'w') as f:
  370. f.write('meta/conf/templates/default\n')
  371. os.makedirs(os.path.join(baseoutpath, core_meta_subdir, 'conf/templates/default'), exist_ok=True)
  372. # Ensure any variables set from the external environment (by way of
  373. # BB_ENV_PASSTHROUGH_ADDITIONS) are set in the SDK's configuration
  374. extralines = []
  375. for name, value in env_passthrough_values.items():
  376. actualvalue = d.getVar(name) or ''
  377. if value != actualvalue:
  378. extralines.append('%s = "%s"\n' % (name, actualvalue))
  379. if extralines:
  380. with open(baseoutpath + '/conf/local.conf', 'a') as f:
  381. f.write('\n')
  382. f.write('# Extra settings from environment:\n')
  383. for line in extralines:
  384. f.write(line)
  385. f.write('\n')
  386. def prepare_locked_cache(d, baseoutpath, derivative, conf_initpath):
  387. import shutil
  388. # Filter the locked signatures file to just the sstate tasks we are interested in
  389. excluded_targets = get_sdk_install_targets(d, images_only=True)
  390. sigfile = d.getVar('WORKDIR') + '/locked-sigs.inc'
  391. lockedsigs_pruned = baseoutpath + '/conf/locked-sigs.inc'
  392. #nativesdk-only sigfile to merge into locked-sigs.inc
  393. sdk_include_nativesdk = (d.getVar("SDK_INCLUDE_NATIVESDK") == '1')
  394. nativesigfile = d.getVar('WORKDIR') + '/locked-sigs_nativesdk.inc'
  395. nativesigfile_pruned = d.getVar('WORKDIR') + '/locked-sigs_nativesdk_pruned.inc'
  396. if sdk_include_nativesdk:
  397. oe.copy_buildsystem.prune_lockedsigs([],
  398. excluded_targets.split(),
  399. nativesigfile,
  400. True,
  401. nativesigfile_pruned)
  402. oe.copy_buildsystem.merge_lockedsigs([],
  403. sigfile,
  404. nativesigfile_pruned,
  405. sigfile)
  406. oe.copy_buildsystem.prune_lockedsigs([],
  407. excluded_targets.split(),
  408. sigfile,
  409. False,
  410. lockedsigs_pruned)
  411. sstate_out = baseoutpath + '/sstate-cache'
  412. bb.utils.remove(sstate_out, True)
  413. # uninative.bbclass sets NATIVELSBSTRING to 'universal%s' % oe.utils.host_gcc_version(d)
  414. fixedlsbstring = "universal%s" % oe.utils.host_gcc_version(d) if bb.data.inherits_class('uninative', d) else ""
  415. sdk_include_toolchain = (d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1')
  416. sdk_ext_type = d.getVar('SDK_EXT_TYPE')
  417. if (sdk_ext_type != 'minimal' or sdk_include_toolchain or derivative) and not sdk_include_nativesdk:
  418. # Create the filtered task list used to generate the sstate cache shipped with the SDK
  419. tasklistfn = d.getVar('WORKDIR') + '/tasklist.txt'
  420. create_filtered_tasklist(d, baseoutpath, tasklistfn, conf_initpath)
  421. else:
  422. tasklistfn = None
  423. # Add packagedata if enabled
  424. if d.getVar('SDK_INCLUDE_PKGDATA') == '1':
  425. lockedsigs_base = d.getVar('WORKDIR') + '/locked-sigs-base.inc'
  426. lockedsigs_copy = d.getVar('WORKDIR') + '/locked-sigs-copy.inc'
  427. shutil.move(lockedsigs_pruned, lockedsigs_base)
  428. oe.copy_buildsystem.merge_lockedsigs(['do_packagedata'],
  429. lockedsigs_base,
  430. d.getVar('STAGING_DIR_HOST') + '/world-pkgdata/locked-sigs-pkgdata.inc',
  431. lockedsigs_pruned,
  432. lockedsigs_copy)
  433. if sdk_include_toolchain:
  434. lockedsigs_base = d.getVar('WORKDIR') + '/locked-sigs-base2.inc'
  435. lockedsigs_toolchain = d.expand("${STAGING_DIR}/${TUNE_PKGARCH}/meta-extsdk-toolchain/locked-sigs/locked-sigs-extsdk-toolchain.inc")
  436. shutil.move(lockedsigs_pruned, lockedsigs_base)
  437. oe.copy_buildsystem.merge_lockedsigs([],
  438. lockedsigs_base,
  439. lockedsigs_toolchain,
  440. lockedsigs_pruned)
  441. oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_toolchain,
  442. d.getVar('SSTATE_DIR'),
  443. sstate_out, d,
  444. fixedlsbstring,
  445. filterfile=tasklistfn)
  446. if sdk_ext_type == 'minimal':
  447. if derivative:
  448. # Assume the user is not going to set up an additional sstate
  449. # mirror, thus we need to copy the additional artifacts (from
  450. # workspace recipes) into the derivative SDK
  451. lockedsigs_orig = d.getVar('TOPDIR') + '/conf/locked-sigs.inc'
  452. if os.path.exists(lockedsigs_orig):
  453. lockedsigs_extra = d.getVar('WORKDIR') + '/locked-sigs-extra.inc'
  454. oe.copy_buildsystem.merge_lockedsigs(None,
  455. lockedsigs_orig,
  456. lockedsigs_pruned,
  457. None,
  458. lockedsigs_extra)
  459. oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_extra,
  460. d.getVar('SSTATE_DIR'),
  461. sstate_out, d,
  462. fixedlsbstring,
  463. filterfile=tasklistfn)
  464. else:
  465. oe.copy_buildsystem.create_locked_sstate_cache(lockedsigs_pruned,
  466. d.getVar('SSTATE_DIR'),
  467. sstate_out, d,
  468. fixedlsbstring,
  469. filterfile=tasklistfn)
  470. # We don't need sstate do_package files
  471. for root, dirs, files in os.walk(sstate_out):
  472. for name in files:
  473. if name.endswith("_package.tar.zst"):
  474. f = os.path.join(root, name)
  475. os.remove(f)
  476. def write_manifest(d, baseoutpath):
  477. import glob
  478. # Write manifest file
  479. # Note: at the moment we cannot include the env setup script here to keep
  480. # it updated, since it gets modified during SDK installation (see
  481. # sdk_ext_postinst() below) thus the checksum we take here would always
  482. # be different.
  483. manifest_file_list = ['conf/*']
  484. if d.getVar('BBMULTICONFIG') is not None:
  485. manifest_file_list.append('conf/multiconfig/*')
  486. esdk_manifest_excludes = (d.getVar('ESDK_MANIFEST_EXCLUDES') or '').split()
  487. esdk_manifest_excludes_list = []
  488. for exclude_item in esdk_manifest_excludes:
  489. esdk_manifest_excludes_list += glob.glob(os.path.join(baseoutpath, exclude_item))
  490. manifest_file = os.path.join(baseoutpath, 'conf', 'sdk-conf-manifest')
  491. with open(manifest_file, 'w') as f:
  492. for item in manifest_file_list:
  493. for fn in glob.glob(os.path.join(baseoutpath, item)):
  494. if fn == manifest_file or os.path.isdir(fn):
  495. continue
  496. if fn in esdk_manifest_excludes_list:
  497. continue
  498. chksum = bb.utils.sha256_file(fn)
  499. f.write('%s\t%s\n' % (chksum, os.path.relpath(fn, baseoutpath)))
  500. python copy_buildsystem () {
  501. import oe.copy_buildsystem
  502. baseoutpath = d.getVar('SDK_OUTPUT') + '/' + d.getVar('SDKPATH')
  503. # Determine if we're building a derivative extensible SDK (from devtool build-sdk)
  504. derivative = (d.getVar('SDK_DERIVATIVE') or '') == '1'
  505. conf_initpath, conf_bbpath, core_meta_subdir, sdkbblayers = copy_bitbake_and_layers(d, baseoutpath, derivative)
  506. write_devtool_config(d, baseoutpath, conf_bbpath, conf_initpath, core_meta_subdir)
  507. write_unlocked_sigs(d, baseoutpath)
  508. write_bblayers_conf(d, baseoutpath, sdkbblayers)
  509. uninative_checksum = copy_uninative(d, baseoutpath)
  510. write_local_conf(d, baseoutpath, derivative, core_meta_subdir, uninative_checksum)
  511. prepare_locked_cache(d, baseoutpath, derivative, conf_initpath)
  512. write_manifest(d, baseoutpath)
  513. }
  514. def get_current_buildtools(d):
  515. """Get the file name of the current buildtools installer"""
  516. import glob
  517. btfiles = glob.glob(os.path.join(d.getVar('SDK_DEPLOY'), '*-buildtools-nativesdk-standalone-*.sh'))
  518. btfiles.sort(key=os.path.getctime)
  519. return os.path.basename(btfiles[-1])
  520. def get_sdk_required_utilities(buildtools_fn, d):
  521. """Find required utilities that aren't provided by the buildtools"""
  522. sanity_required_utilities = (d.getVar('SANITY_REQUIRED_UTILITIES') or '').split()
  523. sanity_required_utilities.append(d.expand('${BUILD_PREFIX}gcc'))
  524. sanity_required_utilities.append(d.expand('${BUILD_PREFIX}g++'))
  525. if buildtools_fn:
  526. buildtools_installer = os.path.join(d.getVar('SDK_DEPLOY'), buildtools_fn)
  527. filelist, _ = bb.process.run('%s -l' % buildtools_installer)
  528. else:
  529. buildtools_installer = None
  530. filelist = ""
  531. localdata = bb.data.createCopy(d)
  532. localdata.setVar('SDKPATH', '.')
  533. sdkpathnative = localdata.getVar('SDKPATHNATIVE')
  534. sdkbindirs = [localdata.getVar('bindir_nativesdk'),
  535. localdata.getVar('sbindir_nativesdk'),
  536. localdata.getVar('base_bindir_nativesdk'),
  537. localdata.getVar('base_sbindir_nativesdk')]
  538. for line in filelist.splitlines():
  539. splitline = line.split()
  540. if len(splitline) > 5:
  541. fn = splitline[5]
  542. if not fn.startswith('./'):
  543. fn = './%s' % fn
  544. if fn.startswith(sdkpathnative):
  545. relpth = '/' + os.path.relpath(fn, sdkpathnative)
  546. for bindir in sdkbindirs:
  547. if relpth.startswith(bindir):
  548. relpth = os.path.relpath(relpth, bindir)
  549. if relpth in sanity_required_utilities:
  550. sanity_required_utilities.remove(relpth)
  551. break
  552. return ' '.join(sanity_required_utilities)
  553. install_tools() {
  554. touch ${SDK_OUTPUT}/${SDKPATH}/.devtoolbase
  555. # find latest buildtools-tarball and install it
  556. if [ -n "${SDK_BUILDTOOLS_INSTALLER}" ]; then
  557. install ${SDK_DEPLOY}/${SDK_BUILDTOOLS_INSTALLER} ${SDK_OUTPUT}/${SDKPATH}
  558. fi
  559. install -m 0644 ${COREBASE}/meta/files/ext-sdk-prepare.py ${SDK_OUTPUT}/${SDKPATH}
  560. }
  561. do_populate_sdk_ext[file-checksums] += "${COREBASE}/meta/files/ext-sdk-prepare.py:True"
  562. sdk_ext_preinst() {
  563. # Since bitbake won't run as root it doesn't make sense to try and install
  564. # the extensible sdk as root.
  565. if [ "`id -u`" = "0" ]; then
  566. echo "ERROR: The extensible sdk cannot be installed as root."
  567. exit 1
  568. fi
  569. if ! command -v locale > /dev/null; then
  570. echo "ERROR: The installer requires the locale command, please install it first"
  571. exit 1
  572. fi
  573. # Check setting of LC_ALL set above
  574. canonicalised_locale=`echo $LC_ALL | sed 's/UTF-8/utf8/'`
  575. if ! locale -a | grep -q $canonicalised_locale ; then
  576. echo "ERROR: the installer requires the $LC_ALL locale to be installed (but not selected), please install it first"
  577. exit 1
  578. fi
  579. # The relocation script used by buildtools installer requires python
  580. if ! command -v python3 > /dev/null; then
  581. echo "ERROR: The installer requires python3, please install it first"
  582. exit 1
  583. fi
  584. missing_utils=""
  585. for util in ${SDK_REQUIRED_UTILITIES}; do
  586. if ! command -v $util > /dev/null; then
  587. missing_utils="$missing_utils $util"
  588. fi
  589. done
  590. if [ -n "$missing_utils" ] ; then
  591. echo "ERROR: the SDK requires the following missing utilities, please install them: $missing_utils"
  592. exit 1
  593. fi
  594. SDK_EXTENSIBLE="1"
  595. if [ "$publish" = "1" ] && [ "${SDK_EXT_TYPE}" = "minimal" ] ; then
  596. EXTRA_TAR_OPTIONS="$EXTRA_TAR_OPTIONS --exclude=sstate-cache"
  597. fi
  598. }
  599. SDK_PRE_INSTALL_COMMAND:task-populate-sdk-ext = "${sdk_ext_preinst}"
  600. # FIXME this preparation should be done as part of the SDK construction
  601. sdk_ext_postinst() {
  602. printf "\nExtracting buildtools...\n"
  603. cd $target_sdk_dir
  604. env_setup_script="$target_sdk_dir/environment-setup-${REAL_MULTIMACH_TARGET_SYS}"
  605. if [ -n "${SDK_BUILDTOOLS_INSTALLER}" ]; then
  606. 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 ; }
  607. # Delete the buildtools tar file since it won't be used again
  608. rm -f ./${SDK_BUILDTOOLS_INSTALLER}
  609. # We don't need the log either since it succeeded
  610. rm -f buildtools.log
  611. # Make sure when the user sets up the environment, they also get
  612. # the buildtools-tarball tools in their path.
  613. echo "# Save and reset OECORE_NATIVE_SYSROOT as buildtools may change it" >> $env_setup_script
  614. echo "SAVED=\"\$OECORE_NATIVE_SYSROOT\"" >> $env_setup_script
  615. echo ". $target_sdk_dir/buildtools/environment-setup*" >> $env_setup_script
  616. echo "export OECORE_NATIVE_SYSROOT=\"\$SAVED\"" >> $env_setup_script
  617. fi
  618. # Allow bitbake environment setup to be ran as part of this sdk.
  619. echo "export OE_SKIP_SDK_CHECK=1" >> $env_setup_script
  620. # 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
  622. # A bit of another hack, but we need this in the path only for devtool
  623. # so put it at the end of $PATH.
  624. echo "export PATH=\"$target_sdk_dir/${esdk_tools_path}:\$PATH\"" >> $env_setup_script
  625. 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
  626. # Warn if trying to use external bitbake and the ext SDK together
  627. 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
  628. if [ "$prepare_buildsystem" != "no" -a -n "${SDK_BUILDTOOLS_INSTALLER}" ]; then
  629. printf "Preparing build system...\n"
  630. # dash which is /bin/sh on Ubuntu will not preserve the
  631. # current working directory when first ran, nor will it set $1 when
  632. # sourcing a script. That is why this has to look so ugly.
  633. LOGFILE="$target_sdk_dir/preparing_build_system.log"
  634. sh -c ". buildtools/environment-setup* > $LOGFILE 2>&1 && 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 2>&1 && python3 $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 ; }
  635. fi
  636. if [ -e $target_sdk_dir/ext-sdk-prepare.py ]; then
  637. rm $target_sdk_dir/ext-sdk-prepare.py
  638. fi
  639. echo done
  640. }
  641. SDK_POST_INSTALL_COMMAND:task-populate-sdk-ext = "${sdk_ext_postinst}"
  642. SDK_POSTPROCESS_COMMAND:prepend:task-populate-sdk-ext = "copy_buildsystem install_tools "
  643. SDK_INSTALL_TARGETS = ""
  644. fakeroot python do_populate_sdk_ext() {
  645. # FIXME hopefully we can remove this restriction at some point, but uninative
  646. # currently forces this upon us
  647. if d.getVar('SDK_ARCH') != d.getVar('BUILD_ARCH'):
  648. 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')))
  649. # FIXME hopefully we can remove this restriction at some point, but the eSDK
  650. # can only be built for the primary (default) multiconfig
  651. if d.getVar('BB_CURRENT_MC') != '':
  652. bb.fatal('The extensible SDK can currently only be built for the default multiconfig. Currently trying to build for %s.' % d.getVar('BB_CURRENT_MC'))
  653. # eSDK dependencies don't use the traditional variables and things don't work properly if they are set
  654. d.setVar("TOOLCHAIN_HOST_TASK", "${TOOLCHAIN_HOST_TASK_ESDK}")
  655. d.setVar("TOOLCHAIN_TARGET_TASK", "")
  656. d.setVar('SDK_INSTALL_TARGETS', get_sdk_install_targets(d))
  657. if d.getVar('SDK_INCLUDE_BUILDTOOLS') == '1':
  658. buildtools_fn = get_current_buildtools(d)
  659. else:
  660. buildtools_fn = None
  661. d.setVar('SDK_REQUIRED_UTILITIES', get_sdk_required_utilities(buildtools_fn, d))
  662. d.setVar('SDK_BUILDTOOLS_INSTALLER', buildtools_fn)
  663. d.setVar('SDKDEPLOYDIR', '${SDKEXTDEPLOYDIR}')
  664. # ESDKs have a libc from the buildtools so ensure we don't ship linguas twice
  665. d.delVar('SDKIMAGE_LINGUAS')
  666. if d.getVar("SDK_INCLUDE_NATIVESDK") == '1':
  667. generate_nativesdk_lockedsigs(d)
  668. populate_sdk_common(d)
  669. }
  670. def generate_nativesdk_lockedsigs(d):
  671. import oe.copy_buildsystem
  672. sigfile = d.getVar('WORKDIR') + '/locked-sigs_nativesdk.inc'
  673. oe.copy_buildsystem.generate_locked_sigs(sigfile, d)
  674. def get_ext_sdk_depends(d):
  675. # Note: the deps varflag is a list not a string, so we need to specify expand=False
  676. deps = d.getVarFlag('do_image_complete', 'deps', False)
  677. pn = d.getVar('PN')
  678. deplist = ['%s:%s' % (pn, dep) for dep in deps]
  679. tasklist = bb.build.tasksbetween('do_image_complete', 'do_build', d)
  680. tasklist.append('do_rootfs')
  681. for task in tasklist:
  682. deplist.extend((d.getVarFlag(task, 'depends') or '').split())
  683. return ' '.join(deplist)
  684. python do_sdk_depends() {
  685. # We have to do this separately in its own task so we avoid recursing into
  686. # dependencies we don't need to (e.g. buildtools-tarball) and bringing those
  687. # into the SDK's sstate-cache
  688. import oe.copy_buildsystem
  689. sigfile = d.getVar('WORKDIR') + '/locked-sigs.inc'
  690. oe.copy_buildsystem.generate_locked_sigs(sigfile, d)
  691. }
  692. addtask sdk_depends
  693. do_sdk_depends[dirs] = "${WORKDIR}"
  694. do_sdk_depends[depends] = "${@get_ext_sdk_depends(d)} meta-extsdk-toolchain:do_populate_sysroot"
  695. do_sdk_depends[recrdeptask] = "${@d.getVarFlag('do_populate_sdk', 'recrdeptask', False)}"
  696. do_sdk_depends[recrdeptask] += "do_populate_lic do_package_qa do_populate_sysroot do_deploy ${SDK_RECRDEP_TASKS}"
  697. do_sdk_depends[rdepends] = "${@' '.join([x + ':do_package_write_${IMAGE_PKGTYPE} ' + x + ':do_packagedata' for x in d.getVar('TOOLCHAIN_HOST_TASK_ESDK').split()])}"
  698. do_populate_sdk_ext[dirs] = "${@d.getVarFlag('do_populate_sdk', 'dirs', False)}"
  699. do_populate_sdk_ext[depends] = "${@d.getVarFlag('do_populate_sdk', 'depends', False)} \
  700. ${@'buildtools-tarball:do_populate_sdk' if d.getVar('SDK_INCLUDE_BUILDTOOLS') == '1' else ''} \
  701. ${@'meta-world-pkgdata:do_collect_packagedata' if d.getVar('SDK_INCLUDE_PKGDATA') == '1' else ''} \
  702. ${@'meta-extsdk-toolchain:do_locked_sigs' if d.getVar('SDK_INCLUDE_TOOLCHAIN') == '1' else ''}"
  703. # 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.
  708. do_populate_sdk_ext[rdepends] += "${@' '.join([x + ':' + (d.getVar('RM_WORK_BUILD_WITHOUT') or 'do_build') for x in d.getVar('SDK_TARGETS').split()])}"
  709. # Make sure code changes can result in rebuild
  710. do_populate_sdk_ext[vardeps] += "copy_buildsystem \
  711. sdk_ext_postinst"
  712. # Since any change in the metadata of any layer should cause a rebuild of the
  713. # sdk(since the layers are put in the sdk) set the task to nostamp so it
  714. # always runs.
  715. do_populate_sdk_ext[nostamp] = "1"
  716. SDKEXTDEPLOYDIR = "${WORKDIR}/deploy-${PN}-populate-sdk-ext"
  717. SSTATETASKS += "do_populate_sdk_ext"
  718. SSTATE_SKIP_CREATION:task-populate-sdk-ext = '1'
  719. do_populate_sdk_ext[cleandirs] = "${SDKEXTDEPLOYDIR}"
  720. do_populate_sdk_ext[sstate-inputdirs] = "${SDKEXTDEPLOYDIR}"
  721. do_populate_sdk_ext[sstate-outputdirs] = "${SDK_DEPLOY}"
  722. do_populate_sdk_ext[stamp-extra-info] = "${MACHINE_ARCH}"
  723. addtask populate_sdk_ext after do_sdk_depends