diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-02-15 18:52:54 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-02-15 18:52:54 +0200 |
commit | ae23feb36eff5cacabee550c769258e505de1303 (patch) | |
tree | 13fb94dede85c283ddcb06acf08abbb0f06266c2 /builder_install.py | |
parent | 127cd43f2ae5bce3e58a8d42341e598c87dc59d6 (diff) | |
download | meson-ae23feb36eff5cacabee550c769258e505de1303.zip meson-ae23feb36eff5cacabee550c769258e505de1303.tar.gz meson-ae23feb36eff5cacabee550c769258e505de1303.tar.bz2 |
Enable PREFIX for installing on some target types.
Diffstat (limited to 'builder_install.py')
-rwxr-xr-x | builder_install.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/builder_install.py b/builder_install.py index 5f9722d..002ff25 100755 --- a/builder_install.py +++ b/builder_install.py @@ -17,7 +17,8 @@ import sys, pickle, os, shutil, subprocess, gzip class InstallData(): - def __init__(self, depfixer, dep_prefix): + def __init__(self, prefix, depfixer, dep_prefix): + self.prefix = prefix self.targets = [] self.depfixer = depfixer self.dep_prefix = dep_prefix @@ -28,6 +29,9 @@ class InstallData(): def do_install(datafilename): ifile = open(datafilename, 'rb') d = pickle.load(ifile) + pref_var = 'PREFIX' + if pref_var in os.environ: + d.prefix = os.environ[pref_var] install_targets(d) install_headers(d) install_man(d) @@ -45,21 +49,22 @@ def install_data(d): def install_man(d): for m in d.man: - fullfilename = m[0] - outfilename = m[1] + outfileroot = m[1] + outfilename = os.path.join(d.prefix, outfileroot) + full_source_filename = m[0] outdir = os.path.split(outfilename)[0] os.makedirs(outdir, exist_ok=True) - print('Installing %s to %s.' % (fullfilename, outdir)) - if outfilename.endswith('.gz') and not fullfilename.endswith('.gz'): - open(outfilename, 'wb').write(gzip.compress(open(fullfilename, 'rb').read())) + print('Installing %s to %s.' % (full_source_filename, outdir)) + if outfilename.endswith('.gz') and not full_source_filename.endswith('.gz'): + open(outfilename, 'wb').write(gzip.compress(open(full_source_filename, 'rb').read())) else: - shutil.copyfile(fullfilename, outfilename) - shutil.copystat(fullfilename, outfilename) + shutil.copyfile(full_source_filename, outfilename) + shutil.copystat(full_source_filename, outfilename) def install_headers(d): for t in d.headers: fullfilename = t[0] - outdir = t[1] + outdir = os.path.join(d.prefix, t[1]) fname = os.path.split(fullfilename)[1] outfilename = os.path.join(outdir, fname) print('Installing %s to %s' % (fname, outdir)) @@ -69,16 +74,15 @@ def install_headers(d): def install_targets(d): for t in d.targets: - fullfilename = t[0] - outdir = t[1] - fname = os.path.split(fullfilename)[1] + fname = t[0] + outdir = os.path.join(d.prefix, t[1]) aliases = t[2] outname = os.path.join(outdir, fname) should_strip = t[3] - print('Installing %s to %s' % (fname, outdir)) + print('Installing %s to %s' % (fname, outname)) os.makedirs(outdir, exist_ok=True) - shutil.copyfile(fullfilename, outname) - shutil.copystat(fullfilename, outname) + shutil.copyfile(fname, outname) + shutil.copystat(fname, outname) if should_strip: print('Stripping target') ps = subprocess.Popen(['strip', outname], stdout=subprocess.PIPE, stderr=subprocess.PIPE) |