1111from .mixins .ti import TICompiler
1212
1313if T .TYPE_CHECKING :
14- from ..environment import Environment
1514 from ..linkers .linkers import DynamicLinker
1615 from ..mesonlib import MachineChoice
1716 from ..envconfig import MachineInfo
17+ from ..environment import Environment
1818
1919nasm_optimization_args : T .Dict [str , T .List [str ]] = {
2020 'plain' : [],
@@ -31,6 +31,19 @@ class ASMCompiler(Compiler):
3131
3232 """Shared base class for all ASM Compilers (Assemblers)"""
3333
34+ _SUPPORTED_ARCHES : T .Set [str ] = set ()
35+
36+ def __init__ (self , ccache : T .List [str ], exelist : T .List [str ], version : str ,
37+ for_machine : MachineChoice , info : MachineInfo ,
38+ linker : T .Optional [DynamicLinker ] = None ,
39+ full_version : T .Optional [str ] = None , is_cross : bool = False ):
40+ if self ._SUPPORTED_ARCHES and info .cpu_family not in self ._SUPPORTED_ARCHES :
41+ raise EnvironmentException (f'ASM Compiler { self .id } does not support building for { info .cpu_family } CPU family.' )
42+ super ().__init__ (ccache , exelist , version , for_machine , info , linker , full_version , is_cross )
43+
44+ def sanity_check (self , work_dir : str , environment : Environment ) -> None :
45+ return None
46+
3447
3548class NasmCompiler (ASMCompiler ):
3649 language = 'nasm'
@@ -45,6 +58,8 @@ class NasmCompiler(ASMCompiler):
4558 'mtd' : ['/DEFAULTLIB:libucrtd.lib' , '/DEFAULTLIB:libvcruntimed.lib' , '/DEFAULTLIB:libcmtd.lib' ],
4659 }
4760
61+ _SUPPORTED_ARCHES = {'x86' , 'x86_64' }
62+
4863 def __init__ (self , ccache : T .List [str ], exelist : T .List [str ], version : str ,
4964 for_machine : 'MachineChoice' , info : 'MachineInfo' ,
5065 linker : T .Optional ['DynamicLinker' ] = None ,
@@ -100,10 +115,6 @@ def get_depfile_suffix(self) -> str:
100115 def get_dependency_gen_args (self , outtarget : str , outfile : str ) -> T .List [str ]:
101116 return ['-MD' , outfile , '-MQ' , outtarget ]
102117
103- def sanity_check (self , work_dir : str , environment : 'Environment' ) -> None :
104- if self .info .cpu_family not in {'x86' , 'x86_64' }:
105- raise EnvironmentException (f'ASM compiler { self .id !r} does not support { self .info .cpu_family } CPU family' )
106-
107118 def get_pic_args (self ) -> T .List [str ]:
108119 return []
109120
@@ -160,6 +171,8 @@ class MasmCompiler(ASMCompiler):
160171 language = 'masm'
161172 id = 'ml'
162173
174+ _SUPPORTED_ARCHES = {'x86' , 'x86_64' }
175+
163176 def get_compile_only_args (self ) -> T .List [str ]:
164177 return ['/c' ]
165178
@@ -187,10 +200,6 @@ def get_debug_args(self, is_debug: bool) -> T.List[str]:
187200 return ['/Zi' ]
188201 return []
189202
190- def sanity_check (self , work_dir : str , environment : 'Environment' ) -> None :
191- if self .info .cpu_family not in {'x86' , 'x86_64' }:
192- raise EnvironmentException (f'ASM compiler { self .id !r} does not support { self .info .cpu_family } CPU family' )
193-
194203 def get_pic_args (self ) -> T .List [str ]:
195204 return []
196205
@@ -217,6 +226,7 @@ def depfile_for_object(self, objfile: str) -> T.Optional[str]:
217226class MasmARMCompiler (ASMCompiler ):
218227 language = 'masm'
219228 id = 'armasm'
229+ _SUPPORTED_ARCHES = {'arm' , 'aarch64' }
220230
221231 def needs_static_linker (self ) -> bool :
222232 return True
@@ -238,10 +248,6 @@ def get_debug_args(self, is_debug: bool) -> T.List[str]:
238248 return ['-g' ]
239249 return []
240250
241- def sanity_check (self , work_dir : str , environment : 'Environment' ) -> None :
242- if self .info .cpu_family not in {'arm' , 'aarch64' }:
243- raise EnvironmentException (f'ASM compiler { self .id !r} does not support { self .info .cpu_family } CPU family' )
244-
245251 def get_pic_args (self ) -> T .List [str ]:
246252 return []
247253
@@ -267,6 +273,7 @@ def depfile_for_object(self, objfile: str) -> T.Optional[str]:
267273# https://downloads.ti.com/docs/esd/SPRUI04/
268274class TILinearAsmCompiler (TICompiler , ASMCompiler ):
269275 language = 'linearasm'
276+ _SUPPORTED_ARCHES = {'c6000' }
270277
271278 def __init__ (self , ccache : T .List [str ], exelist : T .List [str ], version : str ,
272279 for_machine : MachineChoice , info : MachineInfo ,
@@ -284,10 +291,6 @@ def get_always_args(self) -> T.List[str]:
284291 def get_crt_compile_args (self , crt_val : str , buildtype : str ) -> T .List [str ]:
285292 return []
286293
287- def sanity_check (self , work_dir : str , environment : Environment ) -> None :
288- if self .info .cpu_family not in {'c6000' }:
289- raise EnvironmentException (f'TI Linear ASM compiler { self .id !r} does not support { self .info .cpu_family } CPU family' )
290-
291294 def get_depfile_suffix (self ) -> str :
292295 return 'd'
293296
@@ -325,21 +328,15 @@ def needs_static_linker(self) -> bool:
325328
326329class MetrowerksAsmCompilerARM (MetrowerksAsmCompiler ):
327330 id = 'mwasmarm'
331+ _SUPPORTED_ARCHES = {'arm' }
328332
329333 def get_instruction_set_args (self , instruction_set : str ) -> T .Optional [T .List [str ]]:
330334 return mwasmarm_instruction_set_args .get (instruction_set , None )
331335
332- def sanity_check (self , work_dir : str , environment : 'Environment' ) -> None :
333- if self .info .cpu_family not in {'arm' }:
334- raise EnvironmentException (f'ASM compiler { self .id !r} does not support { self .info .cpu_family } CPU family' )
335-
336336
337337class MetrowerksAsmCompilerEmbeddedPowerPC (MetrowerksAsmCompiler ):
338338 id = 'mwasmeppc'
339+ _SUPPORTED_ARCHES = {'ppc' }
339340
340341 def get_instruction_set_args (self , instruction_set : str ) -> T .Optional [T .List [str ]]:
341342 return mwasmeppc_instruction_set_args .get (instruction_set , None )
342-
343- def sanity_check (self , work_dir : str , environment : 'Environment' ) -> None :
344- if self .info .cpu_family not in {'ppc' }:
345- raise EnvironmentException (f'ASM compiler { self .id !r} does not support { self .info .cpu_family } CPU family' )
0 commit comments