From eca89fe5945911b49603a31b3ed8a762ad7e7d8e Mon Sep 17 00:00:00 2001 From: "Lars T. Kyllingstad" Date: Mon, 4 Mar 2024 14:05:56 +0100 Subject: [PATCH] Include dependency licences in distribution bundle --- conanfile.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/conanfile.py b/conanfile.py index f040da2..a09eb4a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -45,8 +45,10 @@ def generate(self): "boost_thread*"], "thrift": ["thrift", "thriftd"], } - for req, dep in self.dependencies.items(): - self._import_dynamic_libs(dep, dldir, dependency_libs.get(req.ref.name, ["*"])) + licensedir = os.path.join(self.build_folder, "dist", "doc", "licenses") + for dep in self.dependencies.host.values(): + self._import_dynamic_libs(dep, dldir, dependency_libs.get(dep.ref.name, ["*"])) + self._import_license(dep, licensedir) if self.dependencies["libcosim"].options.proxyfmu: self._import_executables(self.dependencies["proxyfmu"], bindir, ["*"]) @@ -74,6 +76,20 @@ def _import_executables(self, dependency, target_dir, patterns=["*"]): files = copy(self, patternx, bindir, target_dir, keep_path=False) self._update_rpath(files, "$ORIGIN/../lib") + def _import_license(self, dependency, target_dir): + dep_license_dir = os.path.join(target_dir, dependency.ref.name) + copy(self, "licenses/*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "license*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "*/license*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "copying*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "*/copying*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "notice*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "*/notice*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "authors*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "*/authors*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "copyright*", dependency.package_folder, dep_license_dir, keep_path=False) + copy(self, "*/copyright*", dependency.package_folder, dep_license_dir, keep_path=False) + def _update_rpath(self, files, new_rpath): if files and self.settings.os == "Linux": with VirtualBuildEnv(self).environment().vars(self).apply():