Skip to content

Commit 1b8b2f7

Browse files
committed
update Dockerfile, add DIA SDK, upgrade python version to 3.13.2 and use non-isolated mode for modules discovery, add DXC to tests/3rdparty and go through configure & generate (TODO: add ATL/MFC to our VS bundle), create git/git-submodule.ps1 (TODO: add note to README once created to warn anyone trying to use git submodule in nano container + explain why it will fail)
1 parent 035260b commit 1b8b2f7

File tree

4 files changed

+264
-8
lines changed

4 files changed

+264
-8
lines changed

Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# ---------------- GLOBAL VARS ----------------
55
ARG CMAKE_VERSION=3.31.0
6-
ARG PYTHON_VERSION=3.11.0
6+
ARG PYTHON_VERSION=3.13.2
77
ARG NINJA_VERSION=1.12.1
88
ARG NASM_VERSION=2.16.03
99
ARG GIT_VERSION=2.48.1
@@ -30,6 +30,7 @@ RUN mkdir C:\Temp && cd C:\Temp `
3030
--remove Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
3131
--add Microsoft.VisualStudio.Component.VC.%VC_VERSION%.x86.x64 `
3232
--add Microsoft.VisualStudio.Component.Windows11SDK.%WINDOWS_11_SDK_VERSION% `
33+
--add Microsoft.VisualCpp.DIA.SDK `
3334
--installPath %IMPL_ARTIFACTS_DIR% `
3435
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) `
3536
&& dir %IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC `
@@ -63,7 +64,15 @@ RUN Write-Host "Installing Python $env:PYTHON_VERSION" ; `
6364
New-Item -ItemType Directory -Force -Path C:\Temp, $env:IMPL_ARTIFACTS_DIR ; `
6465
Invoke-WebRequest -Uri "https://www.python.org/ftp/python/$env:PYTHON_VERSION/python-$env:PYTHON_VERSION-embed-amd64.zip" -OutFile C:\Temp\python.zip ; `
6566
tar -xf C:\Temp\python.zip -C $env:IMPL_ARTIFACTS_DIR ; `
66-
Remove-Item C:\Temp\python.zip
67+
Remove-Item C:\Temp\python.zip ; `
68+
Write-Host "Disabling isolated mode..." ; `
69+
$pthFiles = Get-ChildItem -Path $env:IMPL_ARTIFACTS_DIR -Filter "*._pth" ; `
70+
foreach ($file in $pthFiles) { `
71+
$oldName = $file.FullName ; `
72+
$newName = $oldName + '.disabled' ; `
73+
Write-Host "Renaming $oldName to $newName" ; `
74+
Rename-Item -Path $oldName -NewName $newName `
75+
}
6776

6877
# ---------------- NINJA ----------------
6978
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as ninja
@@ -137,8 +146,10 @@ GIT_VERSION=${GIT_VERSION} `
137146
WINDOWS_11_SDK_VERSION=${WINDOWS_11_SDK_VERSION} `
138147
WINDOWS_SDK_VERSION=${WINDOWS_SDK_VERSION} `
139148
VC_VERSION=${VC_VERSION} `
149+
VS_INSTANCE_LOCATION=C:\BuildTools `
140150
MSVC_VERSION=${MSVC_VERSION} `
141151
MSVC_TOOLSET_DIR=C:\BuildTools\VC\Tools\MSVC\${MSVC_VERSION} `
142-
PATH="C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;C:\Git\cmd;C:\Git\bin;C:\Git\usr\bin;C:\Git\mingw64\bin;C:\CMake\cmake-${CMAKE_VERSION}-windows-x86_64\bin;C:\Python;C:\Nasm;C:\Nasm\nasm-${NASM_VERSION};"
152+
PATH="C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;C:\Git\cmd;C:\Git\bin;C:\Git\usr\bin;C:\Git\mingw64\bin;C:\CMake\cmake-${CMAKE_VERSION}-windows-x86_64\bin;C:\Python;C:\Nasm;C:\Nasm\nasm-${NASM_VERSION};C:\Ninja;"
153+
RUN git config --global --add safe.directory '*'
143154

144155
CMD ["pwsh.exe", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass"]

cmake/winsdk-msvc-toolchain.cmake

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,24 @@ if(NOT CMAKE_GENERATOR MATCHES "Ninja*")
88
message(FATAL_ERROR "CMAKE_GENERATOR = \"${CMAKE_GENERATOR}\" is unsupported, use Ninja (single or multi config) generators!")
99
endif()
1010

11+
# https://cmake.org/cmake/help/v3.31/variable/CMAKE_GENERATOR_INSTANCE.html#visual-studio-instance-selection
12+
cmake_path(CONVERT $ENV{VS_INSTANCE_LOCATION} TO_CMAKE_PATH_LIST VS_INSTANCE_LOCATION NORMALIZE)
1113
cmake_path(CONVERT $ENV{CMAKE_WINDOWS_KITS_10_DIR} TO_CMAKE_PATH_LIST WINDOWS_KITS_10_DIR NORMALIZE)
1214
cmake_path(CONVERT $ENV{WINDOWS_SDK_VERSION} TO_CMAKE_PATH_LIST WINDOWS_SDK_VERSION NORMALIZE)
1315
cmake_path(CONVERT $ENV{MSVC_TOOLSET_DIR} TO_CMAKE_PATH_LIST MSVC_TOOLSET_DIR NORMALIZE)
1416

15-
if(VERBOSE)
16-
message(STATUS "WINDOWS_KITS_10_DIR = \"${WINDOWS_KITS_10_DIR}\"")
17-
message(STATUS "WINDOWS_SDK_VERSION = \"${WINDOWS_SDK_VERSION}\"")
18-
message(STATUS "MSVC_TOOLSET_DIR = \"${MSVC_TOOLSET_DIR}\"")
17+
message(STATUS "VS_INSTANCE_LOCATION = \"${VS_INSTANCE_LOCATION}\"")
18+
message(STATUS "WINDOWS_KITS_10_DIR = \"${WINDOWS_KITS_10_DIR}\"")
19+
message(STATUS "WINDOWS_SDK_VERSION = \"${WINDOWS_SDK_VERSION}\"")
20+
message(STATUS "MSVC_TOOLSET_DIR = \"${MSVC_TOOLSET_DIR}\"")
21+
22+
if(NOT EXISTS "${VS_INSTANCE_LOCATION}")
23+
message("VS_INSTANCE_LOCATION ENV not defined!")
24+
endif()
25+
26+
string(FIND "${MSVC_TOOLSET_DIR}" "${VS_INSTANCE_LOCATION}" FOUND)
27+
if("${FOUND}" MATCHES "-1")
28+
message(FATAL_ERROR "MSVC_TOOLSET_DIR is not within VS_INSTANCE_LOCATION, did you move the MSVC toolset directory outside the VS installation? (bad idea!)")
1929
endif()
2030

2131
set(CMAKE_SYSTEM_NAME Windows)
@@ -86,4 +96,15 @@ endmacro()
8696
_UPDATE_STANDARD_DIRECTORIES_(INCLUDE "${INCLUDE}")
8797
_UPDATE_STANDARD_DIRECTORIES_(LINK "${LIB}")
8898

89-
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
99+
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
100+
101+
# extensions
102+
# TODO: could use vswhere.exe with component IDs
103+
macro(_REQUEST_EXTENSION_ WHAT HINT)
104+
if(EXISTS "${HINT}")
105+
set(${WHAT} "${HINT}")
106+
message(STATUS "WITH ${WHAT} = \"${HINT}\"")
107+
endif()
108+
endmacro()
109+
110+
_REQUEST_EXTENSION_(DIASDK_INCLUDE_DIR "${VS_INSTANCE_LOCATION}/DIA SDK/include")

git/git-submodule.ps1

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
#!/usr/bin/env pwsh
2+
3+
<#
4+
.SYNOPSIS
5+
PowerShell version of Git submodule management, replicating `git-submodule.sh`.
6+
7+
.DESCRIPTION
8+
Uses `git submodule--helper` to execute submodule operations like the original shell script.
9+
10+
.PARAMETER Command
11+
The submodule command to execute (e.g., add, init, update, status, deinit).
12+
13+
.PARAMETER Path
14+
The path of the submodule.
15+
16+
.PARAMETER Repository
17+
The repository URL for adding a submodule.
18+
19+
.PARAMETER Branch
20+
The branch to use when adding a submodule.
21+
22+
.PARAMETER Reference
23+
A reference repository.
24+
25+
.PARAMETER Force
26+
Enables force options.
27+
28+
.PARAMETER Recursive
29+
Enables recursive options.
30+
31+
.PARAMETER Quiet
32+
Suppresses output.
33+
34+
.PARAMETER Init
35+
Initializes submodules.
36+
37+
.PARAMETER Remote
38+
Fetches changes from the remote repository.
39+
40+
.PARAMETER NoFetch
41+
Prevents fetching new commits.
42+
43+
.PARAMETER Checkout
44+
Uses "checkout" mode in updates.
45+
46+
.PARAMETER Merge
47+
Uses "merge" mode in updates.
48+
49+
.PARAMETER Rebase
50+
Uses "rebase" mode in updates.
51+
52+
.PARAMETER SingleBranch
53+
Fetches only one branch.
54+
55+
.EXAMPLE
56+
./git-submodule.ps1 add --Repository "https://github.com/example/repo.git" --Path "submodules/my-submodule"
57+
#>
58+
59+
# system wide setup:
60+
# git config --global alias.submodule '!pwsh <PATH_TO_THIS_SCRIPT>/git-submodule.ps1'
61+
# git submodule update --init --recursive
62+
63+
param(
64+
[string]$Command,
65+
[string]$Path,
66+
[string]$Repository,
67+
[string]$Branch,
68+
[string]$Reference,
69+
[switch]$Quiet,
70+
[switch]$Force,
71+
[switch]$Recursive,
72+
[switch]$Init,
73+
[switch]$Remote,
74+
[switch]$NoFetch,
75+
[switch]$Checkout,
76+
[switch]$Merge,
77+
[switch]$Rebase,
78+
[switch]$SingleBranch
79+
)
80+
81+
$insideGitRepo = git rev-parse --is-inside-work-tree 2>$null
82+
if ($insideGitRepo -ne "true") {
83+
Write-Host "Error: Not inside a Git repository." -ForegroundColor Red
84+
exit 1
85+
}
86+
87+
$gitRoot = git rev-parse --show-toplevel
88+
Set-Location $gitRoot
89+
90+
function Execute-GitSubmoduleHelper {
91+
param([string]$Subcommand, [string]$Arguments)
92+
$cmd = "git submodule--helper $Subcommand $Arguments"
93+
94+
if ($Quiet) { $cmd += " --quiet" }
95+
if ($Force) { $cmd += " --force" }
96+
if ($Recursive) { $cmd += " --recursive" }
97+
98+
Write-Host "Executing: $cmd"
99+
Invoke-Expression $cmd
100+
}
101+
102+
switch ($Command) {
103+
"add" {
104+
if (-not $Repository -or -not $Path) {
105+
Write-Host "Usage: git-submodule.ps1 add --Repository <URL> --Path <Path>" -ForegroundColor Yellow
106+
exit 1
107+
}
108+
$args = "--name '$Path'"
109+
if ($Branch) { $args += " --branch '$Branch'" }
110+
if ($Reference) { $args += " --reference '$Reference'" }
111+
Execute-GitSubmoduleHelper "add" "$args '$Repository' '$Path'"
112+
}
113+
114+
"init" {
115+
Execute-GitSubmoduleHelper "init" ""
116+
}
117+
118+
"deinit" {
119+
if (-not $Path) {
120+
Write-Host "Usage: git-submodule.ps1 deinit --Path <Path>" -ForegroundColor Yellow
121+
exit 1
122+
}
123+
Execute-GitSubmoduleHelper "deinit" "--force '$Path'"
124+
}
125+
126+
"update" {
127+
$args = ""
128+
if ($Init) { $args += "--init " }
129+
if ($Remote) { $args += "--remote " }
130+
if ($NoFetch) { $args += "-N " }
131+
if ($Rebase) { $args += "--rebase " }
132+
if ($Merge) { $args += "--merge " }
133+
if ($Checkout) { $args += "--checkout " }
134+
if ($SingleBranch) { $args += "--single-branch " }
135+
Execute-GitSubmoduleHelper "update" "$args '$Path'"
136+
}
137+
138+
"status" {
139+
Execute-GitSubmoduleHelper "status" ""
140+
}
141+
142+
"set-branch" {
143+
if (-not $Path -or -not $Branch) {
144+
Write-Host "Usage: git-submodule.ps1 set-branch --Path <Path> --Branch <Branch>" -ForegroundColor Yellow
145+
exit 1
146+
}
147+
Execute-GitSubmoduleHelper "set-branch" "--branch '$Branch' '$Path'"
148+
}
149+
150+
"set-url" {
151+
if (-not $Path -or -not $NewUrl) {
152+
Write-Host "Usage: git-submodule.ps1 set-url --Path <Path> --NewUrl <URL>" -ForegroundColor Yellow
153+
exit 1
154+
}
155+
Execute-GitSubmoduleHelper "set-url" "'$Path' '$NewUrl'"
156+
}
157+
158+
"summary" {
159+
Execute-GitSubmoduleHelper "summary" ""
160+
}
161+
162+
"foreach" {
163+
if (-not $Path) {
164+
Write-Host "Usage: git-submodule.ps1 foreach --Path <command>" -ForegroundColor Yellow
165+
exit 1
166+
}
167+
Execute-GitSubmoduleHelper "foreach" "'$Path'"
168+
}
169+
170+
"sync" {
171+
Execute-GitSubmoduleHelper "sync" ""
172+
}
173+
174+
"absorbgitdirs" {
175+
Execute-GitSubmoduleHelper "absorbgitdirs" ""
176+
}
177+
178+
default {
179+
Write-Host "Invalid command. Use: add, init, deinit, update, status, set-branch, set-url, summary, foreach, sync, absorbgitdirs" -ForegroundColor Red
180+
exit 1
181+
}
182+
}

tests/3rdparty/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,48 @@ include(${CPM_CMAKE})
1212
CPMAddPackage(NAME libjpeg-turbo URL https://github.com/libjpeg-turbo/libjpeg-turbo/archive/97a1575cb877e593cf9940cd869f41b1ddd4a4fd.tar.gz)
1313
CPMAddPackage(NAME blake3 URL https://github.com/BLAKE3-team/BLAKE3/archive/refs/tags/1.6.1.tar.gz DOWNLOAD_ONLY YES)
1414
add_subdirectory("${blake3_SOURCE_DIR}/c")
15+
CPMAddPackage(NAME dxc GITHUB_REPOSITORY Devsh-Graphics-Programming/DirectXShaderCompiler GIT_TAG b2e75826b70d85d03686dd8a755ef477b4fa3807 GIT_SHALLOW YES DOWNLOAD_ONLY YES)
16+
17+
set(HLSL_OPTIONAL_PROJS_IN_DEFAULT OFF)
18+
set(HLSL_ENABLE_ANALYZE OFF)
19+
set(HLSL_OFFICIAL_BUILD OFF)
20+
set(HLSL_ENABLE_FIXED_VER OFF)
21+
set(HLSL_FIXED_VERSION_LOCATION "")
22+
set(HLSL_BUILD_DXILCONV ON)
23+
set(CLANG_VENDOR "")
24+
set(ENABLE_SPIRV_CODEGEN ON)
25+
set(SPIRV_BUILD_TESTS OFF)
26+
set(CLANG_ENABLE_ARCMT OFF)
27+
set(CLANG_ENABLE_STATIC_ANALYZER OFF)
28+
set(CLANG_INCLUDE_TESTS OFF)
29+
set(LLVM_INCLUDE_TESTS OFF)
30+
set(HLSL_INCLUDE_TESTS OFF)
31+
set(LLVM_INCLUDE_UTILS OFF)
32+
set(LLVM_TARGETS_TO_BUILD None)
33+
set(LLVM_INCLUDE_DOCS OFF)
34+
set(LLVM_INCLUDE_EXAMPLES OFF)
35+
set(LIBCLANG_BUILD_STATIC ON)
36+
set(LLVM_OPTIMIZED_TABLEGEN OFF)
37+
set(LLVM_REQUIRES_EH ON)
38+
set(LLVM_APPEND_VC_REV ON)
39+
set(LLVM_ENABLE_RTTI ON)
40+
set(LLVM_ENABLE_EH ON)
41+
set(LLVM_DEFAULT_TARGET_TRIPLE dxil-ms-dx)
42+
set(CLANG_BUILD_EXAMPLES OFF)
43+
set(LLVM_REQUIRES_RTTI ON)
44+
set(CLANG_CL OFF)
45+
set(LLVM_ENABLE_WERROR OFF)
46+
set(SPIRV_WERROR OFF)
47+
set(DXC_BUILD_ARCH x64)
48+
set(SPIRV_HEADERS_SKIP_INSTALL ON)
49+
set(SPIRV_HEADERS_SKIP_EXAMPLES ON)
50+
set(SKIP_SPIRV_TOOLS_INSTALL ON)
51+
set(SPIRV_SKIP_TESTS ON)
52+
set(SPIRV_SKIP_EXECUTABLES ON)
53+
set(HLSL_ENABLE_DEBUG_ITERATORS ON)
54+
55+
include("${dxc_SOURCE_DIR}/cmake/caches/PredefinedParams.cmake")
56+
add_subdirectory("${dxc_SOURCE_DIR}")
1557

1658
# old jpeg-turbo doesn't explicilty associate .asm extension with ASM dialect, small patch
1759
get_target_property(TARGET_SOURCE_DIR simd SOURCE_DIR)

0 commit comments

Comments
 (0)