|
|
@ -608,6 +608,29 @@ class SharedLibraryHolder(BuildTargetHolder): |
|
|
|
# Set to True only when called from self.func_shared_lib(). |
|
|
|
# Set to True only when called from self.func_shared_lib(). |
|
|
|
target.shared_library_only = False |
|
|
|
target.shared_library_only = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BothLibrariesHolder(BuildTargetHolder): |
|
|
|
|
|
|
|
def __init__(self, shared_holder, static_holder, interp): |
|
|
|
|
|
|
|
# FIXME: This build target always represents the shared library, but |
|
|
|
|
|
|
|
# that should be configurable. |
|
|
|
|
|
|
|
super().__init__(shared_holder.held_object, interp) |
|
|
|
|
|
|
|
self.shared_holder = shared_holder |
|
|
|
|
|
|
|
self.static_holder = static_holder |
|
|
|
|
|
|
|
self.methods.update({'get_shared_lib': self.get_shared_lib_method, |
|
|
|
|
|
|
|
'get_static_lib': self.get_static_lib_method, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __repr__(self): |
|
|
|
|
|
|
|
r = '<{} {}: {}, {}: {}>' |
|
|
|
|
|
|
|
h1 = self.shared_holder.held_object |
|
|
|
|
|
|
|
h2 = self.static_holder.held_object |
|
|
|
|
|
|
|
return r.format(self.__class__.__name__, h1.get_id(), h1.filename, h2.get_id(), h2.filename) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_shared_lib_method(self, args, kwargs): |
|
|
|
|
|
|
|
return self.shared_holder |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_static_lib_method(self, args, kwargs): |
|
|
|
|
|
|
|
return self.static_holder |
|
|
|
|
|
|
|
|
|
|
|
class SharedModuleHolder(BuildTargetHolder): |
|
|
|
class SharedModuleHolder(BuildTargetHolder): |
|
|
|
def __init__(self, target, interp): |
|
|
|
def __init__(self, target, interp): |
|
|
|
super().__init__(target, interp) |
|
|
|
super().__init__(target, interp) |
|
|
@ -1458,6 +1481,7 @@ permitted_kwargs = {'add_global_arguments': {'language'}, |
|
|
|
'shared_library': build.known_shlib_kwargs, |
|
|
|
'shared_library': build.known_shlib_kwargs, |
|
|
|
'shared_module': build.known_shmod_kwargs, |
|
|
|
'shared_module': build.known_shmod_kwargs, |
|
|
|
'static_library': build.known_stlib_kwargs, |
|
|
|
'static_library': build.known_stlib_kwargs, |
|
|
|
|
|
|
|
'both_libraries': known_library_kwargs, |
|
|
|
'library': known_library_kwargs, |
|
|
|
'library': known_library_kwargs, |
|
|
|
'subdir': {'if_found'}, |
|
|
|
'subdir': {'if_found'}, |
|
|
|
'subproject': {'version', 'default_options'}, |
|
|
|
'subproject': {'version', 'default_options'}, |
|
|
@ -1559,6 +1583,7 @@ class Interpreter(InterpreterBase): |
|
|
|
'shared_library': self.func_shared_lib, |
|
|
|
'shared_library': self.func_shared_lib, |
|
|
|
'shared_module': self.func_shared_module, |
|
|
|
'shared_module': self.func_shared_module, |
|
|
|
'static_library': self.func_static_lib, |
|
|
|
'static_library': self.func_static_lib, |
|
|
|
|
|
|
|
'both_libraries': self.func_both_lib, |
|
|
|
'test': self.func_test, |
|
|
|
'test': self.func_test, |
|
|
|
'vcs_tag': self.func_vcs_tag, |
|
|
|
'vcs_tag': self.func_vcs_tag, |
|
|
|
'subdir_done': self.func_subdir_done, |
|
|
|
'subdir_done': self.func_subdir_done, |
|
|
@ -2492,6 +2517,10 @@ root and issuing %s. |
|
|
|
holder.held_object.shared_library_only = True |
|
|
|
holder.held_object.shared_library_only = True |
|
|
|
return holder |
|
|
|
return holder |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@permittedKwargs(permitted_kwargs['both_libraries']) |
|
|
|
|
|
|
|
def func_both_lib(self, node, args, kwargs): |
|
|
|
|
|
|
|
return self.build_both_libraries(node, args, kwargs) |
|
|
|
|
|
|
|
|
|
|
|
@permittedKwargs(permitted_kwargs['shared_module']) |
|
|
|
@permittedKwargs(permitted_kwargs['shared_module']) |
|
|
|
def func_shared_module(self, node, args, kwargs): |
|
|
|
def func_shared_module(self, node, args, kwargs): |
|
|
|
return self.build_target(node, args, kwargs, SharedModuleHolder) |
|
|
|
return self.build_target(node, args, kwargs, SharedModuleHolder) |
|
|
@ -2515,6 +2544,8 @@ root and issuing %s. |
|
|
|
return self.build_target(node, args, kwargs, SharedLibraryHolder) |
|
|
|
return self.build_target(node, args, kwargs, SharedLibraryHolder) |
|
|
|
elif target_type == 'static_library': |
|
|
|
elif target_type == 'static_library': |
|
|
|
return self.build_target(node, args, kwargs, StaticLibraryHolder) |
|
|
|
return self.build_target(node, args, kwargs, StaticLibraryHolder) |
|
|
|
|
|
|
|
elif target_type == 'both_libraries': |
|
|
|
|
|
|
|
return self.build_both_libraries(node, args, kwargs) |
|
|
|
elif target_type == 'library': |
|
|
|
elif target_type == 'library': |
|
|
|
return self.build_library(node, args, kwargs) |
|
|
|
return self.build_library(node, args, kwargs) |
|
|
|
elif target_type == 'jar': |
|
|
|
elif target_type == 'jar': |
|
|
@ -3171,10 +3202,40 @@ different subdirectory. |
|
|
|
if idname not in self.coredata.target_guids: |
|
|
|
if idname not in self.coredata.target_guids: |
|
|
|
self.coredata.target_guids[idname] = str(uuid.uuid4()).upper() |
|
|
|
self.coredata.target_guids[idname] = str(uuid.uuid4()).upper() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def build_both_libraries(self, node, args, kwargs): |
|
|
|
|
|
|
|
shared_holder = self.build_target(node, args, kwargs, SharedLibraryHolder) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if user forces non-PIC static library. |
|
|
|
|
|
|
|
pic = True |
|
|
|
|
|
|
|
if 'pic' in kwargs: |
|
|
|
|
|
|
|
pic = kwargs['pic'] |
|
|
|
|
|
|
|
elif 'b_staticpic' in self.environment.coredata.base_options: |
|
|
|
|
|
|
|
pic = self.environment.coredata.base_options['b_staticpic'].value |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if pic: |
|
|
|
|
|
|
|
# Exclude sources from args and kwargs to avoid building them twice |
|
|
|
|
|
|
|
static_args = [args[0]] |
|
|
|
|
|
|
|
static_kwargs = kwargs.copy() |
|
|
|
|
|
|
|
static_kwargs['sources'] = [] |
|
|
|
|
|
|
|
static_kwargs['objects'] = shared_holder.held_object.extract_all_objects() |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
static_args = args |
|
|
|
|
|
|
|
static_kwargs = kwargs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static_holder = self.build_target(node, static_args, static_kwargs, StaticLibraryHolder) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return BothLibrariesHolder(shared_holder, static_holder, self) |
|
|
|
|
|
|
|
|
|
|
|
def build_library(self, node, args, kwargs): |
|
|
|
def build_library(self, node, args, kwargs): |
|
|
|
if self.coredata.get_builtin_option('default_library') == 'shared': |
|
|
|
default_library = self.coredata.get_builtin_option('default_library') |
|
|
|
|
|
|
|
if default_library == 'shared': |
|
|
|
return self.build_target(node, args, kwargs, SharedLibraryHolder) |
|
|
|
return self.build_target(node, args, kwargs, SharedLibraryHolder) |
|
|
|
|
|
|
|
elif default_library == 'static': |
|
|
|
return self.build_target(node, args, kwargs, StaticLibraryHolder) |
|
|
|
return self.build_target(node, args, kwargs, StaticLibraryHolder) |
|
|
|
|
|
|
|
elif default_library == 'both': |
|
|
|
|
|
|
|
return self.build_both_libraries(node, args, kwargs) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
raise InterpreterException('Unknown default_library value: %s.', default_library) |
|
|
|
|
|
|
|
|
|
|
|
def build_target(self, node, args, kwargs, targetholder): |
|
|
|
def build_target(self, node, args, kwargs, targetholder): |
|
|
|
if not args: |
|
|
|
if not args: |
|
|
|