Skip to content

Commit 556de20

Browse files
committed
generate_getbuildinfo.py now runs _getcompiler program on Windows
1 parent 3b179ca commit 556de20

3 files changed

Lines changed: 18 additions & 12 deletions

File tree

‎Makefile.pre.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,6 +1870,7 @@ Modules/getbuildinfo.h: $(srcdir)/Tools/build/generate_getbuildinfo.py Programs/
18701870
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/build/generate_getbuildinfo.py \
18711871
-o $@ \
18721872
--platform="$(MACHDEP)" \
1873+
--getcompiler-program="Programs/_getcompiler" \
18731874
--git-version="`LC_ALL=C $(GITVERSION)`" \
18741875
--git-tag="`LC_ALL=C $(GITTAG)`" \
18751876
--git-branch="`LC_ALL=C $(GITBRANCH)`"

‎PCbuild/_freeze_module.vcxproj‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,18 +474,13 @@
474474
<GIT Condition="$(GIT) == ''">git</GIT>
475475
<_GIT>$(GIT)</_GIT>
476476
</PropertyGroup>
477-
<Message Text="Getting compiler version string" Importance="high" />
478-
<MakeDir Directories="$(IntDir)" Condition="!Exists($(IntDir))" />
479-
<Exec Command='"$(GetCompilerExe)" &gt; &quot;$(IntDir)compiler.txt&quot;' ContinueOnError="true" />
480477
<PropertyGroup>
481-
<Compiler Condition="Exists('$(IntDir)compiler.txt')">$([System.IO.File]::ReadAllText('$(IntDir)compiler.txt').Trim())</Compiler>
482-
483478
<FreeThreading Condition="$(DisableGil) == 'true'">1</FreeThreading>
484479
<FreeThreading Condition="$(DisableGil) != 'true'">0</FreeThreading>
485480
</PropertyGroup>
486481

487482
<Message Text="Run generate_getbuildinfo.py" Importance="high" />
488-
<Exec Command='$(PythonForBuild) Tools\build\generate_getbuildinfo.py --platform=win32 --git-program="$(_GIT)" --compiler="$(Compiler)" --free-threading=$(FreeThreading)'
483+
<Exec Command='$(PythonForBuild) Tools\build\generate_getbuildinfo.py --platform=win32 --git-program="$(_GIT)" --getcompiler-program="$(GetCompilerExe)" --free-threading=$(FreeThreading)'
489484
WorkingDirectory="$(PySourcePath)" />
490485
</Target>
491486
<Target Name="_RebuildFrozen" AfterTargets="AfterBuild" Condition="$(Configuration) != 'PGUpdate'">

‎Tools/build/generate_getbuildinfo.py‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import sysconfig
1111
import time
1212

13+
14+
MS_WINDOWS = (sys.platform == 'win32')
1315
SRC_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
1416
SCRIPT_NAME = os.path.basename(__file__)
1517
SCRIPT_FULLNAME = f'Tools/build/{SCRIPT_NAME}'
@@ -125,6 +127,7 @@ def parse_args():
125127
parser.add_argument('--git-version', type=str)
126128
parser.add_argument('--git-tag', type=str)
127129
parser.add_argument('--git-branch', type=str)
130+
parser.add_argument('--getcompiler-program', type=str)
128131
parser.add_argument('--compiler', type=str)
129132
parser.add_argument('--free-threading', type=int)
130133
return parser.parse_args()
@@ -155,10 +158,14 @@ def run_command(cmd, *, check=True):
155158
return proc.stdout.rstrip()
156159

157160

158-
def _get_compiler():
161+
def _get_compiler(getcompiler):
159162
# Run _getcompiler program
160-
getcompiler = os.path.join('Programs', '_getcompiler')
161-
HOSTRUNNER = get_hostrunner()
163+
if not getcompiler:
164+
getcompiler = os.path.join('Programs', '_getcompiler')
165+
if not MS_WINDOWS:
166+
HOSTRUNNER = get_hostrunner()
167+
else:
168+
HOSTRUNNER = None
162169
if HOSTRUNNER:
163170
# Cross-compilation
164171
runner = shlex.split(HOSTRUNNER)[0]
@@ -168,6 +175,9 @@ def _get_compiler():
168175
if compiler:
169176
return compiler
170177

178+
if MS_WINDOWS:
179+
return None
180+
171181
# Running _getcompiler failed, run the compiler with --version
172182
CC = get_makefile_cc()
173183
if not CC:
@@ -206,9 +216,9 @@ def compact_compiler(compiler):
206216
return compiler
207217

208218

209-
def get_compiler(compiler):
219+
def get_compiler(compiler, getcompiler_program):
210220
if not compiler:
211-
compiler = _get_compiler()
221+
compiler = _get_compiler(getcompiler_program)
212222
if not compiler:
213223
# Default compiler name when everything else failed
214224
# (see Programs/_getcompiler.c)
@@ -254,7 +264,7 @@ def main():
254264
if not platform:
255265
platform = "unknown"
256266

257-
compiler = get_compiler(args.compiler)
267+
compiler = get_compiler(args.compiler, args.getcompiler_program)
258268

259269
build_info, git_id = get_build_info(git_tag, git_branch, git_version)
260270

0 commit comments

Comments
 (0)