summaryrefslogtreecommitdiff
path: root/python/build/project.py
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-01-05 10:04:47 +0100
committerMax Kellermann <max@musicpd.org>2018-01-05 10:06:22 +0100
commit9cba55b39c708587a25067bfc21013f301407c78 (patch)
tree5fbaf573c1a743199e36cbe0e0801b8020fbbc43 /python/build/project.py
parentc2cbb7b8cecca575ce09aeb04fd1436d44cf9519 (diff)
python/build/project.py: add "edits" parameter to edit source files
Diffstat (limited to 'python/build/project.py')
-rw-r--r--python/build/project.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/python/build/project.py b/python/build/project.py
index c79c4f5a1..087ca3d07 100644
--- a/python/build/project.py
+++ b/python/build/project.py
@@ -7,6 +7,7 @@ from build.tar import untar
class Project:
def __init__(self, url, md5, installed, name=None, version=None,
base=None,
+ edits=None,
use_cxx=False):
if base is None:
basename = os.path.basename(url)
@@ -28,6 +29,7 @@ class Project:
self.md5 = md5
self.installed = installed
+ self.edits = edits
self.use_cxx = use_cxx
def download(self, toolchain):
@@ -47,7 +49,18 @@ class Project:
parent_path = toolchain.src_path
else:
parent_path = toolchain.build_path
- return untar(self.download(toolchain), parent_path, self.base)
+ path = untar(self.download(toolchain), parent_path, self.base)
+
+ if self.edits is not None:
+ for filename, function in self.edits.items():
+ with open(os.path.join(path, filename), 'r+t') as f:
+ old_data = f.read()
+ new_data = function(old_data)
+ f.seek(0)
+ f.truncate(0)
+ f.write(new_data)
+
+ return path
def make_build_path(self, toolchain):
path = os.path.join(toolchain.build_path, self.base)