-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCpp.Boost.targets
131 lines (111 loc) · 7.3 KB
/
Cpp.Boost.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<Project InitialTargets="_BoostCheckVersions">
<!-- Abort if actual version bigger than zou version (probably a missing synchronization) -->
<Target Name="_BoostCheckVersions">
<ReadLinesFromFile File="$(PackagesConfigFile)">
<Output TaskParameter="Lines" ItemName="_BoostPackagesConfigContent"/>
</ReadLinesFromFile>
<!--<LogItems Items="@(_BoostPackagesConfigContent)" Title="_BoostPackagesConfigContent"/>-->
<PropertyGroup>
<_BoostPackagesConfigContent>@(_BoostPackagesConfigContent)</_BoostPackagesConfigContent>
<_BoostVersionMatchGroups>$([System.Text.RegularExpressions.RegEx]::Match('$(_BoostPackagesConfigContent)', 'id=\"boost\"\s+version=\"([^\"]+)\"').Groups)</_BoostVersionMatchGroups>
</PropertyGroup>
<ItemGroup>
<_BoostVersionMatch Include="$(_BoostVersionMatchGroups)" />
</ItemGroup>
<!--<LogItems Items="@(_BoostVersionMatch)" Title="_BoostVersionMatch"/>-->
<PropertyGroup>
<_BoostExistingVersion>%(_BoostVersionMatch.Identity)</_BoostExistingVersion>
<_BoostVersionCompare>$([System.StringComparer]::OrdinalIgnoreCase.Compare('$(_BoostExistingVersion)', '$(BoostVersion)'))</_BoostVersionCompare>
</PropertyGroup>
<!--<Error Condition="'$(_BoostVersionCompare)' == '1'" Text="Boost version mismatch. Expected: $(BoostVersion). Actual: $(_BoostExistingVersion). Did you synchronize bundle?" />-->
<!--<Message Importance="high" Text="BoostVersion = $(BoostVersion)" />
<Message Importance="high" Text="_BoostExistingVersion = $(_BoostExistingVersion)" />
<Message Importance="high" Text="_BoostVersionCompare = $(_BoostVersionCompare)" />-->
<!-- clean -->
<PropertyGroup>
<_BoostPackagesConfigContent />
<_BoostVersionMatchGroups />
<_BoostVersionCompare />
</PropertyGroup>
<ItemGroup>
<_BoostPackagesConfigContent Remove="@(_BoostPackagesConfigContent)" />
<_BoostVersionMatch Remove="@(_BoostVersionMatch)" />
</ItemGroup>
</Target>
<Target Name="_BoostCreateBoostOnlyPackagesConfig">
<Message Condition="'$(BoostDebug)' == 'true'" Importance="high" Text="### [$(MSBuildProjectFile)] _BoostCreateBoostOnlyPackagesConfig(In: $(_BoostTemplatePathPrefix).packages.config), Out: $(_BoostOnlyPackagesConfigFile))" />
<Copy SourceFiles="$(_BoostTemplatePathPrefix).packages.config" DestinationFiles="$(_BoostOnlyPackagesConfigFile)" />
</Target>
<Target Name="_BoostUpdateBoostOnlyPackagesConfig" DependsOnTargets="_BoostCreateBoostOnlyPackagesConfig" >
<Message Condition="'$(BoostDebug)' == 'true'" Importance="high" Text="### [$(MSBuildProjectFile)] _BoostUpdateBoostOnlyPackagesConfig(_BoostOnlyPackagesConfigFile=$(_BoostOnlyPackagesConfigFile))" />
<!-- Update version -->
<FileUpdate Files="$(_BoostOnlyPackagesConfigFile)"
Regex='^(?<A>\s*<package\s+id="boost\S*"\s+version=")\S+(?<Z>"[^\r\n]+)'
ReplacementText="${A}$(BoostVersion)${Z}"
Multiline="true"
IgnoreCase="true" />
<!-- Update toolset -->
<FileUpdate Condition="'$(_BoostPackagesConfigType)' == 'Libs'"
Files="$(_BoostOnlyPackagesConfigFile)"
Regex='^(?<A>\s*<package\s+id="boost\S*-)vc\d+\S*(?<Z>"[^\r\n]+)'
ReplacementText="${A}$(BoostToolset)${Z}"
Multiline="true"
IgnoreCase="true" />
</Target>
<Target Name="_BoostUpdateExistingPackagesConfig" DependsOnTargets="_BoostUpdateBoostOnlyPackagesConfig" >
<Message Condition="'$(BoostDebug)' == 'true'" Importance="high" Text="### [$(MSBuildProjectFile)] _BoostUpdateExistingPackagesConfig(In: $(_BoostOnlyPackagesConfigFile), Out: $(PackagesConfigFile))" />
<Copy Condition="!$(_PackagesConfigExists)" SourceFiles="$(_BoostOnlyPackagesConfigFile)" DestinationFiles="$(PackagesConfigFile)"/>
<!-- Remove previous boost packages -->
<FileUpdate Files="$(PackagesConfigFile)"
Regex='^\s*<package\s+id="boost\S*".*$'
ReplacementTextEmpty="true"
Multiline="true"
IgnoreCase="true" />
<MergePackagesConfig MergeFiles="$(_BoostOnlyPackagesConfigFile)"
IntoFile="$(PackagesConfigFile)" />
</Target>
<Target Name="_BoostCheckPackagesConfigChanged" Condition="$(BundleIsGit)" DependsOnTargets="_BoostUpdateExistingPackagesConfig" >
<!-- Serialize git commands -->
<Lock Name="$(ModuleDir)" Timeout="10000"/>
<Exec Command='git add "$(PackagesConfigFile)"' StandardOutputImportance="low" ContinueOnError='true' />
<Exec Command='git diff-index --quiet HEAD "$(PackagesConfigFile)' ContinueOnError='true' IgnoreExitCode='true'>
<Output TaskParameter="ExitCode" PropertyName="_GitDiffPackagesConfigExitCode" />
</Exec>
<Unlock Name="$(ModuleDir)" />
<PropertyGroup>
<_PackagesConfigChanged Condition="'$(_GitDiffPackagesConfigExitCode)' != '0'">true</_PackagesConfigChanged>
<_PackagesConfigChangedMessage>[#] $(BundleRelativeProjectDir)$(PackagesConfigFile): update boost $(BoostToolset) to v$(BoostVersion)</_PackagesConfigChangedMessage>
</PropertyGroup>
<Message Condition="'$(_PackagesConfigChanged)' == 'true'" Importance="high" Text="$(Cyan)$(_PackagesConfigChangedMessage)$(NC)" />
<Message Condition="'$(BoostDebug)' == 'true'" Importance="high" Text="### [$(MSBuildProjectFile)] _BoostCheckPackagesConfigChanged.End(_PackagesConfigChanged=$(_PackagesConfigChanged))" />
</Target>
<Target Name="_BoostCommitPackagesConfigChanged" Condition="$(BundleIsGit)" >
<Message Condition="'$(BoostDebug)' == 'true'" Importance="high" Text="### [$(MSBuildProjectFile)] _BoostCommitPackagesConfigChanged" />
<!-- Commit packages.config -->
<PropertyGroup>
<_GitCommitMessage>zou-build: update boost $(BoostToolset) to v$(BoostVersion) in $(BundleRelativeProjectDir)$(PackagesConfigFile)</_GitCommitMessage>
</PropertyGroup>
<Message Condition="'$(_PackagesConfigChanged)' == 'true'" Importance="high" Text="$(Cyan)$(_GitCommitMessage)$(NC)" />
<!-- Serialize git commands -->
<Lock Name="$(ModuleDir)" Timeout="10000"/>
<Exec Command='git commit "-m$(_GitCommitMessage)" "$(PackagesConfigFile)"' StandardOutputImportance="low" />
<Unlock Name="$(ModuleDir)" />
</Target>
<!--
copy packages.config template to temp file and update it
if packages.config exists
update packages.config
merge temp file into existing packages.config
else
copy temp file to packages.config
-->
<Target Name="UpdateBoostPackages" DependsOnTargets="_BoostUpdateExistingPackagesConfig;_BoostCheckPackagesConfigChanged" BeforeTargets="_CppBoostHeadersImportCheck;_CppBoostLibsImportCheck">
<Message Condition="'$(BoostDebug)' == 'true'" Importance="high" Text="### [$(MSBuildProjectFile)] UpdateBoostPackages" />
<CallTarget Condition="$(_PackagesConfigChanged) And '$(BoostCommit)' != ''" Targets="_BoostCommitPackagesConfigChanged" />
<!-- Restore nuget packages if necessary... -->
<Exec Condition="$(_PackagesConfigChanged)" Command='"$(ZouBinzOsDir)nuget" restore "$(PackagesConfigFile)" -PackagesDirectory "$(NugetPackagesDir.TrimEnd(\/))"' />
</Target>
<Target Name="BoostClean" AfterTargets="Clean">
<Delete Files="$(_BoostOnlyPackagesConfigFile)" />
</Target>
</Project>