26
building.py
26
building.py
@@ -24,6 +24,7 @@
|
||||
# group definition.
|
||||
#
|
||||
|
||||
from math import fabs
|
||||
import os
|
||||
import sys
|
||||
import string
|
||||
@@ -335,9 +336,12 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||
|
||||
# parse rtconfig.h to get used component
|
||||
PreProcessor = PatchedPreProcessor()
|
||||
f = open(rtt_cfg, 'r')
|
||||
contents = f.read()
|
||||
f.close()
|
||||
contents = ''
|
||||
if os.path.isfile(rtt_cfg):
|
||||
f = open(rtt_cfg, 'r')
|
||||
contents = f.read()
|
||||
f.close()
|
||||
|
||||
PreProcessor.process_contents(contents)
|
||||
BuildOptions = PreProcessor.cpp_namespace
|
||||
|
||||
@@ -725,7 +729,10 @@ def BuildLibInstallAction(target, source, env):
|
||||
do_copy_file(lib_name, dst_name)
|
||||
break
|
||||
|
||||
def DoBuilding(target, objects, is_rtt = False):
|
||||
def DoBuildingLib(lib, objects):
|
||||
DoBuilding(lib, objects, build_lib=True)
|
||||
|
||||
def DoBuilding(target, objects, is_rtt = False, build_lib = False):
|
||||
|
||||
# merge all objects into one list
|
||||
def one_list(l):
|
||||
@@ -757,7 +764,11 @@ def DoBuilding(target, objects, is_rtt = False):
|
||||
|
||||
program = None
|
||||
# check whether special buildlib option
|
||||
lib_name = GetOption('buildlib')
|
||||
if build_lib:
|
||||
lib_name = target
|
||||
else:
|
||||
lib_name = GetOption('buildlib')
|
||||
|
||||
if lib_name:
|
||||
objects = [] # remove all of objects
|
||||
# build library with special component
|
||||
@@ -790,6 +801,7 @@ def DoBuilding(target, objects, is_rtt = False):
|
||||
EndBuilding(target, program, is_rtt)
|
||||
|
||||
def GenTargetProject(program = None):
|
||||
need_exit = True
|
||||
|
||||
if GetOption('target') == 'mdk':
|
||||
from keil import MDKProject
|
||||
@@ -865,6 +877,8 @@ def GenTargetProject(program = None):
|
||||
if GetOption('target') == 'cmake' or GetOption('target') == 'cmake-armclang':
|
||||
from cmake import CMakeProject
|
||||
CMakeProject(Env,Projects)
|
||||
|
||||
return need_exit
|
||||
|
||||
|
||||
def EndBuilding(target, program = None, is_rtt = False):
|
||||
@@ -891,7 +905,7 @@ def EndBuilding(target, program = None, is_rtt = False):
|
||||
Clean(target, 'gen_ports/gen_ports_cpp.cpp')
|
||||
|
||||
if GetOption('target'):
|
||||
GenTargetProject(program)
|
||||
need_exit = GenTargetProject(program)
|
||||
|
||||
BSP_ROOT = Dir('#').abspath
|
||||
if GetOption('make-dist') and program != None:
|
||||
|
44
sharelib.py
44
sharelib.py
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user