Skip to content

Commit

Permalink
Extract pffft license header from source file
Browse files Browse the repository at this point in the history
  • Loading branch information
chausner committed Oct 18, 2021
1 parent 0aaf9b5 commit 1181965
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 54 deletions.
13 changes: 11 additions & 2 deletions recipes/soxr/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
import os
from conans import ConanFile, CMake, tools

Expand All @@ -23,7 +24,7 @@ class SoxrConan(ConanFile):
"with_lsr_bindings": True
}
generators = "cmake"
exports_sources = ["patches/**", "licenses/**"]
exports_sources = "patches/**"

_cmake = None

Expand Down Expand Up @@ -69,9 +70,17 @@ def build(self):
cmake = self._configure_cmake()
cmake.build()

def _extract_pffft_license(self):
# extract license header from pffft.c and store it in the package folder
with open(os.path.join(self._source_subfolder, "src", "pffft.c"), "r") as f:
# the license header starts in line 3 and ends in line 55
lines = map(lambda line: line.lstrip("/* "), itertools.islice(f, 3, 55))
with open(os.path.join(self.package_folder, "licenses", "pffft"), "w") as f2:
f2.writelines(lines)

def package(self):
self.copy("LICENCE", dst="licenses", src=self._source_subfolder)
self.copy("licenses/pffft", dst="licenses", keep_path=False)
self._extract_pffft_license()
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "doc"))
Expand Down
52 changes: 0 additions & 52 deletions recipes/soxr/all/licenses/pffft

This file was deleted.

0 comments on commit 1181965

Please sign in to comment.