forked from abseil/abseil-cpp
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_projects_helper.ps1
145 lines (133 loc) · 5.74 KB
/
build_projects_helper.ps1
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# This script helps creating project files for abseil-cpp. The argument is the path of a subdirectory of absl/.
# It produces three pairs of *.vcxproj, *.vcxproj.filters files: one for the subdirectory being operated upon,
# one for the benchmarks project and one for the tests project. For the first pair, the generated XML may just
# be inserted at the right place in the project files, replacing whatever was there. For the benchmarks and tests
# things are more complicate as the generated XML must be inserted at the right place.
# TODO(phl): The next time we do this dance, start by beefing up the script to generate the complete files for
# benchmarks and tests in one fell swoop. That will save a lot of time and errors.
$dir = resolve-path $args[0]
$vcxprojname = [string]::format("{0}_vcxproj.txt", $dir)
$filtersheaders = " <ItemGroup>`r`n"
$vcxprojheaders = " <ItemGroup>`r`n"
Get-ChildItem "$dir\*" -Include *.h | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*abseil-cpp", "..\.."
$filtersheaders +=
" <ClInclude Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Header Files</Filter>`r`n" +
" </ClInclude>`r`n"
$vcxprojheaders +=
" <ClInclude Include=`"$msvcrelativepath`" />`r`n"
}
$filtersheaders += " </ItemGroup>`r`n"
$vcxprojheaders += " </ItemGroup>`r`n"
$filterssources = " <ItemGroup>`r`n"
$vcxprojsources = " <ItemGroup>`r`n"
Get-ChildItem "$dir\*" -Include *.cc -Exclude *_benchmark.cc,*_test.cc,*_testing.cc,*_test_*.cc,test_*.cc | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*abseil-cpp", "..\.."
$filterssources +=
" <ClCompile Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Source Files</Filter>`r`n" +
" </ClCompile>`r`n"
$vcxprojsources +=
" <ClCompile Include=`"$msvcrelativepath`" />`r`n"
}
$filterssources += " </ItemGroup>`r`n"
$vcxprojsources += " </ItemGroup>`r`n"
$filtersbenchmarks = " <ItemGroup>`r`n"
$vcxprojbenchmarks = " <ItemGroup>`r`n"
Get-ChildItem "$dir\*" -Recurse -Include *_benchmark.cc | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*abseil-cpp", "..\.."
$filtersbenchmarks +=
" <ClCompile Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Source Files</Filter>`r`n" +
" </ClCompile>`r`n"
$vcxprojbenchmarks +=
" <ClCompile Include=`"$msvcrelativepath`" />`r`n"
}
$filtersbenchmarks += " </ItemGroup>`r`n"
$vcxprojbenchmarks += " </ItemGroup>`r`n"
$filterstests = " <ItemGroup>`r`n"
$vcxprojtests = " <ItemGroup>`r`n"
Get-ChildItem "$dir\*" -Recurse -Include *_testing.h,*_test_*.h,test_*.h | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*abseil-cpp", "..\.."
$filterstests +=
" <ClInclude Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Source Files</Filter>`r`n" +
" </ClInclude>`r`n"
$vcxprojtests +=
" <ClInclude Include=`"$msvcrelativepath`" />`r`n"
}
$vcxprojtests += " </ItemGroup>`r`n"
$vcxprojtests += " <ItemGroup>`r`n"
Get-ChildItem "$dir\*" -Recurse -Include *_test.cc,*_testing.cc,*_test_*.cc,test_*.cc | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*abseil-cpp", "..\.."
$filterstests +=
" <ClCompile Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Source Files</Filter>`r`n" +
" </ClCompile>`r`n"
$vcxprojtests +=
" <ClCompile Include=`"$msvcrelativepath`" />`r`n"
}
$filterstests += " </ItemGroup>`r`n"
$vcxprojtests += " </ItemGroup>`r`n"
$filtersinternals = " <ItemGroup>`r`n"
$vcxprojinternals = " <ItemGroup>`r`n"
Get-ChildItem "$dir\*\*" -Recurse -Include *.h -Exclude *_testing.h,*_test_*.h,test_*.h | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*abseil-cpp", "..\.."
$filtersinternals +=
" <ClInclude Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Internal Files</Filter>`r`n" +
" </ClInclude>`r`n"
$vcxprojinternals +=
" <ClInclude Include=`"$msvcrelativepath`" />`r`n"
}
Get-ChildItem "$dir\*\*" -Recurse -Include *.cc -Exclude *_benchmark.cc,*_test.cc,*_testing.cc,*_test_*.cc,test_*.cc | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*abseil-cpp", "..\.."
$filtersinternals +=
" <ClCompile Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Internal Files</Filter>`r`n" +
" </ClCompile>`r`n"
$vcxprojinternals +=
" <ClCompile Include=`"$msvcrelativepath`">`r`n" +
" <ObjectFileName>`$(IntDir)internal/</ObjectFileName>`r`n" +
" </ClCompile>`r`n"
}
$filtersinternals += " </ItemGroup>`r`n"
$vcxprojinternals += " </ItemGroup>`r`n"
$dirfilterspath = [string]::format("{0}_vcxproj_filters.txt", $dir)
[system.io.file]::writealltext(
$dirfilterspath,
$filtersheaders + $filtersinternals + $filterssources,
[system.text.encoding]::utf8)
$benchmarksfilterspath = [string]::format("{0}_benchmarks_vcxproj_filters.txt", $dir)
[system.io.file]::writealltext(
$benchmarksfilterspath,
$filtersbenchmarks,
[system.text.encoding]::utf8)
$testsfilterspath = [string]::format("{0}_tests_vcxproj_filters.txt", $dir)
[system.io.file]::writealltext(
$testsfilterspath,
$filterstests,
[system.text.encoding]::utf8)
$dirvcxprojpath = [string]::format("{0}_vcxproj.txt", $dir)
[system.io.file]::writealltext(
$dirvcxprojpath,
$vcxprojheaders + $vcxprojinternals + $vcxprojsources,
[system.text.encoding]::utf8)
$benchmarksvcxprojpath = [string]::format("{0}_benchmarks_vcxproj.txt", $dir)
[system.io.file]::writealltext(
$benchmarksvcxprojpath,
$vcxprojbenchmarks,
[system.text.encoding]::utf8)
$testsvcxprojpath = [string]::format("{0}_tests_vcxproj.txt", $dir)
[system.io.file]::writealltext(
$testsvcxprojpath,
$vcxprojtests,
[system.text.encoding]::utf8)