diff options
Diffstat (limited to 'meta/classes/externalsrc.bbclass')
| -rw-r--r-- | meta/classes/externalsrc.bbclass | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass index e115a474b8..d64af6a9c9 100644 --- a/meta/classes/externalsrc.bbclass +++ b/meta/classes/externalsrc.bbclass @@ -4,7 +4,7 @@ # Copyright (C) 2009 Chris Larson <clarson@kergoth.com> # Released under the MIT license (see COPYING.MIT for the terms) # -# externalsrc.bbclass enables use of an existing source tree, usually external to +# externalsrc.bbclass enables use of an existing source tree, usually external to # the build system to build a piece of software rather than the usual fetch/unpack/patch # process. # @@ -108,6 +108,10 @@ python () { # We don't want the workdir to go away d.appendVar('RM_WORK_EXCLUDE', ' ' + d.getVar('PN')) + bb.build.addtask('do_buildclean', + 'do_clean' if d.getVar('S') == d.getVar('B') else None, + None, d) + # 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 @@ -116,14 +120,17 @@ python () { 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}') + d.setVar('STAMPCLEAN', '${STAMPS_DIR}/work-shared/${PN}/*-*') } python externalsrc_configure_prefunc() { + s_dir = d.getVar('S') # Create desired symlinks symlinks = (d.getVar('EXTERNALSRC_SYMLINKS') or '').split() + newlinks = [] for symlink in symlinks: symsplit = symlink.split(':', 1) - lnkfile = os.path.join(d.getVar('S'), symsplit[0]) + lnkfile = os.path.join(s_dir, symsplit[0]) target = d.expand(symsplit[1]) if len(symsplit) > 1: if os.path.islink(lnkfile): @@ -135,6 +142,19 @@ python externalsrc_configure_prefunc() { # File/dir exists with same name as link, just leave it alone continue os.symlink(target, lnkfile) + newlinks.append(symsplit[0]) + # Hide the symlinks from git + try: + git_exclude_file = os.path.join(s_dir, '.git/info/exclude') + if os.path.exists(git_exclude_file): + with open(git_exclude_file, 'r+') as efile: + elines = efile.readlines() + for link in newlinks: + if link in elines or '/'+link in elines: + continue + efile.write('/' + link + '\n') + except IOError as ioe: + bb.note('Failed to hide EXTERNALSRC_SYMLINKS from git') } python externalsrc_compile_prefunc() { @@ -142,12 +162,23 @@ python externalsrc_compile_prefunc() { bb.plain('NOTE: %s: compiling from external source tree %s' % (d.getVar('PN'), d.getVar('EXTERNALSRC'))) } -def srctree_hash_files(d): +do_buildclean[dirs] = "${S} ${B}" +do_buildclean[nostamp] = "1" +do_buildclean[doc] = "Call 'make clean' or equivalent in ${B}" +externalsrc_do_buildclean() { + if [ -e Makefile -o -e makefile -o -e GNUmakefile ]; then + oe_runmake clean || die "make failed" + else + bbnote "nothing to do - no makefile found" + fi +} + +def srctree_hash_files(d, srcdir=None): import shutil import subprocess import tempfile - s_dir = d.getVar('EXTERNALSRC') + s_dir = srcdir or d.getVar('EXTERNALSRC') git_dir = os.path.join(s_dir, '.git') oe_hash_file = os.path.join(git_dir, 'oe-devtool-tree-sha1') @@ -159,13 +190,13 @@ def srctree_hash_files(d): # 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) + subprocess.check_output(['git', 'add', '-A', '.'], cwd=s_dir, env=env) sha1 = subprocess.check_output(['git', 'write-tree'], cwd=s_dir, env=env).decode("utf-8") with open(oe_hash_file, 'w') as fobj: fobj.write(sha1) ret = oe_hash_file + ':True' else: - ret = d.getVar('EXTERNALSRC') + '/*:True' + ret = s_dir + '/*:True' return ret def srctree_configure_hash_files(d): @@ -188,3 +219,5 @@ def srctree_configure_hash_files(d): if f in search_files: out_items.append('%s:True' % os.path.join(root, f)) return ' '.join(out_items) + +EXPORT_FUNCTIONS do_buildclean |
