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