Can override install directory on a target-by-target basis.
This commit is contained in:
parent
d84d70fa9a
commit
51827d4484
|
@ -547,6 +547,8 @@ class NinjaBackend(Backend):
|
||||||
should_strip = self.environment.coredata.strip
|
should_strip = self.environment.coredata.strip
|
||||||
for t in self.build.get_targets().values():
|
for t in self.build.get_targets().values():
|
||||||
if t.should_install():
|
if t.should_install():
|
||||||
|
outdir = t.get_custom_install_dir()
|
||||||
|
if outdir is None:
|
||||||
if isinstance(t, build.Executable):
|
if isinstance(t, build.Executable):
|
||||||
outdir = bindir
|
outdir = bindir
|
||||||
else:
|
else:
|
||||||
|
@ -571,6 +573,8 @@ class NinjaBackend(Backend):
|
||||||
headers = self.build.get_headers()
|
headers = self.build.get_headers()
|
||||||
|
|
||||||
for h in headers:
|
for h in headers:
|
||||||
|
outdir = h.get_custom_install_dir()
|
||||||
|
if outdir is None:
|
||||||
outdir = os.path.join(incroot, h.get_subdir())
|
outdir = os.path.join(incroot, h.get_subdir())
|
||||||
for f in h.get_sources():
|
for f in h.get_sources():
|
||||||
abspath = os.path.join(self.environment.get_source_dir(), f) # FIXME
|
abspath = os.path.join(self.environment.get_source_dir(), f) # FIXME
|
||||||
|
|
7
build.py
7
build.py
|
@ -195,6 +195,9 @@ class BuildTarget():
|
||||||
result += i.get_rpaths()
|
result += i.get_rpaths()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def get_custom_install_dir(self):
|
||||||
|
return self.custom_install_dir
|
||||||
|
|
||||||
def process_kwargs(self, kwargs):
|
def process_kwargs(self, kwargs):
|
||||||
self.copy_kwargs(kwargs)
|
self.copy_kwargs(kwargs)
|
||||||
kwargs.get('modules', [])
|
kwargs.get('modules', [])
|
||||||
|
@ -236,6 +239,10 @@ class BuildTarget():
|
||||||
if not isinstance(deplist, list):
|
if not isinstance(deplist, list):
|
||||||
deplist = [deplist]
|
deplist = [deplist]
|
||||||
self.add_external_deps(deplist)
|
self.add_external_deps(deplist)
|
||||||
|
self.custom_install_dir = kwargs.get('install_dir', None)
|
||||||
|
if self.custom_install_dir is not None:
|
||||||
|
if not isinstance(self.custom_install_dir, str):
|
||||||
|
raise InvalidArguments('Custom_install_dir must be a string')
|
||||||
|
|
||||||
def get_subdir(self):
|
def get_subdir(self):
|
||||||
return self.subdir
|
return self.subdir
|
||||||
|
|
|
@ -267,6 +267,10 @@ class Headers(InterpreterObject):
|
||||||
InterpreterObject.__init__(self)
|
InterpreterObject.__init__(self)
|
||||||
self.sources = sources
|
self.sources = sources
|
||||||
self.subdir = kwargs.get('subdir', '')
|
self.subdir = kwargs.get('subdir', '')
|
||||||
|
self.custom_install_dir = kwargs.get('install_dir', None)
|
||||||
|
if self.custom_install_dir is not None:
|
||||||
|
if not isinstance(self.custom_install_dir, str):
|
||||||
|
raise InterpreterException('Custom_install_dir must be a string.')
|
||||||
|
|
||||||
def set_subdir(self, subdir):
|
def set_subdir(self, subdir):
|
||||||
self.subdir = subdir
|
self.subdir = subdir
|
||||||
|
@ -277,6 +281,9 @@ class Headers(InterpreterObject):
|
||||||
def get_sources(self):
|
def get_sources(self):
|
||||||
return self.sources
|
return self.sources
|
||||||
|
|
||||||
|
def get_custom_install_dir(self):
|
||||||
|
return self.custom_install_dir
|
||||||
|
|
||||||
class Data(InterpreterObject):
|
class Data(InterpreterObject):
|
||||||
def __init__(self, subdir, sources, kwargs):
|
def __init__(self, subdir, sources, kwargs):
|
||||||
InterpreterObject.__init__(self)
|
InterpreterObject.__init__(self)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
dib/dab/dub/prog
|
||||||
|
some/dir/sample.h
|
|
@ -0,0 +1,4 @@
|
||||||
|
project('custom install dirs', 'c')
|
||||||
|
|
||||||
|
executable('prog', 'prog.c', install : true, install_dir : 'dib/dab/dub')
|
||||||
|
headers('sample.h', install_dir : 'some/dir')
|
|
@ -0,0 +1,3 @@
|
||||||
|
int main(int argc, char **arv) {
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef SAMPLE_H
|
||||||
|
#define SAMPLE_H
|
||||||
|
|
||||||
|
int wackiness();
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue