from building import *import osimport zipfileuser_libraries_root_path = GetCurrentDir()inc = [user_libraries_root_path]src = Glob('*.c') + Glob('*.cpp')# scripts_path = os.path.join(user_libraries_root_path, '..', '..', 'scripts')# sys.path.append(scripts_path)# run ALM script# alm_path = os.path.join(scripts_path, 'ALM')# sys.path.append(alm_path)# from ALM_CMD import ALM_Init# ALM_Init(alm_path)def rtduino_scons_add_library(library_root_path):global src, inclibrary_root_path = os.path.abspath(library_root_path)# Arduino libraries must have the 'library.properties' file.# If this folder contains SConscript, just follow the SConscript rule rather than the Arduino rule.if os.path.isdir(library_root_path) == False or \os.path.exists(os.path.join(library_root_path, 'library.properties')) == False or \os.path.exists(os.path.join(library_root_path, 'SConscript')) == True:returnlibrary_src_path = os.path.join(library_root_path, 'src') # Arduino library source code folderlibrary_utility_path = os.path.join(library_root_path, 'utility') # Arduino library utility folder# add all .c/cpp files and header files' path in root folder (not include sub-folders)inc = inc + [library_root_path] # add root folder header files' pathsrc = src + Glob(os.path.join(library_root_path, '*.c')) # add all .c filesrc = src + Glob(os.path.join(library_root_path, '*.cpp')) # add all .cpp file# add root, src and untility folder header files' path (not include sub-folders)if os.path.exists(library_src_path):inc = inc + [library_src_path]src = src + Glob(os.path.join(library_src_path, '*.c'))src = src + Glob(os.path.join(library_src_path, '*.cpp'))if os.path.exists(library_utility_path):inc = inc + [library_utility_path]src = src + Glob(os.path.join(library_utility_path, '*.c'))src = src + Glob(os.path.join(library_utility_path, '*.cpp'))# find the src folder's sub-folders and sub-files recursivelyfor root, dirs, files in os.walk(library_src_path):for dir in dirs: # add all sub-folders' header files' path_sub_path = os.path.join(root,dir) # sub-folder path# add all .c/cpp file and .h/hpp filesrc = src + Glob(os.path.join(_sub_path, '*.c'))src = src + Glob(os.path.join(_sub_path, '*.cpp'))# Unzip all zip files in the root of 'libraries' folderfor file in os.listdir(user_libraries_root_path):if os.path.isfile(file) == True:splitext = os.path.splitext(file)if splitext[1] == '.zip':# unzip the filezFile = zipfile.ZipFile(os.path.join(user_libraries_root_path, file), 'r')for fileM in zFile.namelist():zFile.extract(fileM, '.')zFile.close()os.remove(file) # delete the zip file# Add all user libraries at the root of 'libraries' folder into the groupfor dir in os.listdir(user_libraries_root_path):rtduino_scons_add_library(os.path.join(user_libraries_root_path, dir))# Add all Arduino libraries at the root of 'package' folder into the grouprtthread_packages_root_path = os.path.join(user_libraries_root_path, '..', '..', '..')for dir in os.listdir(rtthread_packages_root_path):rtduino_scons_add_library(os.path.join(rtthread_packages_root_path, dir))group = DefineGroup('RTduino-libraries', src, depend = ['PKG_USING_RTDUINO'], CPPPATH = inc)Return('group')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型