From 8e3b2fadd67c80d922e13989db998333c86c09d4 Mon Sep 17 00:00:00 2001 From: valord577 Date: Thu, 9 Jul 2026 17:41:08 +0800 Subject: [PATCH 1/7] simplify func: append_pkgconf_search_path --- modules/ffmpeg.py | 25 ++++++++++++------------- x_utils.py | 4 +++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/modules/ffmpeg.py b/modules/ffmpeg.py index 2559dd3..5b6d6d4 100755 --- a/modules/ffmpeg.py +++ b/modules/ffmpeg.py @@ -33,7 +33,6 @@ def get_build_env() -> "dict[str, str]": env['CXXFLAGS'] = env['CFLAGS'] return env # ---------------------------- -build_env = get_build_env() extra_args: "list[str]" = [] pkg_buld_dir = ctx.args.pkg_buld_dir # ---------------------------- @@ -76,7 +75,7 @@ def _3rd_included(): for dep in _3rd_deps: dep_path = ctx.include_3rd_dependencies(dep) if args := dep['args']: extra_args.append(args) - x.append_pkgconf_search_path(build_env, (dep_path / 'lib' / 'pkgconfig')) + x.append_pkgconf_search_path((dep_path / 'lib' / 'pkgconfig')) def _fetch_source(): ctx.fetch_source_from_git('refs/heads/release/8.1', 'https://git.ffmpeg.org/ffmpeg.git') def _build_step_0(): @@ -135,7 +134,7 @@ def _build_step_0(): pkg_buld_dir = ctx.subproj_src_dir().as_posix() else: args.append('--disable-logging') - x.run_as_subprocess(env=build_env, cwd=pkg_buld_dir, args=args) + x.run_as_subprocess(env=get_build_env(), cwd=pkg_buld_dir, args=args) def _build_step_1(): import shutil import subprocess as sp @@ -145,14 +144,14 @@ def _build_step_1(): if bear_exec := shutil.which('bear'): bear.append(bear_exec) args = ['make', '-j', f'{x.detect_cpu_count()}'] - x.run_as_subprocess(env=build_env, cwd=pkg_buld_dir, args=(bear + args), stdout=sp.DEVNULL) + x.run_as_subprocess(env=get_build_env(), cwd=pkg_buld_dir, args=(bear + args), stdout=sp.DEVNULL) def _build_step_2(): import shlex args = ['make', 'install-headers', 'install-libs'] if ctx.args.target_plat not in {'iphoneos', 'iphonesimulator'}: args.append('install-progs') - x.run_as_subprocess(env=build_env, cwd=pkg_buld_dir, args=args) + x.run_as_subprocess(env=get_build_env(), cwd=pkg_buld_dir, args=args) if ctx.args.target_plat == 'win-msvc': return @@ -180,7 +179,7 @@ def _build_step_2(): _ = f.write('};\n') elif ctx.args.target_plat == 'win-mingw': _dll_sym_arg = f"{' '.join(ctx.args.nm)} -a lib/*.a | grep ' T ' | cut -d ' ' -f 3" - _dll_sym_all = x.run_as_subprocess(env=build_env, cwd=ctx.args.pkg_inst_dir, + _dll_sym_all = x.run_as_subprocess(env=get_build_env(), cwd=ctx.args.pkg_inst_dir, collect_stdout=True, args=_dll_sym_arg, shell=True) _ = f.write('LIBRARY libffmpeg\n') _ = f.write('EXPORTS\n') @@ -197,9 +196,9 @@ def _build_step_2(): ffmpeg_pkgconf_search = (Path(ctx.args.pkg_inst_dir) / 'lib' / 'pkgconfig') - x.append_pkgconf_search_path(build_env, ffmpeg_pkgconf_search) + x.append_pkgconf_search_path(ffmpeg_pkgconf_search) ffmpeg_self_libraries = shlex.split( - x.run_as_subprocess(env=build_env, collect_stdout=True, args=[' '.join(ctx.args.pkgconf), '--libs', 'libavdevice']) + x.run_as_subprocess(env=get_build_env(), collect_stdout=True, args=[' '.join(ctx.args.pkgconf), '--libs', 'libavdevice']) ) ffmpeg_mergeso_libdir: list[str] = [] @@ -269,18 +268,18 @@ def _build_step_2(): cmdlink.extend(ffmpeg_mergeso_libstd) for _lib in ffmpeg_mergeso_libmac: cmdlink.extend(['-framework', _lib]) - x.run_as_subprocess(env=build_env, cwd=ctx.args.pkg_inst_dir, args=cmdlink) + x.run_as_subprocess(env=get_build_env(), cwd=ctx.args.pkg_inst_dir, args=cmdlink) dbgsym = f'{merged.as_posix()}.dbgsym' if ctx.args.target_plat in {'linux', 'win-mingw', 'android'}: - x.run_as_subprocess(env=build_env, cwd=ctx.args.pkg_inst_dir, + x.run_as_subprocess(env=get_build_env(), cwd=ctx.args.pkg_inst_dir, args=(ctx.args.objcopy + ['--only-keep-debug', merged.as_posix(), dbgsym])) - x.run_as_subprocess(env=build_env, cwd=ctx.args.pkg_inst_dir, + x.run_as_subprocess(env=get_build_env(), cwd=ctx.args.pkg_inst_dir, args=(ctx.args.objcopy + ['--strip-debug', '--strip-unneeded', merged.as_posix()])) - x.run_as_subprocess(env=build_env, cwd=ctx.args.pkg_inst_dir, + x.run_as_subprocess(env=get_build_env(), cwd=ctx.args.pkg_inst_dir, args=(ctx.args.objcopy + [f'--add-gnu-debuglink={dbgsym}', merged.as_posix()])) - x.run_as_subprocess(env=build_env, cwd=pkg_buld_dir, + x.run_as_subprocess(env=get_build_env(), cwd=pkg_buld_dir, args=['make', 'uninstall-libs', 'uninstall-pkgconfig']) diff --git a/x_utils.py b/x_utils.py index 2421f06..6939bfa 100644 --- a/x_utils.py +++ b/x_utils.py @@ -74,7 +74,9 @@ def gha_append_env(env: "dict[str, str]"): logv(f'append github action env: {k}={v}') _ = f.write(f'{k}={v}\n') -def append_pkgconf_search_path(env: "dict[str, str]", dir: "Path"): +def append_pkgconf_search_path(dir: "Path", *, env: "dict[str, str] | None" = None): + if not env: + env = ENVIRON new = dir.absolute().as_posix() if old := env.get('PKG_CONFIG_PATH'): new = (new + os.pathsep + old) From aa854bae81877db017b457280c9703e25d3ba8a5 Mon Sep 17 00:00:00 2001 From: valord577 Date: Thu, 9 Jul 2026 21:27:06 +0800 Subject: [PATCH 2/7] refactory: strongly-typed python project --- build_v2.py | 58 ++++++---- modules/llvm.py | 300 +++++++++++++++++++----------------------------- 2 files changed, 152 insertions(+), 206 deletions(-) diff --git a/build_v2.py b/build_v2.py index d38ccd9..8431668 100755 --- a/build_v2.py +++ b/build_v2.py @@ -51,6 +51,8 @@ class BuildCtxArgs: target_arch: "str" target_info: "str" + llvm_triple: "str" + target_archinfo: "str" win32_msvc_env_native: "dict[str, str]" @@ -167,6 +169,8 @@ def __init__(self, self.target_arch: "str" = '' self.target_info: "str" = '' + self.llvm_triple: "str" = '' + # - API Level 30: android.media.MediaCodec#CONFIGURE_FLAG_USE_BLOCK_MODEL # - API Level 31: android.media.MediaCodec#getSupportedVendorParameters() # - API Level 35: android.media.MediaCodec#PARAMETER_KEY_QP_OFFSET_MAP @@ -233,6 +237,8 @@ def build_v2(self, module: "str"): target_arch=self.target_arch, target_info=self.target_info, + llvm_triple=self.llvm_triple, + target_archinfo=self.target_archinfo, win32_msvc_env_native=self.win32_msvc_env_native, @@ -287,21 +293,25 @@ def _setctx_linux( state.nm.extend(['llvm-nm']) state.ldflags.extend(['-fuse-ld=lld']) state.objcopy.extend(['llvm-objcopy']) + + x.ENVIRON['CC'] = 'clang' + x.ENVIRON['CXX'] = 'clang++' + x.ENVIRON['LDFLAGS'] = '-fuse-ld=lld' else: CROSS_TOOLCHAIN_ROOT = x.get_cross_toolchain_dir(state.target_plat) state.target_arch = _tuple[2] state.target_info = _tuple[3] - _target_triple = { + state.llvm_triple = { 'arm64': f'aarch64-unknown-linux-{state.target_info}', 'amd64': f'x86_64-pc-linux-{state.target_info}', 'armv7': f'arm-unknown-linux-{state.target_info}', }[state.target_arch] - _sysroot = (Path(CROSS_TOOLCHAIN_ROOT) / _target_triple).absolute().resolve().as_posix() + _sysroot = (Path(CROSS_TOOLCHAIN_ROOT) / state.llvm_triple).absolute().resolve().as_posix() state.cc.extend([ f'clang', - f'--target={_target_triple}', + f'--target={state.llvm_triple}', f'--gcc-toolchain={_sysroot}/usr', f'--sysroot={_sysroot}' ]) @@ -317,15 +327,16 @@ def _setctx_linux( state.objcopy.extend(['llvm-objcopy']) # pkgconf - state.pkgconf.extend([f'{CROSS_TOOLCHAIN_ROOT}/pkgconf-wrapper.{_target_triple}']) + state.pkgconf.extend([f'{CROSS_TOOLCHAIN_ROOT}/pkgconf-wrapper.{state.llvm_triple}']) # cmake toolchain file - state.extra_cmake.extend(["-D", f"CMAKE_TOOLCHAIN_FILE='{CROSS_TOOLCHAIN_ROOT}/crossfile.cmake.{_target_triple}'"]) + state.extra_cmake.extend(["-D", f"CMAKE_TOOLCHAIN_FILE='{CROSS_TOOLCHAIN_ROOT}/crossfile.cmake.{state.llvm_triple}'"]) # meson toolchain file - state.extra_meson.extend(["--cross-file", f"{CROSS_TOOLCHAIN_ROOT}/crossfile.meson.{_target_triple}"]) + state.extra_meson.extend(["--cross-file", f"{CROSS_TOOLCHAIN_ROOT}/crossfile.meson.{state.llvm_triple}"]) def _setctx_apple( state: _state, _native: "bool", _tuple: "tuple[str, ...]", ): state.target_arch = x.NATIVE_ARCH if _native else _tuple[1] + state.llvm_triple = f'{state.target_arch}-apple-darwin' _apple_arch = { 'arm64': 'arm64', @@ -388,24 +399,24 @@ def _setctx_win32_mingw( state.target_arch = _tuple[1] - _target_triple = { + state.llvm_triple = { 'arm64': f'aarch64-w64-mingw32', 'amd64': f'x86_64-w64-mingw32', }[state.target_arch] state.cc.extend([ - f"{(MINGW_ROOT / 'bin' / f'{_target_triple}-clang').as_posix()}", + f"{(MINGW_ROOT / 'bin' / f'{state.llvm_triple}-clang').as_posix()}", f"-no-canonical-prefixes", ]) if state.target_arch == 'amd64': state.cc.extend(['-march=x86-64-v2']) if state.target_arch == 'arm64': state.cc.extend(['-march=armv8-a']) - state.ar.extend([f"{(MINGW_ROOT / 'bin' / f'{_target_triple}-ar').as_posix()}"]) - state.nm.extend([f"{(MINGW_ROOT / 'bin' / f'{_target_triple}-nm').as_posix()}"]) + state.ar.extend([f"{(MINGW_ROOT / 'bin' / f'{state.llvm_triple}-ar').as_posix()}"]) + state.nm.extend([f"{(MINGW_ROOT / 'bin' / f'{state.llvm_triple}-nm').as_posix()}"]) state.ldflags.extend(['-fuse-ld=lld']) - state.objcopy.extend([f"{(MINGW_ROOT / 'bin' / f'{_target_triple}-objcopy').as_posix()}"]) - state.windres.extend([f"{(MINGW_ROOT / 'bin' / f'{_target_triple}-windres').as_posix()}"]) + state.objcopy.extend([f"{(MINGW_ROOT / 'bin' / f'{state.llvm_triple}-objcopy').as_posix()}"]) + state.windres.extend([f"{(MINGW_ROOT / 'bin' / f'{state.llvm_triple}-windres').as_posix()}"]) # pkgconf state.pkgconf.extend([f'{CROSS_TOOLCHAIN_ROOT}/pkgconf-wrapper.{state.target_arch}']) @@ -422,20 +433,25 @@ def _setctx_win32_msvc( state.win32_msvc_env_native = x.win32_msvc_dump_env(msvc_dir, msvc_devshell, x.NATIVE_ARCH) state.win32_msvc_env_target = x.win32_msvc_dump_env(msvc_dir, msvc_devshell, state.target_arch) - _target_triple = { + state.llvm_triple = { 'arm64': f'aarch64-pc-windows-msvc', 'amd64': f'x86_64-pc-windows-msvc', }[state.target_arch] # cmake toolchain file state.extra_cmake.extend([ - '-G', 'Ninja', - '-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded', + '-G', 'Ninja', + '-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded', "-D", f"CMAKE_C_COMPILER=clang-cl.exe", "-D", f"CMAKE_CXX_COMPILER=clang-cl.exe", - "-D", f"CMAKE_C_COMPILER_TARGET={_target_triple}", - "-D", f"CMAKE_CXX_COMPILER_TARGET={_target_triple}", + "-D", f"CMAKE_C_COMPILER_TARGET={state.llvm_triple}", + "-D", f"CMAKE_CXX_COMPILER_TARGET={state.llvm_triple}", ]) + if not _native: + state.extra_cmake.extend([ + '-D', 'CMAKE_SYSTEM_NAME=Windows', + '-D', 'CMAKE_CROSSCOMPILING:BOOL=TRUE', + ]) def _setctx_android( state: _state, _native: "bool", _tuple: "tuple[str, ...]", ): @@ -460,13 +476,13 @@ def _setctx_android( 'armv7': f'armv7a-linux-androideabi', 'amd64': f'x86_64-linux-android', }[state.target_arch] - _target_triple_ver = f'{_target_triple}{state.android_api_level}' + state.llvm_triple = f'{_target_triple}{state.android_api_level}' ANDROID_NDK_ROOT = x.get_cross_toolchain_dir(state.target_plat) CROSS_TOOLCHAIN_ROOT = (Path(ANDROID_NDK_ROOT) / 'toolchains' / 'llvm' / 'prebuilt' / 'linux-x86_64').absolute() state.cc.extend([ - f"{(CROSS_TOOLCHAIN_ROOT / 'bin' / f'{_target_triple_ver}-clang').as_posix()}", + f"{(CROSS_TOOLCHAIN_ROOT / 'bin' / f'{state.llvm_triple}-clang').as_posix()}", f"-no-canonical-prefixes", ]) if state.target_arch == 'amd64': @@ -506,8 +522,8 @@ def _setctx_android( "-D", f"CMAKE_ANDROID_API_MIN={state.android_api_level}", "-D", f"CMAKE_ANDROID_ARCH_ABI={_cmake_arch_abi}", "-D", f"CMAKE_ANDROID_NDK={ANDROID_NDK_ROOT}", - "-D", f"CMAKE_C_COMPILER_TARGET={_target_triple_ver}", - "-D", f"CMAKE_CXX_COMPILER_TARGET={_target_triple_ver}", + "-D", f"CMAKE_C_COMPILER_TARGET={state.llvm_triple}", + "-D", f"CMAKE_CXX_COMPILER_TARGET={state.llvm_triple}", "-D", f"CMAKE_EXE_LINKER_FLAGS_INIT='{' '.join(flexible_page_ldflags)}'", "-D", f"CMAKE_MODULE_LINKER_FLAGS_INIT='{' '.join(flexible_page_ldflags)}'", "-D", f"CMAKE_SHARED_LINKER_FLAGS_INIT='{' '.join(flexible_page_ldflags)}'", diff --git a/modules/llvm.py b/modules/llvm.py index bd48407..44ff28e 100755 --- a/modules/llvm.py +++ b/modules/llvm.py @@ -1,143 +1,75 @@ -#!/usr/bin/env python3 - # fmt: off -from buildx import utils as x -# ---------------------------- - -import os -import shlex -import shutil - +import sys from pathlib import Path +sys.dont_write_bytecode = True -BUILD_CMD = 'cmake' -BUILD_ENV = os.environ.copy() - -_subproj_src = '' -_subproj_src_patches = '' - -_target_pkg_name = '' -_target_pkg_type = '' -_target_platform = '' -_target_arch = '' -_target_archlibc = '' - -_3rd_deps_dir = '' -_pkg_buld_dir = '' -_pkg_inst_dir = '' - -_cross_build_enabled = False -_cross_target_triple = '' -_extra_sysroot = '' -_extra_args_build: list[str] = [] -_extra_search_dir: list[str] = [] - -_host_cc = '' -_host_cxx = '' - -_win32_msvc_env_native: dict[str, str] = {} - -def module_init(env: dict) -> list: - global _target_pkg_name; \ - _target_pkg_name = env['PKG_NAME'] - global _target_pkg_type; \ - _target_pkg_type = env['PKG_TYPE'] - global _subproj_src; \ - _subproj_src = env['SUBPROJ_SRC'] - global _subproj_src_patches; \ - _subproj_src_patches = env['SUBPROJ_SRC_PATCHES'] - global _target_platform; \ - _target_platform = env['PKG_PLATFORM'] - global _target_arch; \ - _target_arch = env['PKG_ARCH'] - global _target_archlibc; \ - _target_archlibc = env['PKG_ARCH_LIBC'] - global _3rd_deps_dir; \ - _3rd_deps_dir = env['3RD_DEPS_DIR'] - global _pkg_buld_dir; \ - _pkg_buld_dir = env['PKG_BULD_DIR'] - global _pkg_inst_dir; \ - _pkg_inst_dir = env['PKG_INST_DIR'] - global _cross_build_enabled; \ - _cross_build_enabled = env['CROSS_BUILD_ENABLED'] - global _cross_target_triple; \ - _cross_target_triple = env['CROSS_TARGET_TRIPLE'] - global _extra_sysroot; \ - _extra_sysroot = env['SYSROOT'] - global _extra_args_build; \ - _extra_args_build = env[f'EXTRA_{BUILD_CMD.upper()}'] - global _host_cc; \ - _host_cc = env['HOSTCC'] - global _host_cxx; \ - _host_cxx = env['HOSTCXX'] - global _win32_msvc_env_native; \ - _win32_msvc_env_native = env['WIN32_MSVC_ENV_NATIVE'] - - if _target_pkg_type != 'static': - raise NotImplementedError(f'unsupported PKG_TYPE: {_target_pkg_type}') - - - global BUILD_ENV - - if _target_platform == 'android': - BUILD_ENV['ANDROID_API_LEVEL'] = env['ANDROID_API_LEVEL'] - if _target_platform == 'win-msvc': - BUILD_ENV = env['WIN32_MSVC_ENV_TARGET'] - BUILD_ENV['CFLAGS'] = '/utf-8' - BUILD_ENV['CXXFLAGS'] = BUILD_ENV['CFLAGS'] - _extra_args_build.extend(['-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded']) - if _target_platform != 'win-msvc': - x._util_func__pip_install(['ninja']) - _extra_args_build.extend(['-G', 'Ninja']) +_this_file = (Path(__file__).absolute().resolve()) +sys.path.append( + (_this_file.parents[1]).as_posix() +); import x_utils as x +if __name__ == "__main__": x.loge_usage() +# ---------------------------- +from typing import Callable, cast +from build_v2 import BuildCtx +ctx = cast(BuildCtx, globals()["ctx"]) +# ---------------------------- +def build_steps() -> "list[Callable[[], None]]": return [ - _source_dl_3rd_deps, - _source_download, - _build_step_00, - _build_step_01, - _build_step_02, + _3rd_included, + _fetch_source, + _build_step_0, + _build_step_1, + _build_step_2, ] +# ---------------------------- +def get_build_env( + win32_msvc_env: "dict[str, str] | None" = None +) -> "dict[str, str]": + env = x.ENVIRON + if ctx.args.target_plat == 'win-msvc': + if not win32_msvc_env: + win32_msvc_env = ctx.args.win32_msvc_env_target + env.update(win32_msvc_env) + env['CFLAGS'] = '/utf-8' + env['CXXFLAGS'] = env['CFLAGS'] + return env +# ---------------------------- +extra_search_dir: "list[str]" = [] +# ---------------------------- +def _3rd_included(): + from build_v2 import DependencySpec - - -def _source_dl_3rd_deps(): - _3rd_deps: list[dict[str, str]] = [] - if _target_platform not in ['macosx', 'iphoneos', 'iphonesimulator']: + _3rd_deps: list[DependencySpec] = [] + if ctx.args.target_plat not in {'macosx', 'iphoneos', 'iphonesimulator'}: _3rd_deps.extend([ { 'name': 'zlib-ng', 'type': 'static', 'vers': '1273109', + 'args': '', }, ]) for dep in _3rd_deps: - _name = dep['name']; _type = dep['type']; _vers = dep['vers'] - x._util_func__dl_3rd_deps([_target_archlibc, _name, _target_platform, _vers, _type, '', _3rd_deps_dir]) - - _extra_search_dir.append((Path(_3rd_deps_dir) / _name).absolute().as_posix()) -def _source_download(): - _git_target = 'refs/heads/main' - if not (Path(_subproj_src) / '.git').exists(): - x._util_func__subprocess(cwd=_subproj_src, args=['git', 'init']) - x._util_func__subprocess(cwd=_subproj_src, args=['git', 'remote', 'add', 'x', 'https://github.com/llvm/llvm-project.git']) - x._util_func__subprocess(cwd=_subproj_src, args=['git', 'fetch', '-q', '--no-tags', '--prune', '--no-recurse-submodules', '--depth=1', 'x', f'+{_git_target}']) - x._util_func__subprocess(cwd=_subproj_src, args=['git', 'checkout', 'FETCH_HEAD']) - x._util_put_pkg_version_desc(_target_pkg_name, x._util_func__subprocess(cwd=_subproj_src, collect_stdout=True, args=['git', 'describe', '--always', '--abbrev=7'])) - x._util_source_apply_patches(_subproj_src, _subproj_src_patches) -def _build_step_00(): - _tblgen_dir = (Path(_pkg_inst_dir).parent / '.NATIVE').absolute().as_posix() - _tblgen_req = ((_target_platform == 'win-msvc') and (_cross_build_enabled)) - - _cmake_search_dir = ';'.join(_extra_search_dir) - args = [BUILD_CMD, *_extra_args_build, - '-S', (Path(_subproj_src) / 'llvm').absolute().as_posix(), + dep_path = ctx.include_3rd_dependencies(dep) + extra_search_dir.append(dep_path.as_posix()) +def _fetch_source(): + ctx.fetch_source_from_git('refs/heads/main', 'https://github.com/llvm/llvm-project.git') +def _build_step_0(): + # always build from source code + _tblgen_dir = (Path(x.PROJ_ROOT) / 'tmp' / 'llvm.NATIVE') + + _cmake_search_dir = ';'.join(extra_search_dir) + args = [ + 'cmake', *(ctx.args.extra_cmake), + '-S', ctx.subproj_src_dir('llvm').as_posix(), '-D', 'LLVM_BUILD_LLVM_DYLIB:BOOL=0', '-D', 'CMAKE_BUILD_TYPE=Release', '-D', f'CMAKE_PREFIX_PATH={_cmake_search_dir}', - '-D', f'CMAKE_FIND_ROOT_PATH={_extra_sysroot};{_cmake_search_dir}', + '-D', f'CMAKE_FIND_ROOT_PATH={_cmake_search_dir}', '-D', 'LLVM_ENABLE_PROJECTS=clang;clang-tools-extra;lldb', '-D', 'CLANG_PLUGIN_SUPPORT:BOOL=0', '-D', 'LLVM_APPEND_VC_REV:BOOL=0', @@ -155,17 +87,16 @@ def _build_step_00(): '-D', 'LLDB_ENABLE_LUA:BOOL=0', '-D', 'LLDB_ENABLE_PYTHON:BOOL=0', '-D', 'LLDB_ENABLE_LIBXML2:BOOL=0', - '-D', 'LLDB_ENABLE_FBSDVMCORE:BOOL=0', '-D', 'LLVM_TARGETS_TO_BUILD=AArch64;ARM;RISCV;WebAssembly;X86', '-D', 'LLDB_USE_SYSTEM_DEBUGSERVER:BOOL=1', - '-D', f'LLVM_NATIVE_TOOL_DIR={(Path(_tblgen_dir) / "bin").absolute().as_posix()}', + '-D', f'LLVM_NATIVE_TOOL_DIR={(_tblgen_dir / "bin").as_posix()}', ] + if ctx.args.target_plat != 'win-msvc': + x.runpy_pip(['ninja']) + args.extend(['-G', 'Ninja']) - if _tblgen_req: - shutil.rmtree(_tblgen_dir, ignore_errors=True); \ - os.makedirs(_tblgen_dir, exist_ok=True) - - _tblgen_build_args = [*args] + if not _tblgen_dir.exists(): + _tblgen_build_args: list[str] = [*args] _tblgen_build_args_bdir_idx = 0 _tblgen_build_args_zlib_idx = 0 for i, entry in enumerate(_tblgen_build_args): @@ -173,99 +104,98 @@ def _build_step_00(): _tblgen_build_args_bdir_idx = i + 1 if entry.startswith('LLVM_ENABLE_ZLIB'): _tblgen_build_args_zlib_idx = i - _tblgen_build_args[_tblgen_build_args_bdir_idx] = _tblgen_dir + _tblgen_build_args[_tblgen_build_args_bdir_idx] = _tblgen_dir.as_posix() _tblgen_build_args[_tblgen_build_args_zlib_idx] = 'LLVM_ENABLE_ZLIB=OFF' - - _tblgen_build_env = _win32_msvc_env_native - _tblgen_build_env['CFLAGS'] = '/utf-8' - _tblgen_build_env['CXXFLAGS'] = _tblgen_build_env['CFLAGS'] - x._util_func__subprocess(env=_tblgen_build_env, args=_tblgen_build_args) + x.run_as_subprocess(env=get_build_env(ctx.args.win32_msvc_env_native), + args=_tblgen_build_args) _tblgen_build_targets = ['llvm-tblgen', 'clang-tblgen', 'lldb-tblgen', 'clang-tidy-confusable-chars-gen'] - _tblgen_build_args = f"{BUILD_CMD} --build {_tblgen_dir} -j {x.CPU_COUNT} --target {';'.join(_tblgen_build_targets)}" - x._util_func__subprocess(env=_tblgen_build_env, args=shlex.split(_tblgen_build_args)) - + x.run_as_subprocess(env=get_build_env(ctx.args.win32_msvc_env_native), + args=['cmake', '--build', _tblgen_dir.as_posix(), '-j', f'{x.detect_cpu_count()}', '--target', ';'.join(_tblgen_build_targets)]) LLVM_ARCH = { 'amd64': 'X86', 'arm64': 'AArch64', 'armv7': 'ARM', - }[_target_arch] - args.extend([ - '-D', f'LLVM_TARGET_ARCH={LLVM_ARCH}', - '-D', f'CMAKE_C_HOST_COMPILER={_host_cc}', - '-D', f'CMAKE_CXX_HOST_COMPILER={_host_cxx}', - ]) - if _target_platform == 'macosx': - args.extend([ - '-D', f'LLVM_HOST_TRIPLE={_target_arch}-apple-darwin', - ]) - if _target_platform == 'linux' and _cross_build_enabled: - args.extend([ - '-D', f'LLVM_HOST_TRIPLE={_cross_target_triple}', - ]) - if _target_platform == 'win-mingw': + }[ctx.args.target_arch] + args.extend(['-D', f'LLVM_TARGET_ARCH={LLVM_ARCH}']) + + if ctx.args.target_plat != 'win-msvc': args.extend([ - '-D', f'LLVM_HOST_TRIPLE={_cross_target_triple}', + '-D', f'CMAKE_C_HOST_COMPILER="clang"', + '-D', f'CMAKE_CXX_HOST_COMPILER="clang;--driver-mode=g++"', ]) - if _target_platform == 'win-msvc': + else: args.extend([ - '-D', 'CMAKE_SYSTEM_NAME=Windows', - '-D', 'CMAKE_CROSSCOMPILING:BOOL=TRUE', - '-D', f'LLVM_HOST_TRIPLE={_cross_target_triple}', + '-D', f'CMAKE_C_HOST_COMPILER="clang-cl.exe"', + '-D', f'CMAKE_CXX_HOST_COMPILER="clang-cl.exe"', ]) - x._util_func__subprocess(env=BUILD_ENV, args=args) -def _build_step_01(): + if ctx.args.llvm_triple: + args.extend(['-D', f'LLVM_HOST_TRIPLE={ctx.args.llvm_triple}']) + + x.run_as_subprocess(env=get_build_env(), args=args) +def _build_step_1(): _build_targets = ['clangd', 'llvm-symbolizer', 'lldb', 'lldb-dap', 'lldb-instr'] - if _target_platform == 'linux': + if ctx.args.target_plat == 'linux': _build_targets.append('lldbIntelFeatures') - if _target_platform != 'macosx': + if ctx.args.target_plat != 'macosx': _build_targets.append('lldb-server') - - args = f"{BUILD_CMD} --build {_pkg_buld_dir} -j {x.CPU_COUNT} --target {';'.join(_build_targets)}" - x._util_func__subprocess(env=BUILD_ENV, args=shlex.split(args)) -def _build_step_02(): - _install_targets = { - (Path(_pkg_buld_dir) / 'tools').absolute().as_posix(): [ + x.run_as_subprocess(env=get_build_env(ctx.args.win32_msvc_env_native), + args=['cmake', '--build', ctx.args.pkg_buld_dir, '-j', f'{x.detect_cpu_count()}', '--target', ';'.join(_build_targets)]) +def _build_step_2(): + _targets_mapping: dict[Path, list[str]] + _install_targets: dict[Path, list[str]] = { + (Path(ctx.args.pkg_buld_dir) / 'tools'): [ 'llvm-symbolizer', ], - (Path(_pkg_buld_dir) / 'tools' / 'lldb' / 'tools').absolute().as_posix(): [ + (Path(ctx.args.pkg_buld_dir) / 'tools' / 'lldb' / 'tools'): [ 'lldb', 'lldb-argdumper', 'lldb-dap', 'lldb-instr', ], - (Path(_pkg_buld_dir) / 'tools' / 'lldb').absolute().as_posix(): [ + (Path(ctx.args.pkg_buld_dir) / 'tools' / 'lldb'): [ 'liblldb', ], - (Path(_pkg_buld_dir) / 'tools' / 'clang').absolute().as_posix(): [ + (Path(ctx.args.pkg_buld_dir) / 'tools' / 'clang'): [ 'clangd', 'clang-resource-headers', ], } - if _target_platform == 'linux': - _install_targets[(Path(_pkg_buld_dir) / 'tools' / 'lldb' / 'tools').absolute().as_posix()].extend([ - 'lldbIntelFeatures', - ]) - if _target_platform != 'macosx': - _install_targets[(Path(_pkg_buld_dir) / 'tools' / 'lldb' / 'tools').absolute().as_posix()].extend([ - 'lldb-server', - ]) + if ctx.args.target_plat == 'linux': + _targets_mapping = { + (Path(ctx.args.pkg_buld_dir) / 'tools' / 'lldb' / 'tools'): [ + 'lldbIntelFeatures', + ] + } + for k, v in _targets_mapping.items(): + _targets = _install_targets.get(k) or [] + _targets.extend(v) + _install_targets[k] = _targets + if ctx.args.target_plat != 'macosx': + _targets_mapping = { + (Path(ctx.args.pkg_buld_dir) / 'tools' / 'lldb' / 'tools'): [ + 'lldb-server', + ] + } + for k, v in _targets_mapping.items(): + _targets = _install_targets.get(k) or [] + _targets.extend(v) + _install_targets[k] = _targets for _dir, _targets in _install_targets.items(): for _target in _targets: - x._util_func__subprocess(env=BUILD_ENV, args=[ - BUILD_CMD, '--install', _dir, '--component', _target, '--strip' - ]) - if _target_platform == 'macosx': - _src = '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver' - (Path(_pkg_inst_dir) / 'bin' / 'lldb-server').symlink_to(_src, target_is_directory=False) + x.run_as_subprocess(env=get_build_env(), + args=['cmake', '--install', _dir.absolute().as_posix(), '--component', _target, '--strip']) + if ctx.args.target_plat == 'macosx': + src = '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver' + (Path(ctx.args.pkg_inst_dir) / 'bin' / 'lldb-server').symlink_to(src, target_is_directory=False) - if _target_platform in ['win-msvc', 'win-mingw']: + if ctx.args.target_plat in {'win-msvc', 'win-mingw'}: _libname = { 'win-msvc': 'liblldb.lib', 'win-mingw': 'liblldb.dll.a', - }[_target_platform] - (Path(_pkg_inst_dir) / 'lib' / _libname).unlink(missing_ok=True) + }[ctx.args.target_plat] + (Path(ctx.args.pkg_inst_dir) / 'lib' / _libname).unlink(missing_ok=True) From 2e9fd074bd69f9f1e7cb3805f02967687d5020e3 Mon Sep 17 00:00:00 2001 From: valord577 Date: Thu, 9 Jul 2026 21:29:59 +0800 Subject: [PATCH 3/7] refactory: strongly-typed python project --- .github/workflows/llvm.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/llvm.yml b/.github/workflows/llvm.yml index b5017c0..3fdf9da 100644 --- a/.github/workflows/llvm.yml +++ b/.github/workflows/llvm.yml @@ -1,13 +1,22 @@ name: llvm on: workflow_dispatch: + pull_request: + branches: + - main + paths: + - '.github/matrix*.json' + - '.github/workflows/_matrix.yml' + - '.github/workflows/llvm.yml' + - 'patches/llvm/**' + - 'modules/llvm.py' + - 'build_v2.py' jobs: build: - if: ${{ false }} + # if: ${{ false }} secrets: inherit uses: ./.github/workflows/_matrix.yml with: - disable_commit: true - disable_ccache_on_container: false + disable_shared: true select_platforms: "macosx, linux, win-mingw, win-msvc" From 0e74c546306a8ae7db03788408134f8c826610cc Mon Sep 17 00:00:00 2001 From: valord577 Date: Thu, 9 Jul 2026 22:31:03 +0800 Subject: [PATCH 4/7] refactory: strongly-typed python project --- build_v2.py | 4 +- modules/llvm.py | 8 ++-- patches/zlib-ng/03_github_pr_2274.patch | 64 +++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 patches/zlib-ng/03_github_pr_2274.patch diff --git a/build_v2.py b/build_v2.py index 8431668..62c1293 100755 --- a/build_v2.py +++ b/build_v2.py @@ -442,8 +442,8 @@ def _setctx_win32_msvc( state.extra_cmake.extend([ '-G', 'Ninja', '-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded', - "-D", f"CMAKE_C_COMPILER=clang-cl.exe", - "-D", f"CMAKE_CXX_COMPILER=clang-cl.exe", + "-D", f"CMAKE_C_COMPILER='clang.exe;--driver-mode=cl'", + "-D", f"CMAKE_CXX_COMPILER='clang.exe;--driver-mode=cl'", "-D", f"CMAKE_C_COMPILER_TARGET={state.llvm_triple}", "-D", f"CMAKE_CXX_COMPILER_TARGET={state.llvm_triple}", ]) diff --git a/modules/llvm.py b/modules/llvm.py index 44ff28e..c2692d1 100755 --- a/modules/llvm.py +++ b/modules/llvm.py @@ -59,8 +59,8 @@ def _3rd_included(): def _fetch_source(): ctx.fetch_source_from_git('refs/heads/main', 'https://github.com/llvm/llvm-project.git') def _build_step_0(): - # always build from source code _tblgen_dir = (Path(x.PROJ_ROOT) / 'tmp' / 'llvm.NATIVE') + _tblgen_req = ((ctx.args.target_plat == 'win-msvc') and (ctx.args.target_plat != x.NATIVE_ARCH)) _cmake_search_dir = ';'.join(extra_search_dir) args = [ @@ -95,7 +95,7 @@ def _build_step_0(): x.runpy_pip(['ninja']) args.extend(['-G', 'Ninja']) - if not _tblgen_dir.exists(): + if _tblgen_req and (not _tblgen_dir.exists()): _tblgen_build_args: list[str] = [*args] _tblgen_build_args_bdir_idx = 0 _tblgen_build_args_zlib_idx = 0 @@ -127,8 +127,8 @@ def _build_step_0(): ]) else: args.extend([ - '-D', f'CMAKE_C_HOST_COMPILER="clang-cl.exe"', - '-D', f'CMAKE_CXX_HOST_COMPILER="clang-cl.exe"', + '-D', f'CMAKE_C_HOST_COMPILER="clang.exe;--driver-mode=cl"', + '-D', f'CMAKE_CXX_HOST_COMPILER="clang.exe;--driver-mode=cl"', ]) if ctx.args.llvm_triple: diff --git a/patches/zlib-ng/03_github_pr_2274.patch b/patches/zlib-ng/03_github_pr_2274.patch new file mode 100644 index 0000000..ee8dcdb --- /dev/null +++ b/patches/zlib-ng/03_github_pr_2274.patch @@ -0,0 +1,64 @@ +diff --git a/arch/arm/acle_intrins.h b/arch/arm/acle_intrins.h +index 8335c9c..9e417ab 100644 +--- a/arch/arm/acle_intrins.h ++++ b/arch/arm/acle_intrins.h +@@ -2,7 +2,7 @@ + #define ARM_ACLE_INTRINS_H + + #include +-#ifdef _MSC_VER ++#if defined(_MSC_VER) && !defined(__clang__) + # include + #elif defined(HAVE_ARM_ACLE_H) + # include +diff --git a/arch/arm/neon_intrins.h b/arch/arm/neon_intrins.h +index a24887c..89daf77 100644 +--- a/arch/arm/neon_intrins.h ++++ b/arch/arm/neon_intrins.h +@@ -1,7 +1,7 @@ + #ifndef ARM_NEON_INTRINS_H + #define ARM_NEON_INTRINS_H + +-#if defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC)) ++#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_ARM64) || defined(_M_ARM64EC)) + /* arm64_neon.h is MSVC specific */ + # include + #else +diff --git a/cmake/detect-intrinsics.cmake b/cmake/detect-intrinsics.cmake +index 31a049d..e777460 100644 +--- a/cmake/detect-intrinsics.cmake ++++ b/cmake/detect-intrinsics.cmake +@@ -42,7 +42,7 @@ macro(check_armv8_compiler_flag) + ) + # Check whether compiler supports ARMv8 intrinsics + check_c_source_compiles( +- "#if defined(_MSC_VER) ++ "#if defined(_MSC_VER) && !defined(__clang__) + #include + #else + #include +@@ -83,13 +83,13 @@ macro(check_armv6_compiler_flag) + ) + # Check whether compiler supports ARMv6 intrinsics + check_c_source_compiles( +- "#if defined(_MSC_VER) ++ "#if defined(_MSC_VER) && !defined(__clang__) + #include + #else + #include + #endif + unsigned int f(unsigned int a, unsigned int b) { +- #if defined(_MSC_VER) ++ #if defined(_MSC_VER) && !defined(__clang__) + return _arm_uqsub16(a, b); + #else + return __uqsub16(a, b); +@@ -285,7 +285,7 @@ macro(check_neon_ld4_intrinsics) + # Check whether compiler supports loading 4 neon vecs into a register range + set(CMAKE_REQUIRED_FLAGS "${NEONFLAG} ${NATIVEFLAG} ${ZNOLTOFLAG}") + check_c_source_compiles( +- "#if defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC)) ++ "#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_ARM64) || defined(_M_ARM64EC)) + # include + #else + # include From 792e9538847904d850d6ecd0d97ac48d0f2ecd0a Mon Sep 17 00:00:00 2001 From: valord577 Date: Thu, 9 Jul 2026 22:39:55 +0800 Subject: [PATCH 5/7] refactory: strongly-typed python project --- build_v2.py | 4 ++-- modules/llvm.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build_v2.py b/build_v2.py index 62c1293..af4311f 100755 --- a/build_v2.py +++ b/build_v2.py @@ -442,8 +442,8 @@ def _setctx_win32_msvc( state.extra_cmake.extend([ '-G', 'Ninja', '-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded', - "-D", f"CMAKE_C_COMPILER='clang.exe;--driver-mode=cl'", - "-D", f"CMAKE_CXX_COMPILER='clang.exe;--driver-mode=cl'", + "-D", f"CMAKE_C_COMPILER='clang-cl.exe'", + "-D", f"CMAKE_CXX_COMPILER='clang-cl.exe'", "-D", f"CMAKE_C_COMPILER_TARGET={state.llvm_triple}", "-D", f"CMAKE_CXX_COMPILER_TARGET={state.llvm_triple}", ]) diff --git a/modules/llvm.py b/modules/llvm.py index c2692d1..08f8f00 100755 --- a/modules/llvm.py +++ b/modules/llvm.py @@ -127,8 +127,8 @@ def _build_step_0(): ]) else: args.extend([ - '-D', f'CMAKE_C_HOST_COMPILER="clang.exe;--driver-mode=cl"', - '-D', f'CMAKE_CXX_HOST_COMPILER="clang.exe;--driver-mode=cl"', + '-D', f'CMAKE_C_HOST_COMPILER="clang-cl.exe"', + '-D', f'CMAKE_CXX_HOST_COMPILER="clang-cl.exe"', ]) if ctx.args.llvm_triple: From 7caedbc12ec2ef8824db7cd646e9f64cea22b8a3 Mon Sep 17 00:00:00 2001 From: valord577 Date: Thu, 9 Jul 2026 22:43:36 +0800 Subject: [PATCH 6/7] refactory: strongly-typed python project --- modules/llvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/llvm.py b/modules/llvm.py index 08f8f00..e177af3 100755 --- a/modules/llvm.py +++ b/modules/llvm.py @@ -123,7 +123,7 @@ def _build_step_0(): if ctx.args.target_plat != 'win-msvc': args.extend([ '-D', f'CMAKE_C_HOST_COMPILER="clang"', - '-D', f'CMAKE_CXX_HOST_COMPILER="clang;--driver-mode=g++"', + '-D', f'CMAKE_CXX_HOST_COMPILER="clang++"', ]) else: args.extend([ From a74c9e5e5041bdc9e9f9f7482c94de4197cedcd5 Mon Sep 17 00:00:00 2001 From: valord577 Date: Thu, 9 Jul 2026 23:29:55 +0800 Subject: [PATCH 7/7] refactory: strongly-typed python project --- .github/workflows/dav1d.yml | 2 -- .github/workflows/ffmpeg.yml | 1 - .github/workflows/llvm.yml | 1 - .github/workflows/mbedtls3.yml | 2 -- .github/workflows/mbedtls4.yml | 2 -- .github/workflows/sdl2.yml | 2 -- .github/workflows/zlib-ng.yml | 2 -- build_v2.py | 2 ++ modules/llvm.py | 2 +- x_utils.py | 2 ++ 10 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/dav1d.yml b/.github/workflows/dav1d.yml index 726902a..a6b098c 100644 --- a/.github/workflows/dav1d.yml +++ b/.github/workflows/dav1d.yml @@ -10,7 +10,6 @@ on: - '.github/workflows/dav1d.yml' - 'patches/dav1d/**' - 'modules/dav1d.py' - - 'build_v2.py' pull_request: branches: - main @@ -20,7 +19,6 @@ on: - '.github/workflows/dav1d.yml' - 'patches/dav1d/**' - 'modules/dav1d.py' - - 'build_v2.py' jobs: build: diff --git a/.github/workflows/ffmpeg.yml b/.github/workflows/ffmpeg.yml index 0e4a9f2..605d935 100644 --- a/.github/workflows/ffmpeg.yml +++ b/.github/workflows/ffmpeg.yml @@ -10,7 +10,6 @@ on: - '.github/workflows/ffmpeg.yml' - 'patches/ffmpeg/**' - 'modules/ffmpeg.py' - - 'build_v2.py' jobs: build: diff --git a/.github/workflows/llvm.yml b/.github/workflows/llvm.yml index 3fdf9da..99695da 100644 --- a/.github/workflows/llvm.yml +++ b/.github/workflows/llvm.yml @@ -10,7 +10,6 @@ on: - '.github/workflows/llvm.yml' - 'patches/llvm/**' - 'modules/llvm.py' - - 'build_v2.py' jobs: build: diff --git a/.github/workflows/mbedtls3.yml b/.github/workflows/mbedtls3.yml index 8b30797..a608c8d 100644 --- a/.github/workflows/mbedtls3.yml +++ b/.github/workflows/mbedtls3.yml @@ -10,7 +10,6 @@ on: - '.github/workflows/mbedtls3.yml' - 'patches/mbedtls3/**' - 'modules/mbedtls3.py' - - 'build_v2.py' pull_request: branches: - main @@ -20,7 +19,6 @@ on: - '.github/workflows/mbedtls3.yml' - 'patches/mbedtls3/**' - 'modules/mbedtls3.py' - - 'build_v2.py' jobs: build: diff --git a/.github/workflows/mbedtls4.yml b/.github/workflows/mbedtls4.yml index b71547a..ba0de04 100644 --- a/.github/workflows/mbedtls4.yml +++ b/.github/workflows/mbedtls4.yml @@ -10,7 +10,6 @@ on: - '.github/workflows/mbedtls4.yml' - 'patches/mbedtls4/**' - 'modules/mbedtls4.py' - - 'build_v2.py' pull_request: branches: - main @@ -20,7 +19,6 @@ on: - '.github/workflows/mbedtls4.yml' - 'patches/mbedtls4/**' - 'modules/mbedtls4.py' - - 'build_v2.py' jobs: build: diff --git a/.github/workflows/sdl2.yml b/.github/workflows/sdl2.yml index 52d4b0c..a7c4c44 100644 --- a/.github/workflows/sdl2.yml +++ b/.github/workflows/sdl2.yml @@ -10,7 +10,6 @@ on: - '.github/workflows/sdl2.yml' - 'patches/sdl2/**' - 'modules/sdl2.py' - - 'build_v2.py' pull_request: branches: - main @@ -20,7 +19,6 @@ on: - '.github/workflows/sdl2.yml' - 'patches/sdl2/**' - 'modules/sdl2.py' - - 'build_v2.py' jobs: build: diff --git a/.github/workflows/zlib-ng.yml b/.github/workflows/zlib-ng.yml index 9996db4..794f7d1 100644 --- a/.github/workflows/zlib-ng.yml +++ b/.github/workflows/zlib-ng.yml @@ -10,7 +10,6 @@ on: - '.github/workflows/zlib-ng.yml' - 'patches/zlib-ng/**' - 'modules/zlib-ng.py' - - 'build_v2.py' pull_request: branches: - main @@ -20,7 +19,6 @@ on: - '.github/workflows/zlib-ng.yml' - 'patches/zlib-ng/**' - 'modules/zlib-ng.py' - - 'build_v2.py' jobs: build: diff --git a/build_v2.py b/build_v2.py index af4311f..4744291 100755 --- a/build_v2.py +++ b/build_v2.py @@ -681,6 +681,8 @@ def show_help(exitcode: int = 1): target_palt = x.NATIVE_PLAT + if target_palt == 'windows': + target_palt = 'win-msvc' if len(argv_sep_0) > 0: target_palt = argv_sep_0[0] diff --git a/modules/llvm.py b/modules/llvm.py index e177af3..51b90d3 100755 --- a/modules/llvm.py +++ b/modules/llvm.py @@ -60,7 +60,7 @@ def _fetch_source(): ctx.fetch_source_from_git('refs/heads/main', 'https://github.com/llvm/llvm-project.git') def _build_step_0(): _tblgen_dir = (Path(x.PROJ_ROOT) / 'tmp' / 'llvm.NATIVE') - _tblgen_req = ((ctx.args.target_plat == 'win-msvc') and (ctx.args.target_plat != x.NATIVE_ARCH)) + _tblgen_req = ((ctx.args.target_plat == 'win-msvc') and (ctx.args.target_arch != x.NATIVE_ARCH)) _cmake_search_dir = ';'.join(extra_search_dir) args = [ diff --git a/x_utils.py b/x_utils.py index 6939bfa..18c3315 100644 --- a/x_utils.py +++ b/x_utils.py @@ -160,6 +160,8 @@ def run_as_subprocess(args: "str | list[str]", stdout = sp.PIPE if not env: env = ENVIRON + if (NATIVE_PLAT == 'windows') and (ON_CODE_EDIT): + shell = True proc = sp.run(args=args, cwd=cwd, env=env, check=True, shell=shell, stdout=stdout, text=True,) return proc.stdout if collect_stdout else None