aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/classes
diff options
context:
space:
mode:
authorirfan sadiq <irfan_sadiq@mentor.com>2017-11-01 19:52:52 +0500
committerKhem Raj <raj.khem@gmail.com>2018-05-23 15:32:05 -0700
commit88da9035b647ad13238385361d70e7ed12d071b1 (patch)
tree3d1e23c1b403ad8af69b08dd4d87ad29844a7ea0 /meta-oe/classes
parentaeb5b9315df2a5b8c6ea589ee98110618c3d5b57 (diff)
downloadmeta-openembedded-88da9035b647ad13238385361d70e7ed12d071b1.tar.gz
meta-openembedded-88da9035b647ad13238385361d70e7ed12d071b1.tar.bz2
meta-openembedded-88da9035b647ad13238385361d70e7ed12d071b1.zip
scancode.bbclass: Adding a bbclass for scancode license scaning utility
This is adding the functionality to run scancode utility on code. You need to set the following variables to use it. You can override these from local.conf or auto.conf. 1) SCANCODE_GIT_LOCATION: Git Path for scancode-toolkit cloning, default is set. 2) SCANCODE_TAG: Select tag, if you want. 3) SCANCODE_FORMAT: Output file format json or html-app. 4) SCANCODE_SRC_LOCATION: Location to store scancode-toolkit. This belongs to OI-2. Signed-off-by: H M Irfan Sadiq <irfan_sadiq@mentor.com> Signed-off-by: Noor Ahsan <noor_ahsan@mentor.com>
Diffstat (limited to 'meta-oe/classes')
-rw-r--r--meta-oe/classes/scancode.bbclass35
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 000000000..701660f57
--- /dev/null
+++ b/meta-oe/classes/scancode.bbclass
@@ -0,0 +1,35 @@
+# We use scancode utlity for extacting licence information.
+# scancode itself is an OSS Utlitity.
+# For more informaiton https://github.com/nexB/scancode-toolkit
+
+SCANCODE_FORMAT ?= "html-app"
+EXT = "${@'html' if d.getVar('SCANCODE_FORMAT', True) == 'html-app' else 'json'}"
+SCANCODE_TOOLKIT = "${@get_scancode_toolkit(d)}"
+SCANCODE_TAG = "v2.2.1"
+SCANCODE_GIT_LOCATION ?= "https://github.com/nexB/scancode-toolkit.git"
+SCANCODE_SRC_LOCATION ?= "${DL_DIR}/scancode"
+
+def get_scancode_toolkit(d):
+ lf = bb.utils.lockfile(d.getVar('SCANCODE_SRC_LOCATION', True) + ".lock")
+ if (not os.path.exists(d.getVar('SCANCODE_SRC_LOCATION', True))):
+ 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)))
+ bb.utils.unlockfile(lf)
+ return (d.getVar('SCANCODE_SRC_LOCATION', True))
+
+do_scancode() {
+ mkdir -p ${DEPLOY_DIR_IMAGE}/scancode
+ cd ${SCANCODE_TOOLKIT}
+ if [ -d "${S}" ]; then
+ ./scancode ${S} --format ${SCANCODE_FORMAT} ${DEPLOY_DIR_IMAGE}/scancode/${PN}.${EXT}
+ fi
+}
+
+addtask scancode after do_patch
+
+do_scancode_oss() {
+ echo "We are done running scancode"
+}
+
+do_scancode_oss[recrdeptask] = "do_scancode_oss do_scancode"
+do_scancode_oss[nostamp] = "1"
+addtask do_scancode_oss after do_scancode