diff options
| -rw-r--r-- | meta-oe/classes/scancode.bbclass | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/meta-oe/classes/scancode.bbclass b/meta-oe/classes/scancode.bbclass new file mode 100644 index 0000000000..701660f578 --- /dev/null +++ b/meta-oe/classes/scancode.bbclass | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | # 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 | |||
| 5 | SCANCODE_FORMAT ?= "html-app" | ||
| 6 | EXT = "${@'html' if d.getVar('SCANCODE_FORMAT', True) == 'html-app' else 'json'}" | ||
| 7 | SCANCODE_TOOLKIT = "${@get_scancode_toolkit(d)}" | ||
| 8 | SCANCODE_TAG = "v2.2.1" | ||
| 9 | SCANCODE_GIT_LOCATION ?= "https://github.com/nexB/scancode-toolkit.git" | ||
| 10 | SCANCODE_SRC_LOCATION ?= "${DL_DIR}/scancode" | ||
| 11 | |||
| 12 | def get_scancode_toolkit(d): | ||
| 13 | lf = bb.utils.lockfile(d.getVar('SCANCODE_SRC_LOCATION', True) + ".lock") | ||
| 14 | if (not os.path.exists(d.getVar('SCANCODE_SRC_LOCATION', True))): | ||
| 15 | os.system("git clone %s %s -b %s" % (d.getVar('SCANCODE_GIT_LOCATION', True), d.getVar('SCANCODE_SRC_LOCATION', True), d.getVar('SCANCODE_TAG', True))) | ||
| 16 | bb.utils.unlockfile(lf) | ||
| 17 | return (d.getVar('SCANCODE_SRC_LOCATION', True)) | ||
| 18 | |||
| 19 | do_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 | |||
| 27 | addtask scancode after do_patch | ||
| 28 | |||
| 29 | do_scancode_oss() { | ||
| 30 | echo "We are done running scancode" | ||
| 31 | } | ||
| 32 | |||
| 33 | do_scancode_oss[recrdeptask] = "do_scancode_oss do_scancode" | ||
| 34 | do_scancode_oss[nostamp] = "1" | ||
| 35 | addtask do_scancode_oss after do_scancode | ||
