Lines Matching +full:gcc +full:- +full:mingw +full:- +full:w64
2 # -*- coding: utf-8 -*-
9 # http://www.apache.org/licenses/LICENSE-2.0
32 format='%(asctime)s - %(levelname)s - %(message)s',
66 def __init__(self, build_config) -> None:
77 …self._prebuilts_python_path = os.path.join(self._prebuilts_path, 'python', 'linux-x86', self._lldb…
84 def _logger(self) -> logging.Logger:
88 def _cc(self) -> Path:
92 def _cflags(self) -> List[str]:
96 def _ldflags(self) -> List[str]:
100 def _cxx(self) -> Path:
104 def _strip(self) -> Path:
105 return self._clang_toolchain_dir / 'bin' / 'llvm-strip'
108 def _cxxflags(self) -> List[str]:
112 def _rcflags(self) -> List[str]:
116 def _env(self) -> Mapping[str, str]:
123 'WINDRES': str(clang_bin_dir / 'llvm-windres'),
124 'AR': str(clang_bin_dir / 'llvm-ar'),
125 'READELF': str(clang_bin_dir / 'llvm-readelf'),
127 'DLLTOOL': str(clang_bin_dir / 'llvm-dlltoo'),
128 'RANLIB': str(clang_bin_dir / 'llvm-ranlib'),
135 'LIBS': '-lffi'
139 def _configure(self) -> None:
143 def _clean_patches(self) -> None:
145 run_command(['git', 'reset', '--hard', 'HEAD'], cwd=self._source_dir)
146 run_command(['git', 'clean', '-df', '--exclude=.cid'], cwd=self._source_dir)
148 def _pre_build(self) -> None:
152 def _apply_patches(self) -> None:
168 def _deps_build(self) -> None:
172 def build(self) -> None:
188 def _install(self) -> None:
191 cmd = ['make', f'-j{num_jobs}', 'install']
194 def _strip_in_place(self, file: Path) -> None:
202 def _clean_bin_dir(self) -> None:
216 def _remove_dir(self, dir_path: Path) -> None:
221 def _clean_share_dir(self) -> None:
226 def _clean_lib_dir(self) -> None:
232 def _remove_exclude(self) -> None:
235 f'config-{self._major_version}',
258 def _copy_external_libs(self) -> None:
261 …eps_dir / 'ffi' / 'bin' / 'libffi-8.dll', self._clang_toolchain_dir / self.build_config.MINGW_TRIP…
263 target_dir = self._install_dir / 'lib' / 'python3.11' / 'lib-dynload'
269 # 调用提取的方法拷贝 libffi-8.dll
274 def _copy_file_if_exists(self, src_path: Path, dest_dir: Path) -> None:
287 def _is_elf_file(self, file_path: Path) -> bool:
290 hex_magic_number = binascii.hexlify(magic_numbers).decode('utf-8')
294 def install_dir(self) -> str:
299 def __init__(self, build_config) -> None:
302 self.target_platform = "x86_64-w64-mingw32"
305 … os.path.join(self._prebuilts_path, 'mingw-w64', 'ohos', 'linux-x86_64', 'clang-mingw')).resolve()
307 self._build_dir = self._out_dir / 'python-windows-build'
308 self._install_dir = self._out_dir / 'python-windows-install'
309 self._deps_dir = self._out_dir / 'python-windows-deps'
319 定位 libffi-*.tar.gz 文件,清理输出目录后,将其直接解压到 out/libffi 目录。
325 FileNotFoundError: 若未找到 libffi-*.tar.gz 文件。
328 # 找到 libffi-*.tar.gz 包
329 …libffi_tar_gz_files = glob.glob(str(self.repo_root / 'third_party' / 'libffi' / 'libffi-*.tar.gz'))
331 self._logger.error("No libffi-*.tar.gz file found in third_party/libffi directory.")
332 raise FileNotFoundError("No libffi-*.tar.gz file found.")
342 # 直接解压 libffi-*.tar.gz 到 out/libffi 目录
355 def _cflags(self) -> List[str]:
357 f'-target {self.target_platform}',
358 f'--sysroot={self._mingw_install_dir}',
359 f'-fstack-protector-strong',
360 f'-I{str(self._deps_dir / "ffi" / "include")}',
361 f'-nostdinc',
362 f'-I{str(self._mingw_install_dir / "include")}',
363 f'-I{str(self._clang_toolchain_dir / "lib" / "clang" / "15.0.4" / "include")}'
368 def _ldflags(self) -> List[str]:
370 f'--sysroot={self._mingw_install_dir}',
371 f'-rtlib=compiler-rt',
372 f'-target {self.target_platform}',
373 f'-lucrt',
374 f'-lucrtbase',
375 f'-fuse-ld=lld',
376 f'-L{str(self._deps_dir / "ffi" / "lib")}',
381 def _rcflags(self) -> List[str]:
382 return [f'-I{self._mingw_install_dir}/include']
384 def _deps_build(self) -> None:
385 self._logger.info("Starting MinGW dependency build process...")
391 'CC': "/bin/x86_64-w64-mingw32-gcc",
392 'CXX': "/bin/x86_64-w64-mingw32-g++",
393 'WINDRES': "/bin/x86_64-w64-mingw32-windres",
394 'AR': "/bin/x86_64-w64-mingw32-ar",
395 'READELF': "/bin/x86_64-w64-mingw32-readelf",
396 'LD': "/bin/x86_64-w64-mingw32-ld",
397 'DLLTOOL': "/bin/x86_64-w64-mingw32-dlltool",
398 'RANLIB': "/bin/x86_64-w64-mingw32-gcc-ranlib",
399 'STRIP': "/bin/x86_64-w64-mingw32-strip",
400 'CFLAGS': "--sysroot=/usr/x86_64-w64-mingw32 -fstack-protector-strong",
401 'CXXFLAGS': "--sysroot=/usr/x86_64-w64-mingw32 -fstack-protector-strong",
402 'LDFLAGS': "--sysroot=/usr/x86_64-w64-mingw32",
403 'RCFLAGS': "-I/usr/x86_64-w64-mingw32/include",
404 'CPPFLAGS': "--sysroot=/usr/x86_64-w64-mingw32 -fstack-protector-strong"
409 f"--prefix={self._deps_dir / 'ffi'}",
410 "--enable-shared",
411 "--build=x86_64-pc-linux-gnu",
412 "--host=x86_64-w64-mingw32",
413 "--disable-symvers",
414 "--disable-docs"
418 # 执行 make -j16
419 make_cmd = ['make', '-j16']
426 def _configure(self) -> None:
427 self._logger.info("Starting MinGW configuration...")
428 run_command(['autoreconf', '-vfi'], cwd=self._source_dir)
432 f'--prefix={self._install_dir}',
433 f'--build={build_platform}',
434 f'--host={self.target_platform}',
435 f'--with-build-python={self._prebuilts_python_path}',
436 '--enable-shared',
437 '--without-ensurepip',
438 '--enable-loadable-sqlite-extensions',
439 '--disable-ipv6',
440 '--with-pydebug',
441 '--with-system-ffi'
446 def prepare_for_package(self) -> None:
447 self._logger.info("Preparing MinGW build for packaging...")
454 def package(self) -> None:
455 self._logger.info("Packaging MinGW build...")
456 archive = self._out_dir / f'python-mingw-x86-{self._version}.tar.gz'
462 '-czf',
464 '--exclude=__pycache__',
465 '--transform',
466 f's,^,python/windows-x86/{self._lldb_py_version}/,',