Can specify extra files that show up in IDEs as parts of a target.
This commit is contained in:
parent
c06c9ea83e
commit
77e9a24589
15
build.py
15
build.py
|
@ -125,9 +125,10 @@ class BuildTarget():
|
|||
self.pch = {}
|
||||
self.extra_args = {}
|
||||
self.generated = []
|
||||
self.extra_files = []
|
||||
self.process_sourcelist(sources)
|
||||
self.process_objectlist(objects)
|
||||
self.process_kwargs(kwargs)
|
||||
self.process_kwargs(kwargs, environment)
|
||||
if len(self.sources) == 0 and len(self.generated) == 0:
|
||||
raise InvalidArguments('Build target %s has no sources.' % name)
|
||||
|
||||
|
@ -205,7 +206,7 @@ class BuildTarget():
|
|||
def get_custom_install_dir(self):
|
||||
return self.custom_install_dir
|
||||
|
||||
def process_kwargs(self, kwargs):
|
||||
def process_kwargs(self, kwargs, environment):
|
||||
self.copy_kwargs(kwargs)
|
||||
kwargs.get('modules', [])
|
||||
self.need_install = kwargs.get('install', self.need_install)
|
||||
|
@ -272,6 +273,16 @@ class BuildTarget():
|
|||
raise InvalidArguments('Argument gui_app must be boolean.')
|
||||
elif 'gui_app' in kwargs:
|
||||
raise InvalidArguments('Argument gui_app can only be used on executables.')
|
||||
extra_files = kwargs.get('extra_files', [])
|
||||
if isinstance(extra_files, str):
|
||||
extra_files = [extra_files]
|
||||
for i in extra_files:
|
||||
if not isinstance(i, str):
|
||||
raise InvalidArguments('Arguments to extra_files must be strings.')
|
||||
trial = os.path.join(environment.get_source_dir(), self.subdir, i)
|
||||
if not(os.path.isfile(trial)):
|
||||
raise InvalidArguments('Tried to add non-existing extra file %s.' % i)
|
||||
self.extra_files = extra_files
|
||||
|
||||
def get_subdir(self):
|
||||
return self.subdir
|
||||
|
|
|
@ -54,12 +54,14 @@ def list_targets(coredata, builddata):
|
|||
|
||||
def list_target_files(target_name, coredata, builddata):
|
||||
try:
|
||||
sources = builddata.targets[target_name].sources
|
||||
subdir = builddata.targets[target_name].subdir
|
||||
t = builddata.targets[target_name]
|
||||
sources = t.sources + t.extra_files
|
||||
subdir = t.subdir
|
||||
except KeyError:
|
||||
print("Unknown target %s." % target_name)
|
||||
sys.exit(1)
|
||||
print(json.dumps([os.path.join(subdir, i) for i in sources]))
|
||||
sources = [os.path.join(subdir, i) for i in sources]
|
||||
print(json.dumps(sources))
|
||||
|
||||
if __name__ == '__main__':
|
||||
(options, args) = parser.parse_args()
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
project('c++ test', 'cpp')
|
||||
exe = executable('trivialprog', 'trivial.cc')
|
||||
exe = executable('trivialprog', 'trivial.cc', extra_files : 'something.txt')
|
||||
test('runtest', exe)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
This file is only here so it shows up in IDEs as part of this target.
|
|
@ -0,0 +1,3 @@
|
|||
project('missing extra file', 'c')
|
||||
|
||||
executable('myprog', 'prog.c', extra_files : 'missing.txt')
|
|
@ -0,0 +1,3 @@
|
|||
int main(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue