做大型项目的过程中使用bitbake,免不了源代码在不止一个地方,这个python脚本是我上司写的一个简单脚本,直接上代码,做个备份:

//pybuild.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84

#! /usr/bin/python

import os
import filecmp
import shutil

avs_device_sdk = {
"PRJ_ROOT" : "/home/patten/workspace/austin/",
"SRC_PATH" : "guest/linux/meta-austin/recipes-application/alexa-server/avs-device-sdk/avs-device-sdk",
"TGT_PATH" : "guest/linux/build/austin/tmp/work/aarch64-agl-linux/avs-device-sdk/1.0-r0/git/",
"PRJ_NAME" : "avs-device-sdk",

"INCLUDES" : [
"ACL/",
"ADSL/",
"AFML/",
"ApplicationUtilities/",
"AttachCommon/",
"AVSCommon/",
"BluetoothImplementations/",
"build/",
"CapabilitiesDelegate/",
"CapabilityAgents/",
"CertifiedSender/",
"ContextManager/",
"ESP/",
"Integration/",
"KWD/",
"MediaPlayer/",
"PlaylistParser/",
"RegistrationManager/",
"SampleApp/",
"Storage/",
"ThirdParty/",
"tools/",
"alexaservice.service",
"CMakeLists.txt",
"alexaservice.service",
"pkg-config.pc.cmake"
],
"EXCLUDES" : [
#TODO: not in used, now.
],
}


Projects = [
avs_device_sdk,

]


def doBuildProject(prjInfo):
print 'Do build project :' + prjInfo['PRJ_NAME']
for p in prjInfo["INCLUDES"]:
src_path = os.path.join(prjInfo["PRJ_ROOT"], prjInfo["SRC_PATH"], p)
tgt_path = os.path.join(prjInfo["PRJ_ROOT"], prjInfo["TGT_PATH"], p)

if os.path.isfile(src_path):
tryCopyFile(src_path, tgt_path)
elif os.path.isdir(src_path):
tryCopyDir(src_path, tgt_path)
else:
print 'Error, invlaid src path:', src_path

cmd = 'bitbake -c compile -v -f avs-device-sdk;bitbake -c install -v -f avs-device-sdk'
os.system(cmd)

def tryCopyFile(src_path, tgt_path):
if not os.path.exists(tgt_path) or not filecmp.cmp(src_path, tgt_path):
print 'do copy file, from [' + src_path + '] to [' + tgt_path + ']'
shutil.copy2(src_path, tgt_path)

def tryCopyDir(src_path, tgt_path):
for root, _, files in os.walk(src_path):
for f in files:
tryCopyFile(os.path.join(root, f), os.path.join(tgt_path, root[len(src_path):], f))


if __name__ == '__main__':
doBuildProject(Projects[0])