|
|
|
@ -16,7 +16,7 @@ import os.path, subprocess |
|
|
|
|
import typing |
|
|
|
|
|
|
|
|
|
from ..mesonlib import ( |
|
|
|
|
EnvironmentException, MachineChoice, version_compare, is_windows, is_osx |
|
|
|
|
EnvironmentException, MachineChoice, version_compare, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
from .compilers import ( |
|
|
|
@ -119,7 +119,7 @@ class DmdLikeCompilerMixin: |
|
|
|
|
return 'deps' |
|
|
|
|
|
|
|
|
|
def get_pic_args(self): |
|
|
|
|
if is_windows(): |
|
|
|
|
if self.info.is_windows(): |
|
|
|
|
return [] |
|
|
|
|
return ['-fPIC'] |
|
|
|
|
|
|
|
|
@ -217,7 +217,7 @@ class DmdLikeCompilerMixin: |
|
|
|
|
return ['-Wl,--out-implib=' + implibname] |
|
|
|
|
|
|
|
|
|
def build_rpath_args(self, env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath): |
|
|
|
|
if is_windows(): |
|
|
|
|
if self.info.is_windows(): |
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
# This method is to be used by LDC and DMD. |
|
|
|
@ -235,8 +235,7 @@ class DmdLikeCompilerMixin: |
|
|
|
|
paths = paths + ':' + padding |
|
|
|
|
return ['-Wl,-rpath,{}'.format(paths)] |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def translate_args_to_nongnu(cls, args): |
|
|
|
|
def translate_args_to_nongnu(self, args): |
|
|
|
|
dcargs = [] |
|
|
|
|
# Translate common arguments to flags the LDC/DMD compilers |
|
|
|
|
# can understand. |
|
|
|
@ -245,10 +244,10 @@ class DmdLikeCompilerMixin: |
|
|
|
|
for arg in args: |
|
|
|
|
# Translate OS specific arguments first. |
|
|
|
|
osargs = [] |
|
|
|
|
if is_windows(): |
|
|
|
|
osargs = cls.translate_arg_to_windows(arg) |
|
|
|
|
elif is_osx(): |
|
|
|
|
osargs = cls.translate_arg_to_osx(arg) |
|
|
|
|
if self.info.is_windows(): |
|
|
|
|
osargs = self.translate_arg_to_windows(arg) |
|
|
|
|
elif self.info.is_darwin(): |
|
|
|
|
osargs = self.translate_arg_to_osx(arg) |
|
|
|
|
if osargs: |
|
|
|
|
dcargs.extend(osargs) |
|
|
|
|
continue |
|
|
|
@ -367,7 +366,7 @@ class DmdLikeCompilerMixin: |
|
|
|
|
return clike_debug_args[is_debug] + ddebug_args |
|
|
|
|
|
|
|
|
|
def get_crt_args(self, crt_val, buildtype): |
|
|
|
|
if not is_windows(): |
|
|
|
|
if not self.info.is_windows(): |
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
if crt_val in self.mscrt_args: |
|
|
|
@ -433,7 +432,7 @@ class DCompiler(Compiler): |
|
|
|
|
return 'deps' |
|
|
|
|
|
|
|
|
|
def get_pic_args(self): |
|
|
|
|
if is_windows(): |
|
|
|
|
if self.info.is_windows(): |
|
|
|
|
return [] |
|
|
|
|
return ['-fPIC'] |
|
|
|
|
|
|
|
|
@ -569,7 +568,7 @@ class DCompiler(Compiler): |
|
|
|
|
def get_target_arch_args(self): |
|
|
|
|
# LDC2 on Windows targets to current OS architecture, but |
|
|
|
|
# it should follow the target specified by the MSVC toolchain. |
|
|
|
|
if is_windows(): |
|
|
|
|
if self.info.is_windows(): |
|
|
|
|
if self.arch == 'x86_64': |
|
|
|
|
return ['-m64'] |
|
|
|
|
return ['-m32'] |
|
|
|
@ -668,9 +667,8 @@ class LLVMDCompiler(DmdLikeCompilerMixin, LinkerEnvVarsMixin, BasicLinkerIsCompi |
|
|
|
|
def get_crt_link_args(self, crt_val, buildtype): |
|
|
|
|
return self.get_crt_args(crt_val, buildtype) |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def unix_args_to_native(cls, args): |
|
|
|
|
return cls.translate_args_to_nongnu(args) |
|
|
|
|
def unix_args_to_native(self, args): |
|
|
|
|
return self.translate_args_to_nongnu(args) |
|
|
|
|
|
|
|
|
|
def get_optimization_args(self, optimization_level): |
|
|
|
|
return ldc_optimization_args[optimization_level] |
|
|
|
@ -695,7 +693,7 @@ class DmdDCompiler(DmdLikeCompilerMixin, LinkerEnvVarsMixin, BasicLinkerIsCompil |
|
|
|
|
return d_dmd_buildtype_args[buildtype] |
|
|
|
|
|
|
|
|
|
def get_std_exe_link_args(self): |
|
|
|
|
if is_windows(): |
|
|
|
|
if self.info.is_windows(): |
|
|
|
|
# DMD links against D runtime only when main symbol is found, |
|
|
|
|
# so these needs to be inserted when linking static D libraries. |
|
|
|
|
if self.arch == 'x86_64': |
|
|
|
@ -707,7 +705,7 @@ class DmdDCompiler(DmdLikeCompilerMixin, LinkerEnvVarsMixin, BasicLinkerIsCompil |
|
|
|
|
|
|
|
|
|
def get_std_shared_lib_link_args(self): |
|
|
|
|
libname = 'libphobos2.so' |
|
|
|
|
if is_windows(): |
|
|
|
|
if self.info.is_windows(): |
|
|
|
|
if self.arch == 'x86_64': |
|
|
|
|
libname = 'phobos64.lib' |
|
|
|
|
elif self.arch == 'x86_mscoff': |
|
|
|
@ -720,7 +718,7 @@ class DmdDCompiler(DmdLikeCompilerMixin, LinkerEnvVarsMixin, BasicLinkerIsCompil |
|
|
|
|
# DMD32 and DMD64 on 64-bit Windows defaults to 32-bit (OMF). |
|
|
|
|
# Force the target to 64-bit in order to stay consistent |
|
|
|
|
# across the different platforms. |
|
|
|
|
if is_windows(): |
|
|
|
|
if self.info.is_windows(): |
|
|
|
|
if self.arch == 'x86_64': |
|
|
|
|
return ['-m64'] |
|
|
|
|
elif self.arch == 'x86_mscoff': |
|
|
|
@ -731,9 +729,8 @@ class DmdDCompiler(DmdLikeCompilerMixin, LinkerEnvVarsMixin, BasicLinkerIsCompil |
|
|
|
|
def get_crt_compile_args(self, crt_val, buildtype): |
|
|
|
|
return self.get_crt_args(crt_val, buildtype) |
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
def unix_args_to_native(cls, args): |
|
|
|
|
return cls.translate_args_to_nongnu(args) |
|
|
|
|
def unix_args_to_native(self, args): |
|
|
|
|
return self.translate_args_to_nongnu(args) |
|
|
|
|
|
|
|
|
|
def get_optimization_args(self, optimization_level): |
|
|
|
|
return dmd_optimization_args[optimization_level] |
|
|
|
|