[openrtm-commit:00126] r27 - trunk/ImageProcessing/opencv/build
openrtm @ openrtm.org
openrtm @ openrtm.org
2011年 5月 29日 (日) 00:44:37 JST
Author: n-ando
Date: 2011-05-29 00:44:37 +0900 (Sun, 29 May 2011)
New Revision: 27
Modified:
trunk/ImageProcessing/opencv/build/slntool.py
Log:
New solution tool which supports VC10 has been introduced.
Modified: trunk/ImageProcessing/opencv/build/slntool.py
===================================================================
--- trunk/ImageProcessing/opencv/build/slntool.py 2011-05-28 15:43:54 UTC (rev 26)
+++ trunk/ImageProcessing/opencv/build/slntool.py 2011-05-28 15:44:37 UTC (rev 27)
@@ -12,7 +12,7 @@
# Advanced Industrial Science and Technology (AIST), Japan
# All rights reserved.
#
-# $Id: slntool.py 775 2008-07-28 16:14:45Z n-ando $
+# $Id: slntool.py 2061 2011-03-10 05:40:47Z fsi-katami $
#
import sys
@@ -24,7 +24,8 @@
# Generic vcproj template
#------------------------------------------------------------
vcversions = {"VC8": {"sln": "9.00", "vc": "2005"},
- "VC9": {"sln": "10.00", "vc": "2008"}
+ "VC9": {"sln": "10.00", "vc": "2008"},
+ "VC10": {"sln": "11.00", "vc": "2010"}
}
sln_template = """Microsoft Visual Studio Solution File, Format Version %s
# Visual Studio %s
@@ -77,7 +78,7 @@
slntool.py --dep dep_file [--outfile outfile] vcproj_files...
Options:
- --vcversion: Visual C++'s version [VC8|VC9]
+ --vcversion: Visual C++'s version [VC8|VC9|VC10]
--dep: dependency file
--out or --output: output file name
@@ -125,6 +126,31 @@
fd.close()
return {"Name": name, "GUID": guid, "FileName": fname}
+def get_projinfo(fname,vcversion):
+ name = None
+ guid = None
+ regexs = {"VC8": {"guid":'^.*?ProjectGUID=\"{(.*)}\"',"name":'^.*?Name=\"(.*)\"'},
+ "VC9": {"guid":'^.*?ProjectGUID=\"{(.*)}\"',"name":'^.*?Name=\"(.*)\"'},
+ "VC10": {"guid":'^.*?<ProjectGuid>{(.*)}</ProjectGuid>',"name":'^.*<ProjectName>(.*)</ProjectName>'}
+ }
+ re_guid = re.compile(regexs[vcversion]["guid"])
+ re_name = re.compile(regexs[vcversion]["name"])
+ fd = open(fname, "r")
+ pj = fd.readlines()
+ for t in pj:
+ n = re_name.match(t)
+ g = re_guid.match(t)
+
+ if name == None and n:
+ name = n.group(1)
+ if guid == None and g:
+ guid = g.group(1)
+
+ if name and guid:
+ break
+ fd.close()
+ return {"Name": name, "GUID": guid, "FileName": fname}
+
def get_dependencies(fname):
if fname == None: return {}
depdic = {}
@@ -180,29 +206,39 @@
"""
d0 < d1: return -1
d0 == d1: return 0
- d0 < d1: return 1
+ d0 > d1: return 1
"""
d0_depends = d0.has_key("Depend")
d1_depends = d1.has_key("Depend")
if not d0_depends and not d1_depends:
+ # both d0, d1 has no dependency
return 0
- elif not d0_depends and d1_depends:
+
+ if not d0_depends and d1_depends:
+ # only "d1" has dependency: d0 < d1
return -1
- elif d0_depends and not d1_depends:
+
+ if d0_depends and not d1_depends:
+ # only "d0" has dependency: d1 < d0
return 1
- elif d0_depends and d1_depends:
- d0_in_dep = depdict.has_key(d0["Name"])
- d1_in_dep = depdict.has_key(d1["Name"])
- if not d0_in_dep and not d1_in_dep:
- return 0
- elif not d0_in_dep and d1_in_dep:
- return -1
- elif d0_in_dep and not d1_in_dep:
- return 1
- else:
- return 0
- else:
+
+ # d0 and d1 has dependency
+ d0_in_dep = depdict.has_key(d0["Name"])
+ d1_in_dep = depdict.has_key(d1["Name"])
+ if not d0_in_dep and not d1_in_dep:
return 0
+ if not d0_in_dep and d1_in_dep:
+ return -1
+ if d0_in_dep and not d1_in_dep:
+ return 1
+
+ # both d0 and d1 have several dependency
+ if depdict[d0["Name"]].count(d1["Name"]) > 0:
+ return 1
+ if depdict[d1["Name"]].count(d0["Name"]) > 0:
+ return -1
+ return 0
+
projs.sort(depsort)
for pj in projs:
list = """ - Name: %s
@@ -219,7 +255,71 @@
yaml_text = sln_yaml + projlist
return yaml_text
+def get_slnyaml(depfile, projfiles, vcversion):
+ depdict = get_dependencies(depfile)
+ projs = []
+ projlist = """Projects:
+"""
+ for f in projfiles:
+ pj = get_projinfo(f, vcversion)
+ if depdict.has_key(pj["Name"]):
+ pj["Depend"] = depdict[pj["Name"]]
+ projs.append(pj)
+ def depsort(d0, d1):
+ """
+ d0 < d1: return -1
+ d0 == d1: return 0
+ d0 > d1: return 1
+ """
+ d0_depends = d0.has_key("Depend")
+ d1_depends = d1.has_key("Depend")
+ if not d0_depends and not d1_depends:
+ # both d0, d1 has no dependency
+ return 0
+
+ if not d0_depends and d1_depends:
+ # only "d1" has dependency: d0 < d1
+ return -1
+
+ if d0_depends and not d1_depends:
+ # only "d0" has dependency: d1 < d0
+ return 1
+
+ # d0 and d1 has dependency
+ d0_in_dep = depdict.has_key(d0["Name"])
+ d1_in_dep = depdict.has_key(d1["Name"])
+ if not d0_in_dep and not d1_in_dep:
+ return 0
+ if not d0_in_dep and d1_in_dep:
+ return -1
+ if d0_in_dep and not d1_in_dep:
+ return 1
+
+ # both d0 and d1 have several dependency
+ if depdict[d0["Name"]].count(d1["Name"]) > 0:
+ return 1
+ if depdict[d1["Name"]].count(d0["Name"]) > 0:
+ return -1
+ return 0
+
+ projs.sort(depsort)
+ for pj in projs:
+ list = """ - Name: %s
+ FileName: %s
+ GUID: &%s %s
+ Depend:
+""" % (pj["Name"], pj["FileName"], pj["Name"], pj["GUID"])
+ if pj.has_key("Depend"):
+ for dep in pj["Depend"]:
+ dep = """ - *%s
+""" % (dep)
+ list += dep
+ projlist += list
+ yaml_text = sln_yaml + projlist
+ return yaml_text
+
def gen_solution(version, yaml_text):
+
dict = yaml.load(yaml_text)
t = yat.Template(sln_template
% (vcversions[version]["sln"],
@@ -253,9 +353,9 @@
depfile = res[1]
outfile = res[2]
flist = res[3]
+ #sln_text = gen_solution(version, get_slnyaml(depfile, flist))
+ sln_text = gen_solution(version, get_slnyaml(depfile, flist, version))
- sln_text = gen_solution(version, get_slnyaml(depfile, flist))
-
if outfile == None:
fd = sys.stdout
else:
openrtm-commit メーリングリストの案内