-
-
Notifications
You must be signed in to change notification settings - Fork 25
165 lines (135 loc) · 5.82 KB
/
build-windows.yml
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build Millennium (Windows)
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: windows-latest
steps:
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: (Generator) Setup Minimal MSVC
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86
- name: Set up cache for Python source
uses: actions/cache@v3
id: build-cache
with:
path: |
Python-3.11.8/PCbuild/win32
key: ${{ runner.os }}-python-3.11.8-build
restore-keys: |
${{ runner.os }}-python-3.11.8-build-
- name: (Python) Download 3.11.8 win32 source
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
# download python 3.11.8 source code
curl -o Python-3.11.8.tgz https://www.python.org/ftp/python/3.11.8/Python-3.11.8.tgz
# extract the tarball
tar -xzvf Python-3.11.8.tgz >nul 2>&1
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- name: (Python) Stage Python 3.11.8 static build
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
cd Python-3.11.8
$vcxprojPath = "PCbuild/pythoncore.vcxproj"
$content = Get-Content $vcxprojPath -Raw # Read the entire content as a single string
$pattern = '</ClCompile>'
$replacement = @"
<RuntimeLibrary Condition="'`$(Configuration)|`$(Platform)'=='Release|Win32'">MultiThreaded</RuntimeLibrary>
<RuntimeLibrary Condition="'`$(Configuration)|`$(Platform)'=='Debug|Win32'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
"@
$modifiedContent = $content -replace [regex]::Escape($pattern), $replacement
$modifiedContent | Set-Content $vcxprojPath
shell: pwsh
- name: (Python) Build 3.11.8
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
cd Python-3.11.8
# get python external libs before build
./PCbuild/get_externals.bat
# build python 3.11.8 as win32 and release
msbuild PCBuild/pcbuild.sln /p:Configuration=Release /p:Platform=Win32 /p:RuntimeLibrary=MT
msbuild PCBuild/pcbuild.sln /p:Configuration=Debug /p:Platform=Win32 /p:RuntimeLibrary=MT
# verify python is installed
PCbuild\win32\python.exe --version
- name: Upload Python artifacts
run: |
mkdir D:/a/Millennium/Millennium/build/python
# Move the python311.dll binary to the release directory
copy D:\a\Millennium\Millennium\Python-3.11.8\PCbuild\win32\python311.dll D:/a/Millennium/Millennium/build/python/python311.dll
copy D:\a\Millennium\Millennium\Python-3.11.8\PCbuild\win32\python311_d.dll D:/a/Millennium/Millennium/build/python/python311_d.dll
copy D:\a\Millennium\Millennium\Python-3.11.8\PCbuild\win32\python311.lib D:/a/Millennium/Millennium/build/python/python311.lib
copy D:\a\Millennium\Millennium\Python-3.11.8\PCbuild\win32\python311_d.lib D:/a/Millennium/Millennium/build/python/python311_d.lib
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: python 3.11.8 build libraries
path: D:/a/Millennium/Millennium/build/python
- name: (Generator) Integrate VS2022
uses: microsoft/setup-msbuild@v2
with:
vs-version: '17'
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- name: (Generator) Install CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.21.1'
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- name: (Dependency) Install vcpkg
run: |
# clone vcpkg to
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
# bootstrap and install vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
shell: pwsh
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- name: (Generator) Configure CMake
run: |
# set vs variables for cache generation
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
# generate cache for x86/win32 with vs
# - windows @ CMakeUserPresets.json
# - GITHUB_ACTION_BUILD (boolean) is a macro to help set include paths in CMakeLists.txt
cmake --preset=windows -G "Visual Studio 17 2022" -A Win32 -DGITHUB_ACTION_BUILD=ON
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- name: Build Millennium
run: |
mkdir D:/a/Millennium/Millennium/build/artifacts
dir "D:\a\Millennium\Millennium\Python-3.11.8\PCbuild\win32"
# build millennium with msvc; x86; release
cmake --build build --config Release
# Move the python311.dll binary to the release directory
copy D:\a\Millennium\Millennium\Python-3.11.8\PCbuild\win32\python311.dll D:/a/Millennium/Millennium/build/artifacts/python311.dll
copy D:\a\Millennium\Millennium\build\Release\user32.dll D:/a/Millennium/Millennium/build/artifacts/user32.dll
env:
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: millennium
path: D:/a/Millennium/Millennium/build/artifacts