|
7 | 7 | <Targets>_NASM</Targets> |
8 | 8 | </AvailableItemName> |
9 | 9 | </ItemGroup> |
| 10 | + |
10 | 11 | <PropertyGroup> |
11 | 12 | <ComputeLinkInputsTargets> |
12 | 13 | $(ComputeLinkInputsTargets); |
13 | 14 | ComputeNASMOutput; |
14 | 15 | </ComputeLinkInputsTargets> |
| 16 | + </PropertyGroup> |
| 17 | + |
| 18 | + <PropertyGroup> |
15 | 19 | <ComputeLibInputsTargets> |
16 | 20 | $(ComputeLibInputsTargets); |
17 | 21 | ComputeNASMOutput; |
18 | 22 | </ComputeLibInputsTargets> |
19 | 23 | </PropertyGroup> |
| 24 | + |
| 25 | + <PropertyGroup> |
| 26 | + <ComputeImpLibInputsTargets> |
| 27 | + $(ComputeImpLibInputsTargets); |
| 28 | + ComputeNASMOutput; |
| 29 | + </ComputeImpLibInputsTargets> |
| 30 | + </PropertyGroup> |
| 31 | + |
20 | 32 | <UsingTask |
21 | 33 | TaskName="NASM" |
22 | 34 | TaskFactory="XamlTaskFactory" |
23 | 35 | AssemblyName="Microsoft.Build.Tasks.v4.0"> |
24 | 36 | <Task>$(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml</Task> |
25 | 37 | </UsingTask> |
26 | | - <Target |
27 | | - Name="_WriteNasmTlogs" |
28 | | - Condition="'@(NASM)' != '' and '@(SelectedFiles)' == ''"> |
| 38 | + |
| 39 | + <!-- ******************************************************************************************* |
| 40 | + NASM |
| 41 | + ******************************************************************************************* --> |
| 42 | + |
| 43 | + <PropertyGroup Condition="'$(NASMAfterTargets)'!='' or '$(NASMBeforeTargets)'!=''"> |
| 44 | + <NASMToolBeforeTargets>$(NASMBeforeTargets)</NASMToolBeforeTargets> |
| 45 | + <NASMToolAfterTargets>$(NASMAfterTargets)</NASMToolAfterTargets> |
| 46 | + </PropertyGroup> |
| 47 | + |
| 48 | + <!--If no before/after targets are set, then set the default--> |
| 49 | + <PropertyGroup Condition="'$(NASMAfterTargets)'=='' and '$(NASMBeforeTargets)'==''"> |
| 50 | + <NASMToolBeforeTargets>Midl</NASMToolBeforeTargets> |
| 51 | + <NASMToolAfterTargets>PreBuildEvent</NASMToolAfterTargets> |
| 52 | + <NASMBeforeTargets>PostBuildEvent</NASMBeforeTargets> |
| 53 | + <NASMAfterTargets>BscMake</NASMAfterTargets> |
| 54 | + </PropertyGroup> |
| 55 | + |
| 56 | + <!-- If Selective File Build is enabled, then dont let custom interupt the build order--> |
| 57 | + <PropertyGroup Condition="'$(SelectedFiles)'!=''"> |
| 58 | + <NASMToolBeforeTargets></NASMToolBeforeTargets> |
| 59 | + <NASMToolAfterTargets></NASMToolAfterTargets> |
| 60 | + <NASMBeforeTargets></NASMBeforeTargets> |
| 61 | + <NASMAfterTargets></NASMAfterTargets> |
| 62 | + </PropertyGroup> |
| 63 | + |
| 64 | + <Target Name="_NASM" |
| 65 | + BeforeTargets="$(NASMToolBeforeTargets)" |
| 66 | + AfterTargets="$(NASMToolAfterTargets)" |
| 67 | + DependsOnTargets="SelectNASM;ComputeNASMOutput"> |
| 68 | + |
| 69 | + <PropertyGroup> |
| 70 | + <CustomBuildToolArchitecture Condition="'$(CustomBuildToolArchitecture)' == ''">Native32Bit</CustomBuildToolArchitecture> |
| 71 | + </PropertyGroup> |
| 72 | + |
29 | 73 | <ItemGroup> |
30 | | - <NASM Remove="@(NASM)" Condition="'%(NASM.ExcludedFromBuild)' == 'true' or '%(NASM.ObjectFileName)' == ''" /> |
| 74 | + <NASM Update="@(NASM)"> |
| 75 | + <Inputs>%(NASM.FullPath);%(NASM.AdditionalDependencies);$(MSBuildProjectFile)</Inputs> |
| 76 | + <AdditionalInputs>%(NASM.FullPath);%(NASM.AdditionalDependencies);$(MSBuildProjectFile)</AdditionalInputs> |
| 77 | + |
| 78 | + <Message>%(NASM.ExecutionDescription)</Message> |
| 79 | + |
| 80 | + <!-- option fragments used for [AllOptions] --> |
| 81 | + <_NasmOpt_Debug></_NasmOpt_Debug> |
| 82 | + <_NasmOpt_Prefix></_NasmOpt_Prefix> |
| 83 | + <_NasmOpt_Postfix></_NasmOpt_Postfix> |
| 84 | + <_NasmOpt_IncludePaths></_NasmOpt_IncludePaths> |
| 85 | + <_NasmOpt_PreIncludeFiles></_NasmOpt_PreIncludeFiles> |
| 86 | + <_NasmOpt_Defines></_NasmOpt_Defines> |
| 87 | + <_NasmOpt_Undefines></_NasmOpt_Undefines> |
| 88 | + <_NasmOpt_Werror></_NasmOpt_Werror> |
| 89 | + |
| 90 | + <_NasmOpt_Debug Condition="'%(NASM.GenerateDebugInformation)' == 'true'">-g</_NasmOpt_Debug> |
| 91 | + <_NasmOpt_Prefix Condition="'%(NASM.SymbolsPrefix)' != ''">--prefix %(NASM.SymbolsPrefix)</_NasmOpt_Prefix> |
| 92 | + <_NasmOpt_Postfix Condition="'%(NASM.SymbolsPostfix)' != ''">--postfix %(NASM.SymbolsPostfix)</_NasmOpt_Postfix> |
| 93 | + <_NasmOpt_IncludePaths Condition="'%(NASM.IncludePaths)' != ''">-I"$([System.String]::Copy('%(NASM.IncludePaths)').Trim(';').Replace(';', '/" -I"'))/"</_NasmOpt_IncludePaths> |
| 94 | + <_NasmOpt_PreIncludeFiles Condition="'%(NASM.PreIncludeFiles)' != ''">-P"$([System.String]::Copy('%(NASM.PreIncludeFiles)').Trim(';').Replace(';', '" -P"'))"</_NasmOpt_PreIncludeFiles> |
| 95 | + <_NasmOpt_Defines Condition="'%(NASM.PreprocessorDefinitions)' != ''">-D$([System.String]::Copy('%(NASM.PreprocessorDefinitions)').Trim(';').Replace(';', ' -D'))</_NasmOpt_Defines> |
| 96 | + <_NasmOpt_Undefines Condition="'%(NASM.UndefinePreprocessorDefinitions)' != ''">-U$([System.String]::Copy('%(NASM.UndefinePreprocessorDefinitions)').Trim(';').Replace(';', ' -U'))</_NasmOpt_Undefines> |
| 97 | + <_NasmOpt_Werror Condition="'%(NASM.TreatWarningsAsErrors)' == 'true'">-Werror</_NasmOpt_Werror> |
| 98 | + </NASM> |
31 | 99 | </ItemGroup> |
32 | | - <ItemGroup Condition="'@(NASM)' != ''"> |
33 | | - <_NasmReadTlog Include="^%(NASM.FullPath);%(NASM.AdditionalDependencies)" /> |
34 | | - <_NasmWriteTlog Include="^%(NASM.FullPath);$([MSBuild]::NormalizePath('$(MSBuildProjectDirectory)', '%(NASM.ObjectFileName)'))" /> |
| 100 | + |
| 101 | + <ItemGroup> |
| 102 | + <NASM Update="@(NASM)"> |
| 103 | + <_NasmAllOptions>-o "%(NASM.Outputs)" %(NASM._NasmOpt_Debug) %(NASM._NasmOpt_Prefix) %(NASM._NasmOpt_Postfix) %(NASM._NasmOpt_IncludePaths) %(NASM._NasmOpt_PreIncludeFiles) %(NASM._NasmOpt_Defines) %(NASM._NasmOpt_Undefines) %(NASM._NasmOpt_Werror)</_NasmAllOptions> |
| 104 | + </NASM> |
35 | 105 | </ItemGroup> |
36 | | - <WriteLinesToFile |
37 | | - Condition="'@(_NasmReadTlog)' != ''" |
38 | | - File="$(TLogLocation)Nasm.read.1u.tlog" |
39 | | - Lines="@(_NasmReadTlog->MetaData('Identity')->ToUpperInvariant());" |
40 | | - Overwrite="true" |
41 | | - Encoding="Unicode"/> |
42 | | - <WriteLinesToFile |
43 | | - Condition="'@(_NasmWriteTlog)' != ''" |
44 | | - File="$(TLogLocation)Nasm.write.1u.tlog" |
45 | | - Lines="@(_NasmWriteTlog->MetaData('Identity')->ToUpperInvariant());" |
46 | | - Overwrite="true" |
47 | | - Encoding="Unicode"/> |
| 106 | + |
48 | 107 | <ItemGroup> |
49 | | - <_NasmReadTlog Remove="@(_NasmReadTlog)" /> |
50 | | - <_NasmWriteTlog Remove="@(_NasmWriteTlog)" /> |
| 108 | + <NASM Update="@(NASM)"> |
| 109 | + <Command>$([System.String]::Copy('%(NASM.CommandLineTemplate)').Replace('[AllOptions]', '%(NASM._NasmAllOptions)').Replace('[AdditionalOptions]', '%(NASM.AdditionalOptions)'))</Command> |
| 110 | + </NASM> |
51 | 111 | </ItemGroup> |
52 | | - </Target> |
53 | | - <Target |
54 | | - Name="_NASM" |
55 | | - BeforeTargets="$(NASMBeforeTargets)" |
56 | | - AfterTargets="$(NASMAfterTargets)" |
57 | | - Condition="'@(NASM)' != ''" |
58 | | - Outputs="%(NASM.ObjectFileName)" |
59 | | - Inputs="%(NASM.Identity);%(NASM.AdditionalDependencies);$(MSBuildProjectFile)" |
60 | | - DependsOnTargets="_WriteNasmTlogs;_SelectedFiles"> |
61 | | - <ItemGroup Condition="'@(SelectedFiles)' != ''"> |
62 | | - <NASM Remove="@(NASM)" Condition="'%(Identity)' != '@(SelectedFiles)'" /> |
| 112 | + |
| 113 | + <!-- delete old ParallelCustomBuild tlogs, same as CustomBuild --> |
| 114 | + <GetOutOfDateItems |
| 115 | + Sources ="@(_EmptyItemGroup)" |
| 116 | + OutputsMetadataName ="Outputs" |
| 117 | + DependenciesMetadataName ="AdditionalInputs" |
| 118 | + CommandMetadataName ="Command" |
| 119 | + TLogDirectory ="$(TLogLocation)" |
| 120 | + TLogNamePrefix ="ParallelNasmBuild" |
| 121 | + TrackFileAccess ="$(TrackFileAccess)" |
| 122 | + /> |
| 123 | + |
| 124 | + <!-- Get out of date items for NASM (full build case) --> |
| 125 | + <GetOutOfDateItems |
| 126 | + Condition ="'$(SelectedFiles)' == ''" |
| 127 | + Sources ="@(NASM)" |
| 128 | + OutputsMetadataName ="Outputs" |
| 129 | + DependenciesMetadataName ="AdditionalInputs" |
| 130 | + CommandMetadataName ="Command" |
| 131 | + TLogDirectory ="$(TLogLocation)" |
| 132 | + TLogNamePrefix ="NasmBuild" |
| 133 | + TrackFileAccess ="$(TrackFileAccess)" |
| 134 | + CheckForInterdependencies ="true"> |
| 135 | + <Output TaskParameter="OutOfDateSources" ItemName="_NasmBuild" /> |
| 136 | + </GetOutOfDateItems> |
| 137 | + |
| 138 | + <!-- Selected-files build: just take all NASM items --> |
| 139 | + <ItemGroup Condition ="'$(SelectedFiles)' != ''"> |
| 140 | + <_NasmBuild Include="@(NASM)" /> |
| 141 | + </ItemGroup> |
| 142 | + |
| 143 | + <!-- Build items which can be built in parallel (ignored for selected-files build) --> |
| 144 | + <ItemGroup Condition="'$(SelectedFiles)' == ''"> |
| 145 | + <_ParallelNasmBuild Include="@(_NasmBuild)" |
| 146 | + Condition="'%(_NasmBuild.BuildInParallel)' == 'true' and '%(_NasmBuild.DependsOnAnotherItemOutput)' != 'true'" /> |
63 | 147 | </ItemGroup> |
64 | | - <Message |
65 | | - Condition="'@(NASM)' != '' and '%(NASM.ExcludedFromBuild)' != 'true'" |
66 | | - Importance="High" |
67 | | - Text="%(NASM.ExecutionDescription)" /> |
68 | | - <NASM |
69 | | - Condition="'@(NASM)' != '' and '%(NASM.ExcludedFromBuild)' != 'true'" |
70 | | - Inputs="%(NASM.Inputs)" |
71 | | - ObjectFileName="%(NASM.ObjectFileName)" |
72 | | - SymbolsPrefix="%(NASM.SymbolsPrefix)" |
73 | | - SymbolsPostfix="%(NASM.SymbolsPostfix)" |
74 | | - GenerateDebugInformation="%(NASM.GenerateDebugInformation)" |
75 | | - IncludePaths="%(NASM.IncludePaths)" |
76 | | - PreIncludeFiles="%(NASM.PreIncludeFiles)" |
77 | | - PreprocessorDefinitions="%(NASM.PreprocessorDefinitions)" |
78 | | - UndefinePreprocessorDefinitions="%(NASM.UndefinePreprocessorDefinitions)" |
79 | | - TreatWarningsAsErrors="%(NASM.TreatWarningsAsErrors)" |
80 | | - CommandLineTemplate="%(NASM.CommandLineTemplate)" |
81 | | - AdditionalOptions="%(NASM.AdditionalOptions)" |
| 148 | + |
| 149 | + <ParallelCustomBuild |
| 150 | + Condition ="'@(_ParallelNasmBuild)' != ''" |
| 151 | + Sources ="@(_ParallelNasmBuild)" |
| 152 | + MaxProcesses ="%(_ParallelNasmBuild.MaxProcesses)" |
| 153 | + MaxItemsInBatch ="%(_ParallelNasmBuild.MaxItemsInBatch)" |
| 154 | + AcceptableNonZeroExitCodes ="%(_ParallelNasmBuild.AcceptableNonZeroExitCodes)" |
| 155 | + StdOutEncoding ="%(_ParallelNasmBuild.StdOutEncoding)" |
| 156 | + StdErrEncoding ="%(_ParallelNasmBuild.StdErrEncoding)" |
| 157 | + UseMsbuildResourceManager ="$(UseMsbuildResourceManager)" |
82 | 158 | /> |
| 159 | + |
| 160 | + <!-- build the remaining items sequentially --> |
| 161 | + <ItemGroup Condition="'@(_ParallelNasmBuild)' != ''"> |
| 162 | + <_NasmBuild Remove="@(_ParallelNasmBuild)" /> |
| 163 | + <_ParallelNasmBuild Remove="@(_ParallelNasmBuild)" /> |
| 164 | + </ItemGroup> |
| 165 | + |
| 166 | + <CustomBuild Condition ="'@(_NasmBuild)' != ''" |
| 167 | + Sources ="@(_NasmBuild)" |
| 168 | + BuildSuffix ="$(_BuildSuffix)" |
| 169 | + MinimalRebuildFromTracking ="false" |
| 170 | + AcceptableNonZeroExitCodes ="%(_NasmBuild.AcceptableNonZeroExitCodes)" |
| 171 | + StdOutEncoding ="%(_NasmBuild.StdOutEncoding)" |
| 172 | + StdErrEncoding ="%(_NasmBuild.StdErrEncoding)"> |
| 173 | + </CustomBuild> |
| 174 | + |
| 175 | + <ItemGroup Condition="'@(_NasmBuild)' != ''"> |
| 176 | + <_NasmBuild Remove="@(_NasmBuild)" /> |
| 177 | + </ItemGroup> |
| 178 | + |
83 | 179 | </Target> |
84 | | - <Target |
85 | | - Name="ComputeNASMOutput" |
86 | | - Condition="'@(NASM)' != ''"> |
| 180 | + |
| 181 | + <Target Name="SelectNASM" DependsOnTargets="_SelectedFiles"> |
| 182 | + <ItemGroup Condition="'@(SelectedFiles)'!=''"> |
| 183 | + <NASM Remove="@(NASM)" Condition="'%(Identity)'!='@(SelectedFiles)'"/> |
| 184 | + <NASM> |
| 185 | + <MinimalRebuildFromTracking>false</MinimalRebuildFromTracking> |
| 186 | + </NASM> |
| 187 | + </ItemGroup> |
| 188 | + <ItemGroup> |
| 189 | + <NASM Update="@(NASM)"> |
| 190 | + <Outputs Condition="'%(NASM.ObjectFileName)' != ''">%(NASM.ObjectFileName)</Outputs> |
| 191 | + </NASM> |
| 192 | + </ItemGroup> |
| 193 | + </Target> |
| 194 | + |
| 195 | + |
| 196 | + <Target Name="ComputeNASMOutput" DependsOnTargets="SelectNASM" > |
| 197 | + |
| 198 | + <ItemGroup > |
| 199 | + <NASMOutputs Include="@(NASM->Metadata('Outputs'))" Condition="'@(NASM)' != ''"/> |
| 200 | + |
| 201 | + <NASMOutputs Condition="'%(NASMOutputs.ExcludedFromBuild)'!='true' |
| 202 | + and '%(NASMOutputs.OutputItemType)'=='' |
| 203 | + and '%(NASMOutputs.LinkObjects)'=='true' |
| 204 | + and ('%(Extension)'=='.obj' or '%(Extension)'=='.res' or '%(Extension)'=='.rsc' or '%(Extension)'=='.lib')"> |
| 205 | + <OutputItemType Condition="'$(ConfigurationType)'=='StaticLibrary'">Lib</OutputItemType> |
| 206 | + <OutputItemType Condition="'$(ConfigurationType)'!='StaticLibrary'">Link</OutputItemType> |
| 207 | + </NASMOutputs> |
| 208 | + </ItemGroup> |
| 209 | + |
| 210 | + <!-- Add NASM Outputs to lib, link or other tools --> |
| 211 | + <CreateItem |
| 212 | + Include="@(NASMOutputs)" |
| 213 | + Condition="'%(NASMOutputs.OutputItemType)'!=''"> |
| 214 | + <Output |
| 215 | + TaskParameter="Include" |
| 216 | + ItemName="%(NASMOutputs.OutputItemType)"/> |
| 217 | + <Output |
| 218 | + TaskParameter="Include" |
| 219 | + Condition="'%(NASMOutputs.OutputItemType)' == 'Link' and '$(GenerateImportLib)'=='true'" |
| 220 | + ItemName="ImpLib"/> |
| 221 | + </CreateItem> |
| 222 | + |
| 223 | + <MakeDir Directories="@(NASMOutputs->'%(RootDir)%(Directory)')" /> |
| 224 | + |
| 225 | + <!-- Cleanup --> |
87 | 226 | <ItemGroup> |
88 | | - <Link Include="@(NASM->Metadata('ObjectFileName')->Distinct()->ClearMetadata())" Condition="'%(NASM.ExcludedFromBuild)' != 'true'"/> |
89 | | - <Lib Include="@(NASM->Metadata('ObjectFileName')->Distinct()->ClearMetadata())" Condition="'%(NASM.ExcludedFromBuild)' != 'true'"/> |
| 227 | + <NASMOutputs Remove="@(NASMOutputs)" /> |
90 | 228 | </ItemGroup> |
| 229 | + |
91 | 230 | </Target> |
| 231 | + |
| 232 | + |
92 | 233 | </Project> |
0 commit comments