summaryrefslogtreecommitdiffstats
path: root/yocto-poky/meta/classes/externalsrc.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'yocto-poky/meta/classes/externalsrc.bbclass')
-rw-r--r--yocto-poky/meta/classes/externalsrc.bbclass67
1 files changed, 64 insertions, 3 deletions
diff --git a/yocto-poky/meta/classes/externalsrc.bbclass b/yocto-poky/meta/classes/externalsrc.bbclass
index f7ed66d8c..da7eb4781 100644
--- a/yocto-poky/meta/classes/externalsrc.bbclass
+++ b/yocto-poky/meta/classes/externalsrc.bbclass
@@ -25,6 +25,7 @@
#
SRCTREECOVEREDTASKS ?= "do_patch do_unpack do_fetch"
+EXTERNALSRC_SYMLINKS ?= "oe-workdir:${WORKDIR} oe-logs:${T}"
python () {
externalsrc = d.getVar('EXTERNALSRC', True)
@@ -51,7 +52,7 @@ python () {
# Dummy value because the default function can't be called with blank SRC_URI
d.setVar('SRCPV', '999')
- tasks = filter(lambda k: d.getVarFlag(k, "task"), d.keys())
+ tasks = filter(lambda k: d.getVarFlag(k, "task", True), d.keys())
for task in tasks:
if task.endswith("_setscene"):
@@ -82,12 +83,72 @@ python () {
bb.build.deltask(task, d)
d.prependVarFlag('do_compile', 'prefuncs', "externalsrc_compile_prefunc ")
+ d.prependVarFlag('do_configure', 'prefuncs', "externalsrc_configure_prefunc ")
- # Ensure compilation happens every time
- d.setVarFlag('do_compile', 'nostamp', '1')
+ # Force the recipe to be always re-parsed so that the file_checksums
+ # function is run every time
+ d.setVar('BB_DONT_CACHE', '1')
+ d.setVarFlag('do_compile', 'file-checksums', '${@srctree_hash_files(d)}')
+
+ # We don't want the workdir to go away
+ d.appendVar('RM_WORK_EXCLUDE', ' ' + d.getVar('PN', True))
+
+ # If B=S the same builddir is used even for different architectures.
+ # Thus, use a shared CONFIGURESTAMPFILE and STAMP directory so that
+ # change of do_configure task hash is correctly detected and stamps are
+ # invalidated if e.g. MACHINE changes.
+ if d.getVar('S', True) == d.getVar('B', True):
+ configstamp = '${TMPDIR}/work-shared/${PN}/${EXTENDPE}${PV}-${PR}/configure.sstate'
+ d.setVar('CONFIGURESTAMPFILE', configstamp)
+ d.setVar('STAMP', '${STAMPS_DIR}/work-shared/${PN}/${EXTENDPE}${PV}-${PR}')
+}
+
+python externalsrc_configure_prefunc() {
+ # Create desired symlinks
+ symlinks = (d.getVar('EXTERNALSRC_SYMLINKS', True) or '').split()
+ for symlink in symlinks:
+ symsplit = symlink.split(':', 1)
+ lnkfile = os.path.join(d.getVar('S', True), symsplit[0])
+ target = d.expand(symsplit[1])
+ if len(symsplit) > 1:
+ if os.path.islink(lnkfile):
+ # Link already exists, leave it if it points to the right location already
+ if os.readlink(lnkfile) == target:
+ continue
+ os.unlink(lnkfile)
+ elif os.path.exists(lnkfile):
+ # File/dir exists with same name as link, just leave it alone
+ continue
+ os.symlink(target, lnkfile)
}
python externalsrc_compile_prefunc() {
# Make it obvious that this is happening, since forgetting about it could lead to much confusion
bb.plain('NOTE: %s: compiling from external source tree %s' % (d.getVar('PN', True), d.getVar('EXTERNALSRC', True)))
}
+
+def srctree_hash_files(d):
+ import shutil
+ import subprocess
+ import tempfile
+
+ s_dir = d.getVar('EXTERNALSRC', True)
+ git_dir = os.path.join(s_dir, '.git')
+ oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1')
+
+ ret = " "
+ if os.path.exists(git_dir):
+ with tempfile.NamedTemporaryFile(dir=git_dir, prefix='oe-devtool-index') as tmp_index:
+ # Clone index
+ shutil.copy2(os.path.join(git_dir, 'index'), tmp_index.name)
+ # Update our custom index
+ env = os.environ.copy()
+ env['GIT_INDEX_FILE'] = tmp_index.name
+ subprocess.check_output(['git', 'add', '.'], cwd=s_dir, env=env)
+ sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env)
+ with open(oe_hash_file, 'w') as fobj:
+ fobj.write(sha1)
+ ret = oe_hash_file + ':True'
+ else:
+ ret = d.getVar('EXTERNALSRC', True) + '/*:True'
+ return ret
OpenPOWER on IntegriCloud