1 DEPLOY_FILES_DIR = "${WORKDIR}/deploy-files-${PN}"
2 SSTATETASKS += "do_deploy_files"
3 do_deploy_files[sstate-inputdirs] = "${DEPLOY_FILES_DIR}"
4 do_deploy_files[sstate-outputdirs] = "${DEPLOY_DIR}/files/"
6 python do_deploy_files_setscene () {
9 addtask do_deploy_files_setscene
10 do_deploy_files[dirs] = "${DEPLOY_FILES_DIR} ${B}"
13 # DEPLOY_FILES = "abc xyz"
14 # DEPLOY_FILES_FROM[abc] = "file-ab dir-c"
15 # DEPLOY_FILES_TO[abc] = "directory-for-abc"
16 # DEPLOY_FILES_FROM[xyz] = "file-xyz"
17 # DEPLOY_FILES_TO[xyz] = "directory-for-xyz"
19 # The destination directory will be created inside
20 # ${DEPLOYDIR}. The source files and directories
21 # will be copied such that their name and (for
22 # directories) the directory tree below it will
23 # be preserved. Shell wildcards are supported.
25 # The default DEPLOY_FILES copies files for the native host
26 # and the target into two different directories. Use that as follows:
27 # DEPLOY_FILES_FROM_native = "native-file"
28 # DEPLOY_FILES_FROM_target = "target-file"
30 DEPLOY_FILES ?= "native target"
31 DEPLOY_FILES_FROM[native] ?= ""
32 DEPLOY_FILES_TO[native] = "native/${BUILD_ARCH}"
33 DEPLOY_FILES_FROM[target] ?= ""
34 DEPLOY_FILES_TO[target] = "target/${MACHINE}"
36 # We have to use a Python function to access variable flags. Because
37 # bitbake then does not know about the dependency on these variables,
38 # we need to explicitly declare that. DEPLOYDIR may change without
39 # invalidating the sstate, therefore it is not listed.
40 do_deploy_files[vardeps] = "DEPLOY_FILES DEPLOY_FILES_FROM DEPLOY_FILES_TO"
41 python do_deploy_files () {
46 for file in (d.getVar('DEPLOY_FILES', True) or '').split():
47 bb.note('file: %s' % file)
48 from_pattern = d.getVarFlag('DEPLOY_FILES_FROM', file, True)
49 bb.note('from: %s' % from_pattern)
51 to = os.path.join(d.getVar('DEPLOY_FILES_DIR', True), d.getVarFlag('DEPLOY_FILES_TO', file, True))
52 bb.note('to: %s' % to)
53 if not os.path.isdir(to):
55 for from_path in from_pattern.split():
56 for src in (glob.glob(from_path) or [from_path]):
57 bb.note('Deploying %s to %s' % (src, to))
58 if os.path.isdir(src):
59 src_dirname = shutil._basename(src)
60 to = os.path.join(to, src_dirname)
61 if os.path.exists(to):
62 bb.utils.remove(to, True)
63 shutil.copytree(src, to)
68 addtask deploy_files before do_build after do_compile