forked from liaohuqiu/android-cube-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-template.py
41 lines (35 loc) · 1 KB
/
build-template.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
import os
vars = {
'support_v4_version': 'r7',
'clog_version': '1.0.2',
'ptr_lib_version': '1.0.6',
'event_bus_version': '1.3.4',
'cube_sdk_version': '1.0.43-SNAPSHOT',
}
files = [
'README.md',
'README-cn.md',
'pom.xml',
'build.gradle',
]
current_dir = os.path.dirname(os.path.realpath(__file__))
print current_dir
src_dir = current_dir + '/template/'
dst_dir = current_dir + '/'
def update_var_for_file(file, vars):
src_file = src_dir + file
dst_file = dst_dir + file
print "update_var_for_file: %s => %s" % (src_file, dst_file)
infile = open(src_file)
outfile = open(dst_file, 'w')
for line in infile:
for src, target in vars.iteritems():
line = line.replace(src, target)
outfile.write(line)
infile.close()
outfile.close()
real_vars = {}
for src, target in vars.iteritems():
real_vars['{' + src + '}'] = target
for f in files:
update_var_for_file(f, real_vars)