diff options
author | Steve Dower <steve.dower@python.org> | 2022-01-28 16:48:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 16:48:06 +0000 |
commit | 45faf151c693b6f13f78926761caea6df7242024 (patch) | |
tree | 8e45001c8431c55aba7a03015e8e449361b3d4c0 /Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp | |
parent | db77bcd6092f3c174ae855522411ab83854d65a8 (diff) | |
download | cpython-45faf151c693b6f13f78926761caea6df7242024.tar.gz cpython-45faf151c693b6f13f78926761caea6df7242024.zip |
bpo-33125: Enables building traditional installer for Windows ARM64 (GH-30885)
Also makes a few general improvements to the build process and removes some dead code.
Diffstat (limited to 'Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp')
-rw-r--r-- | Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp index fdc2a21d83d..226416f3545 100644 --- a/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp +++ b/Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp @@ -1501,6 +1501,9 @@ private: hr = UpdateUIStrings(_command.action); BalExitOnFailure(hr, "Failed to load UI strings."); + hr = FindProgramFilesArm(); + BalExitOnFailure(hr, "Fatal error locating Program Files (Arm)"); + GetBundleFileVersion(); // don't fail if we couldn't get the version info; best-effort only LExit: @@ -2181,6 +2184,37 @@ private: return hr; } + HRESULT FindProgramFilesArm() { + wchar_t buffer[MAX_PATH + 1]; + DWORD bufferLen = MAX_PATH; + LSTATUS res = RegGetValueW( + HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion", + L"ProgramFilesDir (Arm)", + RRF_RT_REG_SZ | RRF_RT_REG_EXPAND_SZ | RRF_SUBKEY_WOW6464KEY, + NULL, + buffer, + &bufferLen + ); + if (res != ERROR_SUCCESS) { + // ProgramFilesArmFolder will default to ProgramFilesFolder. We only report + // an error if the value existed, as it will simply just be absent on non-ARM + // devices. + if (res != ERROR_FILE_NOT_FOUND) { + BalLog(BOOTSTRAPPER_LOG_LEVEL_ERROR, "Failed to query 'ProgramFilesDir (Arm)': error code %d", res); + } + return S_OK; + } + if (buffer[0]) { + wchar_t *p = &buffer[bufferLen / sizeof(wchar_t) - 1]; + while (*p == L'\\' || *p == L'\0') { p -= 1; } + *++p = L'\\'; + *++p = L'\0'; + _engine->SetVariableString(L"ProgramFilesArmFolder", buffer); + } + return S_OK; + } + // // OnPlan - plan the detected changes. // |