51
51
"STATIC_LIB_SUFFIX" : ".lib" ,
52
52
"SHARED_LIB_SUFFIX" : ".dll" ,
53
53
"INTERMEDIATE_DIR" : "$(IntDir)" ,
54
- "SHARED_INTERMEDIATE_DIR" : "$(OutDir)obj/global_intermediate" ,
54
+ "SHARED_INTERMEDIATE_DIR" : "$(OutDir)/ obj/global_intermediate" ,
55
55
"OS" : "win" ,
56
56
"PRODUCT_DIR" : "$(OutDir)" ,
57
57
"LIB_DIR" : "$(OutDir)lib" ,
@@ -1006,7 +1006,7 @@ def _GetMsbuildToolsetOfProject(proj_path, spec, version):
1006
1006
return toolset
1007
1007
1008
1008
1009
- def _GenerateProject (project , options , version , generator_flags ):
1009
+ def _GenerateProject (project , options , version , generator_flags , spec ):
1010
1010
"""Generates a vcproj file.
1011
1011
1012
1012
Arguments:
@@ -1024,7 +1024,7 @@ def _GenerateProject(project, options, version, generator_flags):
1024
1024
return []
1025
1025
1026
1026
if version .UsesVcxproj ():
1027
- return _GenerateMSBuildProject (project , options , version , generator_flags )
1027
+ return _GenerateMSBuildProject (project , options , version , generator_flags , spec )
1028
1028
else :
1029
1029
return _GenerateMSVSProject (project , options , version , generator_flags )
1030
1030
@@ -1904,6 +1904,8 @@ def _GatherSolutionFolders(sln_projects, project_objects, flat):
1904
1904
# Convert into a tree of dicts on path.
1905
1905
for p in sln_projects :
1906
1906
gyp_file , target = gyp .common .ParseQualifiedTarget (p )[0 :2 ]
1907
+ if p .endswith ("#host" ):
1908
+ target += "_host"
1907
1909
gyp_dir = os .path .dirname (gyp_file )
1908
1910
path_dict = _GetPathDict (root , gyp_dir )
1909
1911
path_dict [target + ".vcproj" ] = project_objects [p ]
@@ -1922,9 +1924,10 @@ def _GetPathOfProject(qualified_target, spec, options, msvs_version):
1922
1924
default_config = _GetDefaultConfiguration (spec )
1923
1925
proj_filename = default_config .get ("msvs_existing_vcproj" )
1924
1926
if not proj_filename :
1925
- proj_filename = (
1926
- spec ["target_name" ] + options .suffix + msvs_version .ProjectExtension ()
1927
- )
1927
+ proj_filename = spec ["target_name" ]
1928
+ if spec ["toolset" ] == "host" :
1929
+ proj_filename += "_host"
1930
+ proj_filename = proj_filename + options .suffix + msvs_version .ProjectExtension ()
1928
1931
1929
1932
build_file = gyp .common .BuildFile (qualified_target )
1930
1933
proj_path = os .path .join (os .path .dirname (build_file ), proj_filename )
@@ -1949,6 +1952,8 @@ def _GetPlatformOverridesOfProject(spec):
1949
1952
_ConfigBaseName (config_name , _ConfigPlatform (c )),
1950
1953
platform ,
1951
1954
)
1955
+ if spec ["toolset" ] == "host" and generator_supports_multiple_toolsets :
1956
+ fixed_config_fullname = "%s|x64" % (config_name ,)
1952
1957
config_platform_overrides [config_fullname ] = fixed_config_fullname
1953
1958
return config_platform_overrides
1954
1959
@@ -1969,21 +1974,19 @@ def _CreateProjectObjects(target_list, target_dicts, options, msvs_version):
1969
1974
projects = {}
1970
1975
for qualified_target in target_list :
1971
1976
spec = target_dicts [qualified_target ]
1972
- if spec ["toolset" ] != "target" :
1973
- raise GypError (
1974
- "Multiple toolsets not supported in msvs build (target %s)"
1975
- % qualified_target
1976
- )
1977
1977
proj_path , fixpath_prefix = _GetPathOfProject (
1978
1978
qualified_target , spec , options , msvs_version
1979
1979
)
1980
1980
guid = _GetGuidOfProject (proj_path , spec )
1981
1981
overrides = _GetPlatformOverridesOfProject (spec )
1982
1982
build_file = gyp .common .BuildFile (qualified_target )
1983
1983
# Create object for this project.
1984
+ target_name = spec ["target_name" ]
1985
+ if spec ["toolset" ] == "host" :
1986
+ target_name += "_host"
1984
1987
obj = MSVSNew .MSVSProject (
1985
1988
proj_path ,
1986
- name = spec [ " target_name" ] ,
1989
+ name = target_name ,
1987
1990
guid = guid ,
1988
1991
spec = spec ,
1989
1992
build_file = build_file ,
@@ -2162,7 +2165,10 @@ def GenerateOutput(target_list, target_dicts, data, params):
2162
2165
for qualified_target in target_list :
2163
2166
spec = target_dicts [qualified_target ]
2164
2167
for config_name , config in spec ["configurations" ].items ():
2165
- configs .add (_ConfigFullName (config_name , config ))
2168
+ config_name = _ConfigFullName (config_name , config )
2169
+ configs .add (config_name )
2170
+ if config_name == "Release|arm64" :
2171
+ configs .add ("Release|x64" )
2166
2172
configs = list (configs )
2167
2173
2168
2174
# Figure out all the projects that will be generated and their guids
@@ -2175,12 +2181,15 @@ def GenerateOutput(target_list, target_dicts, data, params):
2175
2181
for project in project_objects .values ():
2176
2182
fixpath_prefix = project .fixpath_prefix
2177
2183
missing_sources .extend (
2178
- _GenerateProject (project , options , msvs_version , generator_flags )
2184
+ _GenerateProject (project , options , msvs_version , generator_flags , spec )
2179
2185
)
2180
2186
fixpath_prefix = None
2181
2187
2182
2188
for build_file in data :
2183
2189
# Validate build_file extension
2190
+ target_only_configs = configs
2191
+ if generator_supports_multiple_toolsets :
2192
+ target_only_configs = [i for i in configs if i .endswith ("arm64" )]
2184
2193
if not build_file .endswith (".gyp" ):
2185
2194
continue
2186
2195
sln_path = os .path .splitext (build_file )[0 ] + options .suffix + ".sln"
@@ -2197,7 +2206,7 @@ def GenerateOutput(target_list, target_dicts, data, params):
2197
2206
sln = MSVSNew .MSVSSolution (
2198
2207
sln_path ,
2199
2208
entries = root_entries ,
2200
- variants = configs ,
2209
+ variants = target_only_configs ,
2201
2210
websiteProperties = False ,
2202
2211
version = msvs_version ,
2203
2212
)
@@ -2931,22 +2940,24 @@ def _GenerateMSBuildRuleXmlFile(xml_path, msbuild_rules):
2931
2940
easy_xml .WriteXmlIfChanged (content , xml_path , pretty = True , win32 = True )
2932
2941
2933
2942
2934
- def _GetConfigurationAndPlatform (name , settings ):
2943
+ def _GetConfigurationAndPlatform (name , settings , spec ):
2935
2944
configuration = name .rsplit ("_" , 1 )[0 ]
2936
2945
platform = settings .get ("msvs_configuration_platform" , "Win32" )
2946
+ if spec ["toolset" ] == "host" and platform == "arm64" :
2947
+ platform = "x64" # Host-only tools are always built for x64
2937
2948
return (configuration , platform )
2938
2949
2939
2950
2940
- def _GetConfigurationCondition (name , settings ):
2951
+ def _GetConfigurationCondition (name , settings , spec ):
2941
2952
return r"'$(Configuration)|$(Platform)'=='%s|%s'" % _GetConfigurationAndPlatform (
2942
- name , settings
2953
+ name , settings , spec
2943
2954
)
2944
2955
2945
2956
2946
- def _GetMSBuildProjectConfigurations (configurations ):
2957
+ def _GetMSBuildProjectConfigurations (configurations , spec ):
2947
2958
group = ["ItemGroup" , {"Label" : "ProjectConfigurations" }]
2948
2959
for (name , settings ) in sorted (configurations .items ()):
2949
- configuration , platform = _GetConfigurationAndPlatform (name , settings )
2960
+ configuration , platform = _GetConfigurationAndPlatform (name , settings , spec )
2950
2961
designation = "%s|%s" % (configuration , platform )
2951
2962
group .append (
2952
2963
[
@@ -3034,7 +3045,7 @@ def _GetMSBuildConfigurationDetails(spec, build_file):
3034
3045
properties = {}
3035
3046
for name , settings in spec ["configurations" ].items ():
3036
3047
msbuild_attributes = _GetMSBuildAttributes (spec , settings , build_file )
3037
- condition = _GetConfigurationCondition (name , settings )
3048
+ condition = _GetConfigurationCondition (name , settings , spec )
3038
3049
character_set = msbuild_attributes .get ("CharacterSet" )
3039
3050
config_type = msbuild_attributes .get ("ConfigurationType" )
3040
3051
_AddConditionalProperty (properties , condition , "ConfigurationType" , config_type )
@@ -3065,12 +3076,12 @@ def _GetMSBuildLocalProperties(msbuild_toolset):
3065
3076
return properties
3066
3077
3067
3078
3068
- def _GetMSBuildPropertySheets (configurations ):
3079
+ def _GetMSBuildPropertySheets (configurations , spec ):
3069
3080
user_props = r"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
3070
3081
additional_props = {}
3071
3082
props_specified = False
3072
3083
for name , settings in sorted (configurations .items ()):
3073
- configuration = _GetConfigurationCondition (name , settings )
3084
+ configuration = _GetConfigurationCondition (name , settings , spec )
3074
3085
if "msbuild_props" in settings :
3075
3086
additional_props [configuration ] = _FixPaths (settings ["msbuild_props" ])
3076
3087
props_specified = True
@@ -3223,7 +3234,7 @@ def _GetMSBuildConfigurationGlobalProperties(spec, configurations, build_file):
3223
3234
3224
3235
properties = {}
3225
3236
for (name , configuration ) in sorted (configurations .items ()):
3226
- condition = _GetConfigurationCondition (name , configuration )
3237
+ condition = _GetConfigurationCondition (name , configuration , spec )
3227
3238
attributes = _GetMSBuildAttributes (spec , configuration , build_file )
3228
3239
msbuild_settings = configuration ["finalized_msbuild_settings" ]
3229
3240
_AddConditionalProperty (
@@ -3346,7 +3357,7 @@ def _GetMSBuildToolSettingsSections(spec, configurations):
3346
3357
msbuild_settings = configuration ["finalized_msbuild_settings" ]
3347
3358
group = [
3348
3359
"ItemDefinitionGroup" ,
3349
- {"Condition" : _GetConfigurationCondition (name , configuration )},
3360
+ {"Condition" : _GetConfigurationCondition (name , configuration , spec )},
3350
3361
]
3351
3362
for tool_name , tool_settings in sorted (msbuild_settings .items ()):
3352
3363
# Skip the tool named '' which is a holder of global settings handled
@@ -3626,7 +3637,7 @@ def _AddSources2(
3626
3637
3627
3638
if precompiled_source == source :
3628
3639
condition = _GetConfigurationCondition (
3629
- config_name , configuration
3640
+ config_name , configuration , spec
3630
3641
)
3631
3642
detail .append (
3632
3643
["PrecompiledHeader" , {"Condition" : condition }, "Create" ]
@@ -3653,7 +3664,21 @@ def _GetMSBuildProjectReferences(project):
3653
3664
references = []
3654
3665
if project .dependencies :
3655
3666
group = ["ItemGroup" ]
3667
+ added_dependency_set = set ()
3656
3668
for dependency in project .dependencies :
3669
+ dependency_spec = dependency .spec
3670
+ should_skip_dep = False
3671
+ if project .spec ["toolset" ] == "target" :
3672
+ if dependency_spec ["toolset" ] == "host" :
3673
+ if dependency_spec ["type" ] == "static_library" :
3674
+ should_skip_dep = True
3675
+ if dependency .name .startswith ("run_" ):
3676
+ should_skip_dep = False
3677
+ if should_skip_dep :
3678
+ continue
3679
+
3680
+ canonical_name = dependency .name .replace ("_host" , "" )
3681
+ added_dependency_set .add (canonical_name )
3657
3682
guid = dependency .guid
3658
3683
project_dir = os .path .split (project .path )[0 ]
3659
3684
relative_path = gyp .common .RelativePath (dependency .path , project_dir )
@@ -3676,7 +3701,7 @@ def _GetMSBuildProjectReferences(project):
3676
3701
return references
3677
3702
3678
3703
3679
- def _GenerateMSBuildProject (project , options , version , generator_flags ):
3704
+ def _GenerateMSBuildProject (project , options , version , generator_flags , spec ):
3680
3705
spec = project .spec
3681
3706
configurations = spec ["configurations" ]
3682
3707
project_dir , project_file_name = os .path .split (project .path )
@@ -3775,7 +3800,7 @@ def _GenerateMSBuildProject(project, options, version, generator_flags):
3775
3800
},
3776
3801
]
3777
3802
3778
- content += _GetMSBuildProjectConfigurations (configurations )
3803
+ content += _GetMSBuildProjectConfigurations (configurations , spec )
3779
3804
content += _GetMSBuildGlobalProperties (
3780
3805
spec , version , project .guid , project_file_name
3781
3806
)
@@ -3790,7 +3815,7 @@ def _GenerateMSBuildProject(project, options, version, generator_flags):
3790
3815
if spec .get ("msvs_enable_marmasm" ):
3791
3816
content += import_marmasm_props_section
3792
3817
content += _GetMSBuildExtensions (props_files_of_rules )
3793
- content += _GetMSBuildPropertySheets (configurations )
3818
+ content += _GetMSBuildPropertySheets (configurations , spec )
3794
3819
content += macro_section
3795
3820
content += _GetMSBuildConfigurationGlobalProperties (
3796
3821
spec , configurations , project .build_file
@@ -3894,15 +3919,27 @@ def _GenerateActionsForMSBuild(spec, actions_to_add):
3894
3919
sources_handled_by_action = OrderedSet ()
3895
3920
actions_spec = []
3896
3921
for primary_input , actions in actions_to_add .items ():
3922
+ if generator_supports_multiple_toolsets :
3923
+ primary_input = primary_input .replace (".exe" , "_host.exe" )
3897
3924
inputs = OrderedSet ()
3898
3925
outputs = OrderedSet ()
3899
3926
descriptions = []
3900
3927
commands = []
3901
3928
for action in actions :
3929
+
3930
+ def fixup_host_exe (i ):
3931
+ if "$(OutDir)" in i :
3932
+ i = i .replace (".exe" , "_host.exe" )
3933
+ return i
3934
+
3935
+ if generator_supports_multiple_toolsets :
3936
+ action ["inputs" ] = [fixup_host_exe (i ) for i in action ["inputs" ]]
3902
3937
inputs .update (OrderedSet (action ["inputs" ]))
3903
3938
outputs .update (OrderedSet (action ["outputs" ]))
3904
3939
descriptions .append (action ["description" ])
3905
3940
cmd = action ["command" ]
3941
+ if generator_supports_multiple_toolsets :
3942
+ cmd = cmd .replace (".exe" , "_host.exe" )
3906
3943
# For most actions, add 'call' so that actions that invoke batch files
3907
3944
# return and continue executing. msbuild_use_call provides a way to
3908
3945
# disable this but I have not seen any adverse effect from doing that
0 commit comments