Skip to content

Commit d58a707

Browse files
committed
Added vtk-9.1.0-leaks build
1 parent 12b50d2 commit d58a707

File tree

3 files changed

+336
-0
lines changed

3 files changed

+336
-0
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
misc/0001-update-for-memory-leaks.patch text eol=lf
+309
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,309 @@
1+
name: build-vtk-9.1.0-leaks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop*
8+
paths:
9+
- .github/workflows/build-vtk-9.1.0-leaks.yml
10+
- misc/CMakePresets-vtk-9.1.0.json
11+
12+
env:
13+
CL: /MP
14+
VTK_VERSION: 9.1.0
15+
VS_VERSION: vs2019
16+
PRESET: VTK-9.1.0-leaks-vs2019-x64
17+
18+
jobs:
19+
20+
cache-vtk-debug:
21+
# comment the next line if you want to compile vtk
22+
if: github.repository == 'MODFLOW-USGS/modelviewer-mf6'
23+
24+
runs-on: windows-2019
25+
26+
steps:
27+
28+
- uses: actions/checkout@v2
29+
30+
- name: Export env
31+
env:
32+
type: debug
33+
zipfile: v${{env.VTK_VERSION}}.zip
34+
instdir: C:/VTK-${{env.VTK_VERSION}}-leaks-${{env.VS_VERSION}}-x64
35+
builddir: C:/VTK-${{env.VTK_VERSION}}-leaks-${{env.VS_VERSION}}-x64-build
36+
srcdir: C:/VTK-${{env.VTK_VERSION}}
37+
shell: pwsh
38+
run: |
39+
echo "type=$env:type" >> $env:GITHUB_ENV
40+
echo "zipfile=$env:zipfile" >> $env:GITHUB_ENV
41+
echo "instdir=$env:instdir" >> $env:GITHUB_ENV
42+
echo "builddir=$env:builddir" >> $env:GITHUB_ENV
43+
echo "srcdir=$env:srcdir" >> $env:GITHUB_ENV
44+
45+
- name: Cache vtk
46+
id: cache-vtk-debug
47+
uses: actions/cache@v2
48+
with:
49+
path: ${{env.instdir}}
50+
key: windows-2019-vtk-leaks-${{env.type}}-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
51+
52+
- name: Download vtk
53+
if: steps.cache-vtk-debug.outputs.cache-hit != 'true'
54+
shell: pwsh
55+
run: |
56+
curl -L -O "https://github.com/Kitware/VTK/archive/refs/tags/${{env.zipfile}}"
57+
Get-FileHash ${{env.zipfile}}
58+
cd C:\
59+
7z x ${{github.workspace}}\${{env.zipfile}}
60+
rm ${{github.workspace}}\${{env.zipfile}}
61+
62+
# it seems that 'patch' is more forgiving of line endings than 'git apply'
63+
- name: Patch vtk
64+
if: steps.cache-vtk-debug.outputs.cache-hit != 'true'
65+
shell: bash
66+
run: |
67+
cp ./misc/0001-update-for-memory-leaks.patch /c/VTK-${{env.VTK_VERSION}}/Utilities/KWSys/vtksys/.
68+
cd /c/VTK-${{env.VTK_VERSION}}/Utilities/KWSys/vtksys/.
69+
md5sum SystemTools.cxx 0001-update-for-memory-leaks.patch
70+
file SystemTools.cxx 0001-update-for-memory-leaks.patch
71+
patch < 0001-update-for-memory-leaks.patch
72+
md5sum SystemTools.cxx
73+
file SystemTools.cxx
74+
75+
- name: Build vtk
76+
if: steps.cache-vtk-debug.outputs.cache-hit != 'true'
77+
shell: pwsh
78+
run: |
79+
cp misc\CMakePresets-vtk-9.1.0.json ${{env.srcdir}}\CMakePresets.json
80+
cd ${{env.srcdir}}
81+
cmake --preset ${{env.PRESET}}
82+
cmake --build --preset ${{env.PRESET}} --config ${{env.type}}
83+
cmake --install ${{env.builddir}} --prefix ${{env.instdir}} --config ${{env.type}}
84+
85+
- name: Check debug cache
86+
shell: pwsh
87+
run: |
88+
dir ${{env.instdir}}\bin
89+
90+
cache-vtk-release:
91+
# uncomment the next line if you want to compile vtk
92+
if: github.repository == 'MODFLOW-USGS/modelviewer-mf6'
93+
94+
runs-on: windows-2019
95+
96+
steps:
97+
98+
- uses: actions/checkout@v2
99+
100+
- name: Export env
101+
env:
102+
type: release
103+
zipfile: v${{env.VTK_VERSION}}.zip
104+
instdir: C:/VTK-${{env.VTK_VERSION}}-leaks-${{env.VS_VERSION}}-x64
105+
builddir: C:/VTK-${{env.VTK_VERSION}}-leaks-${{env.VS_VERSION}}-x64-build
106+
srcdir: C:/VTK-${{env.VTK_VERSION}}
107+
shell: pwsh
108+
run: |
109+
echo "type=$env:type" >> $env:GITHUB_ENV
110+
echo "zipfile=$env:zipfile" >> $env:GITHUB_ENV
111+
echo "instdir=$env:instdir" >> $env:GITHUB_ENV
112+
echo "builddir=$env:builddir" >> $env:GITHUB_ENV
113+
echo "srcdir=$env:srcdir" >> $env:GITHUB_ENV
114+
115+
- name: Cache vtk
116+
id: cache-vtk-release
117+
uses: actions/cache@v2
118+
with:
119+
path: ${{env.instdir}}
120+
key: windows-2019-vtk-leaks-${{env.type}}-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
121+
122+
- name: Download vtk
123+
if: steps.cache-vtk-release.outputs.cache-hit != 'true'
124+
shell: pwsh
125+
run: |
126+
curl -L -O "https://github.com/Kitware/VTK/archive/refs/tags/${{env.zipfile}}"
127+
Get-FileHash ${{env.zipfile}}
128+
cd C:\
129+
7z x ${{github.workspace}}\${{env.zipfile}}
130+
rm ${{github.workspace}}\${{env.zipfile}}
131+
132+
# it seems that 'patch' is more forgiving of line endings than 'git apply'
133+
- name: Patch vtk
134+
if: steps.cache-vtk-release.outputs.cache-hit != 'true'
135+
shell: bash
136+
run: |
137+
cp ./misc/0001-update-for-memory-leaks.patch /c/VTK-${{env.VTK_VERSION}}/Utilities/KWSys/vtksys/.
138+
cd /c/VTK-${{env.VTK_VERSION}}/Utilities/KWSys/vtksys/.
139+
md5sum SystemTools.cxx 0001-update-for-memory-leaks.patch
140+
file SystemTools.cxx 0001-update-for-memory-leaks.patch
141+
patch < 0001-update-for-memory-leaks.patch
142+
md5sum SystemTools.cxx
143+
file SystemTools.cxx
144+
145+
- name: Build vtk
146+
if: steps.cache-vtk-release.outputs.cache-hit != 'true'
147+
shell: pwsh
148+
run: |
149+
cp misc\CMakePresets-vtk-9.1.0.json ${{env.srcdir}}\CMakePresets.json
150+
cd ${{env.srcdir}}
151+
cmake --preset ${{env.PRESET}}
152+
cmake --build --preset ${{env.PRESET}} --config ${{env.type}}
153+
cmake --install ${{env.builddir}} --prefix ${{env.instdir}} --config ${{env.type}}
154+
155+
- name: Check release cache
156+
shell: pwsh
157+
run: |
158+
dir ${{env.instdir}}\bin
159+
160+
cache-vtk:
161+
# uncomment the next line if you want to compile vtk
162+
if: github.repository == 'MODFLOW-USGS/modelviewer-mf6'
163+
164+
runs-on: windows-2019
165+
needs: [cache-vtk-debug, cache-vtk-release]
166+
167+
steps:
168+
169+
- name: Checkout
170+
uses: actions/checkout@v2
171+
172+
- name: Export env
173+
env:
174+
zipfile: v${{env.VTK_VERSION}}.zip
175+
instdir: C:/VTK-${{env.VTK_VERSION}}-leaks-${{env.VS_VERSION}}-x64
176+
builddir: C:/VTK-${{env.VTK_VERSION}}-leaks-${{env.VS_VERSION}}-x64-build
177+
srcdir: C:/VTK-${{env.VTK_VERSION}}
178+
tag: vtk-${{env.VTK_VERSION}}-leaks-${{env.VS_VERSION}}-x64
179+
shell: pwsh
180+
run: |
181+
echo "zipfile=$env:zipfile" >> $env:GITHUB_ENV
182+
echo "instdir=$env:instdir" >> $env:GITHUB_ENV
183+
echo "builddir=$env:builddir" >> $env:GITHUB_ENV
184+
echo "srcdir=$env:srcdir" >> $env:GITHUB_ENV
185+
echo "tag=$env:tag" >> $env:GITHUB_ENV
186+
187+
- name: Cache vtk
188+
id: cache-vtk
189+
uses: actions/cache@v2
190+
with:
191+
path: ${{env.instdir}}
192+
key: windows-2019-vtk-leaks-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
193+
194+
- name: Cache vtk debug
195+
if: steps.cache-vtk.outputs.cache-hit != 'true'
196+
id: cache-vtk-debug
197+
uses: actions/cache@v2
198+
with:
199+
path: ${{env.instdir}}
200+
key: windows-2019-vtk-leaks-debug-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
201+
202+
- name: Cache vtk release
203+
if: steps.cache-vtk.outputs.cache-hit != 'true'
204+
uses: actions/cache@v2
205+
with:
206+
path: ${{env.instdir}}
207+
key: windows-2019-vtk-leaks-release-${{hashFiles('misc\CMakePresets-vtk-9.1.0.json')}}
208+
209+
- name: Check merged cache
210+
shell: pwsh
211+
run: |
212+
dir ${{env.instdir}}\bin
213+
214+
- name: Compress cache
215+
shell: pwsh
216+
run: |
217+
7z a ${{env.tag}}.7z ${{env.instdir}}
218+
219+
- name: Delete release
220+
env:
221+
releases_url: ${{github.api_url}}/repos/${{github.repository}}/releases
222+
run: |
223+
# create headers dictionary
224+
$h = @{"Authorization" = "token ${{secrets.GITHUB_TOKEN}}"}
225+
226+
try {
227+
# Get a release by tag name
228+
# https://docs.github.com/rest/reference/repos#get-a-release-by-tag-name
229+
# get /repos/{owner}/{repo}/releases/tags/{tag}
230+
$response = Invoke-WebRequest -Uri ${{env.releases_url}}/tags/${{env.tag}} -Headers $h -Method Get
231+
$hashtable = $response.Content | ConvertFrom-Json -AsHashtable
232+
233+
# Delete a release
234+
# https://docs.github.com/en/rest/reference/releases#delete-a-release
235+
# delete /repos/{owner}/{repo}/releases/{release_id}
236+
$id = $hashtable.id.ToString()
237+
$response = Invoke-WebRequest -Uri ${{env.releases_url}}/$id -Headers $h -Method Delete
238+
}
239+
catch {
240+
Write-Output "An error occured:"
241+
Write-Output $_
242+
}
243+
244+
- name: Delete tag
245+
shell: pwsh
246+
run: |
247+
git push --delete origin refs/tags/${{env.tag}}
248+
249+
- name: Create release
250+
env:
251+
releases_url: ${{github.api_url}}/repos/${{github.repository}}/releases
252+
run: |
253+
# setup json variables
254+
$tag_name = "${{env.tag}}"
255+
$filename = "${{env.tag}}.7z"
256+
$hash = (Get-FileHash $filename).Hash.ToLower()
257+
# format using markdown
258+
$body = "```````nsha256`n$hash $filename`n``````"
259+
260+
# store commit
261+
$target_commitish = "${{github.sha}}"
262+
263+
# create headers dictionary
264+
$h = @{"Authorization" = "token ${{secrets.GITHUB_TOKEN}}"}
265+
$releases_url = "${{env.releases_url}}"
266+
# create release
267+
# POST /repos/{owner}/{repo}/releases
268+
# see https://docs.github.com/en/rest/reference/repos#create-a-release
269+
#
270+
$create = @{
271+
"body" = $body
272+
"tag_name" = $tag_name
273+
"target_commitish" = $target_commitish
274+
"name" = $tag_name
275+
"draft" = $true
276+
}
277+
$create_json = $create | ConvertTo-Json
278+
$release = Invoke-WebRequest -Uri $releases_url -Headers $h -Method Post -Body $create_json
279+
# upload artifact (asset)
280+
# POST /repos/{owner}/{repo}/releases/{release_id}/assets
281+
# see https://docs.github.com/en/rest/reference/repos#upload-a-release-asset
282+
#
283+
$upload_uri = ($release.Content | ConvertFrom-Json).upload_url
284+
if (! ($upload_uri -match "(.*)\{\?name,label\}") ) {
285+
# expecting URI{?name,label}
286+
# ie https://uploads.github.com/repos/scharlton2/iricdev-2019/releases/24058628/assets{?name,label}
287+
throw "Bad upload_url"
288+
}
289+
$upload_uri = $Matches[1] + "?name=$filename"
290+
$h["Content-type"] = "application/x-7z-compressed"
291+
$bytes = [System.IO.File]::ReadAllBytes($filename)
292+
$upload = Invoke-WebRequest -Uri $upload_uri -Headers $h -Method Post -Body $bytes
293+
# update release
294+
# PATCH /repos/{owner}/{repo}/releases/{release_id}
295+
# see https://docs.github.com/en/rest/reference/repos#update-a-release
296+
#
297+
$release_id = ($release.Content | ConvertFrom-Json).id
298+
$h.Remove("Content-type")
299+
$update = @{ "draft" = $false }
300+
$update_json = $update | ConvertTo-Json
301+
$release = Invoke-WebRequest -Uri "$releases_url/$release_id" -Headers $h -Method Patch -Body $update_json
302+
303+
# display download url
304+
Write-Output "::group::Results"
305+
Write-Output "$((($release.Content | ConvertFrom-Json).assets).browser_download_url)"
306+
Write-Output "${{github.sha}}"
307+
Write-Output "sha256"
308+
Write-Output "$hash $filename"
309+
Write-Output "::endgroup::"
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
From e3f82dc08568552525527f74632ff09b4561056f Mon Sep 17 00:00:00 2001
2+
From: "Charlton, Scott R" <charlton@usgs.gov>
3+
Date: Wed, 11 May 2022 20:59:42 -0600
4+
Subject: [PATCH] update for memory leaks
5+
6+
---
7+
SystemTools.cxx | 3 +++
8+
1 file changed, 3 insertions(+)
9+
10+
diff --git a/SystemTools.cxx b/SystemTools.cxx
11+
index bd900fe..57ef960 100644
12+
--- a/SystemTools.cxx
13+
+++ b/SystemTools.cxx
14+
@@ -4732,6 +4732,9 @@ SystemToolsManager::~SystemToolsManager()
15+
{
16+
if (--SystemToolsManagerCount == 0) {
17+
SystemTools::ClassFinalize();
18+
+#if defined(_MSC_VER)
19+
+ _CrtDumpMemoryLeaks();
20+
+#endif
21+
}
22+
}
23+
24+
--
25+
2.27.0.windows.1
26+

0 commit comments

Comments
 (0)