sharelib 输出逻辑完善

Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
2022-02-15 14:08:09 +08:00
parent 0209016824
commit 36da572a87
2 changed files with 57 additions and 13 deletions

View File

@@ -24,6 +24,28 @@ Return('group')
'''
SharelibMainSconscript = '''
# for package compiling
import os
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
CPPPATH = [cwd]
Import('SHARE_LIB_HANDLE')
for d in list:
if SHARE_LIB_HANDLE.is_this_lib(d):
continue
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
Return('objs')
'''
class SharelibItem:
'''
share lib handler
@@ -117,13 +139,10 @@ class SharelibHandler:
kcfg.close()
def __gen_ports(self, share_lib_path):
if self._lib_name != "rt-thread":
return False
import json
init_c_path = os.path.join(os.getcwd(), "gen_ports/gen_ports_c.c")
init_cpp_path = os.path.join(os.getcwd(), "gen_ports/gen_ports_cpp.cpp")
init_c_path = os.path.join(os.getcwd(), "gen_ports", "gen_ports_c.c")
init_cpp_path = os.path.join(os.getcwd(), "gen_ports", "gen_ports_cpp.cpp")
finit_c = open(init_c_path, 'w+')
finit_cpp = open(init_cpp_path, 'w+')
@@ -175,12 +194,22 @@ class SharelibHandler:
finit_c.close()
finit_cpp.close()
def __init_sconscipt(self, share_lib_path):
def export(self, share_lib_path):
port_file = os.path.join(share_lib_path, "SConscript")
if os.path.isfile(port_file):
return False
with open(port_file, 'w+') as pf:
pf.write(SharelibMainSconscript)
def export(self, share_lib_path, gen_ports = False):
reserved_subdir = ['.git',
'README.md', '.gitignore', '.gitmodules', '.gitattributes',
'.drone.yml']
self.__init_sconscipt(share_lib_path)
dist_path = share_lib_path + '/' + self._lib_name
if os.path.exists(dist_path):
for d in os.listdir(dist_path):
@@ -239,7 +268,8 @@ class SharelibHandler:
with open(dist_path + '/package.json','w+') as f:
json.dump(data,f, sort_keys=True, indent=4, separators=(',', ': '))
self.__gen_ports(share_lib_path)
if gen_ports:
self.__gen_ports(share_lib_path)
self.update_sharelib(share_lib_path)