blob: e0f0dbca4035b2be805a5aaa492116413d04016d [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001# We use scancode utlity for extacting licence information.
2# scancode itself is an OSS Utlitity.
3# For more informaiton https://github.com/nexB/scancode-toolkit
4
5SCANCODE_FORMAT ?= "html-app"
Brad Bishop19323692019-04-05 15:28:33 -04006EXT = "${@'html' if d.getVar('SCANCODE_FORMAT') == 'html-app' else 'json'}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08007SCANCODE_TOOLKIT = "${@get_scancode_toolkit(d)}"
8SCANCODE_TAG = "v2.2.1"
9SCANCODE_GIT_LOCATION ?= "https://github.com/nexB/scancode-toolkit.git"
10SCANCODE_SRC_LOCATION ?= "${DL_DIR}/scancode"
11
12def get_scancode_toolkit(d):
Brad Bishop19323692019-04-05 15:28:33 -040013 lf = bb.utils.lockfile(d.getVar('SCANCODE_SRC_LOCATION') + ".lock")
14 if (not os.path.exists(d.getVar('SCANCODE_SRC_LOCATION'))):
15 os.system("git clone %s %s -b %s" % (d.getVar('SCANCODE_GIT_LOCATION'), d.getVar('SCANCODE_SRC_LOCATION'), d.getVar('SCANCODE_TAG')))
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080016 bb.utils.unlockfile(lf)
Brad Bishop19323692019-04-05 15:28:33 -040017 return (d.getVar('SCANCODE_SRC_LOCATION'))
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080018
19do_scancode() {
20 mkdir -p ${DEPLOY_DIR_IMAGE}/scancode
21 cd ${SCANCODE_TOOLKIT}
22 if [ -d "${S}" ]; then
23 ./scancode ${S} --format ${SCANCODE_FORMAT} ${DEPLOY_DIR_IMAGE}/scancode/${PN}.${EXT}
24 fi
25}
26
27addtask scancode after do_patch
28
29do_scancode_oss() {
30 echo "We are done running scancode"
31}
32
33do_scancode_oss[recrdeptask] = "do_scancode_oss do_scancode"
34do_scancode_oss[nostamp] = "1"
35addtask do_scancode_oss after do_scancode