Merge pull request #206 from mesonbuild/extractall
Added a extract_all_objects method to make recombining targets easier…
This commit is contained in:
commit
5c38a00068
7
build.py
7
build.py
|
@ -159,7 +159,9 @@ class BuildTarget():
|
|||
self.process_objectlist(objects)
|
||||
self.process_kwargs(kwargs, environment)
|
||||
self.check_unknown_kwargs(kwargs)
|
||||
if len(self.sources) == 0 and len(self.generated) == 0:
|
||||
if len(self.sources) == 0 and \
|
||||
len(self.generated) == 0 and \
|
||||
len(self.objects) == 0:
|
||||
raise InvalidArguments('Build target %s has no sources.' % name)
|
||||
self.validate_sources()
|
||||
|
||||
|
@ -255,6 +257,9 @@ class BuildTarget():
|
|||
obj_src.append(src)
|
||||
return ExtractedObjects(self, obj_src)
|
||||
|
||||
def extract_all_objects(self):
|
||||
return ExtractedObjects(self, self.sources)
|
||||
|
||||
def get_rpaths(self):
|
||||
return self.get_transitive_rpaths()
|
||||
|
||||
|
|
|
@ -429,7 +429,8 @@ class BuildTargetHolder(InterpreterObject):
|
|||
def __init__(self, target):
|
||||
super().__init__()
|
||||
self.held_object = target
|
||||
self.methods.update({'extract_objects' : self.extract_objects_method})
|
||||
self.methods.update({'extract_objects' : self.extract_objects_method,
|
||||
'extract_all_objects' : self.extract_all_objects_method})
|
||||
|
||||
def is_cross(self):
|
||||
return self.held_object.is_cross()
|
||||
|
@ -438,6 +439,10 @@ class BuildTargetHolder(InterpreterObject):
|
|||
gobjs = self.held_object.extract_objects(args)
|
||||
return GeneratedObjectsHolder(gobjs)
|
||||
|
||||
def extract_all_objects_method(self, args, kwargs):
|
||||
gobjs = self.held_object.extract_all_objects()
|
||||
return GeneratedObjectsHolder(gobjs)
|
||||
|
||||
class ExecutableHolder(BuildTargetHolder):
|
||||
def __init__(self, target):
|
||||
super().__init__(target)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
int func1();
|
||||
int func2();
|
||||
int func3();
|
||||
int func4();
|
|
@ -0,0 +1,5 @@
|
|||
#include"extractor.h"
|
||||
|
||||
int func4() {
|
||||
return 4;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
project('extract all', 'c')
|
||||
|
||||
a = static_library('a', 'one.c', 'two.c')
|
||||
b = static_library('b', 'three.c', 'four.c')
|
||||
c = static_library('c',
|
||||
objects : [a.extract_all_objects(), b.extract_all_objects()])
|
||||
|
||||
e = executable('proggie', 'prog.c', link_with : c)
|
||||
test('extall', e)
|
|
@ -0,0 +1,5 @@
|
|||
#include"extractor.h"
|
||||
|
||||
int func1() {
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#include"extractor.h"
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if((1+2+3+4) != (func1() + func2() + func3() + func4())) {
|
||||
printf("Arithmetic is fail.\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
#include"extractor.h"
|
||||
|
||||
int func3() {
|
||||
return 3;
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
#include"extractor.h"
|
||||
|
||||
int func2() {
|
||||
return 2;
|
||||
}
|
Loading…
Reference in New Issue