• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3#
4# Copyright (c) 2025 Huawei Device Co., Ltd.
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18import argparse
19import logging
20import shutil
21from pathlib import Path
22from python_builder import MinGWPythonBuilder, BuildConfig
23
24
25def main():
26    parser = argparse.ArgumentParser(description='Python builder command line options')
27    parser.add_argument('--repo-root', default='.', help='Repository root directory')
28    parser.add_argument('--out-path', default='./out', help='Output directory')
29    parser.add_argument('--lldb-py-version', default='3.11.4', help='LLDB Python version')
30    parser.add_argument('--lldb-py-detailed-version', default='3.11.4_20250509', help='LLDB Python detailed version')
31    parser.add_argument('--mingw-triple', default='x86_64-w64-mingw32', help='MinGW triple')
32
33    args = parser.parse_args()
34    build_config = BuildConfig(args)
35
36    # 删除并重新创建 OUT_PATH
37    out_path = Path(build_config.OUT_PATH)
38    if out_path.exists():
39        shutil.rmtree(out_path)
40    out_path.mkdir(parents=True, exist_ok=True)
41
42    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s',
43                        filename=build_config.OUT_PATH + '/build.log')
44
45    try:
46        mingw_builder = MinGWPythonBuilder(build_config)
47        mingw_builder.build()
48        mingw_builder.prepare_for_package()
49        mingw_builder.package()
50        logging.info("MinGW Python 构建、准备和打包完成。")
51    except Exception as e:
52        logging.error(f"MinGW 构建过程中发生错误: {str(e)}")
53
54
55if __name__ == "__main__":
56    main()
57