1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import os
- import sys
- import subprocess
- import shutil
- import re
- import getpass
- import glob
- def build(build_utils, job_n):
- # 设置环境变量
- root_dir = os.environ['TOP_DIR']
- bin_dir = os.environ['OUT_DIR']
- os.environ['ARCH'] = 'arm'
- os.environ['CROSS_COMPILE'] = f'{root_dir}/buildtools/toolchains/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-'
- os.environ["DESTDIR"] = f'{bin_dir}/Lora/sx1302_hal'
- os.environ["OBJDIR"] = f'{bin_dir}/Lora/sx1302_hal'
- # 调用make命令,指定工作目录
- # 注意:subprocess.run在Python 3.5及以上版本中可用
- # 如果你使用的是旧版本的Python,可能需要使用subprocess.call或其他方法
- os.makedirs(f'{bin_dir}/Lora/sx1302_hal/install', exist_ok=True)
- build_utils.replace_value_in_file(f'{root_dir}/Lora/sx1302_hal/target.cfg', "TARGET_DIR", f'{bin_dir}/Lora/sx1302_hal/install')
- build_utils.replace_value_in_file(f'{root_dir}/Lora/sx1302_hal/target.cfg', "TARGET_USR", getpass.getuser())
- subprocess.check_call(['make', f'--directory={root_dir}/Lora/sx1302_hal', f'--jobs={job_n}'])
- def build_install(build_utils):
- root_dir = os.environ['TOP_DIR']
- bin_dir = os.environ['OUT_DIR']
- install_dir = os.environ['INSTALL_DIR']
- job_n = os.environ["JOBS_N"]
- # install test_loragw_*
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/libloragw/test_loragw_*', f'{install_dir}/Lora/sx1302_hal/')
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/tools/reset_lgw.sh', f'{install_dir}/Lora/sx1302_hal/', True)
- # install packet_forwarder
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/packet_forwarder/lora_pkt_fwd', f'{install_dir}/Lora/sx1302_hal/')
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/packet_forwarder/global_conf.json.sx1250.*', f'{install_dir}/Lora/sx1302_hal/', True)
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/packet_forwarder/global_config.json.sx1255.*', f'{install_dir}/Lora/sx1302_hal/', True)
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/packet_forwarder/global_config.json.sx1257.*', f'{install_dir}/Lora/sx1302_hal/', True)
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/util_boot/boot', f'{install_dir}/Lora/sx1302_hal/')
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/util_chip_id/chip_id', f'{install_dir}/Lora/sx1302_hal/')
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/util_net_downlink/net_downlink', f'{install_dir}/Lora/sx1302_hal/')
- build_utils.move_matching_files(f'{root_dir}/Lora/sx1302_hal/util_spectral_scan/spectral_scan', f'{install_dir}/Lora/sx1302_hal/')
|