MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / BuildPackage

Function BuildPackage

tools/package.py:41–130  ·  view source on GitHub ↗
(package = None)

Source from the content-addressed store, hash-verified

39 return v
40
41def BuildPackage(package = None):
42 if package is None:
43 package = os.path.join(GetCurrentDir(), 'package.json')
44 elif os.path.isdir(package):
45 # support directory path
46 package = os.path.join(package, 'package.json')
47
48 # get package.json path
49 cwd = os.path.dirname(os.path.abspath(package))
50
51 if not os.path.isfile(package):
52 # silent return for conditional usage
53 return []
54
55 with open(package, 'r') as f:
56 package_json = f.read()
57 package = json.loads(package_json)
58
59 # check package name
60 if 'name' not in package or 'type' not in package or package['type'] != 'rt-thread-component':
61 return []
62
63 # get depends
64 depend = []
65 if 'dependencies' in package:
66 depend = ExtendPackageVar(package, 'dependencies')
67
68 # check dependencies
69 if depend:
70 group_enable = False
71 for item in depend:
72 if GetDepend(item):
73 group_enable = True
74 break
75 if not group_enable:
76 return []
77
78 CPPDEFINES = []
79 if 'defines' in package:
80 CPPDEFINES = ExtendPackageVar(package, 'defines')
81
82 src = []
83 CPPPATH = []
84 if 'sources' in package:
85 src_depend = []
86 src_CPPPATH = []
87 for item in package['sources']:
88 if 'includes' in item:
89 includes = item['includes']
90 for include in includes:
91 if include.startswith('/') and os.path.isdir(include):
92 src_CPPPATH = src_CPPPATH + [include]
93 else:
94 path = os.path.abspath(os.path.join(cwd, include))
95 src_CPPPATH = src_CPPPATH + [path]
96
97 if 'dependencies' in item:
98 src_depend = src_depend + ExtendPackageVar(item, 'dependencies')

Callers 1

PackageSConscriptFunction · 0.90

Calls 7

ExtendPackageVarFunction · 0.85
GetCurrentDirFunction · 0.70
GetDependFunction · 0.70
DefineGroupFunction · 0.70
openFunction · 0.50
joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected