Skip to content

Commit 38e7b5b

Browse files
authored
Merge pull request #1019 from Devsh-Graphics-Programming/nscFixes
Package NSC debug symbols and source artifact
2 parents 8242271 + d596885 commit 38e7b5b

4 files changed

Lines changed: 121 additions & 0 deletions

File tree

.github/workflows/build-nabla.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,42 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
jobs:
17+
prepare-host-rg:
18+
name: Prepare host ripgrep
19+
runs-on: windows-2022
20+
21+
steps:
22+
- name: Restore ripgrep host tool
23+
id: cache-rg
24+
uses: actions/cache@v4
25+
with:
26+
path: ${{ runner.temp }}\ripgrep-14.1.1-x86_64-pc-windows-msvc
27+
key: ripgrep-14.1.1-x86_64-pc-windows-msvc
28+
29+
- name: Install ripgrep host tool
30+
if: steps.cache-rg.outputs.cache-hit != 'true'
31+
shell: pwsh
32+
run: |
33+
$rgVersion = '14.1.1'
34+
$archive = Join-Path $env:RUNNER_TEMP "ripgrep-$rgVersion-x86_64-pc-windows-msvc.zip"
35+
$extractRoot = $env:RUNNER_TEMP
36+
Invoke-WebRequest `
37+
-Uri "https://github.com/BurntSushi/ripgrep/releases/download/$rgVersion/ripgrep-$rgVersion-x86_64-pc-windows-msvc.zip" `
38+
-OutFile $archive
39+
Expand-Archive -Path $archive -DestinationPath $extractRoot -Force
40+
41+
- name: Verify ripgrep host tool
42+
shell: pwsh
43+
run: |
44+
$rgExe = Join-Path $env:RUNNER_TEMP 'ripgrep-14.1.1-x86_64-pc-windows-msvc\rg.exe'
45+
if (-not (Test-Path $rgExe)) {
46+
throw "ripgrep was not installed on host."
47+
}
48+
& $rgExe --version
49+
1750
build-windows:
1851
name: Nabla (${{ matrix.os }}, ${{ matrix.vendor }}-${{ matrix.tag }}, ${{ matrix.config }})
52+
needs: prepare-host-rg
1953
runs-on: ${{ matrix.os }}
2054

2155
env:
@@ -124,6 +158,24 @@ jobs:
124158
with:
125159
submodules: 'recursive'
126160

161+
- name: Restore ripgrep host tool
162+
id: cache-rg
163+
uses: actions/cache@v4
164+
with:
165+
path: ${{ runner.temp }}\ripgrep-14.1.1-x86_64-pc-windows-msvc
166+
key: ripgrep-14.1.1-x86_64-pc-windows-msvc
167+
168+
- name: Add ripgrep to PATH
169+
shell: pwsh
170+
run: |
171+
$rgDir = Join-Path $env:RUNNER_TEMP 'ripgrep-14.1.1-x86_64-pc-windows-msvc'
172+
$rgExe = Join-Path $rgDir 'rg.exe'
173+
if (-not (Test-Path $rgExe)) {
174+
throw "ripgrep was not installed on host."
175+
}
176+
$rgDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
177+
& $rgExe --version
178+
127179
- name: Pull Image
128180
run: |
129181
docker pull "${{ env.image }}:${{ matrix.tag }}"
@@ -297,6 +349,39 @@ jobs:
297349
run: |
298350
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-profiling.tar" profiling
299351
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-install.tar" ${{ env.install }}
352+
$sourceTar = "${{ steps.set-prefix.outputs.prefix }}-source.tar"
353+
$sourceFiles = @(
354+
rg --files -uu . `
355+
-g '*.c' -g '*.cc' -g '*.cpp' -g '*.cxx' `
356+
-g '*.h' -g '*.hh' -g '*.hpp' -g '*.hxx' `
357+
-g '*.inc' -g '*.inl' -g '*.ipp' -g '*.tpp' -g '*.ixx' `
358+
-g '!examples_tests/media/**' -g '!.git/**'
359+
) | Sort-Object -Unique
360+
361+
if ($sourceFiles.Count -eq 0) {
362+
throw "No source-like files found for source artifact packaging."
363+
}
364+
365+
$archiveStream = [System.IO.File]::Open($sourceTar, [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write, [System.IO.FileShare]::None)
366+
try {
367+
$tarWriter = [System.Formats.Tar.TarWriter]::new($archiveStream, [System.Formats.Tar.TarEntryFormat]::Pax, $false)
368+
try {
369+
foreach ($sourceFile in $sourceFiles) {
370+
$entryName = $sourceFile -replace '\\', '/'
371+
if ($entryName.StartsWith('./')) {
372+
$entryName = $entryName.Substring(2)
373+
}
374+
$sourcePath = (Resolve-Path -LiteralPath $sourceFile).Path
375+
$tarWriter.WriteEntry($sourcePath, $entryName)
376+
}
377+
}
378+
finally {
379+
$tarWriter.Dispose()
380+
}
381+
}
382+
finally {
383+
$archiveStream.Dispose()
384+
}
300385
301386
- name: Upload NSC Godbolt Image artifact
302387
uses: actions/upload-artifact@v4
@@ -331,6 +416,12 @@ jobs:
331416
name: ${{ steps.set-prefix.outputs.prefix }}-install
332417
path: ${{ steps.set-prefix.outputs.prefix }}-install.tar
333418

419+
- name: Upload source artifacts
420+
uses: actions/upload-artifact@v4
421+
with:
422+
name: ${{ steps.set-prefix.outputs.prefix }}-source
423+
path: ${{ steps.set-prefix.outputs.prefix }}-source.tar
424+
334425
- name: Login to GHCR
335426
if: steps.set-prefix.outputs.shouldPushImage == 'True'
336427
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u $env:GITHUB_ACTOR --password-stdin

cmake/common.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ function(nbl_install_exe_spec _TARGETS _RELATIVE_DESTINATION)
361361
endif()
362362

363363
install(TARGETS ${_TARGETS} ${_EXPORT_ARGS} RUNTIME DESTINATION ${_DEST_GE_} COMPONENT ${_COMPONENT})
364+
365+
foreach(_TRGT IN LISTS _TARGETS)
366+
install(PROGRAMS $<TARGET_PDB_FILE:${_TRGT}> DESTINATION debug/exe/${_RELATIVE_DESTINATION} CONFIGURATIONS Debug COMPONENT ${_COMPONENT})
367+
endforeach()
364368

365369
foreach(_TRGT IN LISTS _TARGETS)
366370
get_property(_DEFINED_PROPERTY_

tools/nsc/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,20 @@ set(NBL_NSC_COMPILE_COMMAND
267267
set(NBL_NSC_PREINSTALL_TARGET_EXE_DIRECTORY "${NBL_NSC_PREINSTALL_DIRECTORY}/${NBL_PACKAGE_RUNTIME_EXE_DIR_PATH}")
268268
set(NBL_NSC_PREINSTALL_TARGET_EXE_FILENAME $<TARGET_FILE_NAME:${EXECUTABLE_NAME}>)
269269
set(NBL_NSC_PREINSTALL_TARGET_EXE_FILEPATH "${NBL_NSC_PREINSTALL_TARGET_EXE_DIRECTORY}/${NBL_NSC_PREINSTALL_TARGET_EXE_FILENAME}")
270+
set(NBL_NSC_PREINSTALL_TARGET_PDB_FILENAME $<TARGET_PDB_FILE_NAME:${EXECUTABLE_NAME}>)
271+
set(NBL_NSC_PREINSTALL_TARGET_PDB_FILEPATH "${NBL_NSC_PREINSTALL_TARGET_EXE_DIRECTORY}/${NBL_NSC_PREINSTALL_TARGET_PDB_FILENAME}")
270272
set(NBL_NSC_BUILD_INFO_FILENAME build-info.json)
271273
set(NBL_NSC_PREINSTALL_TARGET_BUILD_INFO "${NBL_NSC_PREINSTALL_TARGET_EXE_DIRECTORY}/${NBL_NSC_BUILD_INFO_FILENAME}")
272274

275+
add_test(NAME NBL_NSC_INSTALL_EXECUTABLES_PDB_TEST
276+
COMMAND "${CMAKE_COMMAND}"
277+
-DNBL_CONFIG=$<CONFIG>
278+
-DNBL_PDB_FILEPATH=${NBL_NSC_PREINSTALL_TARGET_PDB_FILEPATH}
279+
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/VerifyInstalledExecutablePdb.cmake"
280+
COMMAND_EXPAND_LISTS
281+
)
282+
set_tests_properties(NBL_NSC_INSTALL_EXECUTABLES_PDB_TEST PROPERTIES DEPENDS NBL_NSC_INSTALL_EXECUTABLES_TEST)
283+
273284
add_test(NAME NBL_NSC_COMPILE_AT_EXE_CWD_TEST
274285
COMMAND "${NBL_NSC_PREINSTALL_TARGET_EXE_FILENAME}" ${NBL_NSC_COMPILE_COMMAND}
275286
WORKING_DIRECTORY "${NBL_NSC_PREINSTALL_TARGET_EXE_DIRECTORY}"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
if(NOT DEFINED NBL_CONFIG)
2+
message(FATAL_ERROR "NBL_CONFIG is not set.")
3+
endif()
4+
5+
if(NOT DEFINED NBL_PDB_FILEPATH)
6+
message(FATAL_ERROR "NBL_PDB_FILEPATH is not set.")
7+
endif()
8+
9+
if(NOT NBL_CONFIG STREQUAL "Debug")
10+
return()
11+
endif()
12+
13+
if(NOT EXISTS "${NBL_PDB_FILEPATH}")
14+
message(FATAL_ERROR "Expected installed NSC PDB at \"${NBL_PDB_FILEPATH}\".")
15+
endif()

0 commit comments

Comments
 (0)