From: Rusty Russell Date: Thu, 21 Jul 2011 05:14:46 +0000 (+0930) Subject: ccanlint: license_depends_compat checks dependencies are compatible. X-Git-Url: https://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=7ad50f8e1a15c165f621f01ef1b31f81f90f8141 ccanlint: license_depends_compat checks dependencies are compatible. We don't check external dependencies, but internal ccan deps are pretty easy. --- diff --git a/tools/ccanlint/tests/license_depends_compat.c b/tools/ccanlint/tests/license_depends_compat.c new file mode 100644 index 00000000..c4f4cb7f --- /dev/null +++ b/tools/ccanlint/tests/license_depends_compat.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void check_license_depends_compat(struct manifest *m, + bool keep, + unsigned int *timeleft, + struct score *score) +{ + struct manifest *i; + + score->pass = true; + + /* If our license is unknown, we can't know the answer. */ + if (m->license == LICENSE_UNKNOWN) { + score->score = score->total = 0; + return; + } + + list_for_each(&m->deps, i, list) { + struct doc_section *d = find_license_tag(i); + i->license = which_license(d); + + if (i->license != LICENSE_UNKNOWN + && !license_compatible[m->license][i->license]) { + score_file_error(score, i->info_file, 0, + "Dependency ccan/%s has" + " incompatible license '%s'", + i->basename, + licenses[i->license].name); + score->pass = false; + } + } + + if (score->pass) + score->score = score->total; +} + +struct ccanlint license_depends_compat = { + .key = "license_depends_compat", + .name = "CCAN dependencies don't contain incompatible licenses", + .check = check_license_depends_compat, + .needs = "license_exists depends_exist" +}; +REGISTER_TEST(license_depends_compat);