@@ -12,41 +12,54 @@ def usage():
1212 usage ()
1313 sys .exit (0 )
1414
15+ def update_project_file (project_dir ):
16+ if os .path .isfile (os .path .join (project_dir , 'template.Uv2' )):
17+ print ('prepare MDK3 project file on ' + project_dir )
18+ command = ' --target=mdk -s'
19+ os .system ('scons --directory=' + project_dir + command + ' > 1.txt' )
20+
21+ if os .path .isfile (os .path .join (project_dir , 'template.uvproj' )):
22+ print ('prepare MDK4 project file on ' + project_dir )
23+ command = ' --target=mdk4 -s'
24+ os .system ('scons --directory=' + project_dir + command + ' > 1.txt' )
25+
26+ if os .path .isfile (os .path .join (project_dir , 'template.uvprojx' )):
27+ print ('prepare MDK5 project file on ' + project_dir )
28+ command = ' --target=mdk5 -s'
29+ os .system ('scons --directory=' + project_dir + command + ' > 1.txt' )
30+
31+ if os .path .isfile (os .path .join (project_dir , 'template.ewp' )):
32+ print ('prepare IAR project file on ' + project_dir )
33+ command = ' --target=iar -s'
34+ os .system ('scons --directory=' + project_dir + command + ' > 1.txt' )
35+
36+
37+ def update_all_project_files (root_path ):
38+ # current path is dir
39+ if os .path .isdir (root_path ):
40+ projects = os .listdir (root_path )
41+ # is a project path?
42+ if "SConscript" in projects :
43+ print ('new bsp path {}' .format (root_path ))
44+ try :
45+ os .system ('scons --pyconfig-silent -C {0}' .format (root_path )) # update rtconfig.h and .config
46+ update_project_file (root_path )
47+ except Exception as e :
48+ print ("error message: {}" .format (e ))
49+ sys .exit (- 1 )
50+ else :
51+ for i in projects :
52+ new_root_path = os .path .join (root_path , i )
53+ update_all_project_files (new_root_path )
54+
1555# get command options
1656command = ''
1757if sys .argv [1 ] == 'all' :
1858 command = ' '
1959elif sys .argv [1 ] == 'clean' :
2060 command = ' -c'
2161elif sys .argv [1 ] == 'project' :
22-
23- projects = os .listdir (BSP_ROOT )
24- for item in projects :
25- project_dir = os .path .join (BSP_ROOT , item )
26-
27- if os .path .isfile (os .path .join (project_dir , 'template.Uv2' )):
28- print ('prepare MDK3 project file on ' + project_dir )
29- command = ' --target=mdk -s'
30-
31- os .system ('scons --directory=' + project_dir + command )
32-
33- if os .path .isfile (os .path .join (project_dir , 'template.uvproj' )):
34- print ('prepare MDK4 project file on ' + project_dir )
35- command = ' --target=mdk4 -s'
36-
37- os .system ('scons --directory=' + project_dir + command )
38-
39- if os .path .isfile (os .path .join (project_dir , 'template.uvprojx' )):
40- print ('prepare MDK5 project file on ' + project_dir )
41- command = ' --target=mdk5 -s'
42-
43- os .system ('scons --directory=' + project_dir + command )
44-
45- if os .path .isfile (os .path .join (project_dir , 'template.ewp' )):
46- print ('prepare IAR project file on ' + project_dir )
47- command = ' --target=iar -s'
48-
49- os .system ('scons --directory=' + project_dir + command )
62+ update_all_project_files (BSP_ROOT )
5063
5164 sys .exit (0 )
5265else :
0 commit comments