|
|
@ -13,6 +13,7 @@ |
|
|
|
# limitations under the License. |
|
|
|
# limitations under the License. |
|
|
|
|
|
|
|
|
|
|
|
import os.path, subprocess |
|
|
|
import os.path, subprocess |
|
|
|
|
|
|
|
import textwrap |
|
|
|
import typing as T |
|
|
|
import typing as T |
|
|
|
|
|
|
|
|
|
|
|
from ..mesonlib import EnvironmentException |
|
|
|
from ..mesonlib import EnvironmentException |
|
|
@ -22,6 +23,7 @@ from .mixins.islinker import BasicLinkerIsCompilerMixin |
|
|
|
|
|
|
|
|
|
|
|
if T.TYPE_CHECKING: |
|
|
|
if T.TYPE_CHECKING: |
|
|
|
from ..envconfig import MachineInfo |
|
|
|
from ..envconfig import MachineInfo |
|
|
|
|
|
|
|
from ..environment import Environment |
|
|
|
|
|
|
|
|
|
|
|
cs_optimization_args = {'0': [], |
|
|
|
cs_optimization_args = {'0': [], |
|
|
|
'g': [], |
|
|
|
'g': [], |
|
|
@ -29,57 +31,43 @@ cs_optimization_args = {'0': [], |
|
|
|
'2': ['-optimize+'], |
|
|
|
'2': ['-optimize+'], |
|
|
|
'3': ['-optimize+'], |
|
|
|
'3': ['-optimize+'], |
|
|
|
's': ['-optimize+'], |
|
|
|
's': ['-optimize+'], |
|
|
|
} |
|
|
|
} # type: T.Dict[str, T.List[str]] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CsCompiler(BasicLinkerIsCompilerMixin, Compiler): |
|
|
|
class CsCompiler(BasicLinkerIsCompilerMixin, Compiler): |
|
|
|
|
|
|
|
|
|
|
|
language = 'cs' |
|
|
|
language = 'cs' |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, exelist, version, for_machine: MachineChoice, |
|
|
|
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, |
|
|
|
info: 'MachineInfo', comp_id, runner=None): |
|
|
|
info: 'MachineInfo', comp_id: str, runner: T.Optional[str] = None): |
|
|
|
super().__init__(exelist, version, for_machine, info) |
|
|
|
super().__init__(exelist, version, for_machine, info) |
|
|
|
self.id = comp_id |
|
|
|
self.id = comp_id |
|
|
|
self.runner = runner |
|
|
|
self.runner = runner |
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
@classmethod |
|
|
|
def get_display_language(cls): |
|
|
|
def get_display_language(cls) -> str: |
|
|
|
return 'C sharp' |
|
|
|
return 'C sharp' |
|
|
|
|
|
|
|
|
|
|
|
def get_always_args(self): |
|
|
|
def get_always_args(self) -> T.List[str]: |
|
|
|
return ['/nologo'] |
|
|
|
return ['/nologo'] |
|
|
|
|
|
|
|
|
|
|
|
def get_linker_always_args(self): |
|
|
|
def get_linker_always_args(self) -> T.List[str]: |
|
|
|
return ['/nologo'] |
|
|
|
return ['/nologo'] |
|
|
|
|
|
|
|
|
|
|
|
def get_output_args(self, fname): |
|
|
|
def get_output_args(self, fname: str) -> T.List[str]: |
|
|
|
return ['-out:' + fname] |
|
|
|
return ['-out:' + fname] |
|
|
|
|
|
|
|
|
|
|
|
def get_link_args(self, fname): |
|
|
|
def get_link_args(self, fname: str) -> T.List[str]: |
|
|
|
return ['-r:' + fname] |
|
|
|
return ['-r:' + fname] |
|
|
|
|
|
|
|
|
|
|
|
def get_werror_args(self): |
|
|
|
def get_werror_args(self) -> T.List[str]: |
|
|
|
return ['-warnaserror'] |
|
|
|
return ['-warnaserror'] |
|
|
|
|
|
|
|
|
|
|
|
def get_linker_exelist(self): |
|
|
|
def get_pic_args(self) -> T.List[str]: |
|
|
|
return self.exelist[:] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_compile_only_args(self): |
|
|
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_coverage_args(self): |
|
|
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_std_exe_link_args(self): |
|
|
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_include_args(self, path): |
|
|
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_pic_args(self): |
|
|
|
|
|
|
|
return [] |
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
def compute_parameters_with_absolute_paths(self, parameter_list, build_dir): |
|
|
|
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], |
|
|
|
|
|
|
|
build_dir: str) -> T.List[str]: |
|
|
|
for idx, i in enumerate(parameter_list): |
|
|
|
for idx, i in enumerate(parameter_list): |
|
|
|
if i[:2] == '-L': |
|
|
|
if i[:2] == '-L': |
|
|
|
parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:])) |
|
|
|
parameter_list[idx] = i[:2] + os.path.normpath(os.path.join(build_dir, i[2:])) |
|
|
@ -88,26 +76,27 @@ class CsCompiler(BasicLinkerIsCompilerMixin, Compiler): |
|
|
|
|
|
|
|
|
|
|
|
return parameter_list |
|
|
|
return parameter_list |
|
|
|
|
|
|
|
|
|
|
|
def get_pch_use_args(self, pch_dir, header): |
|
|
|
def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]: |
|
|
|
return [] |
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
|
|
def get_pch_name(self, header_name): |
|
|
|
def get_pch_name(self, header_name: str) -> str: |
|
|
|
return '' |
|
|
|
return '' |
|
|
|
|
|
|
|
|
|
|
|
def sanity_check(self, work_dir, environment): |
|
|
|
def sanity_check(self, work_dir: str, environment: 'Environment') -> None: |
|
|
|
src = 'sanity.cs' |
|
|
|
src = 'sanity.cs' |
|
|
|
obj = 'sanity.exe' |
|
|
|
obj = 'sanity.exe' |
|
|
|
source_name = os.path.join(work_dir, src) |
|
|
|
source_name = os.path.join(work_dir, src) |
|
|
|
with open(source_name, 'w') as ofile: |
|
|
|
with open(source_name, 'w') as ofile: |
|
|
|
ofile.write('''public class Sanity { |
|
|
|
ofile.write(textwrap.dedent(''' |
|
|
|
static public void Main () { |
|
|
|
public class Sanity { |
|
|
|
} |
|
|
|
static public void Main () { |
|
|
|
} |
|
|
|
} |
|
|
|
''') |
|
|
|
} |
|
|
|
|
|
|
|
''')) |
|
|
|
pc = subprocess.Popen(self.exelist + self.get_always_args() + [src], cwd=work_dir) |
|
|
|
pc = subprocess.Popen(self.exelist + self.get_always_args() + [src], cwd=work_dir) |
|
|
|
pc.wait() |
|
|
|
pc.wait() |
|
|
|
if pc.returncode != 0: |
|
|
|
if pc.returncode != 0: |
|
|
|
raise EnvironmentException('Mono compiler %s can not compile programs.' % self.name_string()) |
|
|
|
raise EnvironmentException('C# compiler %s can not compile programs.' % self.name_string()) |
|
|
|
if self.runner: |
|
|
|
if self.runner: |
|
|
|
cmdlist = [self.runner, obj] |
|
|
|
cmdlist = [self.runner, obj] |
|
|
|
else: |
|
|
|
else: |
|
|
@ -117,32 +106,32 @@ class CsCompiler(BasicLinkerIsCompilerMixin, Compiler): |
|
|
|
if pe.returncode != 0: |
|
|
|
if pe.returncode != 0: |
|
|
|
raise EnvironmentException('Executables created by Mono compiler %s are not runnable.' % self.name_string()) |
|
|
|
raise EnvironmentException('Executables created by Mono compiler %s are not runnable.' % self.name_string()) |
|
|
|
|
|
|
|
|
|
|
|
def needs_static_linker(self): |
|
|
|
def needs_static_linker(self) -> bool: |
|
|
|
return False |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def get_buildtype_args(self, buildtype): |
|
|
|
def get_buildtype_args(self, buildtype: str) -> T.List[str]: |
|
|
|
return mono_buildtype_args[buildtype] |
|
|
|
return mono_buildtype_args[buildtype] |
|
|
|
|
|
|
|
|
|
|
|
def get_debug_args(self, is_debug): |
|
|
|
def get_debug_args(self, is_debug: bool) -> T.List[str]: |
|
|
|
return ['-debug'] if is_debug else [] |
|
|
|
return ['-debug'] if is_debug else [] |
|
|
|
|
|
|
|
|
|
|
|
def get_optimization_args(self, optimization_level): |
|
|
|
def get_optimization_args(self, optimization_level: str) -> T.List[str]: |
|
|
|
return cs_optimization_args[optimization_level] |
|
|
|
return cs_optimization_args[optimization_level] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MonoCompiler(CsCompiler): |
|
|
|
class MonoCompiler(CsCompiler): |
|
|
|
def __init__(self, exelist, version, for_machine: MachineChoice, |
|
|
|
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, |
|
|
|
info: 'MachineInfo'): |
|
|
|
info: 'MachineInfo'): |
|
|
|
super().__init__(exelist, version, for_machine, info, 'mono', |
|
|
|
super().__init__(exelist, version, for_machine, info, 'mono', |
|
|
|
runner='mono') |
|
|
|
runner='mono') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VisualStudioCsCompiler(CsCompiler): |
|
|
|
class VisualStudioCsCompiler(CsCompiler): |
|
|
|
def __init__(self, exelist, version, for_machine: MachineChoice, |
|
|
|
def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoice, |
|
|
|
info: 'MachineInfo'): |
|
|
|
info: 'MachineInfo'): |
|
|
|
super().__init__(exelist, version, for_machine, info, 'csc') |
|
|
|
super().__init__(exelist, version, for_machine, info, 'csc') |
|
|
|
|
|
|
|
|
|
|
|
def get_buildtype_args(self, buildtype): |
|
|
|
def get_buildtype_args(self, buildtype: str) -> T.List[str]: |
|
|
|
res = mono_buildtype_args[buildtype] |
|
|
|
res = mono_buildtype_args[buildtype] |
|
|
|
if not self.info.is_windows(): |
|
|
|
if not self.info.is_windows(): |
|
|
|
tmp = [] |
|
|
|
tmp = [] |
|
|
|