Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fcitx
Browse files Browse the repository at this point in the history
  • Loading branch information
Fcitx Bot committed Nov 21, 2024
2 parents 00c2d01 + df1bbd9 commit 020ea48
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 42 deletions.
32 changes: 24 additions & 8 deletions src/build_tools/vs_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@
from typing import Union


def get_vcvarsall(path_hint: Union[str, None] = None) -> pathlib.Path:
def get_vcvarsall(
arch: str,
path_hint: Union[str, None] = None
) -> pathlib.Path:
"""Returns the path of 'vcvarsall.bat'.
Args:
arch: host/target architecture
path_hint: optional path to vcvarsall.bat
Returns:
Expand Down Expand Up @@ -78,12 +82,17 @@ def get_vcvarsall(path_hint: Union[str, None] = None) -> pathlib.Path:
'Microsoft.VisualStudio.Product.Professional',
'Microsoft.VisualStudio.Product.Community',
'Microsoft.VisualStudio.Product.BuildTools',
'-requires',
'Microsoft.VisualStudio.Component.VC.Redist.14.Latest',
'-find',
'VC/Auxiliary/Build/vcvarsall.bat',
'-utf8',
]
cmd += [
'-requires',
'Microsoft.VisualStudio.Component.VC.Redist.14.Latest',
]
if arch.endswith('arm64'):
cmd += ['Microsoft.VisualStudio.Component.VC.Tools.ARM64']

process = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
Expand All @@ -103,11 +112,18 @@ def get_vcvarsall(path_hint: Union[str, None] = None) -> pathlib.Path:

vcvarsall = pathlib.Path(stdout.splitlines()[0])
if not vcvarsall.exists():
raise FileNotFoundError(
'Could not find vcvarsall.bat.'
'Consider using --vcvarsall_path option e.g.\n'
msg = 'Could not find vcvarsall.bat.'
if arch.endswith('arm64'):
msg += (
' Make sure Microsoft.VisualStudio.Component.VC.Tools.ARM64 is'
' installed.'
)
else:
msg += (
' Consider using --vcvarsall_path option e.g.\n'
r' --vcvarsall_path=C:\VS\VC\Auxiliary\Build\vcvarsall.bat'
)
)
raise FileNotFoundError(msg)

return vcvarsall

Expand Down Expand Up @@ -151,7 +167,7 @@ def get_vs_env_vars(
ChildProcessError: When 'vcvarsall.bat' cannot be executed.
FileNotFoundError: When 'vcvarsall.bat' cannot be found.
"""
vcvarsall = get_vcvarsall(vcvarsall_path_hint)
vcvarsall = get_vcvarsall(arch, vcvarsall_path_hint)

pycmd = (r'import json;'
r'import os;'
Expand Down
34 changes: 0 additions & 34 deletions src/gyp/common_win.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
# Visual C++ Runtime Version.
'vcruntime_ver%': '',

# Extra headers and libraries for Visual C++.
'msvs_includes%': [],
'msvs_libs_x86%': [],
'msvs_libs_x64%': [],

'conditions': [
# https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros
['MSVS_VERSION=="2015"', {
Expand Down Expand Up @@ -131,25 +126,11 @@
'/bigobj',
],
},
'VCLibrarianTool': {
'AdditionalLibraryDirectories': [
'<@(msvs_libs_x86)',
],
'AdditionalLibraryDirectories!': [
'<@(msvs_libs_x64)',
],
},
'VCLinkerTool': {
'TargetMachine': '<(win_target_machine_x86)',
'AdditionalOptions': [
'/SAFESEH',
],
'AdditionalLibraryDirectories': [
'<@(msvs_libs_x86)',
],
'AdditionalLibraryDirectories!': [
'<@(msvs_libs_x64)',
],
'EnableUAC': 'true',
'UACExecutionLevel': '0', # level="asInvoker"
'UACUIAccess': 'false', # uiAccess="false"
Expand All @@ -175,22 +156,8 @@
'/bigobj',
],
},
'VCLibrarianTool': {
'AdditionalLibraryDirectories': [
'<@(msvs_libs_x64)',
],
'AdditionalLibraryDirectories!': [
'<@(msvs_libs_x86)',
],
},
'VCLinkerTool': {
'TargetMachine': '<(win_target_machine_x64)',
'AdditionalLibraryDirectories': [
'<@(msvs_libs_x64)',
],
'AdditionalLibraryDirectories!': [
'<@(msvs_libs_x86)',
],
},
},
},
Expand Down Expand Up @@ -332,7 +299,6 @@
'<@(absl_include_dirs)',
'<(abs_depth)',
'<(SHARED_INTERMEDIATE_DIR)',
'<@(msvs_includes)',
'<(third_party_dir)/wil/include',
],
'msvs_configuration_attributes': {
Expand Down

0 comments on commit 020ea48

Please sign in to comment.