forked from google/glog
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build_projects_helper.ps1
95 lines (87 loc) · 3.37 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
# This script helps creating project files for glog. The argument is the path of glog/.
# It produces two pairs of *.vcxproj, *.vcxproj.filters files: one for the project itself, one for its tests.
$dir = resolve-path $args[0]
$filtersheaders = " <ItemGroup>`r`n"
$vcxprojheaders = " <ItemGroup>`r`n"
Get-ChildItem "$dir\src\windows\glog\*" -Recurse -Include *.h | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*src\\", "..\..\src\"
$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\src\*" -Recurse -Include *.h | `
Foreach-Object {
If ( $_.FullName -notmatch ".*windows\\glog") {
$msvcrelativepath = $_.FullName -replace ".*src\\", "..\..\src\"
$filterssources +=
" <ClInclude Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Source Files</Filter>`r`n" +
" </ClInclude>`r`n"
$vcxprojsources +=
" <ClInclude Include=`"$msvcrelativepath`" />`r`n"
}
}
Get-ChildItem "$dir\src\*" -Recurse -Include *.cc -Exclude *test*.cc | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*src\\", "..\..\src\"
$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"
$filterstests = " <ItemGroup>`r`n"
$vcxprojtests = " <ItemGroup>`r`n"
Get-ChildItem "$dir\src\*" -Recurse -Include *test*.h | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*src\\", "..\..\src\"
$filterstests +=
" <ClInclude Include=`"$msvcrelativepath`">`r`n" +
" <Filter>Source Files</Filter>`r`n" +
" </ClInclude>`r`n"
$vcxprojtests +=
" <ClInclude Include=`"$msvcrelativepath`" />`r`n"
}
Get-ChildItem "$dir\src\*" -Recurse -Include *test*.cc | `
Foreach-Object {
$msvcrelativepath = $_.FullName -replace ".*src\\", "..\..\src\"
$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"
$dirfilterspath = [string]::format("{0}\glog_vcxproj_filters.txt", $dir)
[system.io.file]::writealltext(
$dirfilterspath,
$filtersheaders + $filterssources,
[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}\glog_vcxproj.txt", $dir)
[system.io.file]::writealltext(
$dirvcxprojpath,
$vcxprojheaders + $vcxprojsources,
[system.text.encoding]::utf8)
$testsvcxprojpath = [string]::format("{0}\tests_vcxproj.txt", $dir)
[system.io.file]::writealltext(
$testsvcxprojpath,
$vcxprojtests,
[system.text.encoding]::utf8)