Skip to content

Commit

Permalink
Include dependency licences in distribution bundle (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyllingstad authored Mar 6, 2024
1 parent 68fdcca commit 9f16131
Showing 1 changed file with 20 additions and 2 deletions.
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

0 comments on commit 9f16131

Please sign in to comment.