@@ -2572,21 +2572,25 @@ def get_variables(self):
2572
2572
return self .variables
2573
2573
2574
2574
def check_stdlibs (self ):
2575
- for for_machine in MachineChoice :
2575
+ machine_choices = [MachineChoice .HOST ]
2576
+ if self .coredata .is_cross_build ():
2577
+ machine_choices .append (MachineChoice .BUILD )
2578
+ for for_machine in machine_choices :
2576
2579
props = self .build .environment .properties [for_machine ]
2577
2580
for l in self .coredata .compilers [for_machine ].keys ():
2578
2581
try :
2579
2582
di = mesonlib .stringlistify (props .get_stdlib (l ))
2580
- if len (di ) != 2 :
2581
- raise InterpreterException ('Stdlib definition for %s should have exactly two elements.'
2582
- % l )
2583
- projname , depname = di
2584
- subproj = self .do_subproject (projname , 'meson' , {})
2585
- self .build .stdlibs .host [l ] = subproj .get_variable_method ([depname ], {})
2586
2583
except KeyError :
2587
- pass
2588
- except InvalidArguments :
2589
- pass
2584
+ continue
2585
+ if len (di ) == 1 :
2586
+ FeatureNew .single_use ('stdlib without variable name' , '0.56.0' , self .subproject )
2587
+ kwargs = {'fallback' : di ,
2588
+ 'native' : for_machine is MachineChoice .BUILD ,
2589
+ 'force_fallback' : True ,
2590
+ }
2591
+ name = display_name = l + '_stdlib'
2592
+ dep = self .dependency_impl (name , display_name , kwargs )
2593
+ self .build .stdlibs [for_machine ][l ] = dep
2590
2594
2591
2595
def import_module (self , modname ):
2592
2596
if modname in self .modules :
@@ -3682,9 +3686,11 @@ def dependency_impl(self, name, display_name, kwargs):
3682
3686
3683
3687
wrap_mode = self .coredata .get_builtin_option ('wrap_mode' )
3684
3688
force_fallback_for = self .coredata .get_builtin_option ('force_fallback_for' )
3689
+ force_fallback = kwargs .get ('force_fallback' , False )
3685
3690
forcefallback = has_fallback and (wrap_mode == WrapMode .forcefallback or \
3686
3691
name in force_fallback_for or \
3687
- dirname in force_fallback_for )
3692
+ dirname in force_fallback_for or \
3693
+ force_fallback )
3688
3694
if name != '' and not forcefallback :
3689
3695
self ._handle_featurenew_dependencies (name )
3690
3696
kwargs ['required' ] = required and not has_fallback
@@ -4786,8 +4792,7 @@ def build_target_decorator_caller(self, node, args, kwargs):
4786
4792
target = targetclass (name , self .subdir , self .subproject , for_machine , sources , objs , self .environment , kwargs )
4787
4793
target .project_version = self .project_version
4788
4794
4789
- if not self .environment .machines .matches_build_machine (for_machine ):
4790
- self .add_cross_stdlib_info (target )
4795
+ self .add_stdlib_info (target )
4791
4796
l = targetholder (target , self )
4792
4797
self .add_target (name , l .held_object )
4793
4798
self .project_args_frozen = True
@@ -4811,23 +4816,19 @@ def kwarg_strings_to_includedirs(self, kwargs):
4811
4816
kwargs ['d_import_dirs' ] = cleaned_items
4812
4817
4813
4818
def get_used_languages (self , target ):
4814
- result = {}
4819
+ result = set ()
4815
4820
for i in target .sources :
4816
- # TODO other platforms
4817
- for lang , c in self .coredata .compilers .host .items ():
4821
+ for lang , c in self .coredata .compilers [target .for_machine ].items ():
4818
4822
if c .can_compile (i ):
4819
- result [ lang ] = True
4823
+ result . add ( lang )
4820
4824
break
4821
4825
return result
4822
4826
4823
- def add_cross_stdlib_info (self , target ):
4824
- if target .for_machine != MachineChoice .HOST :
4825
- return
4827
+ def add_stdlib_info (self , target ):
4826
4828
for l in self .get_used_languages (target ):
4827
- props = self .environment .properties .host
4828
- if props .has_stdlib (l ) \
4829
- and self .subproject != props .get_stdlib (l )[0 ]:
4830
- target .add_deps (self .build .stdlibs .host [l ])
4829
+ dep = self .build .stdlibs [target .for_machine ].get (l , None )
4830
+ if dep :
4831
+ target .add_deps (dep )
4831
4832
4832
4833
def check_sources_exist (self , subdir , sources ):
4833
4834
for s in sources :
0 commit comments