|
|
|
@ -84,7 +84,7 @@ known_build_target_kwargs = ( |
|
|
|
|
rust_kwargs | |
|
|
|
|
cs_kwargs) |
|
|
|
|
|
|
|
|
|
known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic'} |
|
|
|
|
known_exe_kwargs = known_build_target_kwargs | {'implib', 'export_dynamic', 'pie'} |
|
|
|
|
known_shlib_kwargs = known_build_target_kwargs | {'version', 'soversion', 'vs_module_defs', 'darwin_versions'} |
|
|
|
|
known_shmod_kwargs = known_build_target_kwargs |
|
|
|
|
known_stlib_kwargs = known_build_target_kwargs | {'pic'} |
|
|
|
@ -414,6 +414,8 @@ class BuildTarget(Target): |
|
|
|
|
self.generated = [] |
|
|
|
|
self.extra_files = [] |
|
|
|
|
self.d_features = {} |
|
|
|
|
self.pic = False |
|
|
|
|
self.pie = False |
|
|
|
|
# Sources can be: |
|
|
|
|
# 1. Pre-existing source files in the source tree |
|
|
|
|
# 2. Pre-existing sources generated by configure_file in the build tree |
|
|
|
@ -869,13 +871,14 @@ This will become a hard error in a future Meson release.''') |
|
|
|
|
# since library loading is done differently) |
|
|
|
|
if for_darwin(self.is_cross, self.environment) or for_windows(self.is_cross, self.environment): |
|
|
|
|
self.pic = True |
|
|
|
|
elif '-fPIC' in clist + cpplist: |
|
|
|
|
mlog.warning("Use the 'pic' kwarg instead of passing -fPIC manually to static library {!r}".format(self.name)) |
|
|
|
|
self.pic = True |
|
|
|
|
else: |
|
|
|
|
self.pic = kwargs.get('pic', False) |
|
|
|
|
if not isinstance(self.pic, bool): |
|
|
|
|
raise InvalidArguments('Argument pic to static library {!r} must be boolean'.format(self.name)) |
|
|
|
|
self.pic = self._extract_pic_pie(kwargs, 'pic') |
|
|
|
|
if isinstance(self, Executable): |
|
|
|
|
# Executables must be PIE on Android |
|
|
|
|
if for_android(self.is_cross, self.environment): |
|
|
|
|
self.pie = True |
|
|
|
|
else: |
|
|
|
|
self.pie = self._extract_pic_pie(kwargs, 'pie') |
|
|
|
|
self.implicit_include_directories = kwargs.get('implicit_include_directories', True) |
|
|
|
|
if not isinstance(self.implicit_include_directories, bool): |
|
|
|
|
raise InvalidArguments('Implicit_include_directories must be a boolean.') |
|
|
|
@ -888,6 +891,18 @@ This will become a hard error in a future Meson release.''') |
|
|
|
|
raise InvalidArguments('GNU symbol visibility arg %s not one of: %s', |
|
|
|
|
self.symbol_visibility, ', '.join(permitted)) |
|
|
|
|
|
|
|
|
|
def _extract_pic_pie(self, kwargs, arg): |
|
|
|
|
# Check if we have -fPIC, -fpic, -fPIE, or -fpie in cflags |
|
|
|
|
all_flags = self.extra_args['c'] + self.extra_args['cpp'] |
|
|
|
|
if '-f' + arg.lower() in all_flags or '-f' + arg.upper() in all_flags: |
|
|
|
|
mlog.warning("Use the '{}' kwarg instead of passing '{}' manually to {!r}".format(arg, '-f' + arg, self.name)) |
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
val = kwargs.get(arg, False) |
|
|
|
|
if not isinstance(val, bool): |
|
|
|
|
raise InvalidArguments('Argument {} to {!r} must be boolean'.format(arg, self.name)) |
|
|
|
|
return val |
|
|
|
|
|
|
|
|
|
def get_filename(self): |
|
|
|
|
return self.filename |
|
|
|
|
|
|
|
|
@ -1307,6 +1322,8 @@ class Executable(BuildTarget): |
|
|
|
|
known_kwargs = known_exe_kwargs |
|
|
|
|
|
|
|
|
|
def __init__(self, name, subdir, subproject, is_cross, sources, objects, environment, kwargs): |
|
|
|
|
if 'pie' not in kwargs and 'b_pie' in environment.coredata.base_options: |
|
|
|
|
kwargs['pie'] = environment.coredata.base_options['b_pie'].value |
|
|
|
|
super().__init__(name, subdir, subproject, is_cross, sources, objects, environment, kwargs) |
|
|
|
|
# Unless overridden, executables have no suffix or prefix. Except on |
|
|
|
|
# Windows and with C#/Mono executables where the suffix is 'exe' |
|
|
|
|