Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # Copyright (C) 2012 Linux Foundation |
| 2 | # Author: Richard Purdie |
| 3 | # Some code and influence taken from srctree.bbclass: |
| 4 | # Copyright (C) 2009 Chris Larson <clarson@kergoth.com> |
| 5 | # Released under the MIT license (see COPYING.MIT for the terms) |
| 6 | # |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 7 | # externalsrc.bbclass enables use of an existing source tree, usually external to |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 8 | # the build system to build a piece of software rather than the usual fetch/unpack/patch |
| 9 | # process. |
| 10 | # |
| 11 | # To use, add externalsrc to the global inherit and set EXTERNALSRC to point at the |
| 12 | # directory you want to use containing the sources e.g. from local.conf for a recipe |
| 13 | # called "myrecipe" you would do: |
| 14 | # |
| 15 | # INHERIT += "externalsrc" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 16 | # EXTERNALSRC:pn-myrecipe = "/path/to/my/source/tree" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | # |
| 18 | # In order to make this class work for both target and native versions (or with |
| 19 | # multilibs/cross or other BBCLASSEXTEND variants), B is set to point to a separate |
| 20 | # directory under the work directory (split source and build directories). This is |
| 21 | # the default, but the build directory can be set to the source directory if |
| 22 | # circumstances dictate by setting EXTERNALSRC_BUILD to the same value, e.g.: |
| 23 | # |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 24 | # EXTERNALSRC_BUILD:pn-myrecipe = "/path/to/my/source/tree" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | # |
| 26 | |
| 27 | SRCTREECOVEREDTASKS ?= "do_patch do_unpack do_fetch" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 28 | EXTERNALSRC_SYMLINKS ?= "oe-workdir:${WORKDIR} oe-logs:${T}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | |
| 30 | python () { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 31 | externalsrc = d.getVar('EXTERNALSRC') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 32 | externalsrcbuild = d.getVar('EXTERNALSRC_BUILD') |
| 33 | |
| 34 | if externalsrc and not externalsrc.startswith("/"): |
| 35 | bb.error("EXTERNALSRC must be an absolute path") |
| 36 | if externalsrcbuild and not externalsrcbuild.startswith("/"): |
| 37 | bb.error("EXTERNALSRC_BUILD must be an absolute path") |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 38 | |
| 39 | # If this is the base recipe and EXTERNALSRC is set for it or any of its |
| 40 | # derivatives, then enable BB_DONT_CACHE to force the recipe to always be |
| 41 | # re-parsed so that the file-checksums function for do_compile is run every |
| 42 | # time. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 43 | bpn = d.getVar('BPN') |
Brad Bishop | 004d499 | 2018-10-02 23:54:45 +0200 | [diff] [blame] | 44 | classextend = (d.getVar('BBCLASSEXTEND') or '').split() |
| 45 | if bpn == d.getVar('PN') or not classextend: |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 46 | if (externalsrc or |
| 47 | ('native' in classextend and |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 48 | d.getVar('EXTERNALSRC:pn-%s-native' % bpn)) or |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 49 | ('nativesdk' in classextend and |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 50 | d.getVar('EXTERNALSRC:pn-nativesdk-%s' % bpn)) or |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 51 | ('cross' in classextend and |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 52 | d.getVar('EXTERNALSRC:pn-%s-cross' % bpn))): |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 53 | d.setVar('BB_DONT_CACHE', '1') |
| 54 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 55 | if externalsrc: |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 56 | import oe.recipeutils |
| 57 | import oe.path |
| 58 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 59 | d.setVar('S', externalsrc) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | if externalsrcbuild: |
| 61 | d.setVar('B', externalsrcbuild) |
| 62 | else: |
| 63 | d.setVar('B', '${WORKDIR}/${BPN}-${PV}/') |
| 64 | |
| 65 | local_srcuri = [] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 66 | fetch = bb.fetch2.Fetch((d.getVar('SRC_URI') or '').split(), d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 67 | for url in fetch.urls: |
| 68 | url_data = fetch.ud[url] |
| 69 | parm = url_data.parm |
| 70 | if (url_data.type == 'file' or |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 71 | url_data.type == 'npmsw' or url_data.type == 'crate' or |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | 'type' in parm and parm['type'] == 'kmeta'): |
| 73 | local_srcuri.append(url) |
| 74 | |
| 75 | d.setVar('SRC_URI', ' '.join(local_srcuri)) |
| 76 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 77 | # Dummy value because the default function can't be called with blank SRC_URI |
| 78 | d.setVar('SRCPV', '999') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 80 | if d.getVar('CONFIGUREOPT_DEPTRACK') == '--disable-dependency-tracking': |
| 81 | d.setVar('CONFIGUREOPT_DEPTRACK', '') |
| 82 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 83 | tasks = filter(lambda k: d.getVarFlag(k, "task"), d.keys()) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | |
| 85 | for task in tasks: |
| 86 | if task.endswith("_setscene"): |
| 87 | # sstate is never going to work for external source trees, disable it |
| 88 | bb.build.deltask(task, d) |
Andrew Geissler | 4c19ea1 | 2020-10-27 13:52:24 -0500 | [diff] [blame] | 89 | elif os.path.realpath(d.getVar('S')) == os.path.realpath(d.getVar('B')): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | # Since configure will likely touch ${S}, ensure only we lock so one task has access at a time |
| 91 | d.appendVarFlag(task, "lockfiles", " ${S}/singletask.lock") |
| 92 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame] | 93 | for funcname in [task, "base_" + task, "kernel_" + task]: |
| 94 | # We do not want our source to be wiped out, ever (kernel.bbclass does this for do_clean) |
| 95 | cleandirs = oe.recipeutils.split_var_value(d.getVarFlag(funcname, 'cleandirs', False) or '') |
| 96 | setvalue = False |
| 97 | for cleandir in cleandirs[:]: |
| 98 | if oe.path.is_path_parent(externalsrc, d.expand(cleandir)): |
| 99 | cleandirs.remove(cleandir) |
| 100 | setvalue = True |
| 101 | if setvalue: |
| 102 | d.setVarFlag(funcname, 'cleandirs', ' '.join(cleandirs)) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 103 | |
| 104 | fetch_tasks = ['do_fetch', 'do_unpack'] |
| 105 | # If we deltask do_patch, there's no dependency to ensure do_unpack gets run, so add one |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 106 | # Note that we cannot use d.appendVarFlag() here because deps is expected to be a list object, not a string |
| 107 | d.setVarFlag('do_configure', 'deps', (d.getVarFlag('do_configure', 'deps', False) or []) + ['do_unpack']) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 109 | for task in d.getVar("SRCTREECOVEREDTASKS").split(): |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 110 | if local_srcuri and task in fetch_tasks: |
| 111 | continue |
| 112 | bb.build.deltask(task, d) |
Andrew Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 113 | if task == 'do_unpack': |
| 114 | # The reproducible build create_source_date_epoch_stamp function must |
Patrick Williams | 93c203f | 2021-10-06 16:15:23 -0500 | [diff] [blame] | 115 | # be run after the source is available and before the |
| 116 | # do_deploy_source_date_epoch task. In the normal case, it's attached |
| 117 | # to do_unpack as a postfuncs, but since we removed do_unpack (above) |
| 118 | # we need to move the function elsewhere. The easiest thing to do is |
| 119 | # move it into the prefuncs of the do_deploy_source_date_epoch task. |
| 120 | # This is safe, as externalsrc runs with the source already unpacked. |
| 121 | d.prependVarFlag('do_deploy_source_date_epoch', 'prefuncs', 'create_source_date_epoch_stamp ') |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 122 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | d.prependVarFlag('do_compile', 'prefuncs', "externalsrc_compile_prefunc ") |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 124 | d.prependVarFlag('do_configure', 'prefuncs', "externalsrc_configure_prefunc ") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 125 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 126 | d.setVarFlag('do_compile', 'file-checksums', '${@srctree_hash_files(d)}') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 127 | d.setVarFlag('do_configure', 'file-checksums', '${@srctree_configure_hash_files(d)}') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 128 | |
| 129 | # We don't want the workdir to go away |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 130 | d.appendVar('RM_WORK_EXCLUDE', ' ' + d.getVar('PN')) |
| 131 | |
| 132 | bb.build.addtask('do_buildclean', |
| 133 | 'do_clean' if d.getVar('S') == d.getVar('B') else None, |
| 134 | None, d) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 135 | |
| 136 | # If B=S the same builddir is used even for different architectures. |
| 137 | # Thus, use a shared CONFIGURESTAMPFILE and STAMP directory so that |
| 138 | # change of do_configure task hash is correctly detected and stamps are |
| 139 | # invalidated if e.g. MACHINE changes. |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 140 | if d.getVar('S') == d.getVar('B'): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 141 | configstamp = '${TMPDIR}/work-shared/${PN}/${EXTENDPE}${PV}-${PR}/configure.sstate' |
| 142 | d.setVar('CONFIGURESTAMPFILE', configstamp) |
| 143 | d.setVar('STAMP', '${STAMPS_DIR}/work-shared/${PN}/${EXTENDPE}${PV}-${PR}') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 144 | d.setVar('STAMPCLEAN', '${STAMPS_DIR}/work-shared/${PN}/*-*') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | python externalsrc_configure_prefunc() { |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 148 | s_dir = d.getVar('S') |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 149 | # Create desired symlinks |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 150 | symlinks = (d.getVar('EXTERNALSRC_SYMLINKS') or '').split() |
| 151 | newlinks = [] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 152 | for symlink in symlinks: |
| 153 | symsplit = symlink.split(':', 1) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 154 | lnkfile = os.path.join(s_dir, symsplit[0]) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 155 | target = d.expand(symsplit[1]) |
| 156 | if len(symsplit) > 1: |
| 157 | if os.path.islink(lnkfile): |
| 158 | # Link already exists, leave it if it points to the right location already |
| 159 | if os.readlink(lnkfile) == target: |
| 160 | continue |
| 161 | os.unlink(lnkfile) |
| 162 | elif os.path.exists(lnkfile): |
| 163 | # File/dir exists with same name as link, just leave it alone |
| 164 | continue |
| 165 | os.symlink(target, lnkfile) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 166 | newlinks.append(symsplit[0]) |
| 167 | # Hide the symlinks from git |
| 168 | try: |
| 169 | git_exclude_file = os.path.join(s_dir, '.git/info/exclude') |
| 170 | if os.path.exists(git_exclude_file): |
| 171 | with open(git_exclude_file, 'r+') as efile: |
| 172 | elines = efile.readlines() |
| 173 | for link in newlinks: |
| 174 | if link in elines or '/'+link in elines: |
| 175 | continue |
| 176 | efile.write('/' + link + '\n') |
| 177 | except IOError as ioe: |
| 178 | bb.note('Failed to hide EXTERNALSRC_SYMLINKS from git') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | python externalsrc_compile_prefunc() { |
| 182 | # Make it obvious that this is happening, since forgetting about it could lead to much confusion |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 183 | bb.plain('NOTE: %s: compiling from external source tree %s' % (d.getVar('PN'), d.getVar('EXTERNALSRC'))) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 184 | } |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 185 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 186 | do_buildclean[dirs] = "${S} ${B}" |
| 187 | do_buildclean[nostamp] = "1" |
| 188 | do_buildclean[doc] = "Call 'make clean' or equivalent in ${B}" |
| 189 | externalsrc_do_buildclean() { |
| 190 | if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 191 | rm -f ${@' '.join([x.split(':')[0] for x in (d.getVar('EXTERNALSRC_SYMLINKS') or '').split()])} |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 192 | if [ "${CLEANBROKEN}" != "1" ]; then |
| 193 | oe_runmake clean || die "make failed" |
| 194 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 195 | else |
| 196 | bbnote "nothing to do - no makefile found" |
| 197 | fi |
| 198 | } |
| 199 | |
| 200 | def srctree_hash_files(d, srcdir=None): |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 201 | import shutil |
| 202 | import subprocess |
| 203 | import tempfile |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 204 | import hashlib |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 205 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 206 | s_dir = srcdir or d.getVar('EXTERNALSRC') |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 207 | git_dir = None |
| 208 | |
| 209 | try: |
| 210 | git_dir = os.path.join(s_dir, |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 211 | subprocess.check_output(['git', '-C', s_dir, 'rev-parse', '--git-dir'], stderr=subprocess.DEVNULL).decode("utf-8").rstrip()) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 212 | top_git_dir = os.path.join(s_dir, subprocess.check_output(['git', '-C', d.getVar("TOPDIR"), 'rev-parse', '--git-dir'], |
| 213 | stderr=subprocess.DEVNULL).decode("utf-8").rstrip()) |
| 214 | if git_dir == top_git_dir: |
| 215 | git_dir = None |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 216 | except subprocess.CalledProcessError: |
| 217 | pass |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 218 | |
| 219 | ret = " " |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 220 | if git_dir is not None: |
Brad Bishop | a34c030 | 2019-09-23 22:34:48 -0400 | [diff] [blame] | 221 | oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1-%s' % d.getVar('PN')) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 222 | with tempfile.NamedTemporaryFile(prefix='oe-devtool-index') as tmp_index: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 223 | # Clone index |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 224 | shutil.copyfile(os.path.join(git_dir, 'index'), tmp_index.name) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 225 | # Update our custom index |
| 226 | env = os.environ.copy() |
| 227 | env['GIT_INDEX_FILE'] = tmp_index.name |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 228 | subprocess.check_output(['git', 'add', '-A', '.'], cwd=s_dir, env=env) |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 229 | git_sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env).decode("utf-8") |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 230 | submodule_helper = subprocess.check_output(['git', 'submodule--helper', 'list'], cwd=s_dir, env=env).decode("utf-8") |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 231 | for line in submodule_helper.splitlines(): |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 232 | module_dir = os.path.join(s_dir, line.rsplit(maxsplit=1)[1]) |
| 233 | if os.path.isdir(module_dir): |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 234 | proc = subprocess.Popen(['git', 'add', '-A', '.'], cwd=module_dir, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
| 235 | proc.communicate() |
| 236 | proc = subprocess.Popen(['git', 'write-tree'], cwd=module_dir, env=env, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) |
| 237 | stdout, _ = proc.communicate() |
| 238 | git_sha1 += stdout.decode("utf-8") |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 239 | sha1 = hashlib.sha1(git_sha1.encode("utf-8")).hexdigest() |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 240 | with open(oe_hash_file, 'w') as fobj: |
| 241 | fobj.write(sha1) |
| 242 | ret = oe_hash_file + ':True' |
| 243 | else: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 244 | ret = s_dir + '/*:True' |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 245 | return ret |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 246 | |
| 247 | def srctree_configure_hash_files(d): |
| 248 | """ |
| 249 | Get the list of files that should trigger do_configure to re-execute, |
| 250 | based on the value of CONFIGURE_FILES |
| 251 | """ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 252 | in_files = (d.getVar('CONFIGURE_FILES') or '').split() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 253 | out_items = [] |
| 254 | search_files = [] |
| 255 | for entry in in_files: |
| 256 | if entry.startswith('/'): |
| 257 | out_items.append('%s:%s' % (entry, os.path.exists(entry))) |
| 258 | else: |
| 259 | search_files.append(entry) |
| 260 | if search_files: |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 261 | s_dir = d.getVar('EXTERNALSRC') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 262 | for root, _, files in os.walk(s_dir): |
| 263 | for f in files: |
| 264 | if f in search_files: |
| 265 | out_items.append('%s:True' % os.path.join(root, f)) |
| 266 | return ' '.join(out_items) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 267 | |
| 268 | EXPORT_FUNCTIONS do_buildclean |