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