-
Notifications
You must be signed in to change notification settings - Fork 0
/
export.py
56 lines (48 loc) · 1.52 KB
/
export.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
#!/usr/bin/env python
import shutil
import os
import subprocess
import sys
import re
inputDir="./"
prefix="Z:\Software"
lib=os.path.join(prefix,"lib")
include=os.path.join(prefix,"include")
basename="commandLib"
#find which crossbuild to use
rowleyPath="C:\\Program Files (x86)\\Rowley Associates Limited\\"
#list rowley folder in program files
dirs=os.listdir(rowleyPath);
#initialize variables
path=None
version=None
#search for MSP430 crossworks
for folder in dirs:
m=re.search("CrossWorks for MSP430 ([0-9\\.])",folder)
if m is not None:
#get version tuple
ver=tuple(map(int,m.group(1)[0].split('.')))
#check if a version was found
if version is None or ver>version:
version=ver
path=folder
#get bath to crossbuild
crossbuild=os.path.join(rowleyPath,path,'bin','crossbuild.exe')
for config in ("MSP430 Release","MSP430 Debug"):
#build using crossbuild
print("Building "+config);
rc=subprocess.call([crossbuild,'-config',config,'commands.hzp'])
#check return code
if rc!=0:
print("Error : project did not build exiting")
exit(rc)
outname=basename+"_"+"_".join(config.split()[1:])+".hza"
outpath=os.path.join(lib,outname)
inpath=os.path.join(inputDir,os.path.join(basename+" "+config,basename+".hza"))
print("Copying "+inpath+" to "+outpath)
shutil.copyfile(inpath,outpath)
for file in ("commandLib.h",):
outpath=os.path.join(include,file)
inpath=os.path.join(inputDir,file)
print("Copying "+inpath+" to "+outpath)
shutil.copyfile(inpath,outpath)