From 26a1f7ff31ff42385b3108baaf75636ccdf0c0cd Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Tue, 28 Feb 2017 19:59:07 +0100 Subject: [PATCH] ls-project: only show licences for listed sources --all continues to show all licences, including unused ones Signed-off-by: Tobias Ulmer --- Changelog | 1 + local/e2-ls-project.lua | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index 600ca25..48ef83c 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ NEXT: + * ls-project only shows licences used by the listed sources * Add new source type "licence", providing licence info to build environment * Removed lazytag build mode, it was deprecated for a long time * Fix error in cvs source if cvsroot unset diff --git a/local/e2-ls-project.lua b/local/e2-ls-project.lua index 7b33a0b..9267011 100644 --- a/local/e2-ls-project.lua +++ b/local/e2-ls-project.lua @@ -113,6 +113,26 @@ local function e2_ls_project(arg) end table.sort(sources) + local licences = {} + if opts.all then + for licencename,_ in pairs(licence.licences) do + table.insert(licences, licencename) + end + else + local seen = {} + for _,sourcename in ipairs(sources) do + local src = source.sources[sourcename] + + for licencename in src:get_licences():iter() do + if not seen[licencename] then + table.insert(licences, licencename) + seen[licencename] = true + end + end + end + end + table.sort(licences) + local function pempty(s1, s2, s3) console.infof(" %s %s %s\n", s1, s2, s3) end @@ -291,10 +311,12 @@ local function e2_ls_project(arg) pempty(s1, s2, s3) s2 = "|" p1(s1, s2, "licences") - local llen = #licence.licences_sorted - for _,lic in ipairs(licence.licences_sorted) do - llen = llen - 1 - if llen == 0 then + + local len = #licences + for _,licencename in ipairs(licences) do + local lic = licence.licences[licencename] + len = len - 1 + if len == 0 then s2 = " " end p2(s1, s2, lic:get_name()) -- 2.39.5