Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include dependency licences in distribution bundle #113

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, ["*"])

Expand Down Expand Up @@ -74,6 +76,22 @@ 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, licenses_dir):
src_licenses_dir = os.path.join(dependency.package_folder, "licenses")
tgt_licenses_dir = os.path.join(licenses_dir, dependency.ref.name)
if os.path.isdir(src_licenses_dir):
# Copy the full contents of '<package_dir>/licenses/' if it exists,
# which it does for virtually all conan-center packages.
copy(self, "*", src_licenses_dir, tgt_licenses_dir)
else:
# Copy everything that looks like it might contain license and
# copyright information.
copy(self, "*licen?e*", dependency.package_folder, tgt_licenses_dir, keep_path=False)
copy(self, "*copying*", dependency.package_folder, tgt_licenses_dir, keep_path=False)
copy(self, "*notice*", dependency.package_folder, tgt_licenses_dir, keep_path=False)
copy(self, "*authors*", dependency.package_folder, tgt_licenses_dir, keep_path=False)
copy(self, "*copyright*", dependency.package_folder, tgt_licenses_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():
Expand Down
Loading